summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2015-09-12 12:23:07 -0500
committerBobby Bingham <koorogi@koorogi.info>2015-09-15 22:43:33 -0500
commitb6677f90864028e8faf8d531d801f5cd3d5ed487 (patch)
treef9a47471d3f8e238cc88d541290e0ad9a6908996 /Makefile
parentdee0ef6a7d9b765f3cbc2332c5205dc202fb52ea (diff)
add make install rules
The install.sh script is taken from musl.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 19 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index e4051c4..10bd278 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,8 @@
+prefix = /usr/local
+exec_prefix = $(prefix)
+bindir = $(exec_prefix)/bin
+sharedir = $(prefix)/share/saturn-tools
+
CFLAGS = -Os -pipe -std=c99 -D_POSIX_C_SOURCE=200809L
LDFLAGS =
SATURN_CROSS = saturn-
@@ -6,6 +11,8 @@ SATURN_OBJCOPY = $(SATURN_CROSS)objcopy
SATURN_CFLAGS = -Os -pipe -std=c99 -nostdlib
SATURN_LDFLAGS =
+INSTALL = ./tools/install.sh
+
-include config.mak
BOOTSRCS = $(sort $(wildcard boot/*.c))
@@ -17,10 +24,12 @@ DATA = $(sort $(wildcard src/*.bin))
OBJS = $(SRCS:.c=.o) $(DATA:.bin=.o)
BINS = bin/satmkboot bin/satmkiso
-.PHONY: all clean
+.PHONY: all clean install install-bins install-data
all: $(BINS) $(BOOTBINS)
+install: install-bins install-data
+
clean:
rm -f $(BINS) $(OBJS) $(BOOTBINS) $(BOOTELFS)
@@ -41,3 +50,12 @@ share/boot/%: boot/%.elf
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
+$(DESTDIR)$(bindir)/%: bin/%
+ $(INSTALL) -D $< $@
+
+$(DESTDIR)$(sharedir)/%: share/%
+ $(INSTALL) -D -m 644 $< $@
+
+install-bins: $(BINS:bin/%=$(DESTDIR)$(bindir)/%)
+
+install-data: $(BOOTBINS:share/%=$(DESTDIR)$(sharedir)/%)