about summary refs log tree commit diff
path: root/GNUmakefile
diff options
context:
space:
mode:
Diffstat (limited to 'GNUmakefile')
-rw-r--r--GNUmakefile132
1 files changed, 75 insertions, 57 deletions
diff --git a/GNUmakefile b/GNUmakefile
index ca2181b3..1beebb4c 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -11,6 +11,7 @@
 #   deb:          Make a .deb file in the current dir.
 #
 #   check-tree:     Conduct tests on Netpbm files in the source dir. 
+#                   with "target=pamtotga" tests only pamtotga.
 #   check-package:  Conduct tests on packaged Netpbm files.
 #   check-install:  Conduct tests on installed Netpbm files.
 #   check:          Default check.  Synonym for check-package.
@@ -101,18 +102,27 @@ all: nonmerge
 .PHONY: nonmerge
 nonmerge: $(PRODUCT_SUBDIRS:%=%/all)
 
-# Parallel make (make --jobs) is not smart enough to coordinate builds
-# between submakes, so a naive parallel make would cause certain
-# targets to get built multiple times simultaneously.  That is usually
-# unacceptable.  So we introduce extra dependencies here just to make
-# sure such targets are already up to date before the submake starts,
-# for the benefit of parallel make.  Note that we ensure that parallel
-# make works for 'make all' in the top directory, but it may still fail
-# for the aforementioned reason for other invocations.
+# Completely parallel make (make --jobs) does not work because there are
+# multiple targets somewhere in the Netpbm build that depend upon pm_config.h
+# and similar targets, and the threads building those multiple targets might
+# simultaneously find that pm_config.h needs to be built and proceed to build
+# it.  After one thread has built pm_config.h, it will proceed to use
+# pm_config.h, but the other thread is still building pm_config.h, which is
+# not valid while it is in the middle of being built.
+#
+# But many submakes don't have any such shared dependencies, so build their
+# targets in parallel just fine.  So we declare this make file ineligible for
+# parallel make and have special dependencies to get pm_config.h and like
+# targets built before any submakes begin.  The submakes will thus never find
+# that pm_config.h needs to be built, so we leave them eligible for parallel
+# make.
+
+.NOTPARALLEL:
 
 $(SUBDIRS:%=%/all) lib/util/all: pm_config.h inttypes_netpbm.h version.h
 $(PROG_SUBDIRS:%=%/all): lib/all $(SUPPORT_SUBDIRS:%=%/all)
 lib/all: lib/util/all
+netpbm: lib/all
 
 .PHONY: lib/util/all
 lib/util/all:
@@ -139,7 +149,7 @@ $(TYPEGEN) $(ENDIANGEN): $(BUILDDIR)/buildtools
 	$(MAKE) -C $(dir $@) -f $(SRCDIR)/buildtools/Makefile \
 	    SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 
 
-inttypes_netpbm.h: $(TYPEGEN)
+$(BUILDDIR)/inttypes_netpbm.h: $(TYPEGEN)
 	$(TYPEGEN) >$@
 
 
@@ -155,7 +165,7 @@ $(TESTRANDOM): $(BUILDDIR)/test
 # that or to override the results, because it doesn't work if he's
 # cross compiling.
 
-pm_config.h: \
+$(BUILDDIR)/pm_config.h: \
   $(SRCDIR)/pm_config.in.h config.mk inttypes_netpbm.h \
   $(ENDIANGEN)
 # Note that this rule depends on the effect of the .DELETE_ON_ERROR
@@ -197,7 +207,7 @@ endif
 MAJOR := $(NETPBM_MAJOR_RELEASE)
 MINOR := $(NETPBM_MINOR_RELEASE)
 POINT := $(NETPBM_POINT_RELEASE)
-version.h: $(SRCDIR)/version.mk
+$(BUILDDIR)/version.h: $(SRCDIR)/version.mk
 	@rm -f $@
 	@echo "/* Generated by make file rule */" >>$@
 	@echo "#define NETPBM_VERSION" \
@@ -276,11 +286,9 @@ install-run: install-nonmerge
 endif
 
 .PHONY: install-merge install-nonmerge
-install-merge: install.merge install.lib install.data \
-	install.manwebmain install.manweb install.man
+install-merge: install.merge install.lib install.data
 
