-
Notifications
You must be signed in to change notification settings - Fork 24
/
command.make
313 lines (292 loc) · 7.22 KB
/
command.make
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
ifdef SystemRoot
OS = "Windows"
STATIC_LIB_EXT = .lib
DYNAMIC_LIB_EXT = .dll
PATH_SEP =\
message = @(echo $1)
SHELL = cmd.exe
Filter = %/linux/%.d %/darwin/%.d %/freebsd/%.d %/solaris/%.d
getSource =$(shell dir $(ROOT_SOURCE_DIR) /s /b)
else
SHELL = sh
PATH_SEP =/
getSource =$(shell find $(ROOT_SOURCE_DIR) -name "*.d")
ifeq ($(shell uname), Linux)
OS = "Linux"
STATIC_LIB_EXT = .a
DYNAMIC_LIB_EXT = .so
message = @(echo \033[31m $1 \033[0;0m1)
Filter = %/win32/%.d %/darwin/%.d %/freebsd/%.d %/solaris/%.d
else ifeq ($(shell uname), Solaris)
STATIC_LIB_EXT = .a
DYNAMIC_LIB_EXT = .so
OS = "Solaris"
message = @(echo \033[31m $1 \033[0;0m1)
Filter = %/win32/%.d %/linux/%.d %/darwin/%.d %/freebsd/%.d
else ifeq ($(shell uname),Freebsd)
STATIC_LIB_EXT = .a
DYNAMIC_LIB_EXT = .so
OS = "Freebsd"
message = @(echo \033[31m $1 \033[0;0m1)
Filter = %/win32/%.d %/linux/%.d %/darwin/%.d %/solaris/%.d
else ifeq ($(shell uname),Darwin)
STATIC_LIB_EXT = .a
DYNAMIC_LIB_EXT = .so
OS = "Darwin"
message = @(echo \033[31m $1 \033[0;0m1)
Filter = %/win32/%.d %/linux/%.d %/freebsd/%.d %/solaris/%.d
endif
endif
# Define command for copy, remove and create file/dir
ifeq ($(OS),"Windows")
RM = del /Q
CP = copy /Y
MKDIR = mkdir
MV = move
LN = mklink
else ifeq ($(OS),"Linux")
RM = rm -fr
CP = cp -fr
MKDIR = mkdir -p
MV = mv
LN = ln -s
else ifeq ($(OS),"Freebsd")
RM = rm -fr
CP = cp -fr
MKDIR = mkdir -p
MV = mv
LN = ln -s
else ifeq ($(OS),"Solaris")
RM = rm -fr
CP = cp -fr
MKDIR = mkdir -p
MV = mv
LN = ln -s
else ifeq ($(OS),"Darwin")
RM = rm -fr
CP = cp -fr
MKDIR = mkdir -p
MV = mv
LN = ln -s
endif
# If compiler is not define try to find it
ifndef DC
ifneq ($(strip $(shell which dmd 2>/dev/null)),)
DC=dmd
else ifneq ($(strip $(shell which ldc 2>/dev/null)),)
DC=ldc
else ifneq ($(strip $(shell which ldc2 2>/dev/null)),)
DC=ldc2
else
DC=gdc
endif
endif
# Define flag for gdc other
ifeq ($(DC),gdc)
DCFLAGS = -O2 -fdeprecated
LINKERFLAG= -Wl,
OUTPUT = -o
HF = -fintfc-file=
DF = -fdoc-file=
NO_OBJ = -fsyntax-only
DDOC_MACRO= -fdoc-inc=
else
DCFLAGS = -O -d
LINKERFLAG= -L
OUTPUT = -of
HF = -Hf
DF = -Df
NO_OBJ = -o-
DDOC_MACRO=
endif
#define a suffix lib who inform is build with which compiler, name of phobos lib
ifeq ($(DC),gdc)
COMPILER = gdc
VERSION = -fversion
SONAME_FLAG = $(LINKERFLAG) -soname
PHOBOS = gphobos2
DRUNTIME = gdruntime
else ifeq ($(DC),gdmd)
COMPILER = gdc
VERSION = -fversion
SONAME_FLAG = $(LINKERFLAG) -soname
PHOBOS = gphobos2
DRUNTIME = gdruntime
else ifeq ($(DC),ldc)
COMPILER = ldc
VERSION = -d-version
SONAME_FLAG = -soname
PHOBOS = phobos-ldc
DRUNTIME = druntime-ldc
else ifeq ($(DC),ldc2)
COMPILER = ldc
VERSION = -d-version
SONAME_FLAG = -soname
PHOBOS = phobos-ldc
DRUNTIME = druntime-ldc
else ifeq ($(DC),ldmd)
COMPILER = ldc
VERSION = -d-version
SONAME_FLAG = -soname
PHOBOS = phobos2-ldc
DRUNTIME = druntime-ldc
else ifeq ($(DC),dmd)
COMPILER = dmd
VERSION = -version
SONAME_FLAG = $(LINKERFLAG)-soname
PHOBOS = phobos2
DRUNTIME = druntime
else ifeq ($(DC),dmd2)
COMPILER = dmd
VERSION = -d-version
SONAME_FLAG = $(LINKERFLAG)-soname
PHOBOS = phobos2
DRUNTIME = druntime
endif
# Define relocation model for ldc or other
ifneq (,$(findstring ldc,$(DC)))
FPIC = -relocation-model=pic
else
FPIC = -fPIC
endif
# Add -ldl flag for linux
ifeq ($(OS),"Linux")
LDCFLAGS += $(LINKERFLAG)-ldl
endif
# If model are not given take the same as current system
ifndef ARCH
ifeq ($(OS),"Windows")
ifeq ($(PROCESSOR_ARCHITECTURE), x86)
ARCH = x86
else
ARCH = x86_64
endif
else
ARCH = $(shell arch 2>/dev/null || uname -m)
endif
endif
ifndef MODEL
ifeq ($(ARCH), x86_64)
MODEL = 64
else
MODEL = 32
endif
endif
ifeq ($(MODEL), 64)
DCFLAGS += -m64
LDCFLAGS += -m64
else
DCFLAGS += -m32
LDCFLAGS += -m32
endif
ifndef DESTDIR
DESTDIR =
endif
# Define var PREFIX, BIN_DIR, LIB_DIR, INCLUDE_DIR, DATA_DIR
ifndef PREFIX
ifeq ($(OS),"Windows")
PREFIX = $(PROGRAMFILES)
else ifeq ($(OS), "Linux")
PREFIX = /usr/local
else ifeq ($(OS), "Darwin")
PREFIX = /usr/local
endif
endif
ifndef BIN_DIR
ifeq ($(OS), "Windows")
BIN_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\bin
else ifeq ($(OS), "Linux")
BIN_DIR = $(PREFIX)/bin
else ifeq ($(OS), "Darwin")
BIN_DIR = $(PREFIX)/bin
endif
endif
ifndef LIB_DIR
ifeq ($(OS), "Windows")
LIB_DIR = $(PREFIX)\$(PROJECT_NAME)\lib
else ifeq ($(OS), "Linux")
LIB_DIR = $(PREFIX)/lib
else ifeq ($(OS), "Darwin")
LIB_DIR = $(PREFIX)/lib
endif
endif
ifndef INCLUDE_DIR
ifeq ($(OS), "Windows")
INCLUDE_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\import
else
INCLUDE_DIR = $(PREFIX)/include/d/
endif
endif
ifndef DATA_DIR
ifeq ($(OS), "Windows")
DATA_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\data
else
DATA_DIR = $(PREFIX)/share
endif
endif
ifndef PKGCONFIG_DIR
ifeq ($(OS), "Windows")
PKGCONFIG_DIR = $(PROGRAMFILES)\$(PROJECT_NAME)\data
else
PKGCONFIG_DIR = $(DATA_DIR)/pkgconfig
endif
endif
ifndef CC
CC = gcc
endif
DLIB_PATH = ./lib
IMPORT_PATH = ./import
DOC_PATH = ./doc
DDOC_PATH = ./ddoc
BUILD_PATH = ./build
DCFLAGS_IMPORT = -I"glamour/"
DCFLAGS_LINK = $(LDCFLAGS) $(LINKERFLAG)-lDerelictGL $(LINKERFLAG)-lDerelictIL $(LINKERFLAG)-lDerelictUtil
STATIC_LIBNAME = lib$(PROJECT_NAME)-$(COMPILER)$(STATIC_LIB_EXT)
SHARED_LIBNAME = lib$(PROJECT_NAME)-$(COMPILER)$(DYNAMIC_LIB_EXT)
PKG_CONFIG_FILE = $(PROJECT_NAME).pc
MAKE = make
AR = ar
ARFLAGS = rcs
RANLIB = ranlib
export AR
export ARCH
export ARFLAGS
export BIN_DIR
export BUILD_PATH
export CC
export COMPILER
export CP
export DATA_DIR
export DC
export DF
export DCFLAGS
export DCFLAGS_IMPORT
export DCFLAGS_LINK
export DESTDIR
export DLIB_PATH
export DOC_PATH
export DDOC_PATH
export DYNAMIC_LIB_EXT
export FixPath
export HF
export INCLUDE_DIR
export IMPORT_PATH
export LDCFLAGS
export FPIC
export LIBNAME
export LIB_DIR
export LINKERFLAG
export message
export MAKE
export MKDIR
export MODEL
export MV
export OUTPUT
export OS
export PATH_SEP
export PKG_CONFIG_FILE
export PREFIX
export RANLIB
export RM
export STATIC_LIB_EXT
export SONAME