diff options
| author | Albert Cervin <albert@acervin.com> | 2022-12-07 23:22:05 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2022-12-07 23:22:05 +0100 |
| commit | 31e6fb2ba5fe9fd04722971a13a72ec71e846e46 (patch) | |
| tree | cf4f064bcbd9d2215917c0c2645581722173b694 /Makefile | |
| parent | 66d50bd7b04922a91fbe3e4d49c68070ec1a7b14 (diff) | |
| download | dged-31e6fb2ba5fe9fd04722971a13a72ec71e846e46.tar.gz dged-31e6fb2ba5fe9fd04722971a13a72ec71e846e46.tar.xz dged-31e6fb2ba5fe9fd04722971a13a72ec71e846e46.zip | |
Make make portable
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 57 |
1 files changed, 11 insertions, 46 deletions
@@ -1,50 +1,15 @@ -.PHONY: default clean check run debug debug-tests +# BSD-compatible makefile -default: dged +.include "common.mk" -headers != find src/ -type f -name '*.h' -srcs != find src/ -type f -name '*.c' ! -name 'main.c' +.include "$(UNAME_S).mk" -test_headers != find test/ -type f -name '*.h' -test_srcs != find test/ -type f -name '*.c' +# in this case we need a separate depend target +depend: $(DEPS) + @: -objs-path = objs -objs = $(patsubst %.c,$(objs-path)/%.o, $(srcs)) -test_objs = $(patsubst %.c,$(objs-path)/test/%.o, $(test_srcs)) - -UNAME_S != uname -s - -CFLAGS = -Werror -g -std=c99 - -ifeq ($(UNAME_S),Linux) - DEFINES += -DLINUX -D_XOPEN_SOURCE=700 -endif - -$(objs-path)/test/%.o: %.c $(headers) - @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(DEFINES) -I ./src -I ./test -c $< -o $@ - -$(objs-path)/%.o: %.c $(headers) - @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(DEFINES) -I ./src -c $< -o $@ - -dged: $(objs) $(objs-path)/src/main.o - $(CC) $(LDFLAGS) $(objs) $(objs-path)/src/main.o -o dged - -run-tests: $(test_objs) $(objs) - $(CC) $(LDFLAGS) $(test_objs) $(objs) -o run-tests - -check: run-tests - ./run-tests - -run: dged - ./dged - -debug: dged - gdb ./dged - -debug-tests: run-tests - gdb ./run-tests - -clean: - rm -rf $(objs-path) dged run-tests +.if !(make(clean)) +. for o in ${DEPS} +. sinclude "$o" +. endfor +.endif |
