2 dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012
3 dnl Jonathan Schleifer <js@webkeks.org>
5 dnl https://webkeks.org/git/?p=buildsys.git
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.
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.
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)
30 AC_PATH_PROG(TPUT, tput)
32 AS_IF([test x"$TPUT" != x""], [
33 if x=$($TPUT el 2>/dev/null); then
34 AC_SUBST(TERM_EL, "$x")
36 AC_SUBST(TERM_EL, "$($TPUT ce 2>/dev/null)")
39 if x=$($TPUT sgr0 2>/dev/null); then
40 AC_SUBST(TERM_SGR0, "$x")
42 AC_SUBST(TERM_SGR0, "$($TPUT me 2>/dev/null)")
45 if x=$($TPUT bold 2>/dev/null); then
46 AC_SUBST(TERM_BOLD, "$x")
48 AC_SUBST(TERM_BOLD, "$($TPUT md 2>/dev/null)")
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)")
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)")
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')
76 AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
77 AC_REQUIRE([AC_CANONICAL_HOST])
78 AC_MSG_CHECKING(whether we need an implib)
82 PROG_IMPLIB_NEEDED='yes'
83 PROG_IMPLIB_LDFLAGS='-Wl,-export-all-symbols,--out-implib,lib${PROG}.a'
87 PROG_IMPLIB_NEEDED='no'
88 PROG_IMPLIB_LDFLAGS=''
92 AC_SUBST(PROG_IMPLIB_NEEDED)
93 AC_SUBST(PROG_IMPLIB_LDFLAGS)
96 AC_DEFUN([BUILDSYS_SHARED_LIB], [
97 AC_REQUIRE([AC_CANONICAL_HOST])
98 AC_MSG_CHECKING(for shared library system)
101 AC_MSG_RESULT(Darwin)
102 LIB_CFLAGS='-fPIC -DPIC'
103 LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
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'
115 AC_MSG_RESULT(Solaris)
116 LIB_CFLAGS='-fPIC -DPIC'
117 LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}.${LIB_MINOR}'
120 LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
121 PLUGIN_CFLAGS='-fPIC -DPIC'
122 PLUGIN_LDFLAGS='-shared'
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}'
129 AC_MSG_RESULT(OpenBSD)
130 LIB_CFLAGS='-fPIC -DPIC'
131 LIB_LDFLAGS='-shared'
133 LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
134 LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
135 PLUGIN_CFLAGS='-fPIC -DPIC'
136 PLUGIN_LDFLAGS='-shared'
138 INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
139 UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
145 LIB_LDFLAGS='-shared -Wl,--out-implib,${SHARED_LIB}.a'
148 LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
150 PLUGIN_LDFLAGS='-shared'
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'
158 LIB_CFLAGS='-fPIC -DPIC'
159 LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}'
162 LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
163 PLUGIN_CFLAGS='-fPIC -DPIC'
164 PLUGIN_LDFLAGS='-shared'
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'
173 AC_SUBST(LIB_LDFLAGS)
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)
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"