]> git.draconx.ca Git - upkg.git/blobdiff - Makefile.am
Improve incremental builds with unmodified GOB headers.
[upkg.git] / Makefile.am
index b1330d05cd1dfa0a9e94fbf3173d2271ea070e65..f454e3529c4eab8e54d5be0eee370b70cf9442ec 100644 (file)
@@ -11,6 +11,9 @@ MOSTLYCLEANFILES =
 DISTCLEANFILES =
 CLEANFILES =
 
+# Distribution should be buildable without working gob.
+AM_DISTCHECK_CONFIGURE_FLAGS = GOB2=false
+
 EXTRA_DIST = $(MAINTAINERCLEANFILES) m4/gnulib-cache.m4
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
@@ -47,7 +50,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)
@@ -58,7 +62,8 @@ $(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)
@@ -108,8 +113,13 @@ GOB_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GOB     ' $<;
 # this rule has to make some assumptions about the source tree layout.
 .gob.gobstamp:
 if HAVE_GOB2_DYN
-       $(GOB_V) $(GOB2) -o src --file-sep=/ --no-private-header $<
-       $(AM_V_at) touch $@
+       $(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
@@ -131,5 +141,24 @@ STAMP_RECOVER = \
 .gobstamp.c: ; $(STAMP_RECOVER)
 .gobstamp.h: ; $(STAMP_RECOVER)
 
+# 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