File: Makefile

package info (click to toggle)
jigzo 0.6.1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,232 kB
  • sloc: cpp: 1,745; makefile: 114
file content (218 lines) | stat: -rw-r--r-- 5,186 bytes parent folder | download | duplicates (3)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#ARCH = MACOSX
ARCH = LINUX
#ARCH = MINGW32

PREFIX ?= /usr/local

ifeq "$(ARCH)" "MINGW32"
include makeinclude.mingw32
ARCH_OK = yes
endif

ifeq "$(ARCH)" "LINUX"
include makeinclude.linux
ARCH_OK = yes
endif

ifeq "$(ARCH)" "MACOSX"
include makeinclude.macosx
ARCH_OK = yes
endif

ifeq "$(ARCH_OK)" "yes"
#
# The given ARCH is correct
#

#
# Variables
#

CXXFLAGS = -g $(ARCHCXXFLAGS) -DENABLE_SOUND
LDFLAGS = -O2 $(ARCHLDFLAGS)

CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) $(CXXFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) $(LDFLAGS)


#
# List of all source files.
#
# Architecture-dependend files as defined in the makeinclude files are added
# automatically.
#
SOURCES = \
src/Loader.cxx \
src/Screen.cxx \
src/Texture.cxx \
src/main.cxx \
$(ARCHSOURCES)

# 
# The objects are named like the source files, but instead of in directory
# src/, they are placed in directory obj/, and the architecture gets added
# to the name, e.g. obj/main.LINUX.o 
#
OBJECTS=$(addsuffix .$(ARCH).o,$(basename $(subst src/,obj/,$(SOURCES))))

# 
# The dependency files are named like the source files, but instead of in
# directory src/, they are placed in directory obj/, and the architecture
# gets added to the name, e.g. dep/main.LINUX.d 
#
DEPENDS=$(addsuffix .$(ARCH).d,$(basename $(subst src/,dep/,$(SOURCES))))

#
# We need to create the directories for object and dependency files
# automatically. The following variables are lists of dummy files,
# one for each directory, and are used to in the rule to create the
# directories.
#
OBJECTDIRS=$(addsuffix .dir,$(sort $(dir $(OBJECTS))))
DEPENDDIRS=$(addsuffix .dir,$(sort $(dir $(DEPENDS))))

# 
# Targets / Rules
# 

#
# First target, depends on the target that builds the application
#
all: $(APP) README

#
# Targets / rules to make sure the directories for the object and
# dependency files exist.
#
.PRECIOUS: $(OBJECTDIRS) $(DEPENDDIRS)

%.dir:
	@mkdir $(dir $@)
	@touch $@

#
# Include the dependencies, but only if we are not doing a
# make clean or make depend
#
ifneq "$(MAKECMDGOALS)" "clean"
ifneq "$(MAKECMDGOALS)" "depend"
ifneq "$(MAKECMDGOALS)" ".depend"
-include $(DEPENDS)
endif
endif
endif

#
# Rule to build the application executable
#
$(APP): $(OBJECTS) $(ARCHAPPREQ)
	$(CXX) $(OBJECTS) $(CXXFLAGS) $(LDFLAGS) -o $@

#
# MacOSX applications go into a bundle. The rule creates
# the bundle directory structure and populates it
#
macosx_app: Info.plist
	mkdir -p jigzo.app/Contents/MacOS/
	mkdir -p jigzo.app/Contents/Resources/
	cp Info.plist jigzo.app/Contents/

#
# Compilation rules
#
obj/%.$(ARCH).o: src/%.c $(OBJECTDIRS)
	@echo Compiling $<
	$(CC) $(CXXFLAGS) -Wall -Weffc++ -c $< -o $@

obj/%.$(ARCH).o: src/%.cxx $(OBJECTDIRS)
	@echo Compiling $<
	$(CXX) $(CXXFLAGS) -Wall -c $< -o $@

obj/%.$(ARCH).o: src/%.cpp $(OBJECTDIRS)
	@echo Compiling $<
	$(CXX) $(CXXFLAGS) -Wall -c $< -o $@

#
# Dependency rules
#
dep/%.$(ARCH).d: src/%.c $(DEPENDDIRS)
	@echo Generating dependency information for $<
	$(CXX) -MM -MT $@ $(CXXFLAGS) $< -o $@.tmp
	@(cat $@.tmp ; cat $@.tmp | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
	@rm $@.tmp

dep/%.$(ARCH).d: src/%.cxx $(DEPENDDIRS)
	@echo Generating dependency information for $<
	$(CXX) -MM -MT $@ $(CXXFLAGS) $< -o $@.tmp
	@(cat $@.tmp ; cat $@.tmp | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
	@rm $@.tmp

dep/%.$(ARCH).d: src/%.cpp $(DEPENDDIRS)
	@echo Generating dependency information for $<
	$(CXX) -MM -MT $@ $(CXXFLAGS) $< -o $@.tmp
	@(cat $@.tmp ; cat $@.tmp | sed s/^dep/obj/ | sed s/\.d:/.o:/ ) > $@
	@rm $@.tmp

#
# Rules to force a rebuild of all dependency information
#
depend:
	@rm -f $(DEPENDS)
	@make ARCH=$(ARCH) .depend

.depend: $(DEPENDS)

#
# Rule to clean all generated files (objects, dependencies, executable)
#
clean:
	rm -rf obj/ dep/ $(APP) 

ifeq "$(ARCH)" "LINUX"

install: jigzo
	@echo Installing in $(PREFIX)
	rm -rf "$(PREFIX)/lib/jigzo/"
	mkdir -p "$(PREFIX)/lib/jigzo/"
	cp -r font image sound puzzles "$(PREFIX)/lib/jigzo/"
	cp jigzo $(PREFIX)/lib/jigzo/jigzo.bin
	echo -e '#!/bin/sh\n$(PREFIX)/lib/jigzo/jigzo.bin $$*\n' > $(PREFIX)/bin/jigzo
	chmod +x $(PREFIX)/bin/$(APP)

endif

#
# Rules end here
#
else
#
# The given ARCH is incorrect or missing
#

all: .DEFAULT

clean:
	rm -rf obj/ dep/ $(APP) 

.DEFAULT:
ifeq "$(ARCH)" ""
	@echo '#################################################################'
	@echo 'ARCH not defined. Use make ARCH=[ LINUX | MACOSX | MINGW32 ]'
	@echo 'or set the environment variable'
	@echo '#################################################################'
else
	@echo '#################################################################'
	@echo 'ARCH $(ARCH) invalid. Use make ARCH=[ LINUX | MACOSX | MINGW32 ]'
	@echo 'or set the environment variable'
	@echo '#################################################################'
endif

endif

README: index.html
	lynx -dump index.html | sed 's/^          *//' | sed 's/^   \([^ ]\)/      \1/g' | sed 's/\[[0123456789]\]//' | grep -v References | grep -v '^  *.\. ....://' > README


###### DISTRIBUTABLE_UNTIL_HERE ######