]> git.draconx.ca Git - upkg.git/blobdiff - Makefile.am
Stop using gnulib's flexmember module.
[upkg.git] / Makefile.am
index 1fc339f14f00bc238af3d8ceb6cb82270a84b527..fa034c3ed5080fd873c951e68a13262db126da61 100644 (file)
@@ -1,20 +1,24 @@
-# Copyright © 2009-2012 Nick Bowler
+# Copyright © 2009-2012, 2015, 2019-2020, 2022 Nick Bowler
 #
 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-AUTOMAKE_OPTIONS = parallel-tests color-tests
-ACLOCAL_AMFLAGS = -I m4
+ACLOCAL_AMFLAGS = -I m4 -I common/m4
 MAINTAINERCLEANFILES =
 MOSTLYCLEANFILES =
-CLEANFILES =
+DISTCLEANFILES =
+
+# Distribution should be buildable without working gob.
+AM_DISTCHECK_CONFIGURE_FLAGS = GOB2=false
 
 EXTRA_DIST = $(MAINTAINERCLEANFILES) m4/gnulib-cache.m4
+CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
-       -I$(top_builddir)/lib -I$(top_srcdir)/lib \
-       -DPKGLIBDIR=\"$(pkglibdir)\" -DPKGDATADIR=\"$(pkgdatadir)\"
+              -I$(top_builddir)/lib -I$(top_srcdir)/lib \
+              -I$(DX_BASEDIR)/src -DPKGLIBDIR=\"$(pkglibdir)\" \
+              -DPKGDATADIR=\"$(pkgdatadir)\"
 
 AM_CFLAGS = $(LTDLINCL) $(GLIB_CFLAGS) $(LIBMODPLUG_CFLAGS)
 
@@ -27,16 +31,14 @@ include_HEADERS =
 
 dist_man_MANS = doc/man/upkg.1
 
-# This trick should define orderonly to | iff we're using GNU make.
-have_orderonly = $(findstring order-only,$(.FEATURES))
-orderonly = $(have_orderonly:order-only=|)
-
-upkg_SOURCES  = src/upkg.c
-upkg_LDFLAGS  = $(AM_LDFLAGS) -export-dynamic
-upkg_LDADD    = libuobject.la libupkg.la libgnu.la $(GLIB_LIBS)
-$(upkg_OBJECTS): $(gnulib_headers)
+upkg_SOURCES = src/upkg.c src/upkg.h src/upkgopts.h \
+               common/src/help.c common/src/help.h
+upkg_LDFLAGS = $(AM_LDFLAGS) -export-dynamic
+upkg_LDADD   = libuobject.la libupkg.la libgnu.la $(GLIB_LIBS)
+$(upkg_OBJECTS): $(gnulib_headers) src/upkgopts.h
 
-libupkg_la_SOURCES = src/libupkg.c src/pack.c
+libupkg_la_SOURCES = src/libupkg.c common/src/pack.c common/src/pack.h
+$(libupkg_la_OBJECTS): $(gnulib_headers)
 
 uobjectdir = $(includedir)/uobject
 uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
@@ -45,7 +47,8 @@ uobject_HEADERS = src/uobject/uobject.h src/uobject/exportable.h \
 
 libuobject_la_SOURCES = src/uobject/uobject.c src/uobject/module.c \
        src/uobject/avl.c src/uobject/avl.h src/uobject/package.c \
-       src/uobject/exportable.c src/uobject/loadable.c src/uobject/vfs.c
+       src/uobject/exportable.c src/uobject/loadable.c src/uobject/vfs.c \
+       src/uobject/primitives.c
 libuobject_la_LDFLAGS  = $(AM_LDFLAGS) -export-symbols-regex '^u_'
 libuobject_la_LIBADD   = libgnu.la $(LIBLTDL) $(GLIB_LIBS)
 $(libuobject_la_OBJECTS): $(gnulib_headers)
@@ -56,16 +59,20 @@ $(libuobject_la): $(LTDLDEPS)
 moduleflags = -module -avoid-version -export-symbols-regex _LTX_
 
 engine_GOBS = src/engine/palette.gob src/engine/texture.gob \
-       src/engine/music.gob src/engine/sound.gob
+       src/engine/music.gob src/engine/sound.gob src/engine/mesh.gob
+EXTRA_DIST += $(engine_GOBS)
 
 MAINTAINERCLEANFILES += $(engine_GOBS:.gob=.gobstamp) \
        $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h)
 
 engine_la_SOURCES = $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h) \
-       src/engine/engine.c src/engine/pcx.c
+       src/engine/engine.c \
+       src/engine/music-module.h \
+       src/engine/pcx.c \
+       src/engine/pcx.h
 engine_la_LDFLAGS  = $(AM_LDFLAGS) $(moduleflags)
 engine_la_LIBADD   = $(GLIB_LIBS)
-$(engine_la_OBJECTS): $(orderonly) $(engine_GOBS:.gob=.gobstamp)
+$(engine_la_OBJECTS): $(gnulib_headers) $(engine_GOBS:.gob=.gobstamp)
 
 if USE_DUMMYMOD
 engine_la_SOURCES += src/engine/music-dummymod.c
