Debian Codegraph @

Makefile

raw
1 MAKEFLAGS += --warn-undefined-variables
2 .DELETE_ON_ERROR:
3 SHELL := bash
4 .SHELLFLAGS := -eu -o pipefail -c
5
6 .PHONY: all default distclean clean install dist clean-apidoc show-install-dirs
7
8 all: default
9
10 noincludes := $(patsubst distclean,yes,$(MAKECMDGOALS))
11
12 # Defaults, overridden by config.mk below once configure has run
13 prefix := /usr/local
14 exec_prefix := $(prefix)
15
16 bindir := $(exec_prefix)/bin
17 libdir := $(exec_prefix)/lib
18 mandir := $(prefix)/man
19 docdir := $(prefix)/share/doc/gbsplay
20 localedir := $(prefix)/share/locale
21 mimedir := $(prefix)/share/mime
22 appdir := $(prefix)/share/applications
23 includedir := $(prefix)/include/libgbs
24 pkgconfigdir := $(prefix)/share/pkgconfig
25
26 configured := no
27 ifneq ($(noincludes),yes)
28 -include config.mk
29 endif
30
31 ifeq ($(use_verbosebuild),yes)
32 VERBOSE = 1
33 endif
34 ifeq ("$(origin V)", "command line")
35 VERBOSE = $(V)
36 endif
37 ifndef VERBOSE
38 VERBOSE = 0
39 endif
40 ifeq ($(VERBOSE),1)
41 Q =
42 else
43 Q = @
44 endif
45
46 generatedeps := no
47 ifneq ($(noincludes),yes)
48 ifeq ($(configured),yes)
49 generatedeps := yes
50 endif
51 endif
52
53 TEST_WRAPPER =
54 DESTDIR :=
55
56 # Update paths with user-provided DESTDIR
57 prefix := $(DESTDIR)$(prefix)
58 exec_prefix := $(DESTDIR)$(exec_prefix)
59 libdir := $(DESTDIR)$(libdir)
60 bindir := $(DESTDIR)$(bindir)
61 mandir := $(DESTDIR)$(mandir)
62 docdir := $(DESTDIR)$(docdir)
63 localedir := $(DESTDIR)$(localedir)
64 mimedir := $(DESTDIR)$(mimedir)
65 appdir := $(DESTDIR)$(appdir)
66 includedir := $(DESTDIR)$(includedir)
67 pkgconfigdir := $(DESTDIR)$(pkgconfigdir)
68
69 man1dir := $(mandir)/man1
70 man3dir := $(mandir)/man3
71 man5dir := $(mandir)/man5
72 contribdir := $(docdir)/contrib
73 exampledir := $(docdir)/examples
74
75 DISTDIR := gbsplay-$(VERSION)
76
77 GBSCFLAGS := -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L $(EXTRA_CFLAGS)
78 GBSLDFLAGS := $(EXTRA_LDFLAGS)
79 comma := ,
80 GBSLIBLDFLAGS := -lm $(subst -pie,,$(subst -Wl$(comma)-pie,,$(EXTRA_LDFLAGS)))
81 # Additional ldflags for the gbsplay executable
82 GBSPLAYLDFLAGS :=
83 # Additional ldflags for the xgbsplay executable
84 XGBSPLAYLDFLAGS := -lxcb -lxcb-icccm -lcairo
85
86 EXTRA_CLEAN :=
87
88 export Q VERBOSE CC HOSTCC BUILDCC GBSCFLAGS GBSLDFLAGS
89
90 docs := README.md HISTORY COPYRIGHT LICENCE
91 docs-dist := INSTALL.md CODINGSTYLE gbsformat.txt PACKAGING.md
92 contribs := contrib/gbs2ogg.sh contrib/gbsplay.bashcompletion contrib/gbsplay.zshcompletion
93 examples := examples/nightmode.gbs examples/gbsplayrc_sample
94
95 mans := man/gbsplay.1 man/gbsinfo.1 man/gbsplayrc.5 man/gbs2gb.1
96
97 apimans_list := libgbs.h gbs gbs_channel_status gbs_output_buffer gbs_status
98 apidocdir := apidoc
99 apimans := $(patsubst %,$(apidocdir)/man/man3/%.3,$(apimans_list))
100
101 apiheaders := libgbs.h
102
103 objs_libgbspic := gbcpu.lo gbhw.lo gblfsr.lo mapper.lo gbs.lo crc32.lo
104 objs_libgbs := gbcpu.o gbhw.o gblfsr.o mapper.o gbs.o crc32.o
105 objs_gbs2gb := gbs2gb.o
106 objs_gbsinfo := gbsinfo.o
107 objs_gbsplay := gbsplay.o util.o plugout.o player.o cfgparser.o
108 objs_xgbsplay := xgbsplay.o util.o plugout.o player.o cfgparser.o
109 objs_test_gbs := test_gbs.o
110 objs_gen_impulse_h := gen_impulse_h.ho impulsegen.ho
111
112 tests := util.test impulsegen.test gblfsr.test cfgparser.test
113
114 # terminal handling
115 ifeq ($(windows_libprefix),lib)
116 # when on MINGW
117 objs_gbsplay += terminal_windows.o
118 else
119 objs_gbsplay += terminal_posix.o
120 endif
121
122 # gbsplay output plugins
123 plugout_objs :=
124 plugout_ldflags :=
125
126 ifeq ($(plugout_devdsp),yes)
127 plugout_objs += plugout_devdsp.o
128 endif
129 ifeq ($(plugout_alsa),yes)
130 plugout_objs += plugout_alsa.o
131 plugout_ldflags += -lasound
132 endif
133 ifeq ($(plugout_nas),yes)
134 plugout_objs += plugout_nas.o
135 plugout_ldflags += -laudio $(libaudio_flags)
136 endif
137 ifeq ($(plugout_sdl),yes)
138 plugout_objs += plugout_sdl.o
139 plugout_ldflags += $(libSDL2_flags)
140 endif
141 ifeq ($(plugout_stdout),yes)
142 plugout_objs += plugout_stdout.o
143 endif
144 ifeq ($(plugout_midi),yes)
145 plugout_objs += plugout_midi.o midifile.o filewriter.o
146 endif
147 ifeq ($(plugout_altmidi),yes)
148 plugout_objs += plugout_altmidi.o midifile.o filewriter.o
149 endif
150 ifeq ($(plugout_pipewire),yes)
151 plugout_objs += plugout_pipewire.o
152 plugout_ldflags += $(libpipewire_0_3_flags)
153 endif
154 ifeq ($(plugout_pulse),yes)
155 plugout_objs += plugout_pulse.o
156 plugout_ldflags += -lpulse-simple -lpulse
157 endif
158 ifeq ($(plugout_dsound),yes)
159 plugout_objs += plugout_dsound.o
160 plugout_ldflags += -ldsound $(libdsound_flags)
161 endif
162 ifeq ($(plugout_iodumper),yes)
163 plugout_objs += plugout_iodumper.o
164 endif
165 ifeq ($(plugout_wav),yes)
166 plugout_objs +=plugout_wav.o filewriter.o
167 endif
168 ifeq ($(plugout_vgm),yes)
169 plugout_objs += plugout_vgm.o filewriter.o
170 endif
171
172 # dedupe (and finalize) plugout_objs; order is irrelevant, sorting is ok
173 plugout_objs := $(sort $(plugout_objs))
174
175 objs_gbsplay += $(plugout_objs)
176 objs_xgbsplay += $(plugout_objs)
177 GBSPLAYLDFLAGS += $(plugout_ldflags)
178 XGBSPLAYLDFLAGS += $(plugout_ldflags)
179
180 # install contrib files?
181 ifeq ($(build_contrib),yes)
182 EXTRA_INSTALL += install-contrib
183 EXTRA_UNINSTALL += uninstall-contrib
184 endif
185
186 # test built binary?
187 ifeq ($(build_test),yes)
188 TEST_TARGETS = test
189 else
190 TEST_TARGETS =
191 endif
192
193 # Cygwin automatically adds .exe to binaries.
194 # We should notice that or we can't rm the files later!
195 ifeq ($(windows_build),yes)
196 binsuffix := .exe
197 else
198 binsuffix :=
199 endif
200 gbsplaybin := gbsplay$(binsuffix)
201 xgbsplaybin := xgbsplay$(binsuffix)
202 gbs2gbbin := gbs2gb$(binsuffix)
203 gbsinfobin := gbsinfo$(binsuffix)
204 test_gbsbin := test_gbs$(binsuffix)
205 gen_impulse_h_bin := gen_impulse_h$(binsuffix)
206
207 ifeq ($(use_sharedlibgbs),yes)
208
209 EXTRA_INSTALL += install-headers install-pkg-config
210 EXTRA_UNINSTALL += uninstall-headers uninstall-pkg-config
211
212 ifeq ($(have_doxygen),yes)
213 EXTRA_INSTALL += install-apidoc
214 EXTRA_UNINSTALL += uninstall-apidoc
215 endif
216
217 GBSLDFLAGS += -L. -lgbs
218 objs += $(objs_libgbspic)
219
220 libgbs.so.1.ver: libgbs_whitelist.txt gen_linkercfg.sh
221 ./gen_linkercfg.sh libgbs_whitelist.txt $@ ver
222
223 libgbs.def: libgbs_whitelist.txt gen_linkercfg.sh
224 ./gen_linkercfg.sh libgbs_whitelist.txt $@ def
225
226 ifeq ($(windows_build),yes)
227 EXTRA_INSTALL += install-$(windows_libprefix)gbs-1.dll
228 EXTRA_UNINSTALL += uninstall-$(windows_libprefix)gbs-1.dll
229
230 install-$(windows_libprefix)gbs-1.dll:
231 install -d $(bindir)
232 install -d $(libdir)
233 install -m 644 $(windows_libprefix)gbs-1.dll $(bindir)/$(windows_libprefix)gbs-1.dll
234 install -m 644 libgbs.dll.a $(libdir)/libgbs.dll.a
235
236 uninstall-$(windows_libprefix)gbs-1.dll:
237 rm -f $(bindir)/$(windows_libprefix)gbs-1.dll
238 rm -f $(libdir)/libgbs.dll.a
239 -rmdir -p $(libdir)
240
241 $(windows_libprefix)gbs-1.dll: $(objs_libgbspic) libgbs.so.1.ver
242 $(CC) -fpic -shared -Wl,-soname=$@ -Wl,--version-script,libgbs.so.1.ver -o $@ $(objs_libgbspic) $(EXTRA_LDFLAGS)
243
244 libgbs.dll.a: libgbs.def
245 dlltool --input-def libgbs.def --dllname $(windows_libprefix)gbs-1.dll --output-lib libgbs.dll.a -k
246
247 libgbs: $(windows_libprefix)gbs-1.dll libgbs.dll.a
248 touch libgbs
249
250 libgbspic: $(windows_libprefix)gbs-1.dll libgbs.dll.a
251 touch libgbspic
252 else
253 EXTRA_INSTALL += install-libgbs.so.1
254 EXTRA_UNINSTALL += uninstall-libgbs.so.1
255
256
257 install-libgbs.so.1:
258 install -d $(libdir)
259 install -m 644 libgbs.so.1 $(libdir)/libgbs.so.1
260
261 uninstall-libgbs.so.1:
262 rm -f $(libdir)/libgbs.so.1
263 -rmdir -p $(libdir)
264
265
266 libgbs.so.1: $(objs_libgbspic) libgbs.so.1.ver
267 $(BUILDCC) -fpic -shared -Wl,-soname=$@ -Wl,--version-script,[email protected] -o $@ $(objs_libgbspic) $(GBSLIBLDFLAGS)
268 ln -fs $@ libgbs.so
269
270 libgbs: libgbs.so.1
271 touch libgbs
272
273 libgbspic: libgbs.so.1
274 touch libgbspic
275 endif
276 else
277 GBSLDFLAGS += -lm
278 objs += $(objs_libgbs)
279 objs_gbsplay += libgbs.a
280 objs_gbs2gb += libgbs.a
281 objs_gbsinfo += libgbs.a
282 objs_test_gbs += libgbs.a
283 objs_xgbsplay += libgbs.a
284
285 libgbs: libgbs.a
286 touch libgbs
287
288 libgbspic: libgbspic.a
289 touch libgbspic
290 endif # use_sharedlibs
291
292 objs += $(objs_gbsplay) $(objs_gbs2gb) $(objs_gbsinfo)
293 dsts += gbsplay gbs2gb gbsinfo
294
295 ifeq ($(build_xgbsplay),yes)
296 objs += $(objs_xgbsplay)
297 dsts += xgbsplay
298 mans += man/xgbsplay.1
299 EXTRA_INSTALL += install-xgbsplay
300 EXTRA_UNINSTALL += uninstall-xgbsplay
301 EXTRA_CLEAN += clean-xgbsplay
302 endif
303
304 # include the rules for each subdir
305 include $(shell find . -type f -name "subdir.mk")
306
307 ifeq ($(generatedeps),yes)
308 # Ready to build deps and everything else
309 default: config.mk $(objs) $(dsts) $(mans) $(EXTRA_ALL) $(TEST_TARGETS)
310
311 # Generate & include the dependency files
312 deps := $(patsubst %.o,%.d,$(filter %.o,$(objs)))
313 deps += $(patsubst %.lo,%.d,$(filter %.lo,$(objs)))
314 -include $(deps)
315 else
316 # Configure still needs to run
317 default: config.mk
318 endif
319
320 distclean: clean clean-xgbsplay
321 find . -regex ".*\.d" -exec rm -f "{}" \;
322 rm -f ./config.mk ./config.h ./config.err ./config.sed ./libgbs.pc
323
324 clean: clean-default $(EXTRA_CLEAN) clean-apidoc
325
326 clean-default:
327 find . -regex ".*\.\([aos]\|ho\|lo\|mo\|pot\|test\(\.exe\)?\|so\(\.[0-9]\)?\|gcda\|gcno\|gcov\)" -exec rm -f "{}" \;
328 find . -name "*~" -exec rm -f "{}" \;
329 rm -f libgbs libgbspic libgbs.def libgbs.so.1.ver
330 rm -f $(mans)
331 rm -f $(gbsplaybin) $(gbs2gbbin) $(gbsinfobin)
332 rm -f $(test_gbsbin) gbsplayrc.tmp
333 rm -f $(gen_impulse_h_bin) impulse.h
334
335 clean-apidoc:
336 rm -rf $(apidocdir)/
337
338 clean-xgbsplay:
339 rm -f $(xgbsplaybin)
340
341 install: install-default $(EXTRA_INSTALL)
342
343 install-default: all
344 install -d $(bindir)
345 install -d $(man1dir)
346 install -d $(man5dir)
347 install -d $(docdir)
348 install -d $(exampledir)
349 install -d $(mimedir)/packages
350 install -d $(appdir)
351 install -m 755 $(gbsplaybin) $(gbs2gbbin) $(gbsinfobin) $(bindir)
352 install -m 644 man/gbsplay.1 man/gbsinfo.1 man/gbs2gb.1 $(man1dir)
353 install -m 644 man/gbsplayrc.5 $(man5dir)
354 install -m 644 mime/gbsplay.xml $(mimedir)/packages
355 -update-mime-database $(mimedir)
356 install -m 644 desktop/gbsplay.desktop $(appdir)
357 -update-desktop-database $(appdir)
358 install -m 644 $(docs) $(docdir)
359 install -m 644 $(examples) $(exampledir)
360 for i in $(mos); do \
361 base=`basename $$i`; \
362 install -d $(localedir)/$${base%.mo}/LC_MESSAGES; \
363 install -m 644 $$i $(localedir)/$${base%.mo}/LC_MESSAGES/gbsplay.mo; \
364 done
365
366 install-contrib:
367 install -d $(contribdir)
368 install -m 644 $(contribs) $(contribdir)
369
370 install-xgbsplay: $(xgbsplaybin) $(mans)
371 install -d $(bindir)
372 install -d $(man1dir)
373 install -d $(appdir)
374 install -m 755 $(xgbsplaybin) $(bindir)
375 install -m 644 man/xgbsplay.1 $(man1dir)
376 install -m 644 desktop/xgbsplay.desktop $(appdir)
377 -update-desktop-database $(appdir)
378
379 install-apidoc: generate-apidoc
380 install -d $(man3dir)
381 install -m 644 $(apimans) $(man3dir)
382
383 install-headers:
384 install -d $(includedir)
385 install -m 644 $(apiheaders) $(includedir)
386
387 install-pkg-config:
388 install -d $(pkgconfigdir)
389 install -m 644 libgbs.pc $(pkgconfigdir)
390
391 show-install-dirs:
392 @echo "+ DESTDIR = $(DESTDIR)"
393 @echo "* bindir = $(bindir)"
394 @echo " includedir = $(includedir)"
395 @echo "* libdir = $(libdir)"
396 @echo "* mandir = $(mandir)"
397 @echo " man1dir = $(man1dir)"
398 @echo " man3dir = $(man3dir)"
399 @echo " man5dir = $(man5dir)"
400 @echo "* appdir = $(appdir)"
401 @echo "* docdir = $(docdir)"
402 @echo " contribdir = $(contribdir)"
403 @echo " exampledir = $(exampledir)"
404 @echo " localedir = $(localedir)"
405 @for i in $(mos); do \
406 base=`basename $$i`; \
407 echo " $(localedir)/$${base%.mo}"; \
408 done
409 @echo " mimedir = $(mimedir)"
410 @echo " $(mimedir)/packages"
411 @echo " pkgconfigdir = $(pkgconfigdir)"
412
413 uninstall: uninstall-default $(EXTRA_UNINSTALL)
414
415 uninstall-default:
416 rm -f $(bindir)/$(gbsplaybin) $(bindir)/$(gbs2gbbin) $(bindir)/$(gbsinfobin)
417 -rmdir -p $(bindir)
418 rm -f $(man1dir)/gbsplay.1 $(man1dir)/gbsinfo.1 $(man1dir)/gbs2gb.1
419 -rmdir -p $(man1dir)
420 rm -f $(man5dir)/gbsplayrc.5
421 -rmdir -p $(man5dir)
422 rm -f $(mimedir)/packages/gbsplay.xml
423 -update-mime-database $(mimedir)
424 -rmdir -p $(mimedir)/packages
425 rm -f $(appdir)/gbsplay.desktop
426 -update-desktop-database $(appdir)
427 -rmdir -p $(appdir)
428 rm -rf $(exampledir)
429 -rmdir -p $(exampledir)
430 rm -rf $(docdir)
431 -mkdir -p $(docdir)
432 -rmdir -p $(docdir)
433 -for i in $(mos); do \
434 base=`basename $$i`; \
435 rm -f $(localedir)/$${base%.mo}/LC_MESSAGES/gbsplay.mo; \
436 rmdir -p $(localedir)/$${base%.mo}/LC_MESSAGES; \
437 done
438
439 uninstall-contrib:
440 rm -rf $(contribdir)
441 -rmdir -p $(contribdir)
442
443 uninstall-xgbsplay:
444 rm -f $(bindir)/$(xgbsplaybin)
445 rm -f $(man1dir)/xgbsplay.1
446 rm -f $(appdir)/xgbsplay.desktop
447 -update-desktop-database $(appdir)
448 -rmdir -p $(bindir)
449 -rmdir -p $(man1dir)
450 -rmdir -p $(appdir)
451
452 uninstall-apidoc:
453 rm -f $(patsubst %, $(man3dir)/%.3,$(apimans_list))
454 -rmdir -p $(man3dir)
455
456 uninstall-headers:
457 rm -f $(addprefix $(includedir)/,$(apiheaders))
458 -rmdir -p $(includedir)
459
460 uninstall-pkg-config:
461 rm -f $(pkgconfigdir)/libgbs.pc
462 -rmdir -p $(pkgconfigdir)
463
464 dist: distclean
465 install -d ./$(DISTDIR)
466 sed 's/^VERSION=.*/VERSION=$(VERSION)/' < configure > ./$(DISTDIR)/configure
467 chmod 755 ./$(DISTDIR)/configure
468 install -m 755 depend.sh ./$(DISTDIR)/
469 install -m 644 Makefile ./$(DISTDIR)/
470 install -m 644 *.c ./$(DISTDIR)/
471 install -m 644 *.h ./$(DISTDIR)/
472 install -d ./$(DISTDIR)/man
473 install -m 644 man/*.in.? ./$(DISTDIR)/man
474 install -m 644 $(docs) $(docs-dist) ./$(DISTDIR)/
475 install -d ./$(DISTDIR)/examples
476 install -m 644 $(examples) ./$(DISTDIR)/examples
477 install -d ./$(DISTDIR)/contrib
478 install -m 644 $(contribs) ./$(DISTDIR)/contrib
479 install -d ./$(DISTDIR)/po
480 install -m 644 po/*.po ./$(DISTDIR)/po
481 install -m 644 po/subdir.mk ./$(DISTDIR)/po
482 install -m 644 .gitignore ./$(DISTDIR)/
483 install -d ./$(DISTDIR)/mime
484 install -m 644 mime/* ./$(DISTDIR)/mime
485 install -d ./$(DISTDIR)/desktop
486 install -m 644 desktop/* ./$(DISTDIR)/desktop
487 tar -cvzf ../$(DISTDIR).tar.gz $(DISTDIR)/
488 rm -rf ./$(DISTDIR)
489
490 generate-apidoc: clean-apidoc
491 doxygen Doxyfile
492
493 TESTOPTS := -r 44100 -t 30 -f 0 -g 0 -T 0 -H off
494
495 test: gbsplay $(tests) test_gbs
496 @echo Verifying output correctness for examples/nightmode.gbs:
497 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -o iodumper $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null | (md5sum || md5 -r) | cut -f1 -d\ `; \
498 EXPECT="9e7595c3cd5c37a6a7793d1adb1c0741"; \
499 if [ "$$MD5" = "$$EXPECT" ]; then \
500 echo "iodumper output ok"; \
501 else \
502 echo "iodumper output failed"; \
503 echo " Expected: $$EXPECT"; \
504 echo " Got: $$MD5" ; \
505 exit 1; \
506 fi
507 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E b -o stdout $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null | (md5sum || md5 -r) | cut -f1 -d\ `; \
508 EXPECT="a415dadc7f8b0fcf35da6fc97c583b92"; \
509 if [ "$$MD5" = "$$EXPECT" ]; then \
510 echo "Bigendian output ok"; \
511 else \
512 echo "Bigendian output failed"; \
513 echo " Expected: $$EXPECT"; \
514 echo " Got: $$MD5" ; \
515 exit 1; \
516 fi
517 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E l -o stdout $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null | (md5sum || md5 -r) | cut -f1 -d\ `; \
518 EXPECT="14b351ee391aaa11cfc0a0d0e25babab"; \
519 if [ "$$MD5" = "$$EXPECT" ]; then \
520 echo "Littleendian output ok"; \
521 else \
522 echo "Littleendian output failed"; \
523 echo " Expected: $$EXPECT"; \
524 echo " Got: $$MD5" ; \
525 exit 1; \
526 fi
527 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E l -o wav $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null; cat gbsplay-1.wav | (md5sum || md5 -r) | cut -f1 -d\ `; \
528 EXPECT="f04623d1da242df5ca99effe1e3c3599"; \
529 if [ "$$MD5" = "$$EXPECT" ]; then \
530 echo "WAV output ok"; \
531 else \
532 echo "WAV output failed"; \
533 echo " Expected: $$EXPECT"; \
534 echo " Got: $$MD5" ; \
535 exit 1; \
536 fi
537 $(Q)rm gbsplay-1.wav
538 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E l -o vgm $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null; cat gbsplay-1.vgm | (md5sum || md5 -r) | cut -f1 -d\ `; \
539 EXPECT="2cfb9d87de2b9a144d3e4710be97f429"; \
540 if [ "$$MD5" = "$$EXPECT" ]; then \
541 echo "VGM output ok"; \
542 else \
543 echo "VGM output failed"; \
544 echo " Expected: $$EXPECT"; \
545 echo " Got: $$MD5" ; \
546 exit 1; \
547 fi
548 $(Q)rm gbsplay-1.vgm
549 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E l -o midi $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null; cat gbsplay-1.mid | (md5sum || md5 -r) | cut -f1 -d\ `; \
550 EXPECT="196960b3048d50a748dcd0d26c9ea2de"; \
551 if [ "$$MD5" = "$$EXPECT" ]; then \
552 echo "MIDI output ok"; \
553 else \
554 echo "MIDI output failed"; \
555 echo " Expected: $$EXPECT"; \
556 echo " Got: $$MD5" ; \
557 exit 1; \
558 fi
559 $(Q)MD5=`LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH-} $(TEST_WRAPPER) ./gbsplay -c examples/gbsplayrc_sample -E l -o altmidi $(TESTOPTS) examples/nightmode.gbs 1 < /dev/null; cat gbsplay-1.mid | (md5sum || md5 -r) | cut -f1 -d\ `; \
560 EXPECT="972105e5d0644d65cc557d2904117d13"; \
561 if [ "$$MD5" = "$$EXPECT" ]; then \
562 echo "alternate MIDI output ok"; \
563 else \
564 echo "alternate MIDI output failed"; \
565 echo " Expected: $$EXPECT"; \
566 echo " Got: $$MD5" ; \
567 exit 1; \
568 fi
569 $(Q)rm gbsplay-1.mid
570
571 $(gen_impulse_h_bin): $(objs_gen_impulse_h)
572 $(HOSTCC) -o $(gen_impulse_h_bin) $(objs_gen_impulse_h) -lm
573 impulse.h: $(gen_impulse_h_bin)
574 $(Q)./$(gen_impulse_h_bin) > $@
575 gbhw.d: impulse.h
576
577 libgbspic.a: $(objs_libgbspic)
578 $(AR) r $@ $+
579 libgbs.a: $(objs_libgbs)
580 $(AR) r $@ $+
581 gbs2gb: $(objs_gbs2gb) libgbs
582 $(BUILDCC) -o $(gbs2gbbin) $(objs_gbs2gb) $(GBSLDFLAGS)
583 gbsinfo: $(objs_gbsinfo) libgbs
584 $(BUILDCC) -o $(gbsinfobin) $(objs_gbsinfo) $(GBSLDFLAGS)
585 gbsplay: $(objs_gbsplay) libgbs
586 $(BUILDCC) -o $(gbsplaybin) $(objs_gbsplay) $(GBSLDFLAGS) $(GBSPLAYLDFLAGS) -lm
587 test_gbs: $(objs_test_gbs) libgbs
588 $(BUILDCC) -o $(test_gbsbin) $(objs_test_gbs) $(GBSLDFLAGS)
589
590 xgbsplay: $(objs_xgbsplay) libgbs
591 $(BUILDCC) -o $(xgbsplaybin) $(objs_xgbsplay) $(GBSLDFLAGS) $(XGBSPLAYLDFLAGS) -lm
592
593 # rules for suffixes
594
595 .SUFFIXES: .i .s .lo .ho
596
597 .c.lo:
598 @echo CC $< -o $@
599 $(Q)$(BUILDCC) $(GBSCFLAGS) -fpic -c -o $@ $<
600 .c.o:
601 @echo CC $< -o $@
602 $(Q)$(BUILDCC) $(GBSCFLAGS) -fpie -c -o $@ $<
603 .c.ho:
604 @echo HOSTCC $< -o $@
605 $(Q)$(HOSTCC) $(GBSCFLAGS) -fpie -c -o $@ $<
606
607 .c.i:
608 $(BUILDCC) -E $(GBSCFLAGS) -o $@ $<
609 .c.s:
610 $(BUILDCC) -S $(GBSCFLAGS) -fverbose-asm -o $@ $<
611
612 # rules for generated files
613
614 config.mk: configure
615 ./configure
616
617 %.test: %.c
618 @echo TEST $<
619 $(Q)$(HOSTCC) -DENABLE_TEST=1 -o $@$(binsuffix) $< -lm
620 $(Q)./$@$(binsuffix)
621 $(Q)rm ./$@$(binsuffix)
622
623 %.d: %.c config.mk
624 @echo DEP $< -o $@
625 $(Q)CC=$(BUILDCC) ./depend.sh $< config.mk > $@ || rm -f $@
626
627 %.1: %.in.1 config.sed
628 sed -f config.sed $< > $@
629
630 %.5: %.in.5 config.sed
631 sed -f config.sed $< > $@