Infrastructure for building hardened binaries
[jigdo.git] / src / Makefile.in
1 # Project: Jigdo (Jigsaw download)
2 #  __   _
3 #  |_) /|  Copyright (C) 2001-2004  |  richard@
4 #  | \/¯|  Richard Atterer          |  atterer.net
5 #  ¯ '` ¯
6 srcdir =        @srcdir@
7 VPATH =         @srcdir@
8
9 prefix =        @prefix@
10 datadir =       @datadir@
11
12 SUBDIRS =       glibcurl gtk job net util
13 SUBINCLUDE =    -I"$(srcdir)/glibcurl" -I"$(srcdir)/gtk" -I"$(srcdir)/job" \
14                 -I"$(srcdir)/net" -I"$(srcdir)/util"
15
16 # Prevent these variables from being taken from the environment
17 X =
18 Y =
19
20 # -I. to pick up config.h, _FILE_OFFSET_BITS for big file support under Linux
21 CPPFLAGS =      @CPPFLAGS@ -I. -I"$(srcdir)" $(SUBINCLUDE) \
22                 -D_FILE_OFFSET_BITS=64 @DEFS@ \
23                 -DPACKAGE_DATA_DIR="\"$(datadir)/jigdo/\"" \
24                 -DPACKAGE_LOCALE_DIR="\"$(datadir)/locale\"" \
25                 $(GTKCFLAGS) $(CURLCFLAGS) # $(LIBWWWCFLAGS)
26 CC =            @CC@
27 CFLAGS =        @CFLAGS@ $(X) $(EXTRA_CFLAGS)
28 CXX =           @CXX@
29 CXXFLAGS =      @CXXFLAGS@ $(X) $(EXTRA_CXXFLAGS)
30 LD =            @CXX@
31 LD_C =          @CC@
32 LDFLAGS =       @LIBS@ @LDFLAGS@ $(Y) $(EXTRA_LDFLAGS)
33 LIBS =          @LIBS@
34 AWK =           @AWK@
35 GLADECODE =     glade-2 -w # Create code from .glade file
36 DOC =           doxygen
37 WINDRES =       windres
38 GTKCFLAGS =     @GTKCFLAGS@
39 GTKLIBS =       @GTKLIBS@
40 GLIBLIBS =      @GLIBLIBS@
41 #LIBWWWCFLAGS = @LIBWWWCFLAGS@
42 #LIBWWWLIBS =   @LIBWWWLIBS@
43 CURLCFLAGS =    @CURLCFLAGS@
44 CURLLIBS =      @CURLLIBS@
45
46 programs =      jigdo-file@exe@ @IF_GUI@ jigdo@exe@
47 debug-programs = torture@exe@ util/random@exe@ \
48                 @IF_GUI@ glibcurl/glibcurl-example@exe@
49 #libwww-hacks = @IF_LIBWWW_HACKS@ net/libwww-HTFTP.o net/libwww-HTHost.o
50 windows-res =   @IF_WINDOWS@ jigdo.res
51 test-programs = job/jigdo-io-test@exe@ \
52                 job/makeimagedl-info-test@exe@ job/url-mapping-test@exe@ \
53                 net/proxyguess-test@exe@ \
54                 util/autonullptr-test@exe@ util/rsyncsum-test@exe@ \
55                 util/gunzip-test@exe@ util/log-test@exe@ \
56                 util/md5sum-test@exe@ util/mimestream-test@exe@ \
57                 util/string-utf-test@exe@
58 # net/uri-test@exe@ needs curl
59
60 # fmt -s -w1|sed 's%[^a-zA-Z0-9./-]\+%%g'|sort|fmt -w60|sed 's%$% \\%'
61 objects-jigdo = compat.o glibcurl/glibcurl.o gtk/gtk-makeimage.o \
62                 gtk/gtk-single-url.o gtk/gui.o gtk/interface.o gtk/jigdo.o \
63                 gtk/jobline.o gtk/joblist.o gtk/messagebox.o gtk/support.o \
64                 gtk/treeiter.o jigdoconfig.o job/cached-url.o \
65                 job/datasource.o job/jigdo-io.o job/makeimage.o \
66                 job/makeimagedl-info.o \
67                 job/makeimagedl.o job/single-url.o \
68                 job/url-mapping.o net/download.o net/uri.o net/proxyguess.o \
69                 util/bstream.o util/configfile.o util/glibc-getopt.o \
70                 util/glibc-getopt1.o util/glibc-md5.o util/gunzip.o \
71                 util/log.o util/md5sum.o util/progress.o util/string-utf.o \
72                 $(windows-res) \
73                 util/debug.o # this must come last!
74 #^ net/glibwww-callbacks.o net/glibwww-init.o
75 objects-jigdo-file = cachefile.o compat.o jigdo-file-cmd.o jigdo-file.o \
76                 jigdoconfig.o mkimage.o mkjigdo.o mktemplate.o \
77                 partialmatch.o recursedir.o scan.o util/bstream.o \
78                 util/configfile.o util/glibc-getopt.o util/glibc-getopt1.o \
79                 util/glibc-md5.o util/log.o util/md5sum.o util/rsyncsum.o \
80                 util/string.o zstream.o zstream-bz.o zstream-gz.o \
81                 util/debug.o # this must come last!
82 objects-torture = cachefile.o compat.o jigdoconfig.o mkimage.o mkjigdo.o \
83                 mktemplate.o partialmatch.o recursedir.o scan.o torture.o \
84                 util/bstream.o util/configfile.o util/glibc-md5.o \
85                 util/log.o util/md5sum.o util/rsyncsum.o util/string.o \
86                 zstream.o zstream-bz.o zstream-gz.o \
87                 util/debug.o # this must come last!
88 objects-random = util/glibc-md5.o util/log.o util/md5sum.o util/random.o \
89                 util/string.o \
90                 util/debug.o # this must come last!
91 #______________________________
92
93 .SUFFIXES:
94 .SUFFIXES: .c .cc .h .o
95 .cc.o:
96                 -@echo $(CXX) '$$cxx' -c $< -o $@
97                 @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c "$<" -o "$@"
98 .c.o:
99                 -@echo $(CC) '$$c  ' -c $< -o $@
100                 @$(CC) $(CPPFLAGS) $(CFLAGS) -c "$<" -o "$@"
101 #______________________________________________________________________
102
103 .PHONY:         all all-msg clean distclean mostlyclean maintainer-clean \
104                 dep depend doc strip test test-v test-c
105 all:            all-msg Makefile $(programs) @IF_DEBUG@ $(debug-programs) \
106                 @IFNOT_GXX2@ test-c @IFNOT_CROSSCOMPILING@ test
107 all-msg:
108                 -@if test "$$EMACS" != t; then \
109                     echo "export cpp='$(CPPFLAGS)'"; \
110                     echo 'export cxx="$$cpp $(CXXFLAGS)"'; \
111                     echo 'export c="$$cpp $(CFLAGS)"'; \
112                 fi
113 check:          $(programs) torture@exe@
114                 @echo 
115                 @echo '*** Warning - this will take a few minutes and ~100MB'
116                 @echo '*** disk space, and will bash the disc quite a bit...'
117                 @echo && sleep 3
118                 mkdir ironmaiden || true
119                 ./torture 0 4
120                 ./torture 128 132
121                 ./torture 256 260
122 clean mostlyclean:
123                 for d in . $(SUBDIRS); do \
124                     rm -f $$d/*.o $$d/core; \
125                     for p in $$d/*test; do if test -x "$$p" -a -f \
126                         "$(srcdir)/$$d/$$p.cc"; then rm -f "$$p"; fi; done; \
127                 done
128                 rm -f gtk/interface.hh.tmp gtk/gui.cc.tmp gtk/gui.hh.tmp
129                 rm -f $(programs) $(debug-programs) $(test-programs)
130                 rm -rf apidoc mktemplate-testdir
131 distclean:      clean
132                 for d in . $(SUBDIRS); do \
133                     rm -f $$d/TAGS $$d/*~ $$d/\#*\# $$d/*.bak; \
134                     rm -f $$d/Makefile $$d/config.h; \
135                 done
136                 rm -rf html
137                 if test ! -h ironmaiden; then rm -rf ironmaiden; fi
138 doc:
139                 $(DOC)
140 maintainer-clean: distclean
141                 rm -f gtk/interface.cc gtk/interface.hh
142                 rm -f Makedeps
143
144
145 make-makedeps = (cd "$(srcdir)" && find . -type f \
146                     '(' -name '*.cc' -o -name '*.c' ')') \
147                 | xargs $(AWK) -f "$(srcdir)/../scripts/depend.awk" \
148                     "$(srcdir)" $(SUBDIRS) -
149 # No dependency - don't normally remake Makedeps on gtk/interface.cc remake
150 # (Touching Makedeps/Makefile necessary, or circ. dep. Makefile->Makedeps.)
151 Makedeps:
152                 if test ! -r gtk/interface.cc; then \
153                     touch "$(srcdir)/Makedeps" Makefile; \
154                     $(MAKE) gtk/interface.cc; \
155                 fi
156                 $(make-makedeps)
157 # Dependency ensures auto-generated files are there & appear in depend output
158 dep depend:     gtk/interface.cc
159                 $(make-makedeps)
160                 @if test "$(srcdir)/Makedeps" -nt Makefile; then \
161                     echo "cd .. && sh config.status"; \
162                     cd .. && sh config.status; \
163                 fi
164 strip:
165                 for p in $(programs); do if test -f "$$p"; then \
166                     strip -R .comment -R .note "$$p"; fi; done
167
168 TEST-DEFAULTOBJS = util/log.o util/string-utf.o util/debug.o
169 TEST-LDFLAGS =  @LDFLAGS@ $(GLIBLIBS)
170 EXE =@exe@
171 # Compile only
172 test-c:         $(test-programs)
173 # Compile and run
174 test:           $(test-programs) jigdo-file@exe@ util/random@exe@
175                 @echo "Running unit tests..."; \
176                 for p in $(test-programs); do \
177                     if "$$p"; then continue; fi; \
178                     echo "$$p failed, for details enter: $$p all"; exit 1; \
179                 done; \
180                 testscripts="`cd $(srcdir) && echo *-test*.sh`"; \
181                 export srcdir="$(srcdir)"; \
182                 for p in $$testscripts; do \
183                     if sh "$(srcdir)/$$p"; then continue; fi; \
184                     echo "$$p failed"; exit 1; \
185                 done; \
186                 set $(test-programs) $$testscripts; \
187                     echo "All $$# tests succeeded"
188 # Compile and run, re-run in verbose mode after error
189 test-v:         $(test-programs) jigdo-file@exe@ util/random@exe@
190                 @echo "Running unit tests..."; \
191                 for p in $(test-programs); do \
192                     if "$$p"; then echo "OK: $$p"; continue; fi; \
193                     echo "$$p failed"; "$$p" all; exit 1; \
194                 done; \
195                 testscripts="`cd $(srcdir) && echo *-test*.sh`"; \
196                 export srcdir="$(srcdir)"; \
197                 for p in $$testscripts; do \
198                     if sh "$(srcdir)/$$p"; then echo "OK: $$p"; continue; fi; \
199                     echo "$$p failed"; sh "$(srcdir)/$$p" all; exit 1; \
200                 done; \
201                 set $(test-programs) $$testscripts; \
202                     echo "All $$# tests succeeded"
203
204 config.h:       $(srcdir)/../jigdo.spec
205                 rm -f config.h
206                 @echo "jigdo.spec has changed - rerun the configure script!"; \
207                 exit 1
208 Makefile:       Makefile.in Makedeps config.h.in
209                 cd .. && sh config.status # update Makefile from Makefile.in
210 #______________________________
211
212 jigdo32.ico:    ../gfx/jigdo32.ico
213                 ln -s "$<" . || cp "$<" .
214
215 jigdo.res:      jigdo.rc jigdo32.ico
216                 $(WINDRES) "$<" -O coff -o "$@"
217 #______________________________
218
219 jigdo@exe@:     $(objects-jigdo)
220                 $(LD) -o $@ $(objects-jigdo) $(LDFLAGS) $(GTKLIBS) \
221                     $(CURLLIBS) @IF_WINDOWS@ -lws2_32 @IFNOT_DEBUG@ -mwindows
222 glibcurl/glibcurl-example@exe@: glibcurl/glibcurl-example.o \
223                     glibcurl/glibcurl.o
224                 $(LD_C) -o $@ glibcurl/glibcurl-example.o \
225                     glibcurl/glibcurl.o $(LDFLAGS) $(GTKLIBS) $(CURLLIBS) \
226                     @IF_WINDOWS@ -lws2_32
227 jigdo-file@exe@: $(objects-jigdo-file)
228                 $(LD) -o $@ $(objects-jigdo-file) $(LDFLAGS)
229 torture@exe@:   $(objects-torture)
230                 $(LD) -o $@ $(objects-torture) $(LDFLAGS)
231 util/random@exe@: $(objects-random)
232                 $(LD) -o $@ $(objects-random) $(LDFLAGS)
233 mimestreamtest@exe@: mimestreamtest.o util/debug.o
234                 $(LD) -o $@ mimestreamtest.o util/log.o util/string-utf.o \
235                     util/debug.o $(LDFLAGS) $(GTKLIBS)
236 string-utftest@exe@: util/debug.o util/string-utf.o util/string-utftest.o
237                 $(LD) -o $@ util/string-utf.o util/string-utftest.o \
238                     util/debug.o $(LDFLAGS) $(GTKLIBS)
239 gunziptest@exe@: util/gunzip.o util/gunziptest.o util/debug.o
240                 $(LD) -o $@ util/gunzip.o util/gunziptest.o util/debug.o \
241                     $(LDFLAGS)
242 logtest@exe@:   util/debug.o util/log.o util/logtest.o util/string-utf.o
243                 $(LD) -o $@ util/log.o util/logtest.o util/string-utf.o \
244                     util/debug.o $(LDFLAGS) $(GTKLIBS)
245
246 gtk/interface.cc gtk/interface.hh: $(srcdir)/../jigdo.glade \
247                         $(srcdir)/../scripts/glade-filter.awk
248                 cd $(srcdir)/.. \
249                     && $(GLADECODE) "jigdo.glade"
250                 $(AWK) -f "$(srcdir)/../scripts/glade-filter.awk" \
251                     "$(srcdir)/gtk/interface"
252                 -ln -sf "$(srcdir)/gtk/interface.cc" gtk/interface.cc
253                 cd $(srcdir) && rm -f gtk/gui.cc.tmp gtk/gui.hh.tmp \
254                     gtk/interface.cc.tmp gtk/interface.hh.tmp
255 #______________________________________________________________________
256
257 LDFLAGS_WINSOCK = @IF_WINDOWS@ -lws2_32
258
259 @SRC_MAKEDEPS@