summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-10-21 21:51:49 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-10-21 21:51:49 +0300
commit304bc20a6489309bfb28feebfa02777b1552334b (patch)
treeb4ccd6bf2a9508a8a0eed12ab250445f03528dd0
parent0ede8b64ca5ba1d1fd75f7db0310451c816c45d2 (diff)
Nicer makefile
-rw-r--r--Makefile29
1 files changed, 19 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index f7d3abe..1eefd2c 100644
--- a/Makefile
+++ b/Makefile
@@ -13,17 +13,26 @@ override CPPFLAGS += -Isrc
bins = ptrace-region-rw ptrace-address-rw uio-region-rw uio-address-rw binsearch bintrim
all: $(bins)
+%.a:
+ $(LINK.c) -c $(filter %.c,$^) $(LDLIBS) -o $@
+
$(bins): %:
- $(LINK.c) $^ $(LDLIBS) -o $@
+ $(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -o $@
+
+memio-ptrace.a: src/mem/io-ptrace.c src/mem/io.h
+memio-uio.a: private CPPFLAGS += -D_GNU_SOURCE
+memio-uio.a: src/mem/io-uio.c src/mem/io.h
+memio-stream.a: src/mem/io-stream.c src/mem/io-stream.h
+
+proc-address-rw.a: src/cli/proc-address-rw.c src/cli/cli.h src/util.h
+proc-region-rw.a: src/cli/proc-region-rw.c src/cli/cli.h src/util.h
+ptrace-address-rw: src/ptrace-address-rw.c proc-address-rw.a memio-ptrace.a memio-stream.a
+ptrace-region-rw: src/ptrace-region-rw.c proc-region-rw.a memio-ptrace.a memio-stream.a
+uio-address-rw: src/uio-address-rw.c proc-address-rw.a memio-uio.a memio-stream.a
+uio-region-rw: src/uio-region-rw.c proc-region-rw.a memio-uio.a memio-stream.a
-ptrace-address-rw: src/ptrace-address-rw.c src/cli/proc-address-rw.c src/mem/io-ptrace.c src/mem/io-stream.c
-ptrace-region-rw: src/ptrace-region-rw.c src/cli/proc-region-rw.c src/mem/io-ptrace.c src/mem/io-stream.c
-uio-region-rw: private CPPFLAGS += -D_GNU_SOURCE
-uio-region-rw: src/uio-region-rw.c src/cli/proc-region-rw.c src/mem/io-uio.c src/mem/io-stream.c
-uio-address-rw: private CPPFLAGS += -D_GNU_SOURCE
-uio-address-rw: src/uio-address-rw.c src/cli/proc-address-rw.c src/mem/io-uio.c src/mem/io-stream.c
-binsearch: src/binsearch.c
-bintrim: src/bintrim.c
+binsearch: src/binsearch.c src/util.h
+bintrim: src/bintrim.c src/util.h
install-bin: $(bins)
install -Dm755 $^ -t "$(DESTDIR)$(PREFIX)$(bindir)"
@@ -31,6 +40,6 @@ install-bin: $(bins)
install: install-bin
clean:
- $(RM) $(bins)
+ $(RM) $(bins) *.a
.PHONY: all clean install