forked from snazzy-d/sdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
58 lines (43 loc) · 1.25 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
DMD ?= dmd
GCC ?= gcc
ARCHFLAG ?= -m64
DFLAGS = $(ARCHFLAG) -w -debug -gc -unittest
# DFLAGS = $(ARCHFLAG) -w -O -release
LLVM_CONFIG ?= llvm-config
LLVM_LIB = `$(LLVM_CONFIG) --ldflags` `$(LLVM_CONFIG) --libs`
LIBD_LIB = -Llib -ld-llvm -ld
LDFLAGS ?=
ifdef LD_PATH
LDFLAGS += $(addprefix -L, $(LD_PATH))
endif
LDFLAGS += -lphobos2 $(LIBD_LIB) $(LLVM_LIB)
PLATFORM = $(shell uname -s)
ifeq ($(PLATFORM),Linux)
LDFLAGS += -lstdc++ -export-dynamic -ldl -lffi -lpthread -lm -lncurses
endif
ifeq ($(PLATFORM),Darwin)
LDFLAGS += -lc++ -lncurses
endif
IMPORTS = $(LIBD_LLVM_IMPORTS) -I$(LIBD_LLVM_ROOT)/src
SOURCE = src/sdc/*.d src/util/*.d
SDC = bin/sdc
LIBD_LLVM_ROOT = libd-llvm
LIBSDRT_ROOT = libsdrt
LIBSDRT_EXTRA_DEPS = $(SDC) bin/sdc.conf
ALL_TARGET = $(LIBSDRT)
include libd-llvm/makefile.common
include libsdrt/makefile.common
$(SDC): obj/sdc.o $(LIBD) $(LIBD_LLVM)
@mkdir -p bin
gcc -o $(SDC) obj/sdc.o -m64 $(LDFLAGS)
obj/sdc.o: $(SOURCE)
@mkdir -p lib obj
$(DMD) -c -ofobj/sdc.o $(SOURCE) $(DFLAGS) $(IMPORTS)
bin/sdc.conf:
@mkdir -p bin
echo "{\n\t\"includePath\": [\"$(PWD)/libs\", \".\"],\n\t\"libPath\": [\"$(PWD)/lib\"],\n}" > $@
clean:
rm -rf obj lib $(SDC)
doc:
$(DMD) -o- -op -c -Dddoc index.dd $(SOURCE) $(DFLAGS)
.PHONY: clean run debug doc