summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/makefile.lnx
blob: f6c90f71727a2dc879ae2cd84aab3ffebd1a9b8d (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
# -*- Makefile -*- for Dungeon Crawl (linux)

#
# Modified for Crawl Reference by $Author$ on $Date$
#

GAME = crawl

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

OBJECTS += libunix.o

CXX = g++
DELETE = rm -f
COPY = cp
OS_TYPE = LINUX

CFLAGS = -Wall -Wwrite-strings -fsigned-char \
	-Wshadow -pedantic \
            -g -D$(OS_TYPE) $(EXTRA_FLAGS)

MCHMOD = 2755

# [dshaligram] More common location than /opt/crawl/bin - this is from the
# Debian patch.
INSTALLDIR = /usr/games
LIB = -lncurses

# Include for Linux
INCLUDES = -I/usr/include/ncurses

# If you have lex and yacc, set DOYACC to y (lowercase y).
DOYACC := n

UTIL = util/

LEX  := lex
YACC := yacc

YTABC  := y.tab.c
YTABH  := y.tab.h
LEXYYC := lex.yy.c

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

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

GAME_DEPENDS := compile-levels $(OBJECTS)

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

all: $(GAME)

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

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

$(UTIL)levcomp: $(UTIL)levcomp_yacc.o $(UTIL)levcomp_lex.o mapdef.o
		$(CXX) -o $@ $^

ifeq ($(DOYACC),y)

$(UTIL)levcomp_yacc.cc: $(UTIL)levcomp.y
		cd $(UTIL) && $(YACC) -d levcomp.y \
			   && mv $(YTABC) levcomp_yacc.cc \
			   && mv $(YTABH) levcomp.h

$(UTIL)levcomp_lex.cc: $(UTIL)levcomp.l
		cd $(UTIL) && $(LEX) levcomp.l \
			   && mv $(LEXYYC) levcomp_lex.cc

endif
##########################################################################


install: $(GAME)
	$(COPY) $(GAME) ${INSTALLDIR}
	chmod ${MCHMOD} ${INSTALLDIR}/$(GAME)

clean:
	$(DELETE) *.o
	$(DELETE) $(UTIL)*.o
	$(DELETE) $(UTIL)levcomp

distclean:
	$(DELETE) *.o
	$(DELETE) bones.*
	$(DELETE) morgue.txt
	$(DELETE) scores
	$(DELETE) $(GAME)
	$(DELETE) *.sav
	$(DELETE) core
	$(DELETE) *.0*
	$(DELETE) *.lab
ifeq ($(DOYACC),y)
	$(DELETE) $(UTIL)*.cc $(UTIL)*.c $(UTIL)*.h
endif


$(GAME): $(GAME_DEPENDS)
	${CXX} ${LDFLAGS} $(INCLUDES) $(CFLAGS) $(OBJECTS) -o $(GAME) $(LIB)
	chmod ${MCHMOD} $(GAME)

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

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

# [ds] maps.cc now includes mapdefs.ixx, so add a dependency.
$(OPATH)/maps.o: mapdefs.ixx

.cc.o:
	${CXX} ${CFLAGS} -c $< ${INCLUDE}

# [ds] Note we don't use the standard CFLAGS here; that's intentional, most
# flex/bison combos I've tried don't produce code that passes the warnings
# test.
$(UTIL)%.o: $(UTIL)%.cc
	$(CXX) -I$(UTIL) -I. -o $@ -c $<

.h.cc:
	touch $@