-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
330 lines (281 loc) · 10.9 KB
/
Makefile
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#######################################################################
##
## $Id: Makefile,v 1.25 2020/09/15 10:20:28 thor Exp $
##
#######################################################################
## Makefile for the difftest_ng project,
## THOR Software, 2. Jul. 2003, Thomas Richter for
## Accusoft
##
## This source file is part of difftest_ng, a universal image measuring
## and conversion framework.
##
## difftest_ng 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 3 of the License, or
## (at your option) any later version.
##
## difftest_ng 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 difftest_ng. If not, see <http://www.gnu.org/licenses/>.
##
#######################################################################
##
##
.PHONY: clean debug final valgrind valfinal coverage all install doc dox distrib \
verbose profile profgen profuse Distrib.zip view realclean \
uninstall reconfigure link linkglobal linkprofuse linkprofgen linkprof
help
all: debug
help:
@ echo "difftest_ng Linux Edition. Available make targets:"
@ echo "clean : cleanup directories, remove object code"
@ echo " a second clean will remove autoconf generated files"
@ echo "debug : debug-build target without optimizations and "
@ echo " debugger support (default)"
@ echo "final : final build with optimizer enabled and no debugging"
@ echo "valgrind : debug build without internal memory munger, allows"
@ echo " to detect memory leaks with valgrind"
@ echo "valfinal : final build for valgrind with debug symbols"
@ echo "coverage : build for coverage check tools"
@ echo "doc : build the documentation"
@ echo "distrib : build distribution zip archive"
@ echo "verbose : debug build with verbose logging"
@ echo "profile : build with profiler support"
@ echo "profgen : ICC build target for collecting profiling information"
@ echo "profuse : second stage optimizer, uses profiling information"
@ echo " collected with 'make profgen' generated target"
@ echo "install : install j2k into ~/bin/wavelet"
@ echo "uninstall : remove j2k from ~/bin/wavelet"
#####################################################################
## Varous Autoconf related settings ##
#####################################################################
configure: configure.in autoconfig.h.in
@ -$(AUTOCONF)
autoconfig.h.in: configure.in
@ -$(AUTOHEADER)
autoconfig.h: autoconfig.h.in configure.in configure
@ if test ! -f autoconfig.h; then ./configure CXX=$(COMPILER) CC=$(COMPILER); fi
@ touch autoconfig.h
##
## faked rule for the automake file to shut up
## realclean and clean targets. All others depend
## on autoconfig.h and thus on this file anyhow.
automakefile:
@ echo "" >automakefile
##
##
## The following variable defines the compiler we use
## for running the code. This is the default version
## Use
## $ make COMPILER=icc
## on the command line to test the same stuff with a
## different compiler.
##
##COMPILER = gcc
##
## Include autoconf settings as soon as we have them
## will be included by recursive make process
##
-include automakefile
#####################################################################
#####################################################################
##
## Build up the absolute path for the makefile containing the
## compiler specific definitions
##
ifdef COMPILER
##
## User selection
COMPILER_SETTINGS= $(shell pwd)/Makefile_Settings.$(COMPILER)
else
ifdef SETTINGS
##
## Autoconf selection
COMPILER_SETTINGS= $(shell pwd)/Makefile_Settings.$(SETTINGS)
else
##
## Fallback for realclean, clean
COMPILER_SETTINGS= $(shell pwd)/Makefile_Settings.gcc
endif
endif
AUTOMAKEFILE= $(shell pwd)/automakefile
##
## Include the project specific definitions
include Makefile.template
#####################################################################
#####################################################################
ifdef PREFIX
INSTALLDIR = $(PREFIX)
else
INSTALLDIR = $(HOME)/wavelet/bin
endif
##
##
##
## sub-directory libraries, automatically computed
##
DIRLIBS = $(foreach dir,$(DIRS),$(dir).dir)
BUILDLIBS = $(foreach dir,$(DIRS),$(dir).build)
FINALLIBS = $(foreach dir,$(DIRS),$(dir)/lib$(dir).a)
SHAREDLIBS = $(foreach dir,$(DIRS),$(dir)/lib_$(dir).a)
OBJECTLIST = $(foreach dir,$(DIRS),$(dir)/objects.list)
LIBOBJECTLIST = $(foreach dir,$(DIRS),$(dir)/libobjects.list)
%.dir:
@ $(MAKE) COMPILER_SETTINGS=$(COMPILER_SETTINGS) AUTOMAKEFILE=$(AUTOMAKEFILE) \
--no-print-directory -C $* sub$(TARGET)
%.build:
@ $(MAKE) COMPILER_SETTINGS=$(COMPILER_SETTINGS) AUTOMAKEFILE=$(AUTOMAKEFILE) \
MAKEFILE=$(shell if test -f $*/Makefile.$(HWTYPE); then echo Makefile.$(HWTYPE); else echo Makefile;fi) \
--no-print-directory -C $* -f \
$(shell if test -f $*/Makefile.$(HWTYPE); then echo Makefile.$(HWTYPE); else echo Makefile;fi) \
sub$(TARGET)
echo_settings:
@ $(ECHO) "Using $(CXX) $(OPTIMIZER) $(CFLAGS) $(GSL_CFLAGS) $(PNG_CFLAGS) $(PTHREADCFLAGS) $(EXR_CFLAGS)"
#####################################################################
#####################################################################
##
## Various link targets
##
linkflex:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ sed -e 's/cmd\/main.o/cmd\/$(MAIN).o/' <objects.list >objects.list.tmp
@ mv objects.list.tmp objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o $(MAIN)
link:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o difftest_ng
linkstatic:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -s -static -o difftest_ng
@ strip difftest_ng
linkglobal:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) $(GLOBFLAGS) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o difftest_ng
linkprofgen:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) $(PROFGEN) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o difftest_ng
linkprofuse:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) $(GLOBFLAGS) $(PROFUSE) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o difftest_ng
linkprof:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) $(LDPROF) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS)-o difftest_ng
linkcoverage:
@ $(ECHO) "Linking..."
@ $(CAT) $(OBJECTLIST) >objects.list
@ $(LD) $(LDFLAGS) $(PTHREADLDFLAGS) $(LDCOVERAGE) `cat objects.list` \
$(LDLIBS) $(PTHREADLIBS) $(GSL_LDFLAGS) $(PNG_LDFLAGS) $(EXR_LDFLAGS) -o difftest_ng
#####################################################################
#####################################################################
##
## Various make targets
##
stripe : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="debug"
@ $(MAKE) --no-print-directory -C cmd -f Makefile stripe.o
@ $(MAKE) --no-print-directory linkflex MAIN="stripe"
debug : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory link
verbose : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory link
final : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory link
static : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkstatic
global : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkglobal
profgen : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkprofgen
profuse : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkprofuse
profile : autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkprof
valgrind: autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory link
valfinal: autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory link
coverage: autoconfig.h
@ $(MAKE) --no-print-directory echo_settings $(BUILDLIBS) \
TARGET="$@"
@ $(MAKE) --no-print-directory linkcoverage
clean :
@ find . -name "*.d" -exec rm {} \;
@ $(MAKE) --no-print-directory $(BUILDLIBS) \
TARGET="$@"
@ rm -rf *.dpi *.so difftest_ng gmon.out core Distrib.zip objects.list libobjects.list libj2k.so
@ if test -f "doc/Makefile"; then $(MAKE) --no-print-directory -C doc clean; fi
@ rm -rf dox/html
reconfigure : clean
@ rm -rf autoconfig.h automakefile
@ $(MAKE) COMPILER=$(COMPILER) autoconfig.h
distclean : realclean
@ $(MAKE) configure
@ $(MAKE) autoconfig.h.in
realclean : clean
@ rm -f *.j2k *.ppm *.pgm *.bmp *.pgx *.pgx_?.h *.pgx_?.raw *.jp2 *.jpc cachegrind.out* gmon.out *.zip
@ find . -name "*.da" -exec rm {} \;
@ find . -name "*.bb" -exec rm {} \;
@ find . -name "*.bbg" -exec rm {} \;
@ find . -name "*.gcov" -exec rm {} \;
@ find . -name "*.dyn" -exec rm {} \;
@ find . -name "*.dpi" -exec rm {} \;
@ rm -rf /tmp/*.dyn /tmp/*.dpi
@ rm -rf automakefile autoconfig.h configure
distrib : Distrib.zip
Distrib.zip : doc dox configure autoconfig.h.in
@ touch configure.in
@ sleep 2
@ touch autoconfig.h.in
@ sleep 2
@ touch configure
@ $(MAKE) --no-print-directory $(DIRLIBS) TARGET="zip"
@ $(ZIPASCII) -r Distrib.zip README README.license config.h
@ $(ZIPASCII) -r Distrib.zip vs15.0/difftest_ng/difftest_ng.sln vs15.0/difftest_ng/difftest_ng/difftest_ng.vcxproj
@ $(ZIP) -r Distrib.zip Makefile Makefile.template Makefile_Settings.*
@ $(ZIP) -r Distrib.zip configure configure.in automakefile.in autoconfig.h.in
install :
@ mkdir -p $(INSTALLDIR)
@ cp difftest_ng $(INSTALLDIR)
@ cp difftest_ng $(INSTALLDIR)/difftest_ng
uninstall :
@ rm -rf $(INSTALLDIR)/difftest_ng