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