-install-nonmerge: install.bin install.lib install.data \
-	install.manwebmain install.manweb install.man
+install-nonmerge: install.bin install.lib install.data
 
 .PHONY: merge
 merge: lib/all netpbm
@@ -375,35 +383,12 @@ netpbm:%:%.o $(OBJECT_DEP) $(NETPBMLIB) $(URTLIBDEP) $(LIBOPT)
 
 netpbm.o: mergetrylist
 
-install.merge: local.install.merge
-.PHONY: local.install.merge
-local.install.merge:
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm pnmnoraw
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm gemtopbm
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm pnminterp
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm pgmoil
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm ppmtojpeg
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm bmptoppm
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm pgmnorm
-	cd $(PKGDIR)/bin; $(SYMLINKEXE) netpbm pnmfile
-
 ifneq ($(NETPBMLIBTYPE),unixstatic)
 install.lib: lib/install.lib
 else
 install.lib:
 endif
 
-.PHONY: install.manwebmain
-install.manwebmain: $(PKGDIR)/$(PKGMANDIR)/web/netpbm.url $(PKGDIR)/bin/doc.url
-
-$(PKGDIR)/$(PKGMANDIR)/web/netpbm.url: $(PKGDIR)/$(PKGMANDIR)/web
-	echo "$(NETPBM_DOCURL)" > $@
-	chmod $(INSTALL_PERM_MAN) $@
-
-$(PKGDIR)/bin/doc.url: $(PKGDIR)/bin
-	echo "$(NETPBM_DOCURL)" > $@
-	chmod $(INSTALL_PERM_MAN) $@
-
 .PHONY: install-dev
 # Note that you might install the development package and NOT the runtime
 # package.  If you have a special system for building stuff, maybe for 
@@ -455,10 +440,27 @@ deb:
 .PHONY: check-package
 .PHONY: check-install
 
+# Variables from the make env we pass down to the test scripts.
+CHECK_VARS = \
+	BUILDDIR=$(BUILDDIR) \
+	RGBDEF=$(RGBDEF) \
+	PALMMAPDIR=$(PALMMAPDIR) \
+	BUILD_FIASCO=$(BUILD_FIASCO) \
+	JASPERLIB="$(JASPERLIB)" \
+	JBIGLIB="$(JBIGLIB)" \
+	JPEGLIB="$(JPEGLIB)" \
+	PNGLIB="$(PNGLIB)" \
+	TIFFLIB="$(TIFFLIB)" \
+	URTLIB="$(URTLIB)" \
+	X11LIB="$(X11LIB)" \
+	XML2_LIBS="$(XML2_LIBS)" \
+	LEX="$(LEX)" \
+	ZLIB="$(ZLIB)" \
+
 # Test files in source tree.
-# This does not work when Netpbm is compiled in a separate build dir.
+# BUILDBINDIRS is a list of directories which contain target binaries
 
-check-tree : SRCBINDIRS :=./analyzer \
+check-tree : BUILDBINDIRS :=./analyzer \
 ./converter/other \
 ./converter/other/cameratopam \
 ./converter/other/fiasco \
@@ -470,15 +472,22 @@ check-tree : SRCBINDIRS :=./analyzer \
 ./converter/pbm/pbmtoppa \
 ./converter/pgm \
 ./converter/ppm \
-./converter/ppm/hpcdtoppm \
 ./converter/ppm/ppmtompeg \
 ./converter/ppm \
 ./editor \
 ./editor/pamflip \
 ./editor/specialty \
 ./generator \
+./generator/pamtris \
+./other \
+./other/pamx
+
+check-tree : SRCBINDIRS :=./converter/ \
+./converter/other/ \
+./converter/ppm/hpcdtoppm/ \
+./editor \
+./generator \
 ./other \
-./other/pamx \
 ./
 
 # Create colon-separated PATH list from the above.
@@ -486,10 +495,13 @@ check-tree : SRCBINDIRS :=./analyzer \
 
 # Kludge to test whether realpath is available:
 ifeq ($(realpath $(CURDIR)/.),$(CURDIR))
-  check-tree : RBINDIRS :=\
-    $(foreach dir,$(SRCBINDIRS),$(realpath $(BUILDDIR)/$(dir)))
+  check-tree : RBINDIRS :=$(sort \
+     $(foreach dir,$(BUILDBINDIRS),$(realpath $(BUILDDIR)/$(dir))) \
+     $(foreach dir,$(SRCBINDIRS),$(realpath $(SRCDIR)/$(dir))))
 else
