commit a5b48823f897dcbbc8acc38defc82eddc2de034b
parent 50257af667f359b2a3a20fa368731f67821d3ce4
Author: Dominik Schmidt <dominik@schm1dt.ch>
Date: Sun, 21 Jun 2020 12:31:25 +0200
Add a gnu makefile
Diffstat:
A | Makefile | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,43 @@
+DMD ?= dmd
+DEBUG ?= -g
+RELEASE ?= -release
+DFLAGS ?= -O
+INCLUDES = src
+SRC := $(wildcard src/*.d )
+TARGET = dpuzzle
+LIBS =
+
+_DFLAGS := $(addprefix -I, $(INCLUDES)) $(addprefix -L-l, $(LIBS)) $(DFLAGS)
+
+.PHONY: all shared static clean distclean
+
+all: shared static
+shared: lib$(TARGET)-debug.so lib$(TARGET).so
+static: lib$(TARGET)-debug.a lib$(TARGET).a
+
+lib$(TARGET).a: $(patsubst %.d,%.o,$(SRC))
+ $(DMD) $(_DFLAGS) $(RELEASE) -lib -of$@ $^
+lib$(TARGET)-debug.a: $(patsubst %.d, %-debug.o,$(SRC))
+ $(DMD) $(_DFLAGS) $(DEBUG) -lib -of$@ $^
+lib$(TARGET).so: $(patsubst %.d, %.o, $(SRC))
+ $(DMD) $(_DFLAGS) $(RELEASE) -shared -of$@ $^
+lib$(TARGET)-debug.so: $(patsubst %.d, %-debug.o, $(SRC))
+ $(DMD) $(_DFLAGS) $(DEBUG) -shared -of$@ $^
+
+%.o:%.d
+ $(DMD) $(_DFLAGS) $(RELEASE) -c -of$@ $<
+%-debug.o:%.d
+ $(DMD) $(_DFLAGS) $(DEBUG) -c -of$@ $<
+
+
+.PHONY: clean distclean doc install
+
+clean:
+ rm -f $(patsubst %.d, %.o, $(SRC)) $(patsubst %.d,%-debug.o,$(SRC))
+
+distclean: clean
+ rm -f lib$(TARGET){,-debug}.{so,a}
+
+doc: $(SRC)
+ dmd -D -Dddoc $^ -c
+