Merge branch 'upstream'
[routino] / src / Makefile
1 # $Header: /home/amb/routino/src/RCS/Makefile,v 1.43 2010/11/13 14:22:28 amb Exp $
2 #
3 # Source code Makefile
4 #
5 # Part of the Routino routing software.
6 #
7 # This file Copyright 2008-2010 Andrew M. Bishop
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU Affero General Public License for more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 # Web file paths
24
25 WEBDIR=../web/bin
26
27 # Compilation programs
28
29 CC=gcc
30 LD=gcc
31
32 LEX=flex
33
34 # Compilation program options
35
36 CFLAGS=-Wall -Wmissing-prototypes
37 #CFLAGS+= -Wextra -pedantic -std=c99
38 LDFLAGS=-lm -lc
39
40 CFLAGS+= -O3
41 #CFLAGS+= -O0 -g
42 #CFLAGS+= -pg
43 #CFLAGS+= --coverage
44
45 LDFLAGS+=
46 #LDFLAGS+= -pg -static
47 #LDFLAGS+= --coverage
48
49 LEXFLAGS=
50
51 # Required to use stdio with files > 2GiB on 32-bit system.
52
53 FLAGS64=-D_FILE_OFFSET_BITS=64
54
55 # Compilation targets
56
57 C=$(wildcard *.c)
58 D=$(foreach f,$(C),$(addprefix .deps/,$(addsuffix .d,$(basename $f))))
59
60 EXE=planetsplitter planetsplitter-slim router router-slim filedumper filedumper-slim tagmodifier
61
62 ########
63
64 all : $(EXE)
65         -@[ -d $(WEBDIR) ] && \
66           for file in $(EXE); do \
67              if [ ! -f $(WEBDIR)/$$file ] || [ $$file -nt $(WEBDIR)/$$file ]; then \
68                 echo cp $$file $(WEBDIR) ;\
69                 cp -f $$file $(WEBDIR) ;\
70              fi ;\
71           done
72         @cd xml && $(MAKE) CC="$(CC)" LD="$(LD)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
73
74 ########
75
76 PLANETSPLITTER_OBJ=planetsplitter.o \
77                    nodesx.o segmentsx.o waysx.o relationsx.o superx.o \
78                    ways.o types.o \
79                    files.o logging.o \
80                    results.o queue.o sorting.o \
81                    xmlparse.o tagging.o osmparser.o
82
83 planetsplitter : $(PLANETSPLITTER_OBJ)
84         $(LD) $(PLANETSPLITTER_OBJ) -o $@ $(LDFLAGS)
85
86 ########
87
88 PLANETSPLITTER_SLIM_OBJ=planetsplitter-slim.o \
89                         nodesx-slim.o segmentsx-slim.o waysx-slim.o relationsx-slim.o superx-slim.o \
90                         ways.o types.o \
91                         files.o logging.o \
92                         results.o queue.o sorting.o \
93                         xmlparse.o tagging.o osmparser.o
94
95 planetsplitter-slim : $(PLANETSPLITTER_SLIM_OBJ)
96         $(LD) $(PLANETSPLITTER_SLIM_OBJ) -o $@ $(LDFLAGS)
97
98 ########
99
100 ROUTER_OBJ=router.o \
101            nodes.o segments.o ways.o types.o fakes.o \
102            optimiser.o output.o \
103            files.o logging.o profiles.o xmlparse.o \
104            results.o queue.o translations.o
105
106 router : $(ROUTER_OBJ)
107         $(LD) $(ROUTER_OBJ) -o $@ $(LDFLAGS)
108
109 ########
110
111 ROUTER_SLIM_OBJ=router-slim.o \
112                 nodes-slim.o segments-slim.o ways-slim.o types.o fakes.o \
113                 optimiser-slim.o output-slim.o \
114                 files.o logging.o profiles.o xmlparse.o \
115                 results.o queue.o translations.o
116
117 router-slim : $(ROUTER_SLIM_OBJ)
118         $(LD) $(ROUTER_SLIM_OBJ) -o $@ $(LDFLAGS)
119
120 ########
121
122 FILEDUMPER_OBJ=filedumper.o \
123                nodes.o segments.o ways.o types.o \
124                visualiser.o \
125                files.o logging.o xmlparse.o
126
127 filedumper : $(FILEDUMPER_OBJ)
128         $(LD) $(FILEDUMPER_OBJ) -o $@ $(LDFLAGS)
129
130 ########
131
132 FILEDUMPER_SLIM_OBJ=filedumper-slim.o \
133                nodes-slim.o segments-slim.o ways-slim.o types.o \
134                visualiser-slim.o \
135                files.o logging.o xmlparse.o
136
137 filedumper-slim : $(FILEDUMPER_SLIM_OBJ)
138         $(LD) $(FILEDUMPER_SLIM_OBJ) -o $@ $(LDFLAGS)
139
140 ########
141
142 TAGMODIFIER_OBJ=tagmodifier.o \
143                 files.o logging.o \
144                 xmlparse.o tagging.o
145
146 tagmodifier : $(TAGMODIFIER_OBJ)
147         $(LD) $(TAGMODIFIER_OBJ) -o $@ $(LDFLAGS)
148
149 ########
150
151 xmlparse.c : xmlparse.l
152         $(LEX) $(LEXFLAGS)  $<
153         -@mv lex.yy.c xmlparse.c
154         @echo Created xmlparse.c
155
156 ########
157
158 %.o : %.c
159         $(CC) -c $(CFLAGS) $(FLAGS64) -DSLIM=0 -DDATADIR=\"$(datadir)\" $< -o $@ -MMD -MP -MF $(addprefix .deps/,$(addsuffix .d,$(basename $<)))
160
161 %-slim.o : %.c
162         $(CC) -c $(CFLAGS) $(FLAGS64) -DSLIM=1 -DDATADIR=\"$(datadir)\" $< -o $@ -MMD -MP -MF $(addprefix .deps/,$(addsuffix .d,$(basename $<)))
163
164 ########
165
166 install: all
167         -[ -d $(DESTDIR)$(bindir) ] || mkdir -p $(DESTDIR)$(bindir)
168         @[ -d $(DESTDIR)$(bindir) ] && \
169           for file in $(EXE); do \
170              echo cp $$file $(DESTDIR)$(bindir) ;\
171              cp -f $$file $(DESTDIR)$(bindir) ;\
172           done
173
174 ########
175
176 clean:
177         rm -f *.o
178         rm -f *~
179         rm -f xmlparse.c
180         cd xml && $(MAKE) clean
181
182 ########
183
184 distclean: clean
185         -[ -d ../web/bin ] && cd ../web/bin/ && rm -f $(EXE)
186         -rm -f $(EXE)
187         -rm -f $(D)
188         -rm -fr .deps
189         cd xml && $(MAKE) distclean
190
191 ########
192
193 .deps : .FORCE
194         @[ -d .deps ] || mkdir $@
195
196 $(D) : .deps
197         @touch $@
198
199 include $(D)
200
201 ########
202
203 .FORCE :
204
205 ########
206
207 top=-top
208 include ../Makefile