summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/makefile.mgw_unix
blob: 22399d06cfb7039c26d1d060e79bf54ee59bea6e (plain) (blame)
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
# -*- Makefile -*- for Dungeon Crawl (Cross-compiling MinGW for crawl.develz.org)

# makefile.obj includes a list of object files needed to build Crawl.
include makefile.obj

OPATH := build

# need .exe so make will find the right file
APPNAME = $(OPATH)/crawl.exe
CXX = i586-mingw32msvc-g++
DELETE = rm -f
COPY = cp
OS_TYPE = WIN32CONSOLE

ifeq ($(INSTALLDIR),)
INSTALLDIR := crawl-mingw32
endif

# If you don't have flex or bison, set DOYACC to N or empty.
DOYACC := n

LEX  := flex
YACC := bison -y

ifeq ($(LUASRC),)
LUASRC := util/lua/src
endif

LUALIB = lua
LUALIBA = lib$(LUALIB).a

SQLSRC := util/sqlite
SQLLIB := sqlite3
SQLIBA   := lib$(SQLLIB).a
FSQLLIBA := $(SQLLIB)/$(SQLIBA)

PCRESRC := util/pcre
PCRELIB := pcre
PCRELIBA := lib$(PCRELIB).a

LIB = -static -L$(HOME)/source/mingw32/lib -lwinmm -L$(LUASRC) -l$(LUALIB) -L$(SQLSRC) -l$(SQLLIB) -L$(PCRESRC) -l$(PCRELIB)
INCLUDES := -Iutil -I. -I$(HOME)/source/mingw32/include -I$(LUASRC) -I$(SQLSRC) -I$(PCRESRC)

CFWARN := -Wwrite-strings 

CFOTHERS := -fsigned-char \
		-fstrict-aliasing \
		-pedantic \
		-O2 \
		-D$(OS_TYPE) $(EXTRA_FLAGS) \
		-DWINMM_PLAY_SOUNDS -DCLUA_BINDINGS -DWIZARD

CFLAGS   := $(INCLUDES) $(CFWARN) $(CFOTHERS)
YCFLAGS  := $(INCLUDES) $(CFOTHERS)

OBJECTS := $(OBJECTS) libw32c.o crash-w.o

LDFLAGS =

#LIB = -lcurso -lpano

UTIL = util/

YTABC  := levcomp.tab.c
YTABH  := levcomp.tab.h


ifeq ($(LEX),)
DOYACC :=
endif

ifeq ($(YACC),)
DOYACC :=
endif

RESOURCE := $(UTIL)crawl.rc
RESOURCEOBJ := crawlres.o
WINDRES := i586-mingw32msvc-windres

# Do the levcomp stuff first because that's the most likely to fail.
OBJECTS      := levcomp.tab.o levcomp.lex.o \
		$(OBJECTS) $(RESOURCEOBJ)

OBJECTS := $(foreach file,$(OBJECTS),$(OPATH)/$(file))

GAME_DEPENDS := prepare $(LUASRC)/$(LUALIBA) $(FSQLLIBA) $(PCRESRC)/$(PCRELIBA) $(OBJECTS)

##########################################################################

all:            $(APPNAME)

prepare:
		mkdir -p $(OPATH)

DEPENDENCY_MKF := makefile.dep
-include $(DEPENDENCY_MKF)

##########################################################################
# The level compiler
#
ifeq ($(DOYACC),y)

# [ds] A plague on the broken copy command on Windoze.
prebuildyacc:	$(UTIL)levcomp.lex.cc $(UTIL)levcomp.tab.cc	$(UTIL)levcomp.tab.h
		$(COPY) $^ prebuilt/

$(UTIL)levcomp.tab.cc: $(UTIL)levcomp.ypp
		cd $(UTIL) && $(YACC) -d -b levcomp levcomp.ypp \
		       && mv $(YTABC) levcomp.tab.cc || false

$(UTIL)levcomp.lex.cc: $(UTIL)levcomp.lpp
		cd $(UTIL) && $(LEX) -olevcomp.lex.cc levcomp.lpp

else

