49e583e70dae1526f3f23e32e1ff7473b90c7857
[routino] / src / Makefile
1 # $Header: /home/amb/routino/src/RCS/Makefile,v 1.36 2010/07/09 17:43:00 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 # Programs
24
25 CC=gcc
26 LD=gcc
27
28 LEX=flex
29
30 # Program options
31
32 CFLAGS=-Wall -Wmissing-prototypes
33 #CFLAGS+= -Wextra -pedantic -std=c99
34 LDFLAGS=-lm -lc
35
36 CFLAGS+= -O3
37 #CFLAGS+= -O0 -g
38 #CFLAGS+= -pg
39 #CFLAGS+= --coverage
40
41 LDFLAGS+=
42 #LDFLAGS+= -pg -static
43 #LDFLAGS+= --coverage
44
45 LEXFLAGS=
46
47 # Required to use stdio with files > 2GiB on 32-bit system.
48
49 FLAGS64=-D_FILE_OFFSET_BITS=64
50
51 # Compilation targets
52
53 C=$(wildcard *.c)
54 D=$(foreach f,$(C),$(addprefix .deps/,$(addsuffix .d,$(basename $f))))
55
56 EXE=planetsplitter router filedumper tagmodifier
57
58 WEBDIR=../web/bin
59
60 ########
61
62 all : $(EXE)
63         -@[ -d $(WEBDIR) ] && \
64           for file in $(EXE); do \
65              if [ ! -f $(WEBDIR)/$$file ] || [ $$file -nt $(WEBDIR)/$$file ]; then \
66                 echo cp $$file $(WEBDIR) ;\
67                 cp -f $$file $(WEBDIR) ;\
68              fi ;\
69           done
70         @cd xml && $(MAKE) CC="$(CC)" LD="$(LD)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
71
72 ########
73
74 PLANETSPLITTER_OBJ=planetsplitter.o \
75                    nodesx.o segmentsx.o waysx.o superx.o \
76                    ways.o types.o \
77                    files.o \
78                    results.o queue.o sorting.o \
79                    xmlparse.o tagging.o osmparser.o
80
81 planetsplitter : $(PLANETSPLITTER_OBJ)
82         $(LD) $(PLANETSPLITTER_OBJ) -o $@ $(LDFLAGS)
83
84 ########
85
86 ROUTER_OBJ=router.o \
87            nodes.o segments.o ways.o types.o \
88            files.o profiles.o xmlparse.o \
89            optimiser.o output.o results.o queue.o translations.o
90
91 router : $(ROUTER_OBJ)
92         $(LD) $(ROUTER_OBJ) -o $@ $(LDFLAGS)
93
94 ########
95
96 FILEDUMPER_OBJ=filedumper.o \
97                nodes.o segments.o ways.o types.o \
98                files.o xmlparse.o \
99                visualiser.o
100
101 filedumper : $(FILEDUMPER_OBJ)
102         $(LD) $(FILEDUMPER_OBJ) -o $@ $(LDFLAGS)
103
104 ########
105
106 TAGMODIFIER_OBJ=tagmodifier.o \
107                 files.o \
108                 xmlparse.o tagging.o
109
110 tagmodifier : $(TAGMODIFIER_OBJ)
111         $(LD) $(TAGMODIFIER_OBJ) -o $@ $(LDFLAGS)
112
113 ########
114
115 xmlparse.c : xmlparse.l
116         $(LEX) $(LEXFLAGS)  $<
117         -@mv lex.yy.c xmlparse.c
118         @echo Created xmlparse.c
119
120 ########
121
122 %.o : %.c
123         $(CC) -c $(CFLAGS) $(FLAGS64) $< -o $@ -MMD -MP -MF $(addprefix .deps/,$(addsuffix .d,$(basename $<)))
124
125 ########
126
127 clean:
128         rm -f *.o
129         rm -f *~
130         rm -f xmlparse.c
131         cd xml && $(MAKE) clean
132
133 ########
134
135 distclean: clean
136         -[ -d ../web/bin ] && cd ../web/bin/ && rm -f $(EXE)
137         -rm -f $(EXE)
138         -rm -f $(D)
139         -rm -fr .deps
140         cd xml && $(MAKE) distclean
141
142 ########
143
144 .deps : .FORCE
145         @[ -d .deps ] || mkdir $@
146
147 $(D) : .deps
148         @touch $@
149
150 include $(D)
151
152 ########
153
154 .FORCE :