diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..08898b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,58 @@ +PREFIX = /usr/local +EXEC_PREFIX = $(PREFIX) +BINDIR = $(EXEC_PREFIX)/bin +DATADIR = $(PREFIX)/share +LICENSEDIR = $(DATADIR)/licenses + +PKGNAME = optimised-true + +LD_FLAGS = -s +AS_FLAGS = +CC_FLAGS = -nostdinc -ffreestanding +MACHINE = $(shell uname -m) + +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 + +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)" "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + cp true false -- "$(DESTDIR)$(BINDIR)" + chmod 755 -- "$(DESTDIR)$(BINDIR)/true" + chmod 755 -- "$(DESTDIR)$(BINDIR)/false" + cp COPYING -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + chmod 644 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" + +uninstall: + -rm -- "$(DESTDIR)$(BINDIR)/true" + -rm -- "$(DESTDIR)$(BINDIR)/false" + -rmdir -- "$(DESTDIR)$(BINDIR)" + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING" + -rmdir "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)" + +clean: + -rm true.o true false.o false + +.PHONY: all clean install uninstall + |