-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
116 lines (98 loc) · 2.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
LIBNAME=orange
DC?=dmd
PREFIX?=/usr/local
#Warning, unittests fail with VERSION=release
VERSION?=standard
LIBDIR=lib/$(MODEL)
ARCH=$(shell arch || uname -m)
SRC=core/Attribute.d \
serialization/Events.d \
serialization/RegisterWrapper.d \
serialization/Serializable.d \
serialization/SerializationException.d \
serialization/Serializer.d \
serialization/_.d \
serialization/archives/Archive.d \
serialization/archives/XmlArchive.d \
serialization/archives/_.d \
util/CTFE.d \
util/Reflection.d \
util/Traits.d \
util/Use.d \
util/_.d \
util/collection/Array.d \
util/collection/_.d \
xml/PhobosXml.d \
xml/XmlDocument.d \
xml/_.d
UNITTEST=tests/Array.d \
tests/AssociativeArray.d \
tests/AssociativeArrayReference.d \
tests/BaseClass.d \
tests/Custom.d \
tests/Enum.d \
tests/Event.d \
tests/Events.d \
tests/NonIntrusive.d \
tests/NonSerialized.d \
tests/Object.d \
tests/OverrideSerializer.d \
tests/Pointer.d \
tests/Primitive.d \
tests/Slice.d \
tests/String.d \
tests/Struct.d \
tests/Subclass.d \
tests/unittest.d \
tests/Util.d
TEST=test/UnitTester.d
ifdef MODEL
DCFLAGS=-m$(MODEL)
else ifeq ("$(ARCH)", "x86_64")
DCFLAGS=-m64
override MODEL=64
else
DCFLAGS=-m32
override MODEL=32
endif
ifeq ("$(VERSION)","release")
DCFLAGS += -O
else ifeq ("$(VERSION)","debug")
DCFLAGS += -g
endif
ifeq ("$(DC)","dmd")
LIBCOMMAND = $(DC) -lib $(DCFLAGS) -of$@ $^
else ifeq ("$(DC)","gdc")
override DC=gdmd
LIBCOMMAND = ar rcs $@ $^
else ifeq ("$(DC)","gdmd")
LIBCOMMAND = ar rcs $@ $^
endif
# Everything below this line should be fairly generic (with a few hard-coded things).
OBJ=$(addsuffix .o,$(addprefix $(LIBDIR)/$(LIBNAME)/,$(basename $(SRC))))
HEADER=$(addsuffix .di,$(addprefix import/$(LIBNAME)/,$(basename $(SRC))))
TARGET=$(LIBDIR)/lib$(LIBNAME).a
all: mkdirs $(TARGET) $(HEADER)
mkdirs:
mkdir -p $(addprefix $(LIBDIR)/$(LIBNAME)/, $(sort $(dir $(SRC))))
install: all
@mkdir -p $(PREFIX)/lib $(PREFIX)/include/d
cp $(TARGET) $(PREFIX)/lib/
cp -r import/$(LIBNAME) $(PREFIX)/include/d
uninstall:
rm -rf $(PREFIX)/include/d/$(LIBNAME)
rm -f $(PREFIX)/lib/lib$(LIBNAME).a
@rmdir -p --ignore-fail-on-non-empty $(PREFIX)/lib $(PREFIX)/include/d 2>/dev/null || true
unittest: ~~cleanunittest
$(DC) $(DCFLAGS) -unittest -ofunittest $(addprefix $(LIBNAME)/,$(SRC)) $(UNITTEST) $(LIBNAME)/$(TEST)
./unittest
clean: ~~cleanunittest
rm -rf import/ lib/
~~cleanunittest:
rm -f unittest.o unittest
$(TARGET): $(OBJ)
$(LIBCOMMAND)
$(LIBDIR)/$(LIBNAME)/%.o: $(LIBNAME)/%.d
$(DC) -c $(DCFLAGS) -of$@ $<
import/$(LIBNAME)/%.di: $(LIBNAME)/%.d
$(DC) -c -o- -Hf$@ $<