Commit 412cb1ee authored by Eric Wong's avatar Eric Wong

bs: a work in progress..

git-svn-id: https://svn.musicpd.org/mpd/trunk@4737 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 7b6d45f5
#!/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 $@+ $@
#!/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
}
#!/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
#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;
}
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
}
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 ()
{
}
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
}
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
'
. bs/bs-lib.sh
#!/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
#!/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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment