Skip to content

Commit

Permalink
build: add ability to generate top-level flag files
Browse files Browse the repository at this point in the history
In particular,
- add HAVE_BUILD_FLAGS
- check for HAVE_BUILD_FLAGS in generated Makefiles, and if it isn't present,
  call the top-level Makefile's buildsubdir
- adjust handling of "all_extra:" for the modified Makefile.prog
  • Loading branch information
gperciva committed Jun 28, 2018
1 parent 6215a0d commit 3495923
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ all: cpusupport-config.h posix-flags.sh
export CFLAGS="$${CFLAGS:-${CFLAGS_DEFAULT}}"; \
. ./posix-flags.sh; \
. ./cpusupport-config.h; \
export HAVE_BUILD_FLAGS=1; \
for D in ${PROGS} ${TESTS}; do \
( cd $${D} && ${MAKE} all ) || exit 2; \
done

# For "loop-back" building of a subdirectory
buildsubdir: cpusupport-config.h posix-flags.sh
. ./cpusupport-config.h; \
. ./posix-flags.sh; \
export HAVE_BUILD_FLAGS=1; \
cd ${BUILD_SUBDIR} && ${MAKE} ${BUILD_TARGET}

posix-flags.sh:
if [ -d ${LIBCPERCIVA_DIR}/POSIX/ ]; then \
export CC="${CC}"; \
Expand Down
4 changes: 2 additions & 2 deletions Makefile.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ ${D}/Makefile::
printf "\n" >> $@; \
( cd ${D} && awk '/all_extra:/, /^$$/' Makefile.BSD | \
awk '$$1' ) >> $@; \
( cd ${D} && awk \
'/all:\t${PROG}/ {print $$0 " all_extra";next}{print}' \
( cd ${D} && sed -e \
's/$${MAKE} $${PROG}/$${MAKE} $${PROG} all_extra/' \
Makefile > Makefile.new ); \
( cd ${D} && mv Makefile.new Makefile ); \
fi
Expand Down
9 changes: 8 additions & 1 deletion Makefile.prog
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@

all: ${PROG}
all:
if [ -z "$${HAVE_BUILD_FLAGS}" ]; then \
cd ${SUBDIR_DEPTH}; \
${MAKE} BUILD_SUBDIR=${RELATIVE_DIR} \
BUILD_TARGET=${PROG} buildsubdir; \
else \
${MAKE} ${PROG}; \
fi

install:${PROG}
mkdir -p ${BINDIR}
Expand Down

0 comments on commit 3495923

Please sign in to comment.