-  check-tree : RBINDIRS :=$(foreach dir,$(SRCBINDIRS),$(BUILDDIR)/$(dir))  
+  check-tree : RBINDIRS :=$(sort \
+     $(foreach dir,$(BUILDBINDIRS),$(BUILDDIR)/$(dir)) \
+     $(foreach dir,$(SRCBINDIRS),$(SRCDIR)/$(dir)))
 endif
 
 # Kludge to express characters given special meanings by GNU Make.
@@ -498,15 +510,16 @@ empty :=
 space := $(empty) $(empty)
 colon :=:
 
-check-tree : PBM_TEST_PATH := $(subst $(space),$(colon),$(RBINDIRS))
+check-tree : PBM_TEST_PATH := $(subst $(space),$(colon),$(strip $(RBINDIRS)))
 check-tree : PBM_LIBRARY_PATH ?= $(BUILDDIR)/lib
 check-tree : RGBDEF ?= $(SRCDIR)/lib/rgb.txt
+check-tree : PALMMAPDIR ?= $(SRCDIR)/converter/other/pnmtopalm
 
 
 # Create RESULTDIR.
-# If it already exists, rename and covert to an archive directory.
+# If it already exists, rename and convert to an archive directory.
 # Use numbered backup.
-# TODO: Renaming fails with old versions of mv which do not support -T.  
+# Note: Renaming fails with old versions of mv which do not have -T.  
 
 resultdir-backup: FORCE
 	if [ -d $(RESULTDIR) ]; \
@@ -514,13 +527,17 @@ resultdir-backup: FORCE
 	fi; \
 	mkdir -p $(RESULTDIR); \
 
+.PHONY: testdir test
+
+testdir:
+	$(MAKE) -C test
 
-check-tree: $(TESTRANDOM) resultdir-backup
+check-tree: testdir resultdir-backup
 	cd $(RESULTDIR); \
+	  $(CHECK_VARS) \
 	  CHECK_TYPE=tree \
-	  PBM_TEST_PATH=$(PBM_TEST_PATH) BUILDDIR=$(BUILDDIR) \
+	  PBM_TEST_PATH=$(PBM_TEST_PATH) \
 	  LD_LIBRARY_PATH=$(PBM_LIBRARY_PATH):${LD_LIBRARY_PATH} \
-	  RGBDEF=$(RGBDEF) \
 	  $(SRCDIR)/test/Execute-Tests 2>&1
 
 # Execute-Tests needs to know BUILDDIR in order to locate testrandom.
@@ -533,23 +550,24 @@ check-tree: $(TESTRANDOM) resultdir-backup
 check-package : PBM_TEST_PATH := $(PKGDIR)/bin
 check-package : PBM_LIBRARY_PATH := $(PKGDIR)/lib
 check-package : RGBDEF ?= $(PKGDIR)/misc/rgb.txt
+check-package : PALMMAPDIR ?= $(PKGDIR)/misc/
 check: check-package
 
-check-package: $(TESTRANDOM) resultdir-backup
+check-package: testdir resultdir-backup
 	cd $(RESULTDIR); \
+	  $(CHECK_VARS) \
 	  CHECK_TYPE=package \
-	  PBM_TEST_PATH=$(PBM_TEST_PATH) BUILDDIR=$(BUILDDIR) \
+	  PBM_TEST_PATH=$(PBM_TEST_PATH) \
 	  LD_LIBRARY_PATH=$(PBM_LIBRARY_PATH):${LD_LIBRARY_PATH} \
-	  RGBDEF=$(RGBDEF) \
 	  $(SRCDIR)/test/Execute-Tests 2>&1
 
 
 # Check after install
-check-install: $(TESTRANDOM) resultdir-backup
+check-install: PALMMAPDIR ?= ""
+check-install: testdir resultdir-backup
 	cd $(RESULTDIR); \
+	  $(CHECK_VARS) \
 	  CHECK_TYPE=install \
-	  BUILDDIR=$(BUILDDIR) \
-	  RGBDEF=$(RGBDEF) \
 	  $(SRCDIR)/test/Execute-Tests 2>&1