Some projects offer a mono or "jumbo" build option, where users can download one .c file and compile it into an executable directly. This single .c file is an amalgamation of all existing source files and headers, and is automatically generated every release.
Example projects: SQLite, wak, u-config.
If you're interested in offering a mono build option, I've created a basic amalgamation script along with a Makefile entry.
P.S. Consider adding include guards to make.h.
Makefile entry
pdpmake_mono.c:
./amal.sh $(OBJS:.o=.c) > $@
amal.sh
#!/bin/sh
set -e
# display help
if [ ${#} -lt 1 ]; then
echo "Usage: amal.sh FILE.c [FILE.c ...] > OUT.c"
exit 1
fi
# log of files included so far to avoid double inclusion
LOG="`mktemp`"
true > "${LOG}"
# iterate over input files
while [ ${#} -gt 0 ]; do
# input file location, to resolve relative include files
HERE="$(dirname "$(readlink -f "${1}")")"
# iterate over lines
cat "${1}" | while IFS= read -r line; do
# if normal line, pass it through
if [ -z "`printf "%s\n" "${line}" | grep '^#.*include.*"'`" ]; then
printf "%s\n" "${line}"
# if include line, replace it if not already included
else
INC="${line%\"*}"
INC="${INC#*\"}"
if [ -n "`grep "${HERE}/${INC}" "${LOG}"`" ]; then continue; fi
echo "${HERE}/${INC}" >> "${LOG}"
cat "${HERE}/${INC}"
fi
done
shift; done
# cleanup
rm -f "${LOG}"
Some projects offer a mono or "jumbo" build option, where users can download one .c file and compile it into an executable directly. This single .c file is an amalgamation of all existing source files and headers, and is automatically generated every release.
Example projects: SQLite, wak, u-config.
If you're interested in offering a mono build option, I've created a basic amalgamation script along with a Makefile entry.
P.S. Consider adding include guards to make.h.
Makefile entry
amal.sh