]> git.babelmonkeys.de Git - jubjub.git/blob - m4/buildsys.m4
Add a zxcv-like CLI frontend
[jubjub.git] / m4 / buildsys.m4
1 dnl
2 dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012
3 dnl Jonathan Schleifer <js@webkeks.org>
4 dnl
5 dnl https://webkeks.org/git/?p=buildsys.git
6 dnl
7 dnl Permission to use, copy, modify, and/or distribute this software for any
8 dnl purpose with or without fee is hereby granted, provided that the above
9 dnl copyright notice and this permission notice is present in all copies.
10 dnl
11 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12 dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13 dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14 dnl ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
15 dnl LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
16 dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
17 dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18 dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19 dnl CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
20 dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21 dnl POSSIBILITY OF SUCH DAMAGE.
22 dnl
23
24 AC_DEFUN([BUILDSYS_INIT], [
25         AC_SUBST(CC_DEPENDS, $GCC)
26         AC_SUBST(CXX_DEPENDS, $GXX)
27         AC_SUBST(OBJC_DEPENDS, $GOBJC)
28         AC_SUBST(OBJCXX_DEPENDS, $GOBJCXX)
29
30         AC_PATH_PROG(TPUT, tput)
31
32         AS_IF([test x"$TPUT" != x""], [
33                 if x=$($TPUT el 2>/dev/null); then
34                         AC_SUBST(TERM_EL, "$x")
35                 else
36                         AC_SUBST(TERM_EL, "$($TPUT ce 2>/dev/null)")
37                 fi
38
39                 if x=$($TPUT sgr0 2>/dev/null); then
40                         AC_SUBST(TERM_SGR0, "$x")
41                 else
42                         AC_SUBST(TERM_SGR0, "$($TPUT me 2>/dev/null)")
43                 fi
44
45                 if x=$($TPUT bold 2>/dev/null); then
46                         AC_SUBST(TERM_BOLD, "$x")
47                 else
48                         AC_SUBST(TERM_BOLD, "$($TPUT md 2>/dev/null)")
49                 fi
50
51                 if x=$($TPUT setaf 1 2>/dev/null); then
52                         AC_SUBST(TERM_SETAF1, "$x")
53                         AC_SUBST(TERM_SETAF2, "$($TPUT setaf 2 2>/dev/null)")
54                         AC_SUBST(TERM_SETAF3, "$($TPUT setaf 3 2>/dev/null)")
55                         AC_SUBST(TERM_SETAF4, "$($TPUT setaf 4 2>/dev/null)")
56                         AC_SUBST(TERM_SETAF6, "$($TPUT setaf 6 2>/dev/null)")
57                 else
58                         AC_SUBST(TERM_SETAF1, "$($TPUT AF 1 2>/dev/null)")
59                         AC_SUBST(TERM_SETAF2, "$($TPUT AF 2 2>/dev/null)")
60                         AC_SUBST(TERM_SETAF3, "$($TPUT AF 3 2>/dev/null)")
61                         AC_SUBST(TERM_SETAF4, "$($TPUT AF 4 2>/dev/null)")
62                         AC_SUBST(TERM_SETAF6, "$($TPUT AF 6 2>/dev/null)")
63                 fi
64         ], [
65                 AC_SUBST(TERM_EL, '\033\133K')
66                 AC_SUBST(TERM_SGR0, '\033\133m')
67                 AC_SUBST(TERM_BOLD, '\033\1331m')
68                 AC_SUBST(TERM_SETAF1, '\033\13331m')
69                 AC_SUBST(TERM_SETAF2, '\033\13332m')
70                 AC_SUBST(TERM_SETAF3, '\033\13333m')
71                 AC_SUBST(TERM_SETAF4, '\033\13334m')
72                 AC_SUBST(TERM_SETAF6, '\033\13336m')
73         ])
74 ])
75
76 AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
77         AC_REQUIRE([AC_CANONICAL_HOST])
78         AC_MSG_CHECKING(whether we need an implib)
79         case "$host_os" in
80                 cygwin* | mingw*)
81                         AC_MSG_RESULT(yes)
82                         PROG_IMPLIB_NEEDED='yes'
83                         PROG_IMPLIB_LDFLAGS='-Wl,-export-all-symbols,--out-implib,lib${PROG}.a'
84                         ;;
85                 *)
86                         AC_MSG_RESULT(no)
87                         PROG_IMPLIB_NEEDED='no'
88                         PROG_IMPLIB_LDFLAGS=''
89                         ;;
90         esac
91
92         AC_SUBST(PROG_IMPLIB_NEEDED)
93         AC_SUBST(PROG_IMPLIB_LDFLAGS)
94 ])
95
96 AC_DEFUN([BUILDSYS_SHARED_LIB], [
97         AC_REQUIRE([AC_CANONICAL_HOST])
98         AC_MSG_CHECKING(for shared library system)
99         case "$host_os" in
100                 darwin*)
101                         AC_MSG_RESULT(Darwin)
102                         LIB_CFLAGS='-fPIC -DPIC'
103                         LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
104                         LIB_PREFIX='lib'
105                         LIB_SUFFIX='.dylib'
106                         LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
107                         PLUGIN_CFLAGS='-fPIC -DPIC'
108                         PLUGIN_LDFLAGS='-bundle -undefined dynamic_lookup'
109                         PLUGIN_SUFFIX='.bundle'
110                         INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && install_name_tool -id ${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
111                         UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
112                         CLEAN_LIB=''
113                         ;;
114                 solaris*)
115                         AC_MSG_RESULT(Solaris)
116                         LIB_CFLAGS='-fPIC -DPIC'
117                         LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}.${LIB_MINOR}'
118                         LIB_PREFIX='lib'
119                         LIB_SUFFIX='.so'
120                         LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
121                         PLUGIN_CFLAGS='-fPIC -DPIC'
122                         PLUGIN_LDFLAGS='-shared'
123                         PLUGIN_SUFFIX='.so'
124                         INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
125                         UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
126                         CLEAN_LIB=''
127                         ;;
128                 openbsd* | mirbsd*)
129                         AC_MSG_RESULT(OpenBSD)
130                         LIB_CFLAGS='-fPIC -DPIC'
131                         LIB_LDFLAGS='-shared'
132                         LIB_PREFIX='lib'
133                         LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
134                         LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
135                         PLUGIN_CFLAGS='-fPIC -DPIC'
136                         PLUGIN_LDFLAGS='-shared'
137                         PLUGIN_SUFFIX='.so'
138                         INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
139                         UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
140                         CLEAN_LIB=''
141                         ;;
142                 cygwin* | mingw*)
143                         AC_MSG_RESULT(Win32)
144                         LIB_CFLAGS=''
145                         LIB_LDFLAGS='-shared -Wl,--out-implib,${SHARED_LIB}.a'
146                         LIB_PREFIX='lib'
147                         LIB_SUFFIX='.dll'
148                         LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
149                         PLUGIN_CFLAGS=''
150                         PLUGIN_LDFLAGS='-shared'
151                         PLUGIN_SUFFIX='.dll'
152                         INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 $$i.a ${DESTDIR}${libdir}/$$i.a'
153                         UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/$$i.a'
154                         CLEAN_LIB='${SHARED_LIB}.a'
155                         ;;
156                 *)
157                         AC_MSG_RESULT(GNU)
158                         LIB_CFLAGS='-fPIC -DPIC'
159                         LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}'
160                         LIB_PREFIX='lib'
161                         LIB_SUFFIX='.so'
162                         LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
163                         PLUGIN_CFLAGS='-fPIC -DPIC'
164                         PLUGIN_LDFLAGS='-shared'
165                         PLUGIN_SUFFIX='.so'
166                         INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
167                         UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
168                         CLEAN_LIB=''
169                         ;;
170         esac
171
172         AC_SUBST(LIB_CFLAGS)
173         AC_SUBST(LIB_LDFLAGS)
174         AC_SUBST(LIB_PREFIX)
175         AC_SUBST(LIB_SUFFIX)
176         AC_SUBST(LDFLAGS_RPATH)
177         AC_SUBST(PLUGIN_CFLAGS)
178         AC_SUBST(PLUGIN_LDFLAGS)
179         AC_SUBST(PLUGIN_SUFFIX)
180         AC_SUBST(INSTALL_LIB)
181         AC_SUBST(UNINSTALL_LIB)
182         AC_SUBST(CLEAN_LIB)
183 ])
184
185 AC_DEFUN([BUILDSYS_TOUCH_DEPS], [
186         ${as_echo:="echo"} ${as_me:="configure"}": touching .deps files"
187         for i in $(find . -name Makefile); do
188                 DEPSFILE="$(dirname $i)/.deps"
189                 test -f "$DEPSFILE" && rm "$DEPSFILE"
190                 touch -t 0001010000 "$DEPSFILE"
191         done
192 ])