-
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathcommon.mak
More file actions
69 lines (65 loc) · 2.16 KB
/
common.mak
File metadata and controls
69 lines (65 loc) · 2.16 KB
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
# set explicitly in the make cmdline in druntime/Makefile (`test/%/.run` rule):
ifneq (,$(findstring ldmd2,$(DMD)))
# LDC: we have no top makefile, include osmodel.mak for OS and set up bash shell on Windows
MODEL:=default
include ../../../../dmd/osmodel.mak
else
OS:=
MODEL:=
endif
BUILD:=
DMD:=
DRUNTIME:=
DRUNTIMESO:=
LINKDL:=
QUIET:=
TIMELIMIT:=
PIC:=
SHARED:=
ifeq (,$(findstring ldmd2,$(DMD)))
# Windows: set up bash shell
ifeq (windows,$(OS))
include ../../../compiler/src/osmodel.mak
endif
endif
LDL:=$(subst -L,,$(LINKDL)) # -ldl
SRC:=src
GENERATED:=./generated
ROOT:=$(GENERATED)/$(OS)/$(BUILD)/$(MODEL)
DRUNTIME_IMPLIB:=$(subst .dll,.lib,$(DRUNTIMESO))
MODEL_FLAG:=$(if $(findstring $(MODEL),default),,-m$(MODEL))
CFLAGS_BASE:=$(if $(findstring $(OS),windows),/Wall,$(MODEL_FLAG) $(PIC) -Wall)
ifeq (,$(findstring ldmd2,$(DMD)))
ifeq (osx64,$(OS)$(MODEL))
CFLAGS_BASE+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd
endif
endif
# LDC: use `-defaultlib=druntime-ldc [-link-defaultlib-shared]` instead of `-defaultlib= -L$(DRUNTIME[_IMPLIB])`
DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib=$(if $(findstring ldmd2,$(DMD)),druntime-ldc,) -preview=dip1000 $(if $(findstring $(OS),windows),,-L-lpthread -L-lm $(LINKDL))
# LINK_SHARED may be set by importing makefile
ifeq (,$(findstring ldmd2,$(DMD)))
DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIME_IMPLIB) $(if $(findstring $(OS),windows),-dllimport=all),-L$(DRUNTIME))
else
# LDC: -link-defaultlib-shared takes care of rpath, linking ldc_rt.dso.o etc.
DFLAGS+=$(if $(LINK_SHARED),-link-defaultlib-shared,)
endif
ifeq ($(BUILD),debug)
DFLAGS+=-g -debug $(if $(findstring ldmd2,$(DMD)),-link-defaultlib-debug,)
CFLAGS:=$(CFLAGS_BASE) $(if $(findstring $(OS),windows),/Zi,-g)
else
DFLAGS+=-O -ludicrous
CFLAGS:=$(CFLAGS_BASE) $(if $(findstring $(OS),windows),/O2,-O3)
endif
CXXFLAGS_BASE:=$(CFLAGS_BASE)
CXXFLAGS:=$(CFLAGS)
ifeq (windows,$(OS))
DOTEXE:=.exe
DOTDLL:=.dll
DOTLIB:=.lib
DOTOBJ:=.obj
else
DOTEXE:=
DOTDLL:=$(if $(findstring $(OS),osx),.dylib,.so)
DOTLIB:=.a
DOTOBJ:=.o
endif