-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (155 loc) · 7.13 KB
/
Copy pathMakefile
File metadata and controls
194 lines (155 loc) · 7.13 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
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
###############################################################################
## Makefile-gcc
##
## This file is part of Public Scripts
## Copyright (C) 2005-2011 Tom N Harris <telliamed@whoopdedo.org>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
###############################################################################
.SUFFIXES:
.SUFFIXES: .o .cpp .rc
.PRECIOUS: %.o
GAME = 2
srcdir = .
bindir = ./commonobj
bin1dir = ./t1obj
bin2dir = ./t2obj
bin3dir = ./ss2obj
bindirectories = $(bindir) $(bin1dir) $(bin2dir) $(bin3dir)
LGDIR = ../lg
SCRLIBDIR = ../ScriptLib
DH2DIR = ../DH2
DH2LIB = -ldh2
CC = gcc
CXX = g++
AR = ar
LD = g++
DLLTOOL = dlltool
RC = windres
MKDIR = mkdir -p
DEFINES = -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32_LEAN_AND_MEAN
GAME1 = -D_DARKGAME=1
GAME2 = -D_DARKGAME=2
GAME3 = -D_DARKGAME=3
ifdef DEBUG
DEFINES := $(DEFINES) -DDEBUG
CXXDEBUG = -g -O0
LDDEBUG = -g
LGLIB = -llg-d
SCR1LIB = -lScript1-d
SCR2LIB = -lScript2-d
SCR3LIB = -lScript3-d
else
DEFINES := $(DEFINES) -DNDEBUG
CXXDEBUG = -O2
LDDEBUG =
LGLIB = -llg
SCR1LIB = -lScript1
SCR2LIB = -lScript2
SCR3LIB = -lScript3
endif
ARFLAGS = rc
LDFLAGS = -mwindows -mdll -static-libgcc -static-libstdc++ -Wl,--enable-auto-image-base
LIBDIRS = -L. -L$(LGDIR) -L$(SCRLIBDIR) -L$(DH2DIR)
LIBS = $(DH2LIB) $(LGLIB) -luuid
INCLUDES = -I. -I$(srcdir) -I$(LGDIR) -I$(SCRLIBDIR) -I$(DH2DIR)
# If you care for this... # -Wno-unused-variable
# A lot of the callbacks have unused parameters, so I turn that off.
CXXFLAGS = -W -Wall -masm=intel
DLLFLAGS = --add-underscore
OSM_OBJS = $(bindir)/ScriptModule.o $(bindir)/Script.o $(bindir)/Allocator.o $(bindir)/exports.o
BASE_OBJS = $(bindir)/MsgHandlerArray.o
BASE1_OBJS = $(bin1dir)/BaseTrap.o $(bin1dir)/BaseScript.o $(bin1dir)/CommonScripts.o
BASE2_OBJS = $(bin2dir)/BaseTrap.o $(bin2dir)/BaseScript.o $(bin2dir)/CommonScripts.o
BASE3_OBJS = $(bin3dir)/BaseTrap.o $(bin3dir)/BaseScript.o $(bin3dir)/CommonScripts.o
SCR1_OBJS = $(bin1dir)/PublicScripts.o $(bin1dir)/T1Scripts.o
SCR2_OBJS = $(bin2dir)/PublicScripts.o $(bin2dir)/T2Scripts.o
SCR3_OBJS = $(bin3dir)/PublicScripts.o $(bin3dir)/SS2Scripts.o
MISC1_OBJS = $(bin1dir)/ScriptDef.o $(bin1dir)/utils.o
MISC2_OBJS = $(bin2dir)/ScriptDef.o $(bin2dir)/utils.o
MISC3_OBJS = $(bin3dir)/ScriptDef.o $(bin3dir)/utils.o
RES1_OBJS = $(bin1dir)/script_res.o
RES2_OBJS = $(bin2dir)/script_res.o
RES3_OBJS = $(bin3dir)/script_res.o
$(bindir)/%.o: $(srcdir)/%.cpp
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME2) $(INCLUDES) -o $@ -c $<
$(bin1dir)/%.o: $(srcdir)/%.cpp
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME1) $(INCLUDES) -o $@ -c $<
$(bin2dir)/%.o: $(srcdir)/%.cpp
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME2) $(INCLUDES) -o $@ -c $<
$(bin3dir)/%.o: $(srcdir)/%.cpp
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME3) $(INCLUDES) -o $@ -c $<
$(bindir)/%_res.o: $(srcdir)/%.rc
$(RC) $(DEFINES) -o $@ -i $<
$(bin1dir)/%_res.o: $(srcdir)/%.rc
$(RC) $(DEFINES) $(GAME1) -o $@ -i $<
$(bin2dir)/%_res.o: $(srcdir)/%.rc
$(RC) $(DEFINES) $(GAME2) -o $@ -i $<
$(bin3dir)/%_res.o: $(srcdir)/%.rc
$(RC) $(DEFINES) $(GAME3) -o $@ -i $<
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME2) $(INCLUDES) -o $@ -c $<
%_res.o: %.rc
$(RC) $DEFINES) -o $@ -i $<
%.osm: %.o $(OSM_OBJS)
$(LD) $(LDFLAGS) $(LDDEBUG) $(LIBDIRS) -o $@ script.def $< $(OSM_OBJS) $(SCR2LIB) $(LIBS)
all: $(bindirectories) script-t1.osm script-t2.osm script-ss2.osm version.osm
clean:
$(RM) $(bindir)/* $(bin1dir)/* $(bin2dir)/* $(bin3dir)/*
$(bindir):
$(MKDIR) $@
$(bin1dir):
$(MKDIR) $@
$(bin2dir):
$(MKDIR) $@
$(bin3dir):
$(MKDIR) $@
#.INTERMEDIATE: $(bindir)/exports.o
$(bindir)/exports.o: $(bindir)/ScriptModule.o
$(DLLTOOL) $(DLLFLAGS) --dllname script.osm --output-exp $@ $^
$(bindir)/ScriptModule.o: ScriptModule.cpp ScriptModule.h Allocator.h
$(bindir)/Script.o: Script.cpp Script.h
$(bindir)/Allocator.o: Allocator.cpp Allocator.h
$(bin1dir)/BaseScript.o: BaseScript.cpp BaseScript.h Script.h ScriptModule.h MsgHandlerArray.h
$(bin2dir)/BaseScript.o: BaseScript.cpp BaseScript.h Script.h ScriptModule.h MsgHandlerArray.h
$(bin3dir)/BaseScript.o: BaseScript.cpp BaseScript.h Script.h ScriptModule.h MsgHandlerArray.h
$(bin1dir)/BaseTrap.o: BaseTrap.cpp BaseTrap.h BaseScript.h Script.h
$(bin2dir)/BaseTrap.o: BaseTrap.cpp BaseTrap.h BaseScript.h Script.h
$(bin3dir)/BaseTrap.o: BaseTrap.cpp BaseTrap.h BaseScript.h Script.h
$(bin1dir)/CommonScripts.o: CommonScripts.cpp CommonScripts.h
$(bin2dir)/CommonScripts.o: CommonScripts.cpp CommonScripts.h
$(bin3dir)/CommonScripts.o: CommonScripts.cpp CommonScripts.h
$(bin1dir)/PublicScripts.o: PublicScripts.cpp PublicScripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin2dir)/PublicScripts.o: PublicScripts.cpp PublicScripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin3dir)/PublicScripts.o: PublicScripts.cpp PublicScripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin1dir)/T1Scripts.o: T1Scripts.cpp T1Scripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin2dir)/T2Scripts.o: T2Scripts.cpp T2Scripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin3dir)/SS2Scripts.o: SS2Scripts.cpp SS2Scripts.h CommonScripts.h BaseTrap.h BaseScript.h Script.h
$(bin1dir)/ScriptDef.o: ScriptDef.cpp PublicScripts.h T1Scripts.h BaseTrap.h BaseScript.h ScriptModule.h genscripts.h
$(bin2dir)/ScriptDef.o: ScriptDef.cpp PublicScripts.h T2Scripts.h BaseTrap.h BaseScript.h ScriptModule.h genscripts.h
$(bin3dir)/ScriptDef.o: ScriptDef.cpp PublicScripts.h SS2Scripts.h BaseTrap.h BaseScript.h ScriptModule.h genscripts.h
$(bin1dir)/script_res.o: script.rc version.rc
$(bin2dir)/script_res.o: script.rc version.rc
$(bin3dir)/script_res.o: script.rc version.rc
script-t1.osm: $(SCR1_OBJS) $(BASE1_OBJS) $(BASE_OBJS) $(OSM_OBJS) $(MISC1_OBJS) $(RES1_OBJS)
$(LD) $(LDFLAGS) -Wl,--image-base=0x11200000 $(LDDEBUG) $(LIBDIRS) -o $@ script.def $^ $(SCR1LIB) $(LIBS)
script-t2.osm: $(SCR2_OBJS) $(BASE2_OBJS) $(BASE_OBJS) $(OSM_OBJS) $(MISC2_OBJS) $(RES2_OBJS)
$(LD) $(LDFLAGS) -Wl,--image-base=0x11200000 $(LDDEBUG) $(LIBDIRS) -o $@ script.def $^ $(SCR2LIB) $(LIBS)
script-ss2.osm: $(SCR3_OBJS) $(BASE3_OBJS) $(BASE_OBJS) $(OSM_OBJS) $(MISC3_OBJS) $(RES3_OBJS)
$(LD) $(LDFLAGS) -Wl,--image-base=0x11200000 $(LDDEBUG) $(LIBDIRS) -o $@ script.def $^ $(SCR3LIB) $(LIBS)
$(bindir)/scrversion.o: scrversion.cpp scrversion.h
$(CXX) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(GAME3) $(INCLUDES) -o $@ -c $<
version.osm: $(bindir)/scrversion.o $(OSM_OBJS) $(bindir)/scrversion_res.o
$(LD) $(LDFLAGS) -Wl,--image-base=0x12100000 $(LDDEBUG) $(LIBDIRS) -o $@ script.def $^ $(SCR2LIB) $(LIBS) -lversion