Skip to content
Newer
Older
100644 334 lines (281 sloc) 10.4 KB
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
1 # Makefile to build linux D runtime library libphobos2.a and its unit test
2 #
3 # make clean => removes all targets built by the makefile
4 #
5 # make zip => creates a zip file of all the sources (not targets)
6 # referred to by the makefile, including the makefile
7 #
8 # make release => makes release build of the library (this is also the
9 # default target)
10 #
11 # make debug => makes debug build of the library
12 #
13 # make unittest => builds all unittests (for both debug and release)
14 # and runs them
15 #
16 # make html => makes html documentation
17 #
18 # make install => copies library to /usr/lib
19
20 # Configurable stuff, usually from the command line
21 #
22 # OS can be linux, win32, win32remote, win32wine, osx, or freebsd. If left
23 # blank, the system will be determined by using uname
24
25 ifeq (,$(OS))
26 OS:=$(shell uname)
27 ifeq (Darwin,$(OS))
28 OS:=osx
29 else
30 ifeq (Linux,$(OS))
31 OS:=linux
32 else
33 ifeq (FreeBSD,$(OS))
34 OS:=freebsd
35 else
36 $(error Unrecognized or unsupported OS for uname: $(OS))
37 endif
38 endif
39 endif
40 endif
41
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
42 # For now, 32 bit is the default model
43 ifeq (,$(MODEL))
44 MODEL:=32
45 endif
46
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
47 # Configurable stuff that's rarely edited
48 DRUNTIME_PATH = ../druntime
49 ZIPFILE = phobos.zip
50 ROOT_OF_THEM_ALL = generated
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
51 ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
52 # Documentation-related stuff
0c6b3e9 @andralex Updated website-related build
andralex authored Jan 30, 2011
53 DOCSRC = ../d-programming-language.org
54 WEBSITE_DIR = ../web
55 DOC_OUTPUT_DIR = $(WEBSITE_DIR)/phobos-prerelease
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
56 BIGDOC_OUTPUT_DIR = /tmp
27dc39c @complexmath Fixed build error on Posix. std/net/isemail.d was preset twice in the…
complexmath authored Jun 16, 2011
57 SRC_DOCUMENTABLES = index.d $(addsuffix .d,$(STD_MODULES) $(STD_NET_MODULES) $(EXTRA_DOCUMENTABLES))
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
58 STDDOC = $(DOCSRC)/std.ddoc
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
59 BIGSTDDOC = $(DOCSRC)/std_consolidated.ddoc
60 DDOCFLAGS=-m$(MODEL) -d -c -o- -version=StdDdoc -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
61
62 # Variable defined in an OS-dependent manner (see below)
63 CC =
52b133b Make $(DMD) properly configurable.
alexrp authored Apr 10, 2012
64 DMD ?=
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
65 DDOC =
66 CFLAGS =
67 DFLAGS =
68
69 # BUILD can be debug or release, but is unset by default; recursive
70 # invocation will set it. See the debug and release targets below.
71 BUILD =
72
73 # Fetch the makefile name, will use it in recursive calls
74 MAKEFILE:=$(lastword $(MAKEFILE_LIST))
75
76 # Set DRUNTIME name and full path
77 ifeq (,$(findstring win,$(OS)))
982b350 @andralex Sync with new druntime naming convention
andralex authored Jan 17, 2012
78 DRUNTIME = $(DRUNTIME_PATH)/lib/libdruntime-$(OS)$(MODEL).a
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
79 else
80 DRUNTIME = $(DRUNTIME_PATH)/lib/druntime.lib
81 endif
82
83 # Set CC and DMD
84 ifeq ($(OS),win32wine)
31395f9 @kyllingstad Do not specify paths to DMD and DMC under Wine
kyllingstad authored Jun 1, 2011
85 CC = wine dmc.exe
52b133b Make $(DMD) properly configurable.
alexrp authored Apr 10, 2012
86 DMD ?= wine dmd.exe
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
87 RUN = wine
88 else
89 ifeq ($(OS),win32remote)
52b133b Make $(DMD) properly configurable.
alexrp authored Apr 10, 2012
90 DMD ?= ssh 206.125.170.138 "cd code/dmd/phobos && dmd"
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
91 CC = ssh 206.125.170.138 "cd code/dmd/phobos && dmc"
92 else
52b133b Make $(DMD) properly configurable.
alexrp authored Apr 10, 2012
93 DMD ?= dmd
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
94 ifeq ($(OS),win32)
95 CC = dmc
96 else
97 CC = cc
98 endif
99 endif
100 RUN =
101 endif
102
103 # Set CFLAGS
104 ifeq ($(CC),cc)
105 CFLAGS += -m$(MODEL)
106 ifeq ($(BUILD),debug)
107 CFLAGS += -g
108 else
109 CFLAGS += -O3
110 endif
111 endif
112
113 # Set DFLAGS
3afa5e3 @klickverbot Add -property to default build to prevent regressions.
klickverbot authored Dec 1, 2011
114 DFLAGS := -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -d -property -m$(MODEL)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
115 ifeq ($(BUILD),debug)
116 DFLAGS += -g -debug
117 else
118 DFLAGS += -O -release -nofloat
119 endif
120
121 # Set DOTOBJ and DOTEXE
122 ifeq (,$(findstring win,$(OS)))
123 DOTOBJ:=.o
124 DOTEXE:=
125 PATHSEP:=/
126 else
127 DOTOBJ:=.obj
128 DOTEXE:=.exe
129 PATHSEP:=$(shell echo "\\")
130 endif
131
132 # Set LINKOPTS
133 ifeq (,$(findstring win,$(OS)))
134 ifeq (freebsd,$(OS))
135 LINKOPTS=-L-L$(ROOT)
136 else
137 LINKOPTS=-L-ldl -L-L$(ROOT)
138 endif
139 else
140 LINKOPTS=-L/co $(LIB)
141 endif
142
143 # Set DDOC, the documentation generator
def8ccb @andralex minor bug in documentation generator
andralex authored Dec 23, 2011
144 DDOC=$(DMD)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
145
146 # Set LIB, the ultimate target
147 ifeq (,$(findstring win,$(OS)))
148 LIB = $(ROOT)/libphobos2.a
149 else
150 LIB = $(ROOT)/phobos.lib
151 endif
152
153 ################################################################################
154 MAIN = $(ROOT)/emptymain.d
155
156 # Stuff in std/
dd3a0c2 @jmdavis Created std.ascii to replace std.ctype.
jmdavis authored Jun 14, 2011
157 STD_MODULES = $(addprefix std/, algorithm array ascii base64 bigint \
158 bitmanip compiler complex concurrency container contracts conv \
95b3fb8 @jmdavis Removed the deprecated std.date.
jmdavis authored Mar 10, 2012
159 cpuid cstream ctype csv datetime demangle encoding exception \
160 file format functional getopt json loader math mathspecial md5 \
161 metastrings mmfile numeric outbuffer parallelism path perf \
162 process random range regex regexp signals socket socketstream \
163 stdint stdio stdiobase stream string syserror system traits \
164 typecons typetuple uni uri utf variant xml zip zlib)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
165
ad8b04a @jcd Move to etc.curl to std.net.curl
jcd authored Jan 10, 2012
166 STD_NET_MODULES = $(addprefix std/net/, isemail curl)
0394e12 @jacob-carlborg Added std.net.isemail to the posix makefile.
jacob-carlborg authored Mar 2, 2011
167
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
168 # OS-specific D modules
e992081 @jcd clean up makefile
jcd authored Jan 16, 2012
169 EXTRA_MODULES_LINUX := $(addprefix std/c/linux/, linux socket)
b6a2680 @WalterBright add missing files to manifest
WalterBright authored Jan 30, 2011
170 EXTRA_MODULES_OSX := $(addprefix std/c/osx/, socket)
171 EXTRA_MODULES_FREEBSD := $(addprefix std/c/freebsd/, socket)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
172 EXTRA_MODULES_WIN32 := $(addprefix std/c/windows/, com stat windows \
173 winsock) $(addprefix std/windows/, charset iunknown syserror)
174 ifeq (,$(findstring win,$(OS)))
a3953a2 @jmdavis Switching the order of some stuff seems to fix the linux build.
jmdavis authored Jun 12, 2011
175 EXTRA_DOCUMENTABLES:=$(EXTRA_MODULES_LINUX)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
176 else
a3953a2 @jmdavis Switching the order of some stuff seems to fix the linux build.
jmdavis authored Jun 12, 2011
177 EXTRA_DOCUMENTABLES:=$(EXTRA_MODULES_WIN32)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
178 endif
179
a3953a2 @jmdavis Switching the order of some stuff seems to fix the linux build.
jmdavis authored Jun 12, 2011
180 # Other D modules that aren't under std/
ded26fa @braddr add sqlite3 doc building
braddr authored Dec 17, 2011
181 EXTRA_DOCUMENTABLES += $(addprefix etc/c/,curl sqlite3 zlib) $(addprefix \
a3953a2 @jmdavis Switching the order of some stuff seems to fix the linux build.
jmdavis authored Jun 12, 2011
182 std/c/, fenv locale math process stdarg stddef stdio stdlib string \
183 time wcharh)
184 EXTRA_MODULES += $(EXTRA_DOCUMENTABLES) $(addprefix \
185 std/internal/math/, biguintcore biguintnoasm biguintx86 \
3e0415c @WalterBright add fat library target for OSX
WalterBright authored Dec 2, 2011
186 gammafunction errorfunction) $(addprefix std/internal/, \
187 processinit uni uni_tab)
a3953a2 @jmdavis Switching the order of some stuff seems to fix the linux build.
jmdavis authored Jun 12, 2011
188
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
189 # Aggregate all D modules relevant to this build
0394e12 @jacob-carlborg Added std.net.isemail to the posix makefile.
jacob-carlborg authored Mar 2, 2011
190 D_MODULES = crc32 $(STD_MODULES) $(EXTRA_MODULES) $(STD_NET_MODULES)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
191 # Add the .d suffix to the module names
192 D_FILES = $(addsuffix .d,$(D_MODULES))
193 # Aggregate all D modules over all OSs (this is for the zip file)
a878c8a @jcd Fix makefile to include files in std/net/
jcd authored Jan 17, 2012
194 ALL_D_FILES = $(addsuffix .d, $(D_MODULES) \
e5066e6 @WalterBright add missing files to zip build
WalterBright authored Oct 8, 2011
195 $(EXTRA_MODULES_LINUX) $(EXTRA_MODULES_OSX) $(EXTRA_MODULES_FREEBSD) $(EXTRA_MODULES_WIN32)) \
99ab2b6 @denis-sh Remove __file.d and it's using
denis-sh authored Jan 24, 2012
196 std/stdarg.d std/bind.d std/internal/windows/advapi32.d \
e5066e6 @WalterBright add missing files to zip build
WalterBright authored Oct 8, 2011
197 std/windows/registry.d std/c/linux/pthread.d std/c/linux/termios.d \
b44e3db @WalterBright add missing file
WalterBright authored Jan 30, 2012
198 std/c/linux/tipc.d std/net/isemail.d std/net/curl.d
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
199
200 # C files to be part of the build
201 C_MODULES = $(addprefix etc/c/zlib/, adler32 compress crc32 deflate \
202 gzclose gzlib gzread gzwrite infback inffast inflate inftrees trees uncompr zutil)
203 C_FILES = $(addsuffix .c,$(C_MODULES))
204 # C files that are not compiled (right now only zlib-related)
205 C_EXTRAS = $(addprefix etc/c/zlib/, algorithm.txt ChangeLog crc32.h \
206 deflate.h example.c inffast.h inffixed.h inflate.h inftrees.h \
207 linux.mak minigzip.c osx.mak README trees.h win32.mak zconf.h \
208 gzguts.h zlib.3 zlib.h zutil.h)
209 # Aggregate all C files over all OSs (this is for the zip file)
210 ALL_C_FILES = $(C_FILES) $(C_EXTRAS)
211
212 OBJS = $(addsuffix $(DOTOBJ),$(addprefix $(ROOT)/,$(C_MODULES)))
213
214 ################################################################################
215 # Rules begin here
216 ################################################################################
217
218 ifeq ($(BUILD),)
219 # No build was defined, so here we define release and debug
220 # targets. BUILD is not defined in user runs, only by recursive
221 # self-invocations. So the targets in this branch are accessible to
222 # end users.
223 release :
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
224 $(MAKE) --no-print-directory -f $(MAKEFILE) OS=$(OS) MODEL=$(MODEL) BUILD=release
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
225 debug :
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
226 $(MAKE) --no-print-directory -f $(MAKEFILE) OS=$(OS) MODEL=$(MODEL) BUILD=debug
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
227 unittest :
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
228 $(MAKE) --no-print-directory -f $(MAKEFILE) OS=$(OS) MODEL=$(MODEL) BUILD=debug unittest
229 $(MAKE) --no-print-directory -f $(MAKEFILE) OS=$(OS) MODEL=$(MODEL) BUILD=release unittest
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
230 else
231 # This branch is normally taken in recursive builds. All we need to do
232 # is set the default build to $(BUILD) (which is either debug or
233 # release) and then let the unittest depend on that build's unittests.
234 $(BUILD) : $(LIB)
235 unittest : $(addsuffix $(DOTEXE),$(addprefix $(ROOT)/unittest/,$(D_MODULES)))
236 endif
237
238 ################################################################################
239
240 $(ROOT)/%$(DOTOBJ) : %.c
241 @[ -d $(dir $@) ] || mkdir -p $(dir $@) || [ -d $(dir $@) ]
242 $(CC) -c $(CFLAGS) $< -o$@
243
244 $(LIB) : $(OBJS) $(ALL_D_FILES) $(DRUNTIME)
245 $(DMD) $(DFLAGS) -lib -of$@ $(DRUNTIME) $(D_FILES) $(OBJS)
246
e696518 @WalterBright add fat library target for OSX
WalterBright authored Dec 2, 2011
247 ifeq (osx,$(OS))
248 # Build fat library that combines the 32 bit and the 64 bit libraries
249 libphobos2.a : generated/osx/release/32/libphobos2.a generated/osx/release/64/libphobos2.a
3e0415c @WalterBright add fat library target for OSX
WalterBright authored Dec 3, 2011
250 lipo generated/osx/release/32/libphobos2.a generated/osx/release/64/libphobos2.a -create -output generated/osx/release/libphobos2.a
e696518 @WalterBright add fat library target for OSX
WalterBright authored Dec 3, 2011
251 endif
41c3dc1 @braddr Enable some now passing tests, and rework the disabled list to includ…
braddr authored Feb 5, 2011
252
1083bd4 @andralex One pass through std.range and friends
andralex authored Feb 26, 2011
253 $(addprefix $(ROOT)/unittest/,$(DISABLED_TESTS)) :
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
254 @echo Testing $@ - disabled
255
256 $(ROOT)/unittest/%$(DOTEXE) : %.d $(LIB) $(ROOT)/emptymain.d
257 @echo Testing $@
b6cfde7 @andralex Put binaries in different dirs depending on MODEL
andralex authored Jan 16, 2011
258 @$(DMD) $(DFLAGS) -unittest $(LINKOPTS) $(subst /,$(PATHSEP),"-of$@") \
259 $(ROOT)/emptymain.d $<
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
260 # make the file very old so it builds and runs again if it fails
261 @touch -t 197001230123 $@
262 # run unittest in its own directory
263 @$(RUN) $@
264 # succeeded, render the file new again
265 @touch $@
266
267 # Disable implicit rule
268 %$(DOTEXE) : %$(DOTOBJ)
269
270 $(ROOT)/emptymain.d : $(ROOT)/.directory
271 @echo 'void main(){}' >$@
272
273 $(ROOT)/.directory :
274 mkdir -p $(ROOT) || exists $(ROOT)
275 touch $@
276
277 clean :
278 rm -rf $(ROOT_OF_THEM_ALL) $(ZIPFILE) $(DOC_OUTPUT_DIR)
279
280 zip :
281 zip $(ZIPFILE) $(MAKEFILE) $(ALL_D_FILES) $(ALL_C_FILES)
282
283 install : release
284 sudo cp $(LIB) /usr/lib/
285
286 $(DRUNTIME) :
3e0415c @WalterBright add fat library target for OSX
WalterBright authored Dec 3, 2011
287 $(MAKE) -C $(DRUNTIME_PATH) -f posix.mak MODEL=$(MODEL)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
288
289 ###########################################################
290 # html documentation
291
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
292 HTMLS=$(addprefix $(DOC_OUTPUT_DIR)/, $(subst /,_,$(subst .d,.html, \
293 $(SRC_DOCUMENTABLES))))
294 BIGHTMLS=$(addprefix $(BIGDOC_OUTPUT_DIR)/, $(subst /,_,$(subst \
295 .d,.html, $(SRC_DOCUMENTABLES))))
296
1083bd4 @andralex One pass through std.range and friends
andralex authored Feb 26, 2011
297 $(DOC_OUTPUT_DIR)/. :
298 mkdir -p $@
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
299
300 $(DOC_OUTPUT_DIR)/std_%.html : std/%.d $(STDDOC)
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
301 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
302
303 $(DOC_OUTPUT_DIR)/std_c_%.html : std/c/%.d $(STDDOC)
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
304 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
305
306 $(DOC_OUTPUT_DIR)/std_c_linux_%.html : std/c/linux/%.d $(STDDOC)
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
307 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
308
5a0134d @andralex Fixed 672 broken links
andralex authored Jun 8, 2011
309 $(DOC_OUTPUT_DIR)/std_c_windows_%.html : std/c/windows/%.d $(STDDOC)
310 $(DDOC) $(DDOCFLAGS) -Df$@ $<
311
ce13b8f @kyllingstad Build std.net.isemail documentation
kyllingstad authored Jun 16, 2011
312 $(DOC_OUTPUT_DIR)/std_net_%.html : std/net/%.d $(STDDOC)
313 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
314
24b8162 @andralex Added documentation generation for libcurl
andralex authored Jun 2, 2011
315 $(DOC_OUTPUT_DIR)/etc_c_%.html : etc/c/%.d $(STDDOC)
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
316 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
24b8162 @andralex Added documentation generation for libcurl
andralex authored Jun 2, 2011
317
1083bd4 @andralex One pass through std.range and friends
andralex authored Feb 26, 2011
318 $(DOC_OUTPUT_DIR)/%.html : %.d $(STDDOC)
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
319 $(DDOC) $(DDOCFLAGS) $(STDDOC) -Df$@ $<
1083bd4 @andralex One pass through std.range and friends
andralex authored Feb 26, 2011
320
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
321 html : $(DOC_OUTPUT_DIR)/. $(HTMLS) $(STYLECSS_TGT)
dae504c @braddr set the svn:eol-style to native
braddr authored Jan 4, 2011
322
0c6b3e9 @andralex Updated website-related build
andralex authored Jan 30, 2011
323 rsync-prerelease : html
324 rsync -avz $(DOC_OUTPUT_DIR)/ d-programming@digitalmars.com:data/phobos-prerelease/
325 rsync -avz $(WEBSITE_DIR)/ d-programming@digitalmars.com:data/phobos-prerelase/
83f9fa5 @andralex Added support for consolidated documentation in one single html file
andralex authored Jun 9, 2011
326
327 html_consolidated :
328 $(DDOC) $(DDOCFLAGS) -Df$(DOCSRC)/std_consolidated_header.html $(DOCSRC)/std_consolidated_header.dd
329 $(DDOC) $(DDOCFLAGS) -Df$(DOCSRC)/std_consolidated_footer.html $(DOCSRC)/std_consolidated_footer.dd
330 $(MAKE) DOC_OUTPUT_DIR=$(BIGDOC_OUTPUT_DIR) STDDOC=$(BIGSTDDOC) html -j 8
331 cat $(DOCSRC)/std_consolidated_header.html $(BIGHTMLS) \
332 $(DOCSRC)/std_consolidated_footer.html > $(DOC_OUTPUT_DIR)/std_consolidated.html
cd5b53f @braddr enable std.conv tests on 64 bit platforms.. seems to pass on linux now
braddr authored Nov 28, 2011
333
Something went wrong with that request. Please try again.