aboutsummaryrefslogtreecommitdiffstats
path: root/bs/mkconfig-header.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-06-01 22:24:55 +0000
committerEric Wong <normalperson@yhbt.net>2008-06-01 22:24:55 +0000
commit8a4dff14ad7560aae83e9155d0c62ba7f8c101fd (patch)
treef9803ea83fa7cb6020e84b78f3fc45b4086e4a13 /bs/mkconfig-header.sh
parent97698bd4aaf168620205fea26f089e7b1acc869d (diff)
downloadmpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.tar.gz
mpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.tar.xz
mpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.zip
Add the bs build system from mpd-ke
Dealing with autotools is too painful when having to deal with multiple build environments and configurations. git-svn-id: https://svn.musicpd.org/mpd/trunk@7368 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rwxr-xr-xbs/mkconfig-header.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/bs/mkconfig-header.sh b/bs/mkconfig-header.sh
new file mode 100755
index 000000000..ff0809ffb
--- /dev/null
+++ b/bs/mkconfig-header.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# detect the uninteresting (unlikely to be manually changed by the user)
+# parts of config.h
+
+if test -z "$O" || ! cd "$O"; then
+ echo '$O= not defined or not a directory' >&2
+ exit 1
+fi
+
+> config_detected.mk
+
+ansi_headers='assert ctype errno limits locale math signal
+stdarg stddef stdint stdio stdlib string'
+common_headers='dlfcn inttypes memory strings sched
+sys/inttypes sys/stat sys/types unistd'
+
+all_ansi=t
+echo '/* ANSI C headers: */'
+for h in $ansi_headers; do
+ if test x$h = xlocale; then
+ H=HAVE_LOCALE
+ else
+ H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
+ fi
+ cat > t.c <<EOF
+#include <$h.h>
+int main(void) { return 0; }
+EOF
+ if $CC -o t.o $CFLAGS $CPPFLAGS t.c >> out 2>&1; then
+ echo "#define $H 1"
+ echo "$H := 1" >> config_detected.mk
+ else
+ echo "/* #undef $H */"
+ echo "# $H := " >> config_detected.mk
+ all_ansi=
+ fi
+done
+if test x$all_ansi = xt; then
+ echo '#define STDC_HEADERS 1'
+else
+ echo '/* #undef STDC_HEADERS */'
+fi
+echo ''
+echo '/* common system headers/features on UNIX and UNIX-like system: */'
+for h in $common_headers; do
+ H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
+ cat > t.c <<EOF
+#include <$h.h>
+int main(void) { return 0; }
+EOF
+ if $CC -o t.o $CFLAGS $CPPFLAGS t.c >> out 2>&1; then
+ echo "#define $H 1"
+ echo "$H := 1" >> config_detected.mk
+ else
+ echo "/* #undef $H */"
+ echo "# $H :=" >> config_detected.mk
+ fi
+done
+
+# test for setenv
+cat > t.c <<EOF
+#include <stdlib.h>
+int main(void) { setenv("mpd","rocks", 1); return 0; }
+EOF
+if $CC -o t.o $CFLAGS $CPPFLAGS t.c >> out 2>&1; then
+ echo '#define HAVE_SETENV 1'
+ echo "HAVE_SETENV := 1" >> config_detected.mk
+else
+ echo '/* #undef HAVE_SETENV */'
+ echo "# HAVE_SETENV :=" >> config_detected.mk
+fi
+echo ''
+
+# test for alloca
+cat > t.c <<EOF
+#include <alloca.h>
+int main(void) { char *x = (char *)alloca(2 * sizeof(int)); return 0; }
+EOF
+if $CC -o t.o $CFLAGS $CPPFLAGS t.c >> out 2>&1; then
+ echo '#define HAVE_ALLOCA_H 1'
+ echo "HAVE_ALLOCA_H := 1" >> config_detected.mk
+else
+ echo '/* #undef HAVE_ALLOCA_H */'
+ echo "# HAVE_ALLOCA_H :=" >> config_detected.mk
+fi
+echo ''
+
+exec rm -f out t.c t.o