]> git.draconx.ca Git - upkg.git/blobdiff - Makefile.am
Use gen-options script and help formatting from dxcommon.
[upkg.git] / Makefile.am
index e5140a4679fddcccc4d4b2b9ddaa7e46a6aa2768..d6d99b0fc66251384bd636efa3fa31e137492154 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright © 2009-2012, 2015, 2019-2020 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.
@@ -9,14 +9,17 @@ ACLOCAL_AMFLAGS = -I m4 -I common/m4
 MAINTAINERCLEANFILES =
 MOSTLYCLEANFILES =
 DISTCLEANFILES =
-CLEANFILES =
+
+# 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_srcdir)/$(DX_BASEDIR)/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)
 
@@ -33,10 +36,11 @@ dist_man_MANS = doc/man/upkg.1
 have_orderonly = $(findstring order-only,$(.FEATURES))
 orderonly = $(have_orderonly:order-only=|)
 
-upkg_SOURCES  = src/upkg.c src/upkg.h
-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 common/src/pack.c common/src/pack.h
 
@@ -60,6 +64,7 @@ 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/mesh.gob
+EXTRA_DIST += $(engine_GOBS)
 
 MAINTAINERCLEANFILES += $(engine_GOBS:.gob=.gobstamp) \
        $(engine_GOBS:.gob=.c) $(engine_GOBS:.gob=.h)
@@ -113,7 +118,8 @@ if HAVE_GOB2_DYN
        $(GOB_V) od='$(@D)'; case $$od in \
          src/*) od=src ;; \
          */src/*) od=$${od%/src/*}/src ;; \
-         esac; $(GOB2) -o "$$od" --file-sep=/ --no-private-header $<
+         esac; $(GOB2) -o "$$od" --file-sep=/ \
+           --no-private-header --no-touch-headers $<
        $(AM_V_at) mv -f $@.tmp $@
 else
 if HAVE_GOB2
@@ -136,5 +142,32 @@ STAMP_RECOVER = \
 .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