i3lock-color

The world's most popular non-default computer lockscreen.
Index Commits Files Refs README LICENSE
m4/ax_extend_srcdir.m4 (3336B)
   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 #   Copyright (c) 2021 Raymond Li <i3lock-color@raymond.li>
  67 #
  68 #   Copying and distribution of this file, with or without modification, are
  69 #   permitted in any medium without royalty provided the copyright notice
  70 #   and this notice are preserved.  This file is offered as-is, without any
  71 #   warranty.
  72 
  73 #serial 3
  74 
  75 AC_DEFUN([AX_EXTEND_SRCDIR],
  76 [dnl
  77 AS_CASE([$srcdir],
  78   [.|.*|/*],
  79   [
  80     # pwd -P is specified in IEEE 1003.1 from 2004
  81     as_dir=`cd "$srcdir" && pwd -P`
  82     as_base=`AS_BASENAME([$as_dir])`
  83     srcdir=${srcdir}/../${as_base}
  84 
  85     AC_SUBST([AX_EXTEND_SRCDIR_CPPFLAGS], ["-DSTRIPPED__FILE__=AS_ESCAPE([\"$$(basename $<)\"])"])
  86   ])
  87 ])dnl AX_EXTEND_SRCDIR