home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / Makefile.in < prev    next >
Makefile  |  2008-11-26  |  14KB  |  410 lines

  1. # Top level makefile for pvfs2 test programs
  2. # define a few generic variables that we need to use
  3.  
  4. srcdir = @srcdir@
  5. prefix = @prefix@
  6. mandir = @mandir@
  7. exec_prefix = @exec_prefix@
  8. pvfs2_srcdir = @PVFS2_SRC_RELATIVE_TOP@
  9. pvfs2_builddir = @PVFS2_BUILD_RELATIVE_TOP@
  10.  
  11. VPATH = $(srcdir)
  12. SHELL = @SHELL@
  13. INSTALL = @INSTALL@
  14. # TODO: should probably check for bison and flex in configure
  15. BISON = bison
  16. FLEX = flex
  17. LDSHARED = $(CC) -shared
  18. PICFLAGS = -fPIC
  19. BUILD_MPI = @BUILD_MPI@
  20. MPICC = @MPICC@
  21. GNUC = @GNUC@
  22. INTELC = @INTELC@
  23. MPI_GNUC = @MPI_GNUC@
  24. MPI_INTELC = @MPI_INTELC@
  25. TARGET_OS_DARWIN = @TARGET_OS_DARWIN@
  26. TARGET_OS_LINUX = @TARGET_OS_LINUX@
  27. TARGET_OS_BSD = @TARGET_OS_BSD@
  28. # override default quiet mode with "make V=1"
  29. QUIET_COMPILE = @QUIET_COMPILE@
  30. ifdef V
  31.     QUIET_COMPILE = 0
  32. endif
  33.  
  34. ifeq ($(QUIET_COMPILE),1)
  35.   # say a one-line description of the action, do not echo the command
  36.   Q=@echo
  37.   E=@
  38. else
  39.   # do not say the short Q lines, but do echo the entire command
  40.   Q=@echo >/dev/null
  41.   E=
  42. endif
  43.  
  44. # some of the test programs require the use of the pvfs2 server library;
  45. # we therefore need to find out what libraries the original pvfs2 build
  46. # used for server components
  47. SERVERLIBS = @SERVERLIBS@
  48.  
  49. # Eliminate all default suffixes.  We want explicit control.
  50. .SUFFIXES:
  51.  
  52. # PHONEY targets are targets that do not result in the generation
  53. #    of a file that has the same name as the target.  Listing them
  54. #    here keeps make from accidentally doing too much work (see GNU
  55. #    make manual).
  56. .PHONY: all clean distclean cscope tags 
  57.  
  58. ################################################################
  59. # Find project subdirectories
  60.  
  61. # MODULES is a list of subdirectories that we wish to operate on.
  62. #    They are identified by the presence of module.mk files (makefile
  63. #    includes).
  64. MODULES := $(shell find . -name "*.mk" | sed -e 's/^.\///;s/module.mk//')
  65.  
  66. # List of directories to search for headers.
  67. INCLUDES := \
  68.     ${pvfs2_srcdir}/src/client/sysint \
  69.     ${pvfs2_srcdir}/src/common/misc \
  70.     ${pvfs2_srcdir}/src/common/quickhash \
  71.     ${pvfs2_srcdir}/src/common/quicklist \
  72.     ${pvfs2_srcdir}/src/common/dotconf \
  73.     ${pvfs2_srcdir}/src/common/id-generator \
  74.     ${pvfs2_srcdir}/src/common/gossip \
  75.     ${pvfs2_srcdir}/src/common/gen-locks \
  76.     ${pvfs2_srcdir}/src/common/llist \
  77.     ${pvfs2_srcdir}/src/io/trove \
  78.     ${pvfs2_srcdir}/src/io/bmi \
  79.     ${pvfs2_srcdir}/src/io/description \
  80.     ${pvfs2_srcdir}/src/io/flow \
  81.     ${pvfs2_srcdir}/src/io/buffer \
  82.     ${pvfs2_srcdir}/src/io/job \
  83.     ${pvfs2_srcdir}/src/io/dev \
  84.     ${pvfs2_srcdir}/src/proto \
  85.     ${pvfs2_srcdir}/src/server \
  86.     ${pvfs2_srcdir}/src/server/request-scheduler \
  87.     ${pvfs2_srcdir} \
  88.     ${pvfs2_srcdir} \
  89.     ${pvfs2_builddir}/include
  90.  
  91. #################################################################
  92. # Setup global flags
  93.  
  94. # These should all be self explanatory; they are standard flags
  95. # for compiling and linking unless otherwise noted
  96. CC = @CC@
  97. CFLAGS = @CFLAGS@ @DB_CFLAGS@
  98. LDFLAGS = @LDFLAGS@
  99. LIBS = @LIBS@ 
  100. LD = gcc
  101. LDSHARED = $(CC) -shared
  102. PICFLAGS = -fPIC
  103. LDFLAGS += -Llib 
  104.  
  105.   # turn on large file support by default
  106. CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
  107.   # include current directory (for pvfs2-test-config.h)
  108. CFLAGS += -I .
  109.   # add in include paths from pvfs2 src tree
  110. CFLAGS += $(patsubst %,-I%,$(INCLUDES))
  111.  
  112. # special Intel cc options, all warnings, but disable:
  113.   # remark #279: controlling expression is constant
  114.   #   shows up in ifdefs such as "do { ... } while (0)" construct
  115. INTEL_CFLAGS := -Wall -wd279
  116.   # special gcc options
  117. GCC_CFLAGS := -Wall -Wstrict-prototypes -pipe
  118.  
  119. ################################################################
  120. # Setup component specific flags
  121.  
  122. # Use these same cflags for the mpi test codes.
  123. MPICFLAGS := $(CFLAGS)
  124.  
  125. # Add gcc-specific flags if we know it is a gnu compiler.
  126. ifdef GNUC
  127. CFLAGS += $(GCC_CFLAGS)
  128. endif
  129. ifdef INTELC
  130. CFLAGS += $(INTEL_CFLAGS)
  131. endif
  132. ifdef MPI_INTELC
  133. MPICFLAGS += $(INTEL_CFLAGS)
  134. endif
  135. ifdef MPI_GNUC
  136. MPICFLAGS += $(GCC_CFLAGS)
  137. endif
  138.  
  139. #################################################################
  140. # Starter variables 
  141.  
  142. # NOTES: These variables are used to categorize the various source
  143. #    files.  We let the makefile includes append to them so that we
  144. #    gradually build up a list of source files without having to
  145. #    list them all at the top level.
  146.  
  147. # TESTSRC is source code for test programs
  148. TESTSRC :=
  149. # MISCSRC is a grab bag of other sources that must be built into
  150. #    object form (for example, shared test components)
  151. MISCSRC := 
  152. # SHAREDSRC is a hack to get things to build when mpi is not passed to configure.
  153. SHAREDSRC :=
  154. # MPIIOTESTSRC is the source for test programs that must be compiled 
  155. #    with MPI-IO
  156. MPIIOTESTSRC :=
  157. # MPITESTSRC is the source code for test programs that must be compiled
  158. #    with MPI
  159. MPITESTSRC :=
  160. # MPIMISCSRC is a collection of sources that must be built into
  161. #    object form using MPI
  162. MPIMISCSRC :=
  163. # DLLSRC is a collection of sources that must be built into
  164. # dlls/shared objects.
  165. DLLSRC := 
  166. # files generated as part of the build that should be deleted on "make clean"
  167. CLEANFILES :=
  168.  
  169. ################################################################
  170. # Top level (default) targets
  171.  
  172. # default rule builds server, library, and test programs
  173. all: tests
  174.  
  175. ################################################################
  176. # Makefile includes
  177.  
  178. # this is how we pull build information from all of the project
  179. #    subdirectories, make sure to catch top level module.mk as well
  180. include $(patsubst %, %/module.mk, $(MODULES))
  181.  
  182. ################################################################
  183. # Derived file lists
  184.  
  185. # NOTES: At this point, the subdirectory makefile includes have informed
  186. #    us what the source files are.  Now we want to generate some
  187. #    other lists (such as objects, executables, and dependency files)
  188. #    by manipulating the lists of source files
  189.  
  190. # TESTOBJS is a list of test program objects
  191. TESTOBJS := $(patsubst %.c,%.o, $(filter %.c,$(TESTSRC)))
  192. # TESTS is a list of test program executables
  193. TESTS := $(patsubst %.c,%, $(filter %.c, $(TESTSRC)))
  194. # TESTDEPENDS is a list of dependency files for test programs
  195. TESTDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(TESTSRC)))
  196.  
  197. # MISCOBJS is a list of misc. objects not in the above categories
  198. MISCOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MISCSRC)))
  199. # MISCDEPENDS is a list of dependency files for misc. objects
  200. MISCDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MISCSRC)))
  201.  
  202. # SHAREDOBJS is a list of shared. objects not in the above categories
  203. SHAREDOBJS := $(patsubst %.c,%.o, $(filter %.c,$(SHAREDSRC)))
  204. # SHAREDDEPENDS is a list of dependency files for shared. objects
  205. SHAREDDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(SHAREDSRC)))
  206.  
  207. # MPIMISCOBJS is a list of misc. MPI objects not in the above categories
  208. MPIMISCOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MPIMISCSRC)))
  209. # MPIMISCDEPENDS is a list of dependency files for MPI misc. objects
  210. MPIMISCDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MPIMISCSRC)))
  211.  
  212. # DLLOBJS is a list of misc. objects made into DLLs
  213. DLLOBJS := $(patsubst %.c,%.po, $(filter %.c,$(DLLSRC)))
  214. # DLLDEPENDS is a list of dependency files for dll objects
  215. DLLDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(DLLSRC)))
  216. #DLLS is a list of DLLs
  217. DLLS := $(patsubst %.c,%.so, $(filter %.c,$(DLLSRC)))
  218.  
  219. # MPITESTOBJS is a list of MPI test program objects
  220. MPITESTOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MPITESTSRC)))
  221. # MPITESTS is a list of MPI test program executables
  222. MPITESTS := $(patsubst %.c,%, $(filter %.c, $(MPITESTSRC)))
  223. # TESTDEPENDS is a list of dependency files for MPI test programs
  224. MPITESTDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MPITESTSRC)))
  225.  
  226. # MPIIOTESTOBJS is a list of MPI-IO test program objects
  227. MPIIOTESTOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MPIIOTESTSRC)))
  228. # MPIIOTESTS is a list of MPI-IO test program executables
  229. MPIIOTESTS := $(patsubst %.c,%, $(filter %.c, $(MPIIOTESTSRC)))
  230. # MPIIOTESTDEPENDS is a list of dependency files for MPI-IO test programs
  231. MPIIOTESTDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MPIIOTESTSRC)))
  232.  
  233. # DEPENDS is a global list of all of our dependency files.  
  234. # NOTE: sort is just a trick to remove duplicates; the order
  235. #   doesn't matter at all.
  236. DEPENDS := $(sort $(TESTDEPENDS) $(MISCDEPENDS) $(DLLDEPENDS))
  237. ifdef BUILD_MPI
  238. DEPENDS += $(MPITESTDEPENDS) $(MPIMISCDEPENDS)
  239. endif
  240.  
  241. ####################################################################
  242. # Rules and dependencies
  243.  
  244. # target for building MPI-IO test programs 
  245. mpiiotests: $(MPIIOTESTS)
  246.  
  247. # Just like dir, but strip the slash off the end, to be pretty.
  248. dirname = $(patsubst %/,%,$(dir $(1)))
  249.  
  250. # Generate the canonical in-tree location of a file, given a possibly
  251. # out-of-tree reference.
  252. canonname = $(patsubst $(srcdir)/%,%,$(call dirname,$(1)))
  253.  
  254. # Grab any CFLAGS defined by the make stub for a particular file, and
  255. # for the directory in which the source resides.
  256. # Always add the directory in question for "local" includes.
  257. modcflags = $(MODCFLAGS_$(call canonname,$(1))) \
  258.             $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1))) \
  259.         -I$(call dirname,$(1))
  260.  
  261. modldflags = $(MODLDFLAGS_$(call canonname,$(1))) \
  262.             $(MODLDFLAGS_$(patsubst $(srcdir)/%,%,$(1))) \
  263.         -L$(call dirname,$(1))
  264.  
  265.  
  266. # target for building the test program executables
  267. tests: $(TESTS)
  268.  
  269. # target for building MPI test program executables
  270. mpitests: $(MPITESTS)
  271. ifdef BUILD_MPI
  272. # add MPI programs to default rule
  273. all: mpitests mpiiotests
  274. endif
  275.  
  276. # rule for building MPI objects
  277. $(MPITESTOBJS): %.o: %.c
  278. ifdef BUILD_MPI
  279.     $(Q) "  MPICC        $@"
  280.     $(E)$(MPICC) $(LIBCFLAGS) $(MPICFLAGS) $(call modcflags,$<) $< -c -o $@
  281. else
  282.     @echo Error: You must specify --with-mpi=dir at configure time 
  283.     @echo   in order to enable compilation of MPI programs.
  284.     @false
  285. endif
  286.  
  287. # rule for building MPI-IO objects
  288. $(MPIIOTESTOBJS): %.o: %.c
  289. ifdef BUILD_MPI
  290.     $(Q) "  MPICC        $@"
  291.     $(E)$(MPICC) $(LIBCFLAGS) $(MPICFLAGS) $(call modcflags,$<) $< -c -o $@
  292. else
  293.     @echo Error: You must specify --with-mpi=dir at configure time 
  294.     @echo   in order to enable compilation of MPI programs.
  295.     @false
  296. endif
  297.  
  298. # rule for building MPI misc. objects
  299. $(MPIMISCOBJS): %.o: %.c
  300. ifdef BUILD_MPI
  301.     $(Q) "  MPICC        $@"
  302.     $(E)$(MPICC) $(LIBCFLAGS) $(MPICFLAGS) $(call modcflags,$<) $< -c -o $@
  303. else
  304.     @echo Error: You must specify --with-mpi=dir at configure time 
  305.     @echo   in order to enable compilation of MPI programs.
  306.     @false
  307. endif
  308.  
  309. # rule for building MPI executables from object files
  310. $(MPITESTS): %: %.o $(MPIMISCOBJS) $(SHAREDOBJS) $(LIBRARIES)
  311.     $(Q) "  MPILD        $@"
  312.     $(E)$(MPICC) $^ $(LDFLAGS) $(call modldflags,$<) $(LIBS) -lm -o $@
  313.  
  314. # rule for building MPI-IO executables from object files
  315. # note: add a $(MPIMISCOBJS) prereq if we build multi-object tests someday
  316. $(MPIIOTESTS): %: %.o $(LIBRARIES)
  317.     $(Q) "  MPILD        $@"
  318.     $(E)$(MPICC) $^ $(LDFLAGS) $(call modldflags,$<) $(LIBS) -lm -o $@
  319.  
  320. # default rule for building executables from object files
  321. %: %.o $(LIBRARIES) $(MISCOBJS) $(SHAREDOBJS)
  322.     $(Q) "  LD        $@"
  323.     $(E)$(LD) $(LDFLAGS) $(call modldflags,$<) $< $(MISCOBJS) $(SHAREDOBJS) $(LIBS) -o $@
  324.  
  325. # default rule for building objects 
  326. %.o: %.c
  327.     $(Q) "  CC        $@"
  328.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -c -o $@
  329.  
  330. # rule for building shared objects 
  331. %.po: %.c
  332.     $(Q) "  CCPIC        $@"
  333.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(PICFLAGS) $(call modcflags,$<) $< -c -o $@
  334.  
  335. %.so: $(DLLOBJS)
  336.     $(Q) " LDSO        $@"
  337.     $(E)$(LDSHARED) -o $@ $(DLLOBJS)
  338.  
  339. # all test programs depend on the pvfs2 library
  340. $(TESTS): %: %.o $(LIBRARIES)
  341.  
  342. # rule for generating cscope information
  343. cscope:
  344.     find @SRC_ABSOLUTE_TOP@ -iname "*.[ch]" -o -iname "*.sm" \
  345.          > $(srcdir)/cscope.files
  346.     ( cd @SRC_ABSOLUTE_TOP@; cscope -be -i @SRC_ABSOLUTE_TOP@/cscope.files )
  347.  
  348. # build editor tags file over all source files *.[ch] *.sm and
  349. # some known scripts
  350. tags:
  351.     ( find $(addprefix $(srcdir)/,$(MODULES)) \
  352.         -maxdepth 1 -name '*.[ch]' ;\
  353.     ) | ctags -L- --excmd=pattern -B --extra=+f -I __hidden
  354.  
  355. # top rule for cleaning up tree
  356. clean: 
  357.     $(Q) "  CLEAN"
  358.     $(E)rm -f $(TESTOBJS) $(MISCOBJS) $(TESTS) $(MISCDEPENDS)\
  359.         $(DEPENDS) $(CLEANFILES) $(MPIMISCOBJS) $(SHAREDOBJS) $(SHAREDDEPENDS)\
  360.         $(MPITESTS) $(MPITESTOBJS) $(MPITESTDEPENDS) $(MPIMISCDEPENDS)\
  361.         $(MPIIOTESTOBJS) $(MPIIOTESTS) $(DLLDEPENDS) $(DLLS) $(DLLOBJS)
  362.  
  363. # some stuff that is cleaned in both distclean and dist targets
  364. cleaner: clean
  365.     rm -f tags
  366.     rm -f examples/pvfs2-server.rc
  367.     rm -rf autom4te*.cache
  368.     rm -f $(srcdir)/cscope.out $(srcdir)/cscope.files
  369.     rm -f config.log config.status config.cache 
  370.     rm -f maint/mpi-depend.sh common/pav/configfile.sample
  371.  
  372. # _really_ clean the tree; should go back to pristine state
  373. distclean: cleaner 
  374.     find . -name "module.mk" -exec rm \{\} \;
  375.     rm -f Makefile pvfs2-test-config.h
  376.  
  377. # this is where we include all of our automatic dependencies.
  378. # NOTE: we wrap this in ifneq's in order to prevent the
  379. #    dependencies from being generated for special targets that don't 
  380. #    require them
  381. ifeq (,$(filter clean distclean cscope tags nodep,$(MAKECMDGOALS)))
  382. -include $(DEPENDS)
  383. endif
  384. # add this as a make goal to disable rebuilding dependencies
  385. .PHONY: nodep
  386. nodep:; @:
  387.  
  388. # rule for generating dependency files for MPI code
  389. #
  390. # note: mpi-depend.sh is automatically generated, so it is in
  391. #       the build directory already.
  392. ifdef BUILD_MPI
  393. $(MPITESTDEPENDS) $(MPIMISCDEPENDS): %.d: %.c
  394.     $(Q) "  DEP        $@"
  395.     $(E)sh ./maint/mpi-depend.sh `dirname $*` $(MPICFLAGS) $(call modcflags,$<) $< > $@
  396. endif
  397.  
  398. # default rule for generating dependency files
  399. %.d: %.c
  400.     $(Q) "  DEP        $@"
  401.     $(E)CC="$(CC)" $(pvfs2_srcdir)/maint/depend.sh $(call dirname,$*) $(CFLAGS) $(call modcflags,$<) $< > $@
  402.  
  403. install:: 
  404.     install -d @PVFS2_TOP_PREFIX@/test
  405.     install -m 755 $(TESTS) @PVFS2_TOP_PREFIX@/test
  406. ifdef BUILD_MPI
  407.     install -m 755 $(MPITESTS) @PVFS2_TOP_PREFIX@/test
  408.     install -m 755 $(MPIIOTESTS) @PVFS2_TOP_PREFIX@/test
  409. endif
  410.