Skip to content

Instantly share code, notes, and snippets.

@lboulard
Last active December 9, 2024 22:09
Show Gist options
  • Save lboulard/68a446a76c0a769dbc236b8ba63f1281 to your computer and use it in GitHub Desktop.
Save lboulard/68a446a76c0a769dbc236b8ba63f1281 to your computer and use it in GitHub Desktop.
makefile sample to rebuild on flags change
*~
*.bak
*.orig
\#*\#
.build/
sh.exe
FLAGS ?= 0
SHELL ?= sh
all: .build/all
.build/all: .build/a .build/b .build/c .build/d .build/e .build/f
touch .build/all
.build/: FORCE
mkdir -p $@
.build/.flags: .build/ FORCE
echo "FLAGS=${FLAGS}" >[email protected]; \
if ! cmp -s [email protected] $@; then mv -f [email protected] $@; fi; \
rm -fr [email protected]
.build/a: a .build/.flags
touch $@
.build/b: b .build/.flags
touch $@
.build/c: c .build/.flags
touch $@
.build/d: d .build/.flags
touch $@
.build/e: e .build/.flags
touch $@
.build/f: f .build/.flags
touch $@
.PHONY: FORCE
FORCE: ;
.PHONY: clean
clean:
rm -fr .build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment