diff options
author | Mattias Andrée <maandree@kth.se> | 2023-07-01 09:26:44 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-07-01 09:26:44 +0200 |
commit | bd32947e35d5da5747a02f0744730cb16077ba39 (patch) | |
tree | bf9a9b81b4d50e29fc3dbc63261f1dc064b1ed13 /Makefile | |
parent | Change PREFIX to /usr (diff) | |
download | optimised-true-bd32947e35d5da5747a02f0744730cb16077ba39.tar.gz optimised-true-bd32947e35d5da5747a02f0744730cb16077ba39.tar.bz2 optimised-true-bd32947e35d5da5747a02f0744730cb16077ba39.tar.xz |
Improve makefile
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 94 |
1 files changed, 52 insertions, 42 deletions
@@ -1,53 +1,63 @@ -PREFIX = /usr -EXEC_PREFIX = $(PREFIX) -BINDIR = $(EXEC_PREFIX)/bin -DATADIR = $(PREFIX)/share -LICENSEDIR = $(DATADIR)/licenses +.POSIX: -PKGNAME = optimised-true +MACHINE != uname -m +MACHINE !=\ + if test -d "$(MACHINE)"; then \ + printf '%s\n' "$(MACHINE)"; \ + else \ + printf '%s\n' "generic"; \ + fi -LD_FLAGS = -s -AS_FLAGS = -CC_FLAGS = -nostdinc -ffreestanding -MACHINE = $(shell uname -m) +CONFIGFILE = config.mk +include $(CONFIGFILE) -ifneq ($(shell test -d $(MACHINE) && echo 0 || echo 1),0) -GENERIC = 1 -LD = $(CC) -endif -ifndef GENERIC -LD_FLAGS += -nodefaultlibs -nostdlib -endif - - -all: true false +BIN = true false +all: $(BIN) true: true.o - $(LD) $(LD_FLAGS) -o $@ $^ false: false.o - $(LD) $(LD_FLAGS) -o $@ $^ - -ifdef GENERIC -%.o: generic/%.c - $(CC) $(CC_FLAGS) -c -o $@ $^ -endif -ifndef GENERIC -%.o: $(MACHINE)/%.s - $(AS) $(AS_FLAGS) -o $@ $^ -endif - -install: true false - mkdir -p -- "$(DESTDIR)$(BINDIR)" - cp true false -- "$(DESTDIR)$(BINDIR)" - chmod 755 -- "$(DESTDIR)$(BINDIR)/true" - chmod 755 -- "$(DESTDIR)$(BINDIR)/false" + +.SUFFIXES: +.SUFFIXES: .o + +include $(MACHINE)/build.mk + +check: $(BIN:=-check) + +true-check: true + ./true + ./true + ./true + ./true + ./true + ./true + ./true + ./true + ./true + ./true + +false-check: false + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + set +e; ./false; test $$? = 1 || exit 1 + +install: $(BIN) + mkdir -p -- "$(DESTDIR)/$(PREFIX)/bin" + cp -- $(BIN) "$(DESTDIR)/$(PREFIX)/bin" + cd -- "$(DESTDIR)/$(PREFIX)/bin" && chmod -- 755 "$(BIN)" uninstall: - -rm -- "$(DESTDIR)$(BINDIR)/true" - -rm -- "$(DESTDIR)$(BINDIR)/false" - -rmdir -- "$(DESTDIR)$(BINDIR)" + -cd -- "$(DESTDIR)/$(PREFIX)/bin" && rm -f -- $(BIN) + -rmdir -- "$(DESTDIR)/$(PREFIX)/bin" clean: - -rm true.o true false.o false + -rm -f -- *.o *.su $(BIN) -.PHONY: all clean install uninstall +.PHONY: all check true-check false-check install uninstall clean |