[MOAB-dev] r3974 - MOAB/trunk/examples

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri May 28 10:49:50 CDT 2010


Author: kraftche
Date: 2010-05-28 10:49:50 -0500 (Fri, 28 May 2010)
New Revision: 3974

Modified:
   MOAB/trunk/examples/Makefile.am
   MOAB/trunk/examples/examples.make.in
Log:
Generate targets for installed makefile automatically using contents of
check_PROGRAMS from Makefile.am.  

Note:  Assumes that a) all examples are listed in check_PROGRAMS and
       b) that the source file name is the executable name with a
       .cpp suffix.


The resulting file is identical to the previous one with manually specified
targets.  It is just generated automatically now, removing the need to
specify example targets in both Makefile.am and examples.make.in, as long
as the conventions above are followed.




Modified: MOAB/trunk/examples/Makefile.am
===================================================================
--- MOAB/trunk/examples/Makefile.am	2010-05-28 15:44:55 UTC (rev 3973)
+++ MOAB/trunk/examples/Makefile.am	2010-05-28 15:49:50 UTC (rev 3974)
@@ -1,3 +1,9 @@
+# NOTE:  The 'makefile' in the *installed* examples directory is generated
+#        using the install-data-hook target below.  This logic assumes that:
+#        1) All examples are listed in check_PROGRAMS
+#        2) All examples have a single source file with the same name (case
+#           sensitive) as the example executable with a .cpp suffix.
+
 check_PROGRAMS = FileRead \
                  GeomSetHierarchy \
                  GetEntities \
@@ -35,8 +41,17 @@
                SurfArea.cpp 
                
 
+ex_make = $(DESTDIR)$(exampledir)/makefile
 install-data-hook:
-	mv -f $(DESTDIR)$(exampledir)/examples.make $(DESTDIR)$(exampledir)/makefile
+	rm -f $(ex_make)
+	mv $(DESTDIR)$(exampledir)/examples.make $(ex_make)
+	echo "all: $(check_PROGRAMS)" >>$(ex_make)
+	rule='	$$(CXX) -o $$@ $$< $$(MOAB_LIBS_LINK)'; \
+	for example in $(check_PROGRAMS); do \
+	  echo >>$(ex_make); \
+	  echo "$${example}: $${example}.o" >>$(ex_make); \
+	  echo "$$rule" >>$(ex_make); \
+	done
 
 uninstall-hook:
 	rm -f $(DESTDIR)$(exampledir)/makefile

Modified: MOAB/trunk/examples/examples.make.in
===================================================================
--- MOAB/trunk/examples/examples.make.in	2010-05-28 15:44:55 UTC (rev 3973)
+++ MOAB/trunk/examples/examples.make.in	2010-05-28 15:49:50 UTC (rev 3974)
@@ -8,25 +8,3 @@
 
 default: all
 
-all: FileRead GeomSetHierarchy SetsNTags SkinMesh SurfArea KDTree ObbTree
-
-FileRead: FileRead.o
-	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
-
-GeomSetHierarchy: GeomSetHierarchy.o
-	$(CXX) -o $@ $< $(MOAB_LIBS_LINK)
-
-SetsNTags: SetsNTags.o


More information about the moab-dev mailing list