-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
156 lines (125 loc) · 3.27 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
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
########################################
# Find which compilers are installed.
#
CC ?= gcc
DMD ?= $(shell which dmd)
HOST_UNAME := $(strip $(shell uname))
HOST_MACHINE := $(strip $(shell uname -m))
UNAME ?= $(HOST_UNAME)
MACHINE ?= $(strip $(shell uname -m))
ifeq ($(strip $(DMD)),)
DMD := $(shell which gdmd-v1)
ifeq ($(strip $(DMD)),)
DMD := $(shell which gdmd)
ifeq ($(strip $(DMD)),)
DMD = gdmd
endif
endif
endif
########################################
# The find which platform rules to use.
#
ifeq ($(HOST_UNAME),Linux)
OBJ_TYPE := o
else
ifeq ($(HOST_UNAME),Darwin)
OBJ_TYPE := o
else
OBJ_TYPE := obj
endif
endif
# gdmd's -g exports native D debugging info use
# that instead of emulated c ones that -gc gives us.
ifeq ($(notdir $(DMD)),gdmd)
DEBUG_DFLAGS = -g -debug
else
ifeq ($(notdir $(DMD)),gdmd-v1)
DEBUG_DFLAGS = -g -debug
else
DEBUG_DFLAGS = -gc -debug
endif
endif
CFLAGS ?= -g
DFLAGS ?= $(DEBUG_DFLAGS)
LDFLAGS ?= $(DEBUG_DFLAGS)
DDEFINES = $(ODE_DDEFINES) $(SDL_DDEFINES)
LDFLAGS_ = $(ODE_LDFLAGS) $(SDL_LDFLAGS) $(LDFLAGS)
TARGET = Charge
CCOMP_FLAGS = $(CARCH) $(CFLAGS)
MCOMP_FLAGS = $(CARCH) $(CFLAGS)
DCOMP_FLAGS = -w -Isrc -Jres/builtins -Jres/miners $(DDEFINES) $(DFLAGS)
LINK_FLAGS = -quiet -L-ldl $(LDFLAGS_)
ifneq ($(strip $(USE_SDL)),)
SDL_LDFLAGS = -L-lSDL
else
SDL_DDEFINES = -version=DynamicSDL
endif
ifneq ($(strip $(USE_ODE)),)
ODE_LDFLAGS = -L-L. -L-lode -L-lstdc++
else
ODE_DDEFINES = -version=DynamicODE
endif
ifeq ($(UNAME),Linux)
PLATFORM=linux
else
ifeq ($(UNAME),Darwin)
PLATFORM=mac
# Extra to get the program working correctly
MSRC = $(shell find src -name "*.m")
EXTRA_OBJ = $(patsubst src/%.m, $(OBJ_DIR)/%.$(OBJ_TYPE), $(MSRC))
CARCH= -arch i386 -arch x86_64
LINK_FLAGS = -quiet -L-ldl -L-framework -LCocoa $(LDFLAGS_)
else
ifeq ($(UNAME),WindowsCross)
PLATFORM=windows
TARGET = Charge.exe
# Work around winsocket issue
LINK_FLAGS = -gc -quiet -L-lgphobos -L-lws2_32 $(LDFLAGS_)
else
PLATFORM=windows
TARGET = Charge.exe
CCOMP_FLAGS = $(CARCH) -c $(CFLAGS) -o"$@"
# Change the link flags
LINK_FLAGS = -quiet $(LDFLAGS_)
endif
endif
endif
OBJ_DIR=.obj/$(PLATFORM)-$(MACHINE)
CSRC = $(shell find src -name "*.c")
COBJ = $(patsubst src/%.c, $(OBJ_DIR)/%.$(OBJ_TYPE), $(CSRC))
DSRC = $(shell find src -name "*.d")
DOBJ = $(patsubst src/%.d, $(OBJ_DIR)/%.$(OBJ_TYPE), $(DSRC))
OBJ := $(COBJ) $(DOBJ) $(EXTRA_OBJ)
all: $(TARGET)
$(OBJ_DIR)/%.$(OBJ_TYPE) : src/%.m
@echo " CC src/$*.m"
@mkdir -p $(dir $@)
@$(CC) $(MCOMP_FLAGS) -c -o $@ src/$*.m
$(OBJ_DIR)/%.$(OBJ_TYPE) : src/%.c
@echo " CC src/$*.c"
@mkdir -p $(dir $@)
@$(CC) $(CCOMP_FLAGS) -c -o $@ src/$*.c
$(OBJ_DIR)/%.$(OBJ_TYPE) : src/%.d
@echo " DMD src/$*.d"
@mkdir -p $(dir $@)
@$(DMD) $(DCOMP_FLAGS) -c -of$@ src/$*.d
$(TARGET): $(OBJ)
@echo " LD $@"
@$(DMD) $(LINK_FLAGS) -of$@ $(OBJ)
clean:
@rm -rf $(TARGET) .obj
run: $(TARGET)
@./$(TARGET)
debug: $(TARGET)
@gdb ./$(TARGET)
server: $(TARGET)
@./$(TARGET) -server
xml: $(TARGET)
@./$(TARGET) -xmltest
touch: dotouch all
dotouch:
@find src/robbers -name "*.d" | xargs touch
.PHONY: all clean run debug server xml touch dotouch
# Special dependancy for minecraft lua inbuilt scripts.
MCLUAFILES = $(shell find res/miners -name "*.lua")
$(OBJ_DIR)/miners/lua/builtin.$(OBJ_TYPE): $(MCLUAFILES)