aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-09-06 09:26:51 +0000
committerEric Wong <normalperson@yhbt.net>2006-09-06 09:26:51 +0000
commit412cb1ee105a74999a3ffac4e60e6602c5f2e541 (patch)
treefc8b9e117fc3ff5eaf0f55113be9dc89418b7a6f
parent7b6d45f50fa49f4da56cc4ae29758a01ec958792 (diff)
downloadmpd-412cb1ee105a74999a3ffac4e60e6602c5f2e541.tar.gz
mpd-412cb1ee105a74999a3ffac4e60e6602c5f2e541.tar.xz
mpd-412cb1ee105a74999a3ffac4e60e6602c5f2e541.zip
bs: a work in progress..
git-svn-id: https://svn.musicpd.org/mpd/trunk@4737 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--bs.mk60
-rw-r--r--bs/bs-lib.sh50
-rw-r--r--bs/deftypes-cross.sh33
-rw-r--r--bs/deftypes.c18
-rw-r--r--bs/dep-alsa.sh78
-rw-r--r--bs/dep-input.sh46
-rw-r--r--bs/dep-output.sh78
-rw-r--r--bs/deps.sh27
-rw-r--r--bs/features.sh2
-rwxr-xr-xbs/mkconfig_header.sh93
-rwxr-xr-xbs/mkdep.sh21
11 files changed, 506 insertions, 0 deletions
diff --git a/bs.mk b/bs.mk
new file mode 100644
index 000000000..2fadffc94
--- /dev/null
+++ b/bs.mk
@@ -0,0 +1,60 @@
+#!/usr/bin/make -f
+# default target
+all:
+
+export CPP CC CPPFLAGS CFLAGS LD LDFLAGS UNAME_S UNAME_M HOST TARGET O
+
+# output directory can be set with O:=dir
+ifeq ($(O),)
+ O := .
+endif
+
+UNAME_S := $(shell uname -s 2>/dev/null || echo unknown)
+UNAME_M := $(shell uname -m 2>/dev/null || echo unknown)
+HOST := $(UNAME_S)-$(UNAME_M)
+TARGET := $(HOST)
+
+include src/Makefile.am
+
+CFLAGS += -I $(O)/src
+mpd_SRC := $(addprefix src/,$(filter %.c,$(mpd_SOURCES)))
+mpd_HDR := $(addprefix src/,$(filter %.h,$(mpd_SOURCES)))
+mpd_OBJ := $(subst .c,.o,$(addprefix $(O)/,$(mpd_SRC)))
+mpd_DEP := $(subst .o,.d,$(mpd_OBJ))
+DIRS := $(O)/src/inputPlugins $(O)/src/audioOutputs
+HDR_DEP_HACK := $(addprefix $(0), $(mpd_HDR))
+export HDR_DEP_HACK
+
+dbg:
+ @echo mpd_OBJ $(mpd_OBJ)
+ @echo mpd_SRC $(mpd_SRC)
+ @echo mpd_DEP $(mpd_DEP)
+
+dep: $(mpd_DEP)
+ @echo $(mpd_DEP)
+
+$(O)/deftypes: bs/deftypes.c
+ $(CC) $(CFLAGS) -o $@+ $<
+ if test "$(HOST)" != "$(TARGET)"; then \
+ cp bs/deftypes-cross.sh $@+ && chmod +x $@+; fi
+ mv $@+ $@
+
+$(O)/config.h: $(O)/deftypes $(O)/config.mk
+ @-test -f $@ && mv $@ $@~
+ ./bs/mkconfig_header.sh > $@+ && $(O)/deftypes >> $@+ && mv $@+ $@
+
+config: $(O)/config.h
+$(O)/config.mk:
+ @mkdir -p $(DIRS) && >> $@
+
+-include $(O)/config.mk
+
+$(O)/src/%.d: src/%.c $(O)/config.h
+ ./bs/mkdep.sh $< > $@+ && mv $@+ $@
+
+include $(mpd_OBJ:.o=.d)
+
+$(O)/src/%.o: $(O)/src/%.d $(O)/config.h $(O)/config.mk
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@+ $< && mv $@+ $@
+
+
diff --git a/bs/bs-lib.sh b/bs/bs-lib.sh
new file mode 100644
index 000000000..8b13653f2
--- /dev/null
+++ b/bs/bs-lib.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# common shell functions and variable setup for the bs build system,
+# expect variables to be set and exported in bs.mk
+
+test -z "$CC" && CC=cc
+test -z "$CPP" && CPP='cc -E'
+test -z "$PKGCONFIG" && PKGCONFIG=pkg-config
+
+p ()
+{
+ echo >&2 "$@"
+}
+
+run_cc ()
+{
+ $CC $CPPFLAGS $CFLAGS $LDFLAGS \
+ $cppflags $cflags $ldflags -o t.o t.c >/dev/null 2>&1
+}
+
+test_header ()
+{
+ cat > t.c <<EOF
+#include <$1.h>
+int main (void) { return 0; }
+EOF
+ run_cc
+}
+
+dep_paths ()
+{
+ name=$1
+ eval "cflags=`echo '$'`${name}_cflags"
+ eval "ldflags=`echo '$'`${name}_ldflags"
+ eval "pfx=`echo '$'`${name}_pfx"
+ if test -n "$pfx"; then
+ cflags="$cflags -I$pfx/include"
+ ldflags="$ldflags -L$pfx/lib"
+ fi
+}
+
+test_compile ()
+{
+ h=shift
+ cat > t.c <<EOF
+#include <$h.h>
+int main () { $@ return 0; }
+EOF
+ run_cc
+}
+
diff --git a/bs/deftypes-cross.sh b/bs/deftypes-cross.sh
new file mode 100644
index 000000000..a5f78a816
--- /dev/null
+++ b/bs/deftypes-cross.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+cat <<EOF
+/*
+ * Manually set type sizes for cross compile
+ * build-target: $TARGET
+ * build-host: $HOST
+ */
+
+/* If your target is big-endian, define the below: */
+EOF
+
+be='/* #undef WORDS_BIGENDIAN */'
+
+# add more targets here
+case "$TARGET" in
+*-ppc* | *-sparc*)
+ be='#define WORDS_BIGENDIAN'
+ ;;
+esac
+echo "$bs"
+
+sizeof_int=0
+sizeof_long=0
+sizeof_long_long=0
+sizeof_short=0
+
+cat <<EOF
+#define SIZEOF_INT $sizeof_int
+#define SIZEOF_LONG $sizeof_long
+#define SIZEOF_LONG_LONG $sizeof_long_long
+#define SIZEOF_SHORT $sizeof_short
+EOF
+
diff --git a/bs/deftypes.c b/bs/deftypes.c
new file mode 100644
index 000000000..dad9b58a8
--- /dev/null
+++ b/bs/deftypes.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+int main(int argc, char argv[])
+{
+ long one = 1;
+ puts( *((char *)(&one)) ? "/* #undef WORDS_BIGENDIAN */"
+ : "#define WORDS_BIGENDIAN" );
+ printf( "#define SIZEOF_INT %ld\n"
+ "#define SIZEOF_LONG %ld\n"
+ "#define SIZEOF_LONG_LONG %ld\n"
+ "#define SIZEOF_SHORT %ld\n",
+ (long int)(sizeof(int)),
+ (long int)(sizeof(long)),
+ (long int)(sizeof(long long)),
+ (long int)(sizeof(short)) );
+
+ return 0;
+}
diff --git a/bs/dep-alsa.sh b/bs/dep-alsa.sh
new file mode 100644
index 000000000..0354d3a6a
--- /dev/null
+++ b/bs/dep-alsa.sh
@@ -0,0 +1,78 @@
+t_alsa ()
+{
+ dep_paths alsa
+ if test_header 'alsa/asoundlib'; then
+ ldflags="-lasound -lm -ldl -lpthread"
+ echo t
+ fi
+}
+
+t_ao ()
+{
+ dep_paths ao
+ if test_header 'ao/ao'; then
+ ldflags="-ld -lao"
+ echo t
+ fi
+}
+
+t_fifo ()
+{
+ echo t
+}
+
+t_mvp ()
+{
+ echo t
+}
+
+t_oss ()
+{
+ dep_paths oss
+ test_header 'sys/soundcard' && echo t
+}
+
+t_pulse ()
+{
+ dep_paths pulse
+ test_header 'pulse/simple' && echo 't'
+}
+
+t_shout ()
+{
+ dep_paths shout
+ ok=
+ if test "$PKGCONFIG" != "no" && `$PKGCONFIG --exists shout`; then
+ cflags="`$PKGCONFIG --variable=cflags_only shout`"
+ cflags="$cflags `$PKGCONFIG --variable=cppflags shout`"
+ ldflags="`$PKGCONFIG --libs shout`"
+ ok=t
+ else
+ test -z "$sc" && sc="`which shoutconfig`"
+ if test `$sc --package` = "libshout"; then
+ cflags="`$sc --cflags-only`"
+ cflags="$cflags `$sc --cppflags shout`"
+ ldflags="$ldflags `$sc --libs`"
+ ok=t
+ fi
+ fi
+ # freebsd 6.1 + shout 2.2 port seems to leave pthread out
+ case "$uname_s" in
+ freebsd*)
+ case "$cflags" in
+ *-D_THREAD_SAFE*)
+ ldflags="$ldflags -lpthread"
+ ;;
+ esac
+ ;;
+ esac
+
+ echo $ok
+}
+
+t_sun ()
+{
+ dep_paths sun
+ test_header 'sys/audioio' && echo t
+}
+
diff --git a/bs/dep-input.sh b/bs/dep-input.sh
new file mode 100644
index 000000000..ece570875
--- /dev/null
+++ b/bs/dep-input.sh
@@ -0,0 +1,46 @@
+t_aac ()
+{
+ dep_paths aac
+ if test_header 'faad' && test_header 'mp4ff'; then
+ ldflags="-lfaad -lmp4ff"
+ echo t
+ fi
+}
+
+audiofile ()
+{
+ dep_paths audiofile
+ if test_header 'audiofile'; then
+ ldflags="-lm -laudiofile"
+ echo t
+ fi
+
+}
+
+flac ()
+{
+}
+
+oggvorbis ()
+{
+}
+
+oggflac ()
+{
+}
+
+mod ()
+{
+}
+
+mpc ()
+{
+}
+
+mp3 ()
+{
+}
+
+tremor ()
+{
+}
diff --git a/bs/dep-output.sh b/bs/dep-output.sh
new file mode 100644
index 000000000..2e885540c
--- /dev/null
+++ b/bs/dep-output.sh
@@ -0,0 +1,78 @@
+t_alsa ()
+{
+ dep_paths alsa
+ if test_header 'alsa/asoundlib'; then
+ ldflags="$ldflags -lasound -lm -ldl -lpthread"
+ echo t
+ fi
+}
+
+t_ao ()
+{
+ dep_paths ao
+ if test_header 'ao/ao'; then
+ ldflags="$ldflags -ld -lao"
+ echo t
+ fi
+}
+
+t_fifo ()
+{
+ echo t
+}
+
+t_mvp ()
+{
+ echo t
+}
+
+t_oss ()
+{
+ dep_paths oss
+ test_header 'sys/soundcard' && echo t
+}
+
+t_pulse ()
+{
+ dep_paths pulse
+ test_header 'pulse/simple' && echo 't'
+}
+
+t_shout ()
+{
+ dep_paths shout
+ ok=
+ if test "$PKGCONFIG" != "no" && `$PKGCONFIG --exists shout`; then
+ cflags="$cflags `$PKGCONFIG --variable=cflags_only shout`"
+ cflags="$cflags `$PKGCONFIG --variable=cppflags shout`"
+ ldflags="$ldflags `$PKGCONFIG --libs shout`"
+ ok=t
+ else
+ test -z "$sc" && sc="`which shoutconfig`"
+ if test `$sc --package` = "libshout"; then
+ cflags="$cflags `$sc --cflags-only`"
+ cflags="$cflags `$sc --cppflags shout`"
+ ldflags="$ldflags `$sc --libs`"
+ ok=t
+ fi
+ fi
+ # freebsd 6.1 + shout 2.2 port seems to leave pthread out
+ case "$uname_s" in
+ freebsd*)
+ case "$cflags" in
+ *-D_THREAD_SAFE*)
+ ldflags="$ldflags -lpthread"
+ ;;
+ esac
+ ;;
+ esac
+
+ echo $ok
+}
+
+t_sun ()
+{
+ dep_paths sun
+ test_header 'sys/audioio' && echo t
+}
+
diff --git a/bs/deps.sh b/bs/deps.sh
new file mode 100644
index 000000000..f2a86bc6c
--- /dev/null
+++ b/bs/deps.sh
@@ -0,0 +1,27 @@
+output_deps='
+alsa=t
+ao=f
+fifo=f
+mvp=f
+oss=t
+pulse=t
+shout=t
+sun=t
+'
+
+input_deps='
+aac=t
+audiofile=t
+flac=t
+oggvorbis=t
+oggflac=t
+mod=f
+mpc=t
+mp3=t
+tremor=f
+'
+
+other_deps='
+id3=t
+iconv=t
+'
diff --git a/bs/features.sh b/bs/features.sh
new file mode 100644
index 000000000..48000a02c
--- /dev/null
+++ b/bs/features.sh
@@ -0,0 +1,2 @@
+. bs/bs-lib.sh
+
diff --git a/bs/mkconfig_header.sh b/bs/mkconfig_header.sh
new file mode 100755
index 000000000..0f3f0d0e3
--- /dev/null
+++ b/bs/mkconfig_header.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+# basic package info
+p=mpd
+v=0.12.0
+b=warren.dukes@gmail.com
+
+. bs/bs-lib.sh
+
+cat <<EOF
+#define PACKAGE "$p"
+#define VERSION "$p"
+#define PACKAGE_BUGREPORT "$b"
+#define PACKAGE_NAME "$p"
+#define PACKAGE_STRING "$p $v"
+#define PACKAGE_TARNAME "$p"
+#define PACKAGE_VERSION "$v"
+EOF
+
+# check for common headers:
+ansi_headers='
+assert
+ctype
+errno
+limits
+locale
+math
+signal
+stdarg
+stddef
+stdint
+stdio
+stdlib
+string
+'
+common_headers='
+dlfcn
+inttypes
+memory
+strings
+sys/inttypes
+sys/stat
+sys/types
+unistd
+'
+
+all_ansi=t
+for h in $ansi_headers; do
+ H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
+ if test_header $h; then
+ echo "#define $H 1"
+ else
+ echo "/* #undef $H */"
+ all_ansi=
+ fi
+done
+test x$all_ansi = xt && echo "#define STDC_HEADERS 1"
+
+for h in $common_headers; do
+ H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
+ if test_header $h; then
+ echo "#define $H 1"
+ else
+ echo "/* #undef $H */"
+ fi
+done
+
+# test for langinfo.h and codeset
+cat > t.c <<EOF
+#include <langinfo.h>
+int main () { char *cs = nl_langinfo(CODESET); return 0; }
+EOF
+run_cc
+test $? -eq 0 && echo '#define HAVE_LANGINFO_CODESET 1'
+
+# the only feature (non-external library) feature we currently have
+if test x$want_ipv6 != xno; then
+ cat > t.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#ifdef PF_INET6
+#ifdef AF_INET6
+AP_maGiC_VALUE
+#endif
+#endif
+EOF
+ if $CPP t.c 2>&1 | grep AP_maGiC_VALUE >/dev/null 2>&1; then
+ echo '#define HAVE_IPV6 1'
+ fi
+fi
+
+rm -f t.o t.c
diff --git a/bs/mkdep.sh b/bs/mkdep.sh
new file mode 100755
index 000000000..fb3ce12a7
--- /dev/null
+++ b/bs/mkdep.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+f="$1"
+d="`dirname $1`"
+t=.tmp.$$
+
+# -MM is gcc-specific...
+$CC -MM $CPPFLAGS $CFLAGS "$f" > $t
+
+if test $? -ne 0; then
+ # ok, maybe -M is supported...
+ $CC -M $CPPFLAGS $CFLAGS "$f" > "$t"
+
+ # guess not, fudge the dependencies by using all headers
+ if test $? -ne 0; then
+ echo "$O/$f: $f $O/config.h $HDR_DEP_HACK" | sed -e 's#c:#o:#'
+ exec rm -f $t
+ fi
+fi
+
+sed -e 's#.c$#.o#' -e "1s#^#$O/$d/&#" < $t
+exec rm -f $t