diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-03 22:04:38 +0200 | 
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-12-03 22:04:38 +0200 | 
| commit | 2253da61e9b3dd5408bed182ea08e5270156c17e (patch) | |
| tree | 298bb06e681ec5366faa539906cae6e805fe5862 /scripts/gen-deps | |
| download | fwd-2253da61e9b3dd5408bed182ea08e5270156c17e.tar.gz fwd-2253da61e9b3dd5408bed182ea08e5270156c17e.zip | |
initial commit
+ Lots of code copied from ek, so didn't have to start from scratch, but
  might mean there are some quirks here and there that made sense in ek
  but not necessarily here.
Diffstat (limited to 'scripts/gen-deps')
| -rwxr-xr-x | scripts/gen-deps | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/scripts/gen-deps b/scripts/gen-deps new file mode 100755 index 0000000..f45707c --- /dev/null +++ b/scripts/gen-deps @@ -0,0 +1,37 @@ +#!/bin/sh + +PREFIX= +COMPILE=COMPILE +LINT=LINT +BUILD=build/ + +while getopts "p:c:b:l:" opt; do +	case "$opt" in +		p) PREFIX="$OPTARG"_;; +		c) COMPILE="$OPTARG";; +		l) LINT="$OPTARG";; +		b) BUILD=build/"$OPTARG";; +		*) echo "unrecognised option -$OPTARG" >&2; exit 1;; +	esac +done + +shift $((OPTIND - 1)) + +# create all subdirectories +mkdir -p $(echo "${@}" | tr ' ' '\n' | sed "s|[^/]*$||;s|^|${BUILD}/|" | uniq) + +for s in ${@} +do +	obj="${BUILD}/${s%.*}.o" +	lint="${obj}.l" +	dep="${obj}.d" + +	echo "${PREFIX}OBJS += ${obj}"			>> deps.mk +	echo "${PREFIX}LINTS += ${lint}"		>> deps.mk +	echo "${dep}:"					>> deps.mk +	echo "-include ${dep}"				>> deps.mk +	echo "${obj}: ${s}"				>> deps.mk +	echo "	\$(${COMPILE}) -c ${s} -o ${obj}"	>> deps.mk +	echo "${lint}: ${s}"				>> deps.mk +	echo "	\$(${LINT}) -c ${s} -o /dev/null"	>> deps.mk +done | 
