Debian Codegraph @

Makefile

raw ◀ ▶
1 Debian patch touch this file
1 #ARCH = MACOSX
2 ARCH = LINUX
3 #ARCH = MINGW32
4
5 PREFIX ?= /usr/local
6
7 ifeq "$(ARCH)" "MINGW32"
8 include makeinclude.mingw32
9 ARCH_OK = yes
10 endif
11
12 ifeq "$(ARCH)" "LINUX"
13 include makeinclude.linux
14 ARCH_OK = yes
15 endif
16
17 ifeq "$(ARCH)" "MACOSX"
18 include makeinclude.macosx
19 ARCH_OK = yes
20 endif
21
22 ifeq "$(ARCH_OK)" "yes"
23 #
24 # The given ARCH is correct
25 #
26
27 #
28 # Variables
29 #
30
31 CXXFLAGS = -g $(ARCHCXXFLAGS) -DENABLE_SOUND
32 LDFLAGS = -O2 $(ARCHLDFLAGS)
33
•34 CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) $(CXXFLAGS)
35 CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
36 CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
37 LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) $(LDFLAGS)
38
39
40 #
41 # List of all source files.
42 #
43 # Architecture-dependend files as defined in the makeinclude files are added
44 # automatically.
45 #
46 SOURCES = \
47 src/Loader.cxx \
48 src/Screen.cxx \
49 src/Texture.cxx \
50 src/main.cxx \
51 $(ARCHSOURCES)
52
53 #
54 # The objects are named like the source files, but instead of in directory
55 # src/, they are placed in directory obj/, and the architecture gets added
56 # to the name, e.g. obj/main.LINUX.o
57 #
58 OBJECTS=$(addsuffix .$(ARCH).o,$(basename $(subst src/,obj/,$(SOURCES))))
59
60 #
61 # The dependency files are named like the source files, but instead of in
62 # directory src/, they are placed in directory obj/, and the architecture
63 # gets added to the name, e.g. dep/main.LINUX.d
64 #
65 DEPENDS=$(addsuffix .$(ARCH).d,$(basename $(subst src/,dep/,$(SOURCES))))
66
67 #
68 # We need to create the directories for object and dependency files
69 # automatically. The following variables are lists of dummy files,
70 # one for each directory, and are used to in the rule to create the
71 # directories.
72 #
73 OBJECTDIRS=$(addsuffix .dir,$(sort $(dir $(OBJECTS))))
74 DEPENDDIRS=$(addsuffix .dir,$(sort $(dir $(DEPENDS))))
75
76 #
77 # Targets / Rules
78 #
79
80 #
81 # First target, depends on the target that builds the application
82 #
83 all: $(APP) README
84
85 #
86 # Targets / rules to make sure the directories for the object and
87 # dependency files exist.
88 #
89 .PRECIOUS: $(OBJECTDIRS) $(DEPENDDIRS)
90
91 %.dir:
92 @mkdir $(dir $@)
93 @touch $@
94
95 #
96 # Include the dependencies, but only if we are not doing a
97 # make clean or make depend
98 #
99 ifneq "$(MAKECMDGOALS)" "clean"
100 ifneq "$(MAKECMDGOALS)" "depend"
101 ifneq "$(MAKECMDGOALS)" ".depend"
102 -include $(DEPENDS)
103 endif
104 endif
105 endif
106
107 #
108 # Rule to build the application executable
109 #
110 $(APP): $(OBJECTS) $(ARCHAPPREQ)
111 $(CXX) $(OBJECTS) $(CXXFLAGS) $(LDFLAGS) -o $@
112
113 #
114 # MacOSX applications go into a bundle. The rule creates
115 # the bundle directory structure and populates it
116 #
117 macosx_app: Info.plist
118 mkdir -p jigzo.app/Contents/MacOS/
119 mkdir -p jigzo.app/Contents/Resources/
120 cp Info.plist jigzo.app/Contents/
121
122 #
123 # Compilation rules
124 #
125 obj/%.$(ARCH).o: src/%.c $(OBJECTDIRS)
126 @echo Compiling $<
127 $(CC) $(CXXFLAGS) -Wall -Weffc++ -c $< -o $@
128
129 obj/%.$(ARCH).o: src/%.cxx $(OBJECTDIRS)
130 @echo Compiling $<
131 $(CXX) $(CXXFLAGS) -Wall -c $< -o $@
132
133 obj/%.$(ARCH).o: src/%.cpp $(OBJECTDIRS)
134 @echo Compiling $<
135 $(CXX) $(CXXFLAGS) -Wall -c $< -o $@
136
137 #
138 # Dependency rules
139 #
140 dep/%.$(ARCH).d: src/%.c $(DEPENDDIRS)
141 @echo Generating dependency information for $<
142 $(CXX) -MM -MT $@ $(CXXFLAGS) $< -o [email protected]
143 @(cat [email protected] ; cat [email protected] | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
144 @rm [email protected]
145
146 dep/%.$(ARCH).d: src/%.cxx $(DEPENDDIRS)
147 @echo Generating dependency information for $<
148 $(CXX) -MM -MT $@ $(CXXFLAGS) $< -o [email protected]
149 @(cat [email protected] ; cat [email protected] | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
150 @rm [email protected]
151
152 dep/%.$(ARCH).d: src/%.cpp $(DEPENDDIRS)
153 @echo Generating dependency information for $<
154 $(CXX) -MM -MT $@ $(CXXFLAGS) $< -o [email protected]
155 @(cat [email protected] ; cat [email protected] | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
156 @rm [email protected]
157
158 #
159 # Rules to force a rebuild of all dependency information
160 #
161 depend:
162 @rm -f $(DEPENDS)
163 @make ARCH=$(ARCH) .depend
164
165 .depend: $(DEPENDS)
166
167 #
168 # Rule to clean all generated files (objects, dependencies, executable)
169 #
170 clean:
171 rm -rf obj/ dep/ $(APP)
172
173 ifeq "$(ARCH)" "LINUX"
174
175 install: jigzo
176 @echo Installing in $(PREFIX)
177 rm -rf "$(PREFIX)/lib/jigzo/"
178 mkdir -p "$(PREFIX)/lib/jigzo/"
179 cp -r font image sound puzzles "$(PREFIX)/lib/jigzo/"
180 cp jigzo $(PREFIX)/lib/jigzo/jigzo.bin
181 echo -e '#!/bin/sh\n$(PREFIX)/lib/jigzo/jigzo.bin $$*\n' > $(PREFIX)/bin/jigzo
182 chmod +x $(PREFIX)/bin/$(APP)
183
184 endif
185
186 #
187 # Rules end here
188 #
189 else
190 #
191 # The given ARCH is incorrect or missing
192 #
193
194 all: .DEFAULT
195
196 clean:
197 rm -rf obj/ dep/ $(APP)
198
199 .DEFAULT:
200 ifeq "$(ARCH)" ""
201 @echo '#################################################################'
202 @echo 'ARCH not defined. Use make ARCH=[ LINUX | MACOSX | MINGW32 ]'
203 @echo 'or set the environment variable'
204 @echo '#################################################################'
205 else
206 @echo '#################################################################'
207 @echo 'ARCH $(ARCH) invalid. Use make ARCH=[ LINUX | MACOSX | MINGW32 ]'
208 @echo 'or set the environment variable'
209 @echo '#################################################################'
210 endif
211
212 endif
213
214 README: index.html
215 lynx -dump index.html | sed 's/^ *//' | sed 's/^ \([^ ]\)/ \1/g' | sed 's/\[[0123456789]\]//' | grep -v References | grep -v '^ *.\. ....://' > README
216
217
218 ###### DISTRIBUTABLE_UNTIL_HERE ######