]> git.draconx.ca Git - upkg.git/blob - Makefile.am
Use gen-options script and help formatting from dxcommon.
[upkg.git] / Makefile.am
1 # Copyright © 2009-2012, 2015, 2019-2020, 2022 Nick Bowler
2 #
3 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 # This is free software: you are free to do what the fuck you want to.
5 # There is NO WARRANTY, to the extent permitted by law.
6
7 AUTOMAKE_OPTIONS = parallel-tests color-tests
8 ACLOCAL_AMFLAGS = -I m4 -I common/m4
9 MAINTAINERCLEANFILES =
10 MOSTLYCLEANFILES =
11 DISTCLEANFILES =
12
13 # Distribution should be buildable without working gob.
14 AM_DISTCHECK_CONFIGURE_FLAGS = GOB2=false
15
16 EXTRA_DIST = $(MAINTAINERCLEANFILES) m4/gnulib-cache.m4
17 CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
18
19 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
20               -I$(top_builddir)/lib -I$(top_srcdir)/lib \
21               -I$(DX_BASEDIR)/src -DPKGLIBDIR=\"$(pkglibdir)\" \
22               -DPKGDATADIR=\"$(pkgdatadir)\"
23
24 AM_CFLAGS = $(LTDLINCL) $(GLIB_CFLAGS) $(LIBMODPLUG_CFLAGS)
25
26 bin_PROGRAMS = upkg
27 lib_LTLIBRARIES = libupkg.la libuobject.la
28 pkglib_LTLIBRARIES = engine.la
29 noinst_LTLIBRARIES =
30 EXTRA_LTLIBRARIES =
31 include_HEADERS =
32
33 dist_man_MANS = doc/man/upkg.1
34
35 # This trick should define orderonly to | iff we're using GNU make.
36 have_orderonly = $(findstring order-only,$(.FEATURES))
37 orderonly = $(have_orderonly:order-only=|)
38
39 upkg_SOURCES = src/upkg.c src/upkg.h src/upkgopts.h \
40                common/src/help.c common/src/help.h
41 upkg_LDFLAGS = $(AM_LDFLAGS) -export-dynamic
42 upkg_LDADD   = libuobject.la libupkg.la libgnu.la $(GLIB_LIBS)
43 $(upkg_OBJECTS): $(gnulib_headers) src/upkgopts.h
44
45 libupkg_la_SOURCES = src/libupkg.c common/src/pack.c common/src/pack.h
46
47 uobjectdir = $(includedir)/uobject
48 uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
49         src/uobject/loadable.h src/uobject/module.h src/uobject/package.h \
50         src/uobject/vfs.h
51
52 libuobject_la_SOURCES = src/uobject/uobject.c src/uobject/module.c \
53         src/uobject/avl.c src/uobject/avl.h src/uobject/package.c \
54         src/uobject/exportable.c src/uobject/loadable.c src/uobject/vfs.c \
55         src/uobject/primitives.c
56 libuobject_la_LDFLAGS  = $(AM_LDFLAGS) -export-symbols-regex '^u_'
57 libuobject_la_LIBADD   = libgnu.la $(LIBLTDL) $(GLIB_LIBS)
58 $(libuobject_la_OBJECTS): $(gnulib_headers)
59
60 libuobject_la = libuobject.la
61 $(libuobject_la): $(LTDLDEPS)
62
63 moduleflags = -module -avoid-version -export-symbols-regex _LTX_
64
65 engine_GOBS = src/engine/palette.gob src/engine/texture.gob \
66         src/engine/music.gob src/engine/sound.gob src/engine/mesh.gob
67 EXTRA_DIST += $(engine_GOBS)
68
69 MAINTAINERCLEANFILES += $(engine_GOBS:.gob=.gobstamp) \
70         $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h)
71
72 engine_la_SOURCES = $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h) \
73         src/engine/engine.c \
74         src/engine/music-module.h \
75         src/engine/pcx.c \
76         src/engine/pcx.h
77 engine_la_LDFLAGS  = $(AM_LDFLAGS) $(moduleflags)
78 engine_la_LIBADD   = $(GLIB_LIBS)
79 $(engine_la_OBJECTS): $(orderonly) $(engine_GOBS:.gob=.gobstamp)
80
81 if USE_DUMMYMOD
82 engine_la_SOURCES += src/engine/music-dummymod.c
83 endif
84
85 if USE_LIBMODPLUG
86 engine_la_SOURCES  += src/engine/music-modplug.c src/engine/modplug-types.h
87 engine_la_LIBADD   += $(LIBMODPLUG_LIBS)
88 endif
89
90 check_LTLIBRARIES = libtest.la
91 check_PROGRAMS = test/decodeindex test/pcxrle
92
93 libtest_la_SOURCES = test/common.c test/common.h
94
95 test_decodeindex_LDADD = libupkg.la libgnu.la libtest.la
96 $(test_decodeindex_OBJECTS): $(gnulib_headers)
97 test_pcxrle_LDADD = src/engine/pcx.lo libupkg.la libgnu.la libtest.la
98 $(test_pcxrle_OBJECTS): $(gnulib_headers)
99
100 TESTS_ENVIRONMENT = SHELL='$(SHELL)' EXEEXT='$(EXEEXT)'
101 TEST_EXTENSIONS = .sh
102 SH_LOG_COMPILER = $(SHELL)
103
104 TESTS = tests/libupkg-index-decode.sh tests/engine-pcx-rlencode.sh
105 EXTRA_DIST += $(TESTS)
106
107 # Supporting rules for GObject Builder
108 GOB_V   = $(GOB_V_@AM_V@)
109 GOB_V_  = $(GOB_V_@AM_DEFAULT_V@)
110 GOB_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GOB     ' $<;
111
112 # Unfortunately, GOB's output filenames depend on the contents of the gob file,
113 # rather than its filename.  This isn't really suitable for use with make, so
114 # this rule has to make some assumptions about the source tree layout.
115 .gob.gobstamp:
116 if HAVE_GOB2_DYN
117         $(AM_V_at) touch $@.tmp
118         $(GOB_V) od='$(@D)'; case $$od in \
119           src/*) od=src ;; \
120           */src/*) od=$${od%/src/*}/src ;; \
121           esac; $(GOB2) -o "$$od" --file-sep=/ \
122             --no-private-header --no-touch-headers $<
123         $(AM_V_at) mv -f $@.tmp $@
124 else
125 if HAVE_GOB2
126         @echo "ERROR: *** $(GOB2) does not support dynamic types." 1>&2
127 else
128         @echo "ERROR: *** gob2 is missing on your system."  1>&2
129 endif
130         @:; { \
131          echo "       *** Because of this, I cannot compile $<, but"; \
132          echo "       *** (perhaps because you modified it) the sources appear out of date."; \
133          echo "       *** A newer version of gob2 may be required; the latest version"; \
134          echo "       *** may be found at <https://draconx.ca/projects/gob-dx/>."; \
135          echo "       *** See config.log for more details."; \
136         } 1>&2
137         @false
138 endif
139
140 STAMP_RECOVER = \
141         @if test -f $@; then :; else rm -f $<; $(MAKE) $(AM_MAKEFLAGS) $<; fi
142 .gobstamp.c: ; $(STAMP_RECOVER)
143 .gobstamp.h: ; $(STAMP_RECOVER)
144
145 OPTFILES = src/upkgopts.opt
146 .opt.h:
147         $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
148         $(AM_V_at) mv -f $@.tmp $@
149 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
150 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
151 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
152
153 # The gob rules refrain from updating unchanged headers for the convenience of
154 # developers, but the headers should be distributed with up-to-date timestamps.
155 dist-hook: update-headers
156 update-headers: unfuck-distdir
157         for f in $(engine_GOBS:.gob=.h); do \
158           touch -c '$(distdir)'/"$$f" || exit; \
159         done
160 .PHONY: update-headers
161
162 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
163 # will produce a distribution with all files read-only.  Moreover, the files
164 # are read-only in distdir when the dist hooks are run.  This hook will
165 # manually fix up the permissions.  All dist hooks that modify files in
166 # distdir should list unfuck-distdir as a prerequisite.
167 dist-hook: unfuck-distdir
168 unfuck-distdir:
169         find '$(distdir)' -type f -exec chmod u+w {} +
170 .PHONY: unfuck-distdir
171
172 include $(top_srcdir)/lib/gnulib.mk
173 include $(top_srcdir)/libltdl/ltdl.mk