$(UTIL)levcomp.tab.cc: prebuilt/levcomp.tab.cc
		$(COPY) prebuilt/*.h $(UTIL)
		$(COPY) $< $@

$(UTIL)levcomp.lex.cc: prebuilt/levcomp.lex.cc
		$(COPY) $< $@

endif

##########################################################################

install:        $(APPNAME)
ifneq ($(OPATH),$(INSTALLDIR))
		mkdir -p $(INSTALLDIR)
		$(COPY) $(APPNAME) ${INSTALLDIR}
endif
		mkdir -p $(INSTALLDIR)/dat
		mkdir -p $(INSTALLDIR)/dat/clua
		mkdir -p $(INSTALLDIR)/dat/database
		mkdir -p $(INSTALLDIR)/dat/descript
		mkdir -p $(INSTALLDIR)/dat/lua
		mkdir -p $(INSTALLDIR)/docs
		mkdir -p $(INSTALLDIR)/settings
		$(COPY) dat/*.des $(INSTALLDIR)/dat/
		$(COPY) dat/clua/*.lua $(INSTALLDIR)/dat/clua/
		$(COPY) dat/database/*.txt $(INSTALLDIR)/dat/database/
		$(COPY) dat/descript/*.txt $(INSTALLDIR)/dat/descript/
		$(COPY) dat/lua/*.lua $(INSTALLDIR)/dat/lua/
		$(COPY) ../docs/*.txt $(INSTALLDIR)/docs/
		$(COPY) ../docs/changes.stone_soup $(INSTALLDIR)/docs/
		$(COPY) ../CREDITS.txt $(INSTALLDIR)/
		$(COPY) ../README.txt ../README.pdf $(INSTALLDIR)/
		$(COPY) ../licence.txt $(INSTALLDIR)/LICENCE.txt
		$(COPY) ../settings/* $(INSTALLDIR)/settings/

clean:
		$(DELETE) $(OPATH)/*.o
		$(DELETE) $(UTIL)*.o
		$(DELETE) $(UTIL)*.exe
		$(DELETE) $(UTIL)*.lex.cc
		$(DELETE) $(UTIL)*.tab.cc
		$(DELETE) $(UTIL)*.tab.h
		$(DELETE) $(UTIL)*.tab.c
		$(DELETE) *.ixx

clean-lua:
	    cd $(LUASRC) && $(MAKE) clean_win

clean-sql:
		cd $(SQLSRC) && $(MAKE) clean

clean-pcre:
		cd $(PCRESRC) && $(MAKE) clean

distclean: clean clean-lua clean-sql clean-pcre
		$(DELETE) $(OPATH)/*.o
		$(DELETE) *.o
		$(DELETE) bones.*
		$(DELETE) $(OPATH)/bones.*
		$(DELETE) morgue.txt
		$(DELETE) $(OPATH)/morgue.txt
		$(DELETE) scores
		$(DELETE) $(OPATH)/scores
		$(DELETE) crawl.exe
		$(DELETE) $(APPNAME)
		$(DELETE) *.sav
		$(DELETE) $(OPATH)/*.sav
		$(DELETE) core
		$(DELETE) $(OPATH)/core
		$(DELETE) *.0*
		$(DELETE) $(OPATH)/*.0*
		$(DELETE) *.lab
		$(DELETE) $(OPATH)/*.lab

$(APPNAME):	$(GAME_DEPENDS)
		${CXX} ${LDFLAGS} $(CFLAGS) $(OBJECTS) -o $(APPNAME) $(LIB)
		i586-mingw32msvc-strip $(APPNAME)

debug:		$(GAME_DEPENDS)
		${CXX} ${LDFLAGS} $(CFLAGS) $(OBJECTS) -o $(APPNAME) $(LIB)

profile:	$(GAME_DEPENDS)
		${CXX} -g -p ${LDFLAGS} $(CFLAGS) $(OBJECTS) -o $(APPNAME) $(LIB)

$(OPATH)/%.o: %.cc
		${CXX} ${CFLAGS} -o $@ -c $< 

$(OPATH)/%.o: $(UTIL)%.cc
		$(CXX) $(YCFLAGS) -o $@ -c $<

#############################################################################
# Build Lua

$(LUASRC)/$(LUALIBA):
	@echo Building Lua...
	@cd $(LUASRC) && $(MAKE) crawl_mingw

#############################################################################
# Build SQLite

$(FSQLLIBA):
	@echo Building SQLite
	cd $(SQLSRC) && $(MAKE)

#############################################################################
# Build unrandart data
art-data.h: art-data.txt util/art-data.pl art-func.h
	util/art-data.pl

#############################################################################
# Build PCRE

$(PCRESRC)/$(PCRELIBA):
	@echo Building PCRE...
	@cd $(PCRESRC) && $(MAKE)

##########################################################################
# Resources
#

$(OPATH)/$(RESOURCEOBJ): $(RESOURCE)
	$(WINDRES) $< $@