8d6eea99f4af7b8b5a8d50e42f12643a573326b3
[supertux.git] / mk / autoconf / installdirs.m4
1 #-----------------------------------------------------------------------------
2 # installdirs.m4 (c) Matze Braun <matze@braunis.de>
3 # Macros for outputing the installation paths which autoconf gathers into the
4 # Jamconfig file.
5 #-----------------------------------------------------------------------------
6
7 #-----------------------------------------------------------------------------
8 # AC_OUTPUT_INSTALLDIRS
9 #   Transforms the installation dirs which are gathered by autoconf and sets
10 #   properties in the Jamconfig file for them. We deal with stuff like
11 #   variable references inside the paths (often the paths contain ${prefix})
12 #   and with correct quoting here.
13 #   The script will set the INSTALLDIR.PREFIX, INSTALLDIR.EXEC_PREFIX,
14 #   INSTALLDIR.APPLICATION, INSTALLDIR.SBIN, INSTALLDIR.LIBEXEC,
15 #   INSTALLDIR.DATA, INSTALLDIR.MAP, INSTALLDIR.CONFIG, INSTALLDIR.SHAREDSTATE
16 #   INSTALLDIR.LOCALSTATE, INSTALLDIR.PLUGIN, INSTALLDIR.DOC
17 #   INSTALLDIR.LIBRARY, INSTALLDIR.INCLUDE, INSTALLDIR.OLDINCLUDE,
18 #   INSTALLDIR.INFO, INSTALLDIR.MAN
19 #-----------------------------------------------------------------------------
20 AC_DEFUN([AC_OUTPUT_INSTALLDIRS],[
21 # Handle the case when no prefix is given. And the special case when a path
22 # contains more than 2 slashes, these paths seem to be correct but jam fails
23 # on them.
24 AS_IF([test $prefix = NONE], [prefix="$ac_default_prefix"],
25     [prefix=`echo "$prefix" | sed -e 's:///*:/:g'`])
26 AS_IF([test $exec_prefix = NONE],
27     [exec_prefix="AS_ESCAPE([$(prefix)])"],
28     [exec_prefix=`echo "$exec_prefix" | sed -e 's:///*:/:g'`])
29
30 prefix=AC_FIX_VARIABLEREF([$prefix])
31 exec_prefix=AC_FIX_VARIABLEREF([$exec_prefix])
32 bindir=AC_FIX_VARIABLEREF([$bindir])
33 sbindir=AC_FIX_VARIABLEREF([$sbindir])
34 libexecdir=AC_FIX_VARIABLEREF([$libexecdir])
35 datadir=AC_FIX_VARIABLEREF([$datadir])
36 sysconfdir=AC_FIX_VARIABLEREF([$sysconfdir])
37 sharedstatedir=AC_FIX_VARIABLEREF([$sharedstatedir])
38 localstatedir=AC_FIX_VARIABLEREF([$localstatedir])
39 libdir=AC_FIX_VARIABLEREF([$libdir])
40 includedir=AC_FIX_VARIABLEREF([$includedir])
41 oldincludedir=AC_FIX_VARIABLEREF([$oldincludedir])
42 infodir=AC_FIX_VARIABLEREF([$infodir])
43 mandir=AC_FIX_VARIABLEREF([$mandir])
44
45 #hack to get the order right :-/ (autoconf --trace reports wrong order...)
46 AC_SUBST(prefix)
47 AC_SUBST(exec_prefix)
48 AC_SUBST(bindir)
49 AC_SUBST(sbindir)
50 AC_SUBST(libexecdir)
51 AC_SUBST(datadir)
52 AC_SUBST(sysconfdir)
53 AC_SUBST(sharedstatedir)
54 AC_SUBST(localstatedir)
55 AC_SUBST(libdir)
56 AC_SUBST(includedir)
57 AC_SUBST(oldincludedir)
58 AC_SUBST(infodir)
59 AC_SUBST(mandir)
60 ])
61
62 #-----------------------------------------------------------------------------
63 # AC_FIX_INSTALL
64 #   Fixes the output from AC_PROG_INSTALL
65 #-----------------------------------------------------------------------------
66 AC_DEFUN([AC_FIX_INSTALL], [
67 AC_REQUIRE([AC_PROG_INSTALL])
68 INSTALL=AC_FIX_VARIABLEREF([$INSTALL])
69 INSTALL_PROGRAM=AC_FIX_VARIABLEREF([$INSTALL_PROGRAM])
70 INSTALL_SCRIPT=AC_FIX_VARIABLEREF([$INSTALL_SCRIPT])
71 INSTALL_DATA=AC_FIX_VARIABLEREF([$INSTALL_DATA])
72
73 # fix for order...
74 AC_SUBST([INSTALL])
75 AC_SUBST([INSTALL_PROGRAM])
76 AC_SUBST([INSTALL_SCRIPT])
77 AC_SUBST([INSTALL_DATA])
78 ])
79
80 #-----------------------------------------------------------------------------
81 # AC_PREPARE_INSTALLPATH
82 #   Transform variables of the form ${bla} to $(bla) inside the string and
83 #   correctly quotes backslashes.
84 #   This is needed if you want to output some of the paths that autoconf
85 #   creates to the Jamconfig file.
86 #-----------------------------------------------------------------------------
87 AC_DEFUN([AC_FIX_VARIABLEREF],
88 dnl We need all the strange \\\\ quoting here, because the command will be
89 dnl inserted into a "" block and sed needs quoting as well
90 [`echo "$1" | sed -e 's/\${\([[a-zA-Z_][a-zA-Z_]]*\)}/$(\1)/g' -e 's/\\\\/\\\\\\\\/g'`])
91