lw-build-system/scripts/build.module.c/build.module

40 lines
844 B
Bash

# These are external variables, and shouldn't clash with anything else
# @CNAME@
# @CNAME@_BUILT
if [ -z ${@CNAME@_BUILT} ]
then
@CNAME@="obj/@NAME@.so"
SO_EXTRA="-D_GNU_SOURCE -std=gnu99 -DMODULE_NAME=\"@NAME@\"" # @TODO@
echo "Building module ${@CNAME@}..."
do_cmd source src/@NAME@/build.monolithic || return 1
MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC}
do
if [ ${test} -nt ${@CNAME@} ]
then
MODIFIED=1
break
fi
done
if [ ${MODIFIED} -ne 0 ]
then
echo " Compiling"
do_cmd ${CC} ${CFLAGS} -Iobj -shared -fpic -o "${@CNAME@}" \
${SRC} ${SO_EXTRA} || return 1
print_success "Module built"
else
print_success "Module up to date"
fi
@CNAME@_BUILT=1
fi
# vim: syntax=sh:@VIM_MODELINE@