@@ -76,39 +83,86 @@ engine_la_SOURCES  += src/engine/music-modplug.c src/engine/modplug-types.h
 engine_la_LIBADD   += $(LIBMODPLUG_LIBS)
 endif
 
-check_LTLIBRARIES = libtest.la
 check_PROGRAMS = test/decodeindex test/pcxrle
+check_LIBRARIES = libtest.a
 
-libtest_la_SOURCES = test/common.c
+libtest_a_SOURCES = test/common.c test/common.h common/src/help.c
+$(libtest_a_OBJECTS): $(gnulib_headers)
 
-test_decodeindex_LDADD = libupkg.la libgnu.la libtest.la
+TEST_LIBS = libtest.a libgnu.la
+
+test_decodeindex_LDADD = libupkg.la $(TEST_LIBS)
 $(test_decodeindex_OBJECTS): $(gnulib_headers)
-test_pcxrle_LDADD = src/engine/pcx.lo libupkg.la libgnu.la libtest.la
+test_pcxrle_LDADD = src/engine/pcx.lo libupkg.la $(TEST_LIBS)
 $(test_pcxrle_OBJECTS): $(gnulib_headers)
 
-TESTS_ENVIRONMENT = SHELL='$(SHELL)' EXEEXT='$(EXEEXT)'
-TEST_EXTENSIONS = .sh
-SH_LOG_COMPILER = $(SHELL)
-
-TESTS = tests/libupkg-index-decode.sh tests/engine-pcx-rlencode.sh
-EXTRA_DIST += $(TESTS)
+EXTRA_DIST += tests/data/test0.utx tests/data/hatch2x2.pcx
 
 # Supporting rules for GObject Builder
-GOB_V   = $(GOB_V_$(V))
-GOB_V_  = $(GOB_V_$(AM_DEFAULT_VERBOSITY))
-GOB_V_0 = @echo "  GOB   " $<;
+GOB_V   = $(GOB_V_@AM_V@)
+GOB_V_  = $(GOB_V_@AM_DEFAULT_V@)
+GOB_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GOB     ' $<;
 
 # Unfortunately, GOB's output filenames depend on the contents of the gob file,
 # rather than its filename.  This isn't really suitable for use with make, so
 # this rule has to make some assumptions about the source tree layout.
 .gob.gobstamp:
-       $(GOB_V) $(GOB2) -o src --file-sep=/ --no-private-header $<
-       $(AM_V_at) touch $@
+if HAVE_GOB2_DYN
+       $(AM_V_at) touch $@.tmp
+       $(GOB_V) od='$(@D)'; case $$od in \
+         src/*) od=src ;; \
+         */src/*) od=$${od%/src/*}/src ;; \
+         esac; $(GOB2) -o "$$od" --file-sep=/ \
+           --no-private-header --no-touch-headers $<
+       $(AM_V_at) mv -f $@.tmp $@
+else
+if HAVE_GOB2
+       @echo "ERROR: *** $(GOB2) does not support dynamic types." 1>&2
+else
+       @echo "ERROR: *** gob2 is missing on your system."  1>&2
+endif
+       @:; { \
+        echo "       *** Because of this, I cannot compile $<, but"; \
+        echo "       *** (perhaps because you modified it) the sources appear out of date."; \
+        echo "       *** A newer version of gob2 may be required; the latest version"; \
+        echo "       *** may be found at <https://draconx.ca/projects/gob-dx/>."; \
+        echo "       *** See config.log for more details."; \
+       } 1>&2
+       @false
+endif
 
 STAMP_RECOVER = \
        @if test -f $@; then :; else rm -f $<; $(MAKE) $(AM_MAKEFLAGS) $<; fi
 .gobstamp.c: ; $(STAMP_RECOVER)
 .gobstamp.h: ; $(STAMP_RECOVER)
 
+OPTFILES = src/upkgopts.opt
+.opt.h:
+       $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+$(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
+MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
+EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
+
+# The gob rules refrain from updating unchanged headers for the convenience of
+# developers, but the headers should be distributed with up-to-date timestamps.
+dist-hook: update-headers
+update-headers: unfuck-distdir
+       for f in $(engine_GOBS:.gob=.h); do \
+         touch -c '$(distdir)'/"$$f" || exit; \
+       done
+.PHONY: update-headers
+
+# When running "make dist" in a VPATH build with a read-only srcdir, Automake
+# will produce a distribution with all files read-only.  Moreover, the files
+# are read-only in distdir when the dist hooks are run.  This hook will
+# manually fix up the permissions.  All dist hooks that modify files in
+# distdir should list unfuck-distdir as a prerequisite.
+dist-hook: unfuck-distdir
+unfuck-distdir:
+       find '$(distdir)' -type f -exec chmod u+w {} +
+.PHONY: unfuck-distdir
+
 include $(top_srcdir)/lib/gnulib.mk
 include $(top_srcdir)/libltdl/ltdl.mk
+include $(top_srcdir)/common/snippet/autotest.mk