From 412cb1ee105a74999a3ffac4e60e6602c5f2e541 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 6 Sep 2006 09:26:51 +0000 Subject: bs: a work in progress.. git-svn-id: https://svn.musicpd.org/mpd/trunk@4737 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- bs.mk | 60 +++++++++++++++++++++++++++++++++ bs/bs-lib.sh | 50 +++++++++++++++++++++++++++ bs/deftypes-cross.sh | 33 ++++++++++++++++++ bs/deftypes.c | 18 ++++++++++ bs/dep-alsa.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ bs/dep-input.sh | 46 +++++++++++++++++++++++++ bs/dep-output.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ bs/deps.sh | 27 +++++++++++++++ bs/features.sh | 2 ++ bs/mkconfig_header.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ bs/mkdep.sh | 21 ++++++++++++ 11 files changed, 506 insertions(+) create mode 100644 bs.mk create mode 100644 bs/bs-lib.sh create mode 100644 bs/deftypes-cross.sh create mode 100644 bs/deftypes.c create mode 100644 bs/dep-alsa.sh create mode 100644 bs/dep-input.sh create mode 100644 bs/dep-output.sh create mode 100644 bs/deps.sh create mode 100644 bs/features.sh create mode 100755 bs/mkconfig_header.sh create mode 100755 bs/mkdep.sh 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 < +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 < +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 < + +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 < t.c < +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 < +#include +#include +#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 -- cgit v1.2.3