Hash :
1303f01c
Author :
Thomas de Grivel
Date :
2022-11-03T08:26:35
portable makefiles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
#!/bin/sh
set -e
. ../config.subr
LIB_SRCDIR="$(dirname $0)"
SOURCES="$(ls *.c | grep -Ev '_type.c$' | tr '\n' ' ')"
DIRS="$(ls -d */)"
if [ x"$DEBUG" = x"yes" ]; then
CFLAGS="$CFLAGS -DDEBUG -O0 -ggdb"
else
CFLAGS="$CFLAGS -DNDEBUG -O3"
fi
CFLAGS="$CFLAGS -W -Wall -Werror -std=c89 -pedantic"
LIBS=""
check_libbsd
check_portaudio
check_sndio
if test "x$HAVE_LIBBSD" = "xYes"; then
CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D__USE_MISC"
fi
if ! test "x$HAVE_SNDIO" = "xYes"; then
DIRS="$(echo "$DIRS" | grep -v sndio)"
fi
if ! test "x$HAVE_PORTAUDIO" = "xYes"; then
DIRS="$(echo "$DIRS" | grep -v portaudio)"
fi
echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
echo "CPPFLAGS = $CPPFLAGS" >> ${CONFIG_MK}
echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
echo "LIBS = $LIBS" >> ${CONFIG_MK}
TYPES=
type_prog music
if test "x$HAVE_PORTAUDIO" = "xYes"; then
type_prog portaudio
fi
type_prog reverb
type_prog signal
if test "x$HAVE_SNDIO" = "xYes"; then
type_prog sndio
fi
type_prog synth
echo "types:${TYPES}" >> ${CONFIG_MK}
LIBRARIES=
for SRC in $SOURCES; do
SRC_LO="$(c2lo "$SRC")"
echo >> ${CONFIG_MK}
lo_rule "$SRC" >> ${CONFIG_MK}
echo " ${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
SRC_LA="librtbuf_$(c2la "$SRC")"
echo >> ${CONFIG_MK}
echo "$SRC_LA: $SRC_LO" >> ${CONFIG_MK}
echo " ${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS} $SRC_LO \${LIBS} -o $SRC_LA -rpath \${LIBDIR}" >> ${CONFIG_MK}
LIBRARIES="$LIBRARIES $SRC_LA"
done
echo >> ${CONFIG_MK}
echo "libraries:${LIBRARIES} ${TYPES}" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "libraries-install: ${LIBRARIES}" >> ${CONFIG_MK}
for LIB in $LIBRARIES; do
echo " \${LIBTOOL} --tag=CC --mode=install \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 $LIB \${LIBDIR}" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo "subdirs: ${TYPES}" >> ${CONFIG_MK}
for DIR in $DIRS; do
echo " \${MAKE} -C $DIR" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo "subdirs-clean:" >> ${CONFIG_MK}
for DIR in $DIRS; do
echo " \${MAKE} -C $DIR clean" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo "subdirs-install: libraries" >> ${CONFIG_MK}
for DIR in $DIRS; do
echo " \${MAKE} -C $DIR install" >> ${CONFIG_MK}
done
for DIR in $DIRS; do
(cd $DIR && ./configure)
done
for TYPE_SRC in $TYPE_SOURCES; do
TYPE_PROG="$(c2prog "$TYPE_SRC")"
TYPE_H="${TYPE_PROG}.h"
rm "$TYPE_H"
done
echo >> ${CONFIG_MK}
echo ".PHONY: types libraries install subdirs subdirs-clean subdirs-install" >> ${CONFIG_MK}