Makefile (981B)
1 TARGET:=$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m) 2 3 BIN:=sfinx 4 5 FIND:=$(shell command -v gfind find) 6 7 WATCH?= 8 WATCH+=$(shell $(FIND) src -type f -name '*.c') 9 WATCH+=$(shell $(FIND) src -type f -name '*.h') 10 11 .PHONY: default 12 default: build/${TARGET}/${BIN} 13 14 build/${TARGET}/${BIN}: build/${TARGET} $(WATCH) 15 cd build/${TARGET} && dep install 16 $(MAKE) --directory build/${TARGET} TARGET=${TARGET} 17 18 build/${TARGET}: $(WATCH) 19 mkdir -p build/${TARGET} 20 cp -rT src/ build/${TARGET}/src 21 cp -rT target/common/ build/${TARGET} 22 cp -rT target/${TARGET}/ build/${TARGET} 23 24 .PHONY: targets 25 targets: 26 @ls -1 target | grep -v '^common$$' 27 28 .PHONY: clean 29 clean: 30 rm -rf build 31 32 # Never let the catch-all try to rebuild the makefiles themselves 33 Makefile: ; 34 35 # Forward any other goal verbatim into the assembled target tree 36 .PHONY: FORCE 37 FORCE: 38 %: build/${TARGET} FORCE 39 cd build/${TARGET} && dep install 40 $(MAKE) --directory build/${TARGET} TARGET=${TARGET} $@