summaryrefslogtreecommitdiff
path: root/m4/ax_extend_srcdir.m4
diff options
context:
space:
mode:
authorSimeon Simeonov2020-03-12 12:30:51 +0100
committerSimeon Simeonov2020-03-12 12:30:51 +0100
commit69a05d516bd0c7e369a0ba1fb78aac57a5ea26f2 (patch)
tree87e37110ea0e328533a41c3b16b64036ff132641 /m4/ax_extend_srcdir.m4
Initial commit for the last i3lock commit at this time f3b061233e28ad0cf920c9421adc2459b6920812
Diffstat (limited to 'm4/ax_extend_srcdir.m4')
-rw-r--r--m4/ax_extend_srcdir.m486
1 files changed, 86 insertions, 0 deletions
diff --git a/m4/ax_extend_srcdir.m4 b/m4/ax_extend_srcdir.m4
new file mode 100644
index 0000000..40f3787
--- /dev/null
+++ b/m4/ax_extend_srcdir.m4
@@ -0,0 +1,86 @@
1# ===========================================================================
2# http://www.gnu.org/software/autoconf-archive/ax_extend_srcdir.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7# AX_EXTEND_SRCDIR
8#
9# DESCRIPTION
10#
11# The AX_EXTEND_SRCDIR macro extends $srcdir by one path component.
12#
13# As an example, when working in /home/michael/i3-4.12/build and calling
14# ../configure, your $srcdir is "..". After calling AX_EXTEND_SRCDIR,
15# $srcdir will be set to "../../i3-4.12".
16#
17# The result of extending $srcdir is that filenames (e.g. in the output of
18# the "backtrace" gdb command) will include one more path component of the
19# absolute source path. The additional path component makes it easy for
20# users to recognize which files belong to the PACKAGE, and -- provided a
21# dist tarball was unpacked -- which version of PACKAGE was used.
22#
23# As an example, in "backtrace", you will see:
24#
25# #0 main (argc=1, argv=0x7fffffff1fc8) at ../../i3-4.12/src/main.c:187
26#
27# instead of:
28#
29# #0 main (argc=1, argv=0x7fffffff1fc8) at ../src/main.c:187
30#
31# In case your code uses the __FILE__ preprocessor directive to refer to
32# the filename of the current source file (e.g. in debug messages), using
33# the extended path might be undesirable. For this purpose,
34# AX_EXTEND_SRCDIR defines the output variable AX_EXTEND_SRCDIR_CPPFLAGS,
35# which can be added to AM_CPPFLAGS in Makefile.am in order to define the
36# preprocessor directive STRIPPED__FILE__. As an example, when compiling
37# the file "../../i3-4.12/src/main.c", STRIPPED__FILE__ evaluates to
38# "main.c".
39#
40# There are some caveats: When $srcdir is "." (i.e. when ./configure was
41# called instead of ../configure in a separate build directory),
42# AX_EXTEND_SRCDIR will still extend $srcdir, but the intended effect will
43# not be achieved because of the way automake specifies file paths:
44# automake defines COMPILE to use "`test -f '$source' || echo
45# '\$(srcdir)/'`$source" in order to prefer files in the current directory
46# over specifying $srcdir explicitly.
47#
48# The AX_EXTEND_SRCDIR author is not aware of any way to influence this
49# automake behavior. Patches very welcome.
50#
51# To work around this issue, you can use AX_ENABLE_BUILDDIR i.e. by adding
52# the following code to configure.ac:
53#
54# AX_ENABLE_BUILDDIR
55# dnl ...
56# AX_EXTEND_SRCDIR
57#
58# Then also add this bit to Makefile.am (if you wish to use
59# STRIPPED__FILE__ in your code):
60#
61# AM_CPPFLAGS = @AX_EXTEND_SRCDIR_CPPFLAGS@
62#
63# LICENSE
64#
65# Copyright (c) 2016 Michael Stapelberg <michael@i3wm.org>
66#
67# Copying and distribution of this file, with or without modification, are
68# permitted in any medium without royalty provided the copyright notice
69# and this notice are preserved. This file is offered as-is, without any
70# warranty.
71
72#serial 3
73
74AC_DEFUN([AX_EXTEND_SRCDIR],
75[dnl
76AS_CASE([$srcdir],
77 [.|.*|/*],
78 [
79 # pwd -P is specified in IEEE 1003.1 from 2004
80 as_dir=`cd "$srcdir" && pwd -P`
81 as_base=`AS_BASENAME([$as_dir])`
82 srcdir=${srcdir}/../${as_base}
83
84 AC_SUBST([AX_EXTEND_SRCDIR_CPPFLAGS], ["-DSTRIPPED__FILE__=AS_ESCAPE([\"$$(basename $<)\"])"])
85 ])
86])dnl AX_EXTEND_SRCDIR