-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile.win
152 lines (132 loc) · 4.8 KB
/
Makefile.win
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Useage Examples
# ---------------
# 'make -f Makefile.win' make everything using dmd, standard build, 32-bit
# 'make -f Makefile.win install PREFIX=InstallDir' same as above, but also install to directory InstallDir
# 'make -f Makefile.win clean' delete last build output so you can build again
#
# Summary
# -------
# This is a makefile for windows. Install MSYS first (for make & other tools), set your *System* Path variable to MSYS's bin directory (where make.exe),
# so that you can run make from any where and your command shell will find it). Pass in variable assignments such as doing 'make MODEL=64' to mean build
# for 64-bit machines. Here are all the possible variable assignments accessible at the command line:
#
# Variable Possible Values Default Value Description
# ------------------------------------------------------------------------------
# DC dmd, gdc, gdmd dmd Which compiler to use.
# VERSION standard, release, debug standard Build for debug or for release?
# 'standard' means the default of the chosen compiler.
# MODEL 32, 64 32 Build 32-bit or 64-bit code?
# PREFIX (any empty directory) Install The directory to install the library and D includes to.
#
# Installation
# ------------
# Either edit your compiler's default import & library paths (for dmd that's done in dmd2/windows/bin/sc.ini), or
# copy directory & contents of InstallDir/include/d/orange to dmd2/src/orange (these are your imports for using orange in a D program),
# and copy InstallDir/lib/orange.lib to dmd2/windows/lib/orange.lib (this is orange's code that you link with). When building your program
# make sure to link with orange.lib.
#
# BUGS
# ----
# 'make clean':
# If you get:
# rm: cannot lstat 'lib//32/orange/cor': Permission denied
# make *** [clean] Error 1
# Fix: open up msconfig (Start > Run > 'msconfig'), and enable the Application Experience service
#
# Doesn't work in some shells:
# For instance, spawning a shell from GitHub's native windows app causes MSYS commands to not work.
# Fix: start your shell, e.g. PowerShell, cmd.exe directly.
LIBNAME=orange
PREFIX?=Install
DC?=dmd
#Warning, unittests fail with VERSION=release
VERSION?=standard
LIBDIR=lib/$(MODEL)
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
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 .obj,$(addprefix $(LIBDIR)/$(LIBNAME)/,$(basename $(SRC))))
HEADER=$(addsuffix .di,$(addprefix import/$(LIBNAME)/,$(basename $(SRC))))
TARGET=$(LIBDIR)/$(LIBNAME).lib
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/$(LIBNAME).lib
@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.obj unittest
$(TARGET): $(OBJ)
$(LIBCOMMAND)
$(LIBDIR)/$(LIBNAME)/%.obj: $(LIBNAME)/%.d
$(DC) -c $(DCFLAGS) -of$@ $<
import/$(LIBNAME)/%.di: $(LIBNAME)/%.d
$(DC) -c -o- -Hf$@ $<