1 # Project: Jigdo (Jigsaw download)
3 # |_) /| Copyright (C) 2001-2004 | richard@
4 # | \/¯| Richard Atterer | atterer.org
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"
16 # Prevent these variables from being taken from the environment
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)
27 CFLAGS = @CFLAGS@ $(X) $(EXTRA_CFLAGS)
29 CXXFLAGS = @CXXFLAGS@ $(X) $(EXTRA_CXXFLAGS)
32 LDFLAGS = @LIBS@ @LDFLAGS@ $(Y) $(EXTRA_LDFLAGS)
35 GLADECODE = glade-2 -w # Create code from .glade file
38 GTKCFLAGS = @GTKCFLAGS@
41 #LIBWWWCFLAGS = @LIBWWWCFLAGS@
42 #LIBWWWLIBS = @LIBWWWLIBS@
43 CURLCFLAGS = @CURLCFLAGS@
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/sha256sum-test@exe@ util/mimestream-test@exe@ \
57 util/string-utf-test@exe@
58 # net/uri-test@exe@ needs curl
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/glibc-sha256.o util/gunzip.o \
71 util/log.o util/md5sum.o util/sha256sum.o util/progress.o util/string-utf.o \
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/glibc-sha256.o util/log.o util/md5sum.o \
80 util/sha256sum.o util/rsyncsum.o \
81 util/string.o zstream.o zstream-bz.o zstream-gz.o \
82 util/debug.o # this must come last!
83 objects-torture = cachefile.o compat.o jigdoconfig.o mkimage.o mkjigdo.o \
84 mktemplate.o partialmatch.o recursedir.o scan.o torture.o \
85 util/bstream.o util/configfile.o util/glibc-md5.o util/glibc-sha256.o \
86 util/log.o util/md5sum.o util/sha256sum.o util/rsyncsum.o util/string.o \
87 zstream.o zstream-bz.o zstream-gz.o \
88 util/debug.o # this must come last!
89 objects-random = util/glibc-md5.o util/glibc-sha256.o util/log.o util/md5sum.o \
90 util/sha256sum.o util/random.o \
92 util/debug.o # this must come last!
93 #______________________________
96 .SUFFIXES: .c .cc .h .o
98 -@echo $(CXX) '$$cxx' -c $< -o $@
99 @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c "$<" -o "$@"
101 -@echo $(CC) '$$c ' -c $< -o $@
102 @$(CC) $(CPPFLAGS) $(CFLAGS) -c "$<" -o "$@"
103 #______________________________________________________________________
105 .PHONY: all all-msg clean distclean mostlyclean maintainer-clean \
106 dep depend doc strip test test-v test-c
107 all: all-msg Makefile $(programs) @IF_DEBUG@ $(debug-programs) \
108 @IFNOT_GXX2@ test-c @IFNOT_CROSSCOMPILING@ test
110 -@if test "$$EMACS" != t; then \
111 echo "export cpp='$(CPPFLAGS)'"; \
112 echo 'export cxx="$$cpp $(CXXFLAGS)"'; \
113 echo 'export c="$$cpp $(CFLAGS)"'; \
115 check: $(programs) torture@exe@
117 @echo '*** Warning - this will take a few minutes and ~100MB'
118 @echo '*** disk space, and will bash the disc quite a bit...'
120 mkdir ironmaiden || true
125 for d in . $(SUBDIRS); do \
126 rm -f $$d/*.o $$d/core; \
127 for p in $$d/*test; do if test -x "$$p" -a -f \
128 "$(srcdir)/$$d/$$p.cc"; then rm -f "$$p"; fi; done; \
130 rm -f gtk/interface.hh.tmp gtk/gui.cc.tmp gtk/gui.hh.tmp
131 rm -f $(programs) $(debug-programs) $(test-programs)
132 rm -rf apidoc mktemplate-testdir
134 for d in . $(SUBDIRS); do \
135 rm -f $$d/TAGS $$d/*~ $$d/\#*\# $$d/*.bak; \
136 rm -f $$d/Makefile $$d/config.h; \
139 if test ! -h ironmaiden; then rm -rf ironmaiden; fi
142 maintainer-clean: distclean
143 rm -f gtk/interface.cc gtk/interface.hh
147 make-makedeps = (cd "$(srcdir)" && find . -type f \
148 '(' -name '*.cc' -o -name '*.c' ')') \
149 | xargs $(AWK) -f "$(srcdir)/../scripts/depend.awk" \
150 "$(srcdir)" $(SUBDIRS) -
151 # No dependency - don't normally remake Makedeps on gtk/interface.cc remake
152 # (Touching Makedeps/Makefile necessary, or circ. dep. Makefile->Makedeps.)
154 if test ! -r gtk/interface.cc; then \
155 touch "$(srcdir)/Makedeps" Makefile; \
156 $(MAKE) gtk/interface.cc; \
159 # Dependency ensures auto-generated files are there & appear in depend output
160 dep depend: gtk/interface.cc
162 @if test "$(srcdir)/Makedeps" -nt Makefile; then \
163 echo "cd .. && sh config.status"; \
164 cd .. && sh config.status; \
167 for p in $(programs); do if test -f "$$p"; then \
168 strip -R .comment -R .note "$$p"; fi; done
170 TEST-DEFAULTOBJS = util/log.o util/string-utf.o util/debug.o
171 TEST-LDFLAGS = @LDFLAGS@ $(GLIBLIBS)
174 test-c: $(test-programs)
176 test: $(test-programs) jigdo-file@exe@ util/random@exe@
177 @echo "Running unit tests..."; \
178 for p in $(test-programs); do \
179 if "$$p"; then continue; fi; \
180 echo "$$p failed, for details enter: $$p all"; exit 1; \
182 testscripts="`cd $(srcdir) && echo *-test*.sh`"; \
183 export srcdir="$(srcdir)"; \
184 for p in $$testscripts; do \
185 if sh "$(srcdir)/$$p"; then continue; fi; \
186 echo "$$p failed"; exit 1; \
188 set $(test-programs) $$testscripts; \
189 echo "All $$# tests succeeded"
190 # Compile and run, re-run in verbose mode after error
191 test-v: $(test-programs) jigdo-file@exe@ util/random@exe@
192 @echo "Running unit tests..."; \
193 for p in $(test-programs); do \
194 if "$$p"; then echo "OK: $$p"; continue; fi; \
195 echo "$$p failed"; "$$p" all; exit 1; \
197 testscripts="`cd $(srcdir) && echo *-test*.sh`"; \
198 export srcdir="$(srcdir)"; \
199 for p in $$testscripts; do \
200 if sh "$(srcdir)/$$p"; then echo "OK: $$p"; continue; fi; \
201 echo "$$p failed"; sh "$(srcdir)/$$p" all; exit 1; \
203 set $(test-programs) $$testscripts; \
204 echo "All $$# tests succeeded"
206 config.h: $(srcdir)/../jigdo.spec
208 @echo "jigdo.spec has changed - rerun the configure script!"; \
210 Makefile: Makefile.in Makedeps config.h.in
211 cd .. && sh config.status # update Makefile from Makefile.in
212 #______________________________
214 jigdo32.ico: ../gfx/jigdo32.ico
215 ln -s "$<" . || cp "$<" .
217 jigdo.res: jigdo.rc jigdo32.ico
218 $(WINDRES) "$<" -O coff -o "$@"
219 #______________________________
221 jigdo@exe@: $(objects-jigdo)
222 $(LD) -o $@ $(objects-jigdo) $(LDFLAGS) $(GTKLIBS) \
223 $(CURLLIBS) @IF_WINDOWS@ -lws2_32 @IFNOT_DEBUG@ -mwindows
224 glibcurl/glibcurl-example@exe@: glibcurl/glibcurl-example.o \
226 $(LD_C) -o $@ glibcurl/glibcurl-example.o \
227 glibcurl/glibcurl.o $(LDFLAGS) $(GTKLIBS) $(CURLLIBS) \
228 @IF_WINDOWS@ -lws2_32
229 jigdo-file@exe@: $(objects-jigdo-file)
230 $(LD) -o $@ $(objects-jigdo-file) $(LDFLAGS)
231 torture@exe@: $(objects-torture)
232 $(LD) -o $@ $(objects-torture) $(LDFLAGS)
233 util/random@exe@: $(objects-random)
234 $(LD) -o $@ $(objects-random) $(LDFLAGS)
235 mimestreamtest@exe@: mimestreamtest.o util/debug.o
236 $(LD) -o $@ mimestreamtest.o util/log.o util/string-utf.o \
237 util/debug.o $(LDFLAGS) $(GTKLIBS)
238 string-utftest@exe@: util/debug.o util/string-utf.o util/string-utftest.o
239 $(LD) -o $@ util/string-utf.o util/string-utftest.o \
240 util/debug.o $(LDFLAGS) $(GTKLIBS)
241 gunziptest@exe@: util/gunzip.o util/gunziptest.o util/debug.o
242 $(LD) -o $@ util/gunzip.o util/gunziptest.o util/debug.o \
244 logtest@exe@: util/debug.o util/log.o util/logtest.o util/string-utf.o
245 $(LD) -o $@ util/log.o util/logtest.o util/string-utf.o \
246 util/debug.o $(LDFLAGS) $(GTKLIBS)
248 gtk/interface.cc gtk/interface.hh: $(srcdir)/../jigdo.glade \
249 $(srcdir)/../scripts/glade-filter.awk
251 && $(GLADECODE) "jigdo.glade"
252 $(AWK) -f "$(srcdir)/../scripts/glade-filter.awk" \
253 "$(srcdir)/gtk/interface"
254 -ln -sf "$(srcdir)/gtk/interface.cc" gtk/interface.cc
255 cd $(srcdir) && rm -f gtk/gui.cc.tmp gtk/gui.hh.tmp \
256 gtk/interface.cc.tmp gtk/interface.hh.tmp
257 #______________________________________________________________________
259 LDFLAGS_WINSOCK = @IF_WINDOWS@ -lws2_32