summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/makefile.mgw
blob: ccd1c708f69d193888530a863ecebf98914c1b2d (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
# Make file for Dungeon Crawl (Win32, MinGW)

# this file contains a list of the libraries.
# it will make a variable called OBJECTS that contains all the libraries
include makefile.obj

ifeq ($(DEBUG_CRAWL),)
OPATH := rel
else
OPATH := dbg
endif

# need .exe so make will find the right file
APPNAME = $(OPATH)\crawl.exe
CXX = g++
DELETE = del
COPY = copy
OS_TYPE = WIN32CONSOLE
CFLAGS = -Wall -Wwrite-strings \
			-Wshadow \
			-Werror \
			-fsigned-char \
			-fstrict-aliasing \
			-pedantic \
			-D$(OS_TYPE) $(EXTRA_FLAGS) \
			-DWINMM_PLAY_SOUNDS

OBJECTS := $(OBJECTS) libw32c.o
OBJECTS := $(foreach file,$(OBJECTS),$(OPATH)/$(file))

LDFLAGS = 
INSTALLDIR = .
#LIB = -lcurso -lpano
LIB = -lwinmm -static

UTIL = util/

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

LEX  := flex
YACC := bison -y

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


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

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

GAME_DEPENDS := prepare compile-levels $(OBJECTS)

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

all:            $(APPNAME)

prepare:
		if not exist $(OPATH) mkdir $(OPATH)

##########################################################################
# The level compiler
#
compile-levels: $(UTIL)levcomp.exe mapdefs.ixx

mapdefs.ixx:	dat/vaults.des dat/splev.des $(UTIL)levcomp.exe
		$(subst /,\, $(UTIL)levcomp.exe $@ < dat/vaults.des)
		$(subst /,\, $(UTIL)levcomp.exe -a $@ < dat/splev.des)

$(UTIL)levcomp.exe: $(UTIL)levcomp.tab.o $(UTIL)levcomp.lex.o $(OPATH)/mapdef.o $(UTIL)levcomp.o
		$(CXX) -o $@ $^

ifeq ($(DOYACC),y)

# [ds] A plague on the broken copy command on Windoze.
prebuildyacc:	mapdefs.ixx $(UTIL)levcomp.lex.cc $(UTIL)levcomp.tab.cc	$(UTIL)levcomp.tab.h
		$(subst /,\,for %%f in ($^) do $(COPY) %%f prebuilt)

$(UTIL)levcomp.tab.cc: $(UTIL)levcomp.ypp
		$(subst /,\, cd $(UTIL)) && $(YACC) -d -b levcomp levcomp.ypp
		$(subst /,\, cd $(UTIL)) && move $(YTABC) levcomp.tab.cc

$(UTIL)levcomp.lex.cc: $(UTIL)levcomp.lpp
		$(subst /,\, cd $(UTIL) && $(LEX) -olevcomp.lex.cc levcomp.lpp)

else

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

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

endif

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

install:        $(APPNAME)
		$(COPY) $(APPNAME) ${INSTALLDIR}

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

distclean:
		$(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) $(subst /,\,$(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} $(INCLUDES) $(CFLAGS) $(OBJECTS) -o $(APPNAME) $(LIB)
		strip $(APPNAME)

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

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

$(OPATH)/maps.o: mapdefs.ixx

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

$(UTIL)%.o: $(UTIL)%.cc
		$(CXX) -I$(UTIL) -I. -o $@ -c $<