aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile94
-rw-r--r--config.mk9
-rw-r--r--generic/build.mk7
-rw-r--r--x86_64/build.mk5
4 files changed, 73 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index aac1216..1c6a304 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..f5d0b4e
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,9 @@
+PREFIX = /usr
+
+CC = c99
+LD = ld
+AS = as
+
+CFLAGS = -nostdinc -ffreestanding
+ASFLAGS =
+LDFLAGS = -s
diff --git a/generic/build.mk b/generic/build.mk
new file mode 100644
index 0000000..0b2f531
--- /dev/null
+++ b/generic/build.mk
@@ -0,0 +1,7 @@
+CFLAGS = -nostdinc -ffreestanding
+LDFLAGS = -s
+
+LD = $(CC)
+
+true.o false.o: $(MACHINE)/true.c $(MACHINE)/false.c
+ $(CC) -c -o $@ $(MACHINE)/$(@:.o=.c) $(CFLAGS)
diff --git a/x86_64/build.mk b/x86_64/build.mk
new file mode 100644
index 0000000..a3c8d8d
--- /dev/null
+++ b/x86_64/build.mk
@@ -0,0 +1,5 @@
+ASFLAGS =
+LDFLAGS = -s -nodefaultlibs -nostdlib
+
+true.o false.o: $(MACHINE)/true.s $(MACHINE)/false.s
+ $(AS) -o $@ $(MACHINE)/$(@:.o=.s) $(ASFLAGS)