summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 9b247eaeb42dc11203ec5ef2fabfd7bf4603ece9 (plain)
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
#
#   Copyright 2001-2007 Adrian Thurston <thurston@complang.org>
#

#   This file is part of Colm.
#
#   Colm 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.
#
#   Colm 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 Colm; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 


# Logging:
# colm: rt on/off
# rt_prd: off
# rt_db: on
# rt_clm: rt on/off

INCS += -I../aapl

DEFS_COLM += -DCOLM_LOG -DPREFIX='"$(prefix)"'
DEFS_RT_P +=
DEFS_RT_D += -DCOLM_LOG

CFLAGS += -g -Wall -Wwrite-strings
LDFLAGS +=

# Frequently changed ones first.
COLM_SRC = \
	compile.cpp \
	lmparse.cpp \
	lmscan.cpp \
	parsetree.cpp \
	parsedata.cpp \
	fsmstate.cpp \
	fsmbase.cpp \
	fsmattach.cpp \
	fsmmin.cpp \
	fsmgraph.cpp \
	pdagraph.cpp \
	pdabuild.cpp \
	pdacodegen.cpp \
	fsmcodegen.cpp \
	redfsm.cpp \
	fsmexec.cpp \
	main.cpp \
	redbuild.cpp \
	closure.cpp \
	fsmap.cpp \
	dotgen.cpp \
	pcheck.cpp

RUNTIME_SRC = fsmrun.cpp pdarun.cpp bytecode.cpp list.cpp \
	map.cpp string.cpp input.cpp tree.cpp

ALL_SRC = $(COLM_SRC) $(RUNTIME_SRC)

# Files in ALL_SRC that are generated.
GEN_SRC = version.h lmscan.cpp lmparse.h lmparse.cpp 

RUNTIME_P = libcolmp.a
RUNTIME_D = libcolmd.a

LIBS = 

#*************************************

# Get the version info.
include ../version.mk

prefix = @prefix@

BUILD_PARSERS = @BUILD_PARSERS@

# Programs
CXX = @CXX@

# Get objects and dependencies from sources.
COLM_OBJ = $(COLM_SRC:%.cpp=%.o)
RUNTIME_OBJ_P = $(RUNTIME_SRC:%.cpp=%_p.o)
RUNTIME_OBJ_D = $(RUNTIME_SRC:%.cpp=%_d.o)

DEPS = $(COLM_SRC:%.cpp=.%.d) $(RUNTIME_SRC:%.cpp=.%_p.d) $(RUNTIME_SRC:%.cpp=.%_d.d)

# Rules.
all: colm $(RUNTIME_P) $(RUNTIME_D)

colm: $(GEN_SRC) $(COLM_OBJ) $(RUNTIME_OBJ_D) $(LIBS)
	$(CXX) $(LDFLAGS) -o $@ $(COLM_OBJ) $(RUNTIME_OBJ_D) $(LIBS)

$(RUNTIME_P): $(RUNTIME_OBJ_P)
	ar -cr $@ $^

$(RUNTIME_D): $(RUNTIME_OBJ_D)
	ar -cr $@ $^

version.h: ../version.mk
	echo '#define VERSION "$(VERSION)"' > version.h
	echo '#define PUBDATE "$(PUBDATE)"' >> version.h

ifeq ($(BUILD_PARSERS),true)

lmparse.h: lmparse.kh
	kelbt -o $@ $<

lmparse.cpp: lmparse.kl lmparse.kh
	kelbt -o $@ $<

lmscan.cpp: lmparse.h

lmscan.cpp: lmscan.rl
	ragel -G2 -o $@ $<

endif

$(COLM_OBJ): %.o: %.cpp
	@$(CXX) -M $(DEFS_COLM) $(INCS) $< > .$*.d
	$(CXX) -c $(CFLAGS) $(DEFS_COLM) $(INCS) -o $@ $<

$(RUNTIME_OBJ_P): %_p.o: %.cpp
	@$(CXX) -M -MT $@ $(DEFS_RT_P) $(INCS) $< > .$*_p.d
	$(CXX) -c $(CFLAGS) $(DEFS_RT_P) $(INCS) -o $@ $<

$(RUNTIME_OBJ_D): %_d.o: %.cpp
	@$(CXX) -M -MT $@ $(DEFS_RT_D) $(INCS) $< > .$*_d.d
	$(CXX) -c $(CFLAGS) $(DEFS_RT_D) $(INCS) -o $@ $<


distclean: clean
	rm -f Makefile config.h

ifeq ($(BUILD_PARSERS),true)
EXTRA_CLEAN = $(GEN_SRC)
endif

clean:
	rm -f tags .*.d *.o colm $(EXTRA_CLEAN) $(RUNTIME_P) $(RUNTIME_D)

install: all
	install -d $(prefix)/bin
	install -d $(prefix)/include
	install -d $(prefix)/include/colm
	install -d $(prefix)/lib
	install -s colm $(prefix)/bin/colm
	install libcolmp.a libcolmd.a $(prefix)/lib
	install ../aapl/astring.h ../aapl/avlcommon.h ../aapl/avlmap.h \
		../aapl/compare.h ../aapl/dlcommon.h ../aapl/dlist.h \
		../aapl/dlistval.h ../aapl/resize.h ../aapl/table.h \
		../aapl/vector.h bytecode.h config.h fsmrun.h input.h \
		pdarun.h $(prefix)/include/colm

-include $(DEPS)