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 / Makefile.in < prev    next >
Makefile  |  2010-12-21  |  41KB  |  1,218 lines

  1. # Top level makefile for pvfs2
  2.  
  3. ###############################################################
  4. # LIST OF TARGETS WHICH MAY BE USED WHEN RUNNING MAKE:
  5. #
  6. # all            default rule; builds libs, server, and test programs
  7. # clean          cleans up files
  8. # develtools     builds development related tools
  9. # distclean      _really_ cleans up; returns to pristine tree
  10. # docs           builds documentation in docs subdirectory
  11. # docsclean      cleans up documentation files
  12. # publish        copy over documents to the PVFS.org web pags
  13. # admintools     builds admin tools
  14. # usertools     builds user tools
  15. # kernapps       builds userland helper programs for kernel driver
  16. # cscope         generates information for cscope utility
  17. # tags           generates tags file for use by editors
  18. # codecheck      checks source code for nonconformance to our std.
  19. # kmod           builds 2.6.x kernel module
  20. # kmod24         builds 2.4.x kernel module
  21. # kmod_install   installs 2.6.x module in default module location
  22. # kmod24_install installs 2.4.x module in default module location
  23. # NOTE: you can also specify any single object or executable to
  24. #    build by providing its name (including the relative path) as the
  25. #    make target
  26. #
  27.  
  28. ###############################################################
  29. # General documentation
  30. #
  31. # This is a single makefile that runs the entire pvfs2 build
  32. # process.  There are no makefiles in subdirectories.  For a
  33. # general introduction to this approach, please read this document
  34. # by Peter Miller:
  35. #
  36. # http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
  37. #
  38. # Each subdirectory contains a module.mk file that gets included
  39. # when make is executed.  These module.mk files tell make about the
  40. # files in each subdirectory that must be built, including any
  41. # special case rules.  Make uses this information to generate a
  42. # sinle dependency graph and orchestrate the build process from this
  43. # top level directory.
  44. #
  45. # We categorize our source depending on what it will be used for.
  46. # For example, there are lists of source files for building the
  47. # server, building the library, building documentation, etc.
  48. #
  49.  
  50. ###############################################################
  51. # Generic makefile setup 
  52.  
  53. # define a few generic variables that we need to use; DESTDIR may
  54. # be overridden on the command line during make install
  55. DESTDIR =
  56. srcdir = @srcdir@
  57. builddir = @BUILD_ABSOLUTE_TOP@
  58. prefix = @prefix@
  59. datarootdir = @datarootdir@
  60. exec_prefix = @exec_prefix@
  61. includedir = $(DESTDIR)@includedir@
  62. mandir = $(DESTDIR)@mandir@
  63. sbindir = $(DESTDIR)@sbindir@
  64. bindir = $(DESTDIR)@bindir@
  65. libdir = $(DESTDIR)@libdir@
  66.  
  67. VPATH = $(srcdir)
  68. SHELL = @SHELL@
  69. INSTALL = @INSTALL@
  70. # TODO: should probably check for bison and flex in configure
  71. BISON = bison
  72. FLEX = flex
  73. LN_S = ln -snf
  74. BUILD_BMI_TCP = @BUILD_BMI_TCP@
  75. BUILD_BMI_ONLY = @BUILD_BMI_ONLY@
  76. BUILD_GM = @BUILD_GM@
  77. BUILD_MX = @BUILD_MX@
  78. BUILD_IB = @BUILD_IB@
  79. BUILD_OPENIB = @BUILD_OPENIB@
  80. BUILD_PORTALS = @BUILD_PORTALS@
  81. BUILD_ZOID = @BUILD_ZOID@
  82. BUILD_VIS = @BUILD_VIS@
  83. BUILD_KARMA = @BUILD_KARMA@
  84. BUILD_FUSE = @BUILD_FUSE@
  85. BUILD_SERVER = @BUILD_SERVER@
  86. BUILD_TAU = @BUILD_TAU@
  87. BUILD_KERNEL = @BUILD_KERNEL@
  88. NEEDS_LIBRT = @NEEDS_LIBRT@
  89. TARGET_OS_DARWIN = @TARGET_OS_DARWIN@
  90. TARGET_OS_LINUX = @TARGET_OS_LINUX@
  91. GNUC = @GNUC@
  92. INTELC = @INTELC@
  93. # configure default is silent, unless --enable-verbose-build in
  94. # which case QUIET_COMPILE will _not_ be defined.  Further allow
  95. # silence to be overriden with "make V=1".
  96. QUIET_COMPILE = @QUIET_COMPILE@
  97. ifdef V
  98.     QUIET_COMPILE = 0
  99. endif
  100. LINUX_KERNEL_SRC = @LINUX_KERNEL_SRC@
  101. LINUX24_KERNEL_SRC = @LINUX24_KERNEL_SRC@
  102.  
  103. ifeq ($(QUIET_COMPILE),1)
  104.   # say a one-line description of the action, do not echo the command
  105.   Q=@echo
  106.   E=@
  107. else
  108.   # do not say the short Q lines, but do echo the entire command
  109.   Q=@echo >/dev/null
  110.   E=
  111. endif
  112.  
  113. # build which client libs
  114. build_shared = @build_shared@
  115. build_static = @build_static@
  116.  
  117. # Eliminate all default suffixes.  We want explicit control.
  118. .SUFFIXES:
  119.  
  120. # PHONEY targets are targets that do not result in the generation
  121. #    of a file that has the same name as the target.  Listing them
  122. #    here keeps make from accidentally doing too much work (see GNU
  123. #    make manual).
  124. .PHONY: all clean develtools dist distclean docs docsclean publish cscope tags codecheck admintools kernapps usertools
  125.  
  126. ################################################################
  127. # Find project subdirectories
  128.  
  129. # MODULES is a list of subdirectories that we wish to operate on.
  130. #    They are identified by the presence of module.mk files (makefile
  131. #    includes).
  132. MODULES := $(shell find . -name "*.mk" | sed -e 's/^.\///;s/module.mk//')
  133.  
  134. # List of directories to search for headers.
  135. ifdef BUILD_BMI_ONLY
  136. BUILD_SERVER=""
  137. INCLUDES := \
  138.     include \
  139.     src/io/bmi \
  140.     src/common/misc \
  141.     src/common/quickhash \
  142.     src/common/quicklist \
  143.     src/common/id-generator \
  144.     src/common/gossip \
  145.     src/common/gen-locks \
  146.     src/common/events
  147. GENINCLUDES := \
  148.     include
  149. else
  150. INCLUDES := \
  151.     src/client/sysint \
  152.     src/common/misc \
  153.     src/common/quickhash \
  154.     src/common/quicklist \
  155.     src/common/id-generator \
  156.     src/common/gossip \
  157.     src/common/gen-locks \
  158.     src/common/events \
  159.     src/io/trove \
  160.     src/io/bmi \
  161.     src/io/description \
  162.     src/io/buffer \
  163.     src/io/job \
  164.     src/io/dev \
  165.     src/proto \
  166.     src/common/mgmt
  167. GENINCLUDES := \
  168.     include
  169. endif
  170.  
  171. #################################################################
  172. # Setup global flags
  173.  
  174. # These should all be self explanatory; they are standard flags
  175. # for compiling and linking unless otherwise noted
  176. CC = @CC@
  177. LD = @CC@
  178. BUILD_CC = @BUILD_CC@
  179. BUILD_LD = @BUILD_CC@
  180. BUILD_CFLAGS = @BUILD_CFLAGS@
  181. BUILD_LDFLAGS = @BUILD_LDFLAGS@
  182. # make sure the srcdir include gets included first
  183. CFLAGS = -I$(srcdir)/include @CFLAGS@ @CPPFLAGS@
  184. LDFLAGS = -L@BUILD_ABSOLUTE_TOP@/lib
  185. LDFLAGS += @LDFLAGS@
  186. SERVER_LDFLAGS = -L@BUILD_ABSOLUTE_TOP@/lib
  187. SERVER_LDFLAGS += @SERVER_LDFLAGS@
  188. DB_CFLAGS = @DB_CFLAGS@
  189. LDSHARED = $(CC) -shared
  190. PICFLAGS = -fPIC
  191. LIBS += -lpvfs2 @LIBS@ 
  192. LIBS_THREADED += -lpvfs2-threaded @LIBS@
  193. # need to include external dependency libs when building shared libraries
  194. DEPLIBS := @LIBS@
  195. MMAP_RA_CACHE = @MMAP_RA_CACHE@
  196. TRUSTED_CONNECTIONS = @TRUSTED_CONNECTIONS@
  197. REDHAT_RELEASE = @REDHAT_RELEASE@
  198. NPTL_WORKAROUND = @NPTL_WORKAROUND@
  199. STRICT_CFLAGS = @STRICT_CFLAGS@
  200. SO_VER = @PVFS2_VERSION_MAJOR@
  201. SO_MINOR = @PVFS2_VERSION_MINOR@
  202. SO_RELEASE = @PVFS2_VERSION_SUB@
  203. SO_FULLVER = $(SO_VER).$(SO_MINOR).$(SO_RELEASE)
  204. # for Solaris:
  205. # LIBS += -lsocket -lnsl
  206.  
  207.   # enable Flow debugging protocol
  208. #CFLAGS += -D__STATIC_FLOWPROTO_DUMP_OFFSETS__
  209.   # enable new style Flow BMI/Trove protocol
  210. CFLAGS += -D__STATIC_FLOWPROTO_MULTIQUEUE__
  211.   # turn on large file support by default
  212. CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
  213.   # include current directory (for pvfs2-config.h)
  214. CFLAGS += -I .
  215.   # include toplevel source dir
  216. CFLAGS += -I $(srcdir)
  217.   # add selected include directories
  218. CFLAGS += $(patsubst %,-I$(srcdir)/%,$(INCLUDES))
  219. CFLAGS += $(patsubst %,-I$(builddir)/%,$(GENINCLUDES))
  220.  
  221.   # add package version information
  222. CFLAGS += -DPVFS2_VERSION="\"@PVFS2_VERSION@\""
  223.  
  224. # always want these gcc flags
  225. GCC_CFLAGS := -pipe -Wall -Wstrict-prototypes
  226.  
  227. ifneq (,$(STRICT_CFLAGS))
  228.     GCC_CFLAGS += -Wcast-align -Wbad-function-cast
  229.     GCC_CFLAGS += -Wmissing-prototypes -Wmissing-declarations
  230.     GCC_CFLAGS += -Wundef -Wpointer-arith
  231.     GCC_CFLAGS += -Wnested-externs
  232.     GCC_CFLAGS += -Wredundant-decls
  233.     # These are very noisy, and probably too strict.
  234.     #GCC_CFLAGS += -W -Wno-unused -Wno-sign-compare
  235.     #GCC_CFLAGS += -Wcast-qual
  236.     #GCC_CFLAGS += -Wshadow
  237.     #GCC_CFLAGS += -Wwrite-strings
  238. endif
  239.  
  240. # Intel cc options, enable all warnings, then disable some
  241. INTEL_CFLAGS := -Wall
  242. # #279: controlling expression is constant
  243. # shows up in ifdefs such as "do { ... } while (0)" construct
  244. INTEL_CFLAGS += -wd279
  245. # #424: extra ";" ignored e.g. in endecode_fields_2(); usage
  246. INTEL_CFLAGS += -wd424
  247. # #188: enumerated type mixed with another type, like flag |= ENUM_VALUE;
  248. # bogus compiler warning
  249. INTEL_CFLAGS += -wd188
  250. # #981: operands are evaluated in unspecified order, like printf that
  251. # uses functions to get some values; unimportant.
  252. INTEL_CFLAGS += -wd981
  253.  
  254. # do not disable these if strict, i.e. enable some more warnings
  255. ifeq (,$(STRICT_CFLAGS))
  256.     # #1419: external declaration in primary source file; would be good
  257.     # to get rid of these someday
  258.     INTEL_CFLAGS += -wd1419
  259.     # #1419: external definition with no prior declaration; most of these
  260.     # want to be static
  261.     INTEL_CFLAGS += -wd1418
  262.     # #181: argument is incompatible with corresponding format string
  263.     # conversion; investigate someday.
  264.     INTEL_CFLAGS += -wd181
  265.     # #869: parameter .. was never referenced, like -Wunused
  266.     INTEL_CFLAGS += -wd869
  267.     # #810: conversion from .. to .. may lose significant bits; investigate
  268.     # but probably harmless
  269.     INTEL_CFLAGS += -wd810
  270. endif
  271.  
  272. ################################################################
  273. # Setup component specific flags
  274.  
  275. # the server can use a threaded trove and job configuration.
  276. # Working combinations of trove/job thread configurations
  277. # are as follows:
  278. #
  279. # NOTE: __PVFS2_TROVE_SUPPORT__, and __GEN_POSIX_LOCKING__
  280. # are required for all server configurations 
  281. #
  282. # config 1)
  283. # =========
  284. # __PVFS2_TROVE_THREADED__
  285. # __PVFS2_JOB_THREADED__
  286. # __PVFS2_TROVE_AIO_THREADED__ (auto detected MISC_TROVE_FLAGS)
  287. # e.g.
  288. #
  289. #SERVERCFLAGS = -D__GEN_POSIX_LOCKING__ -D__PVFS2_JOB_THREADED__ \
  290. #-D__PVFS2_TROVE_THREADED__ @MISC_TROVE_FLAGS@ \
  291. #-D__PVFS2_TROVE_SUPPORT__
  292. #
  293. # config 2)
  294. # =========
  295. # __PVFS2_TROVE_THREADED__
  296. # __PVFS2_JOB_THREADED__
  297. # e.g.
  298. #
  299. #SERVERCFLAGS = -D__GEN_POSIX_LOCKING__ -D__PVFS2_JOB_THREADED__ \
  300. #-D__PVFS2_TROVE_THREADED__ -D__PVFS2_TROVE_SUPPORT__
  301. #
  302. # config 3)
  303. # =========
  304. # none (non-threaded)
  305. # e.g.
  306. #
  307. #SERVERCFLAGS = -D__GEN_POSIX_LOCKING__ -D__PVFS2_TROVE_SUPPORT__
  308.  
  309. SERVERCFLAGS = @CFLAGS@ -D__GEN_POSIX_LOCKING__ -D__PVFS2_JOB_THREADED__ \
  310. -D__PVFS2_TROVE_THREADED__ @MISC_TROVE_FLAGS@ @DB_CFLAGS@ \
  311. -D__PVFS2_TROVE_SUPPORT__ -D__PVFS2_SERVER__
  312.  
  313. # server side flow protocol connecting BMI with NCAC cache
  314. SERVERCFLAGS += -D__STATIC_FLOWPROTO_BMI_CACHE__
  315.  
  316. SERVERLIBS = -lpvfs2-server @LIBS@ @DB_LIB@ -lpthread 
  317.  
  318. ifdef NEEDS_LIBRT 
  319.     SERVERLIBS += -lrt
  320. endif
  321.  
  322. # you can optionally disable thread safety support in the client
  323. # though it's not recommended unless *required*.
  324. #
  325. # run ./configure --help for information on how to do this cleanly.
  326. LIBCFLAGS=@LIBCFLAGS@ -D__PVFS2_CLIENT__
  327. LIBTHREADEDCFLAGS=-D__GEN_POSIX_LOCKING__ -D__PVFS2_JOB_THREADED__ -D__PVFS2_CLIENT__
  328. LIBS += @THREAD_LIB@
  329. DEPLIBS += @THREAD_LIB@
  330. LIBS_THREADED += @THREAD_LIB@
  331.  
  332. ################################################################
  333. # build BMI TCP?
  334.  
  335. ifdef BUILD_BMI_TCP
  336.     CFLAGS += -D__STATIC_METHOD_BMI_TCP__
  337. endif
  338.  
  339.  
  340. ################################################################
  341. # enable GM if configure detected it
  342.  
  343. ifdef BUILD_GM
  344.     # other settings in bmi_gm/module.mk.in
  345.     CFLAGS += -D__STATIC_METHOD_BMI_GM__
  346.     GMLIBS := -L@GM_LIBDIR@ -lgm
  347.     LIBS += $(GMLIBS)
  348.     DEPLIBS += $(GMLIBS)
  349.     LIBS_THREADED += $(GMLIBS)
  350.     SERVERLIBS += $(GMLIBS)
  351. endif
  352.  
  353. ################################################################
  354. # enable MX if configure detected it
  355.  
  356. ifdef BUILD_MX
  357.     # other settings in bmi_mx/module.mk.in
  358.     CFLAGS += -D__STATIC_METHOD_BMI_MX__
  359.     MXLIBS := -L@MX_LIBDIR@ -lmyriexpress -lpthread
  360.     LIBS += $(MXLIBS)
  361.     DEPLIBS += $(MXLIBS)
  362.     LIBS_THREADED += $(MXLIBS)
  363.     SERVERLIBS += $(MXLIBS)
  364. endif
  365.  
  366. #####################################
  367. # enable IB if configure requested it
  368.  
  369. ifdef BUILD_IB
  370.     # other settings in bmi_ib/module.mk.in
  371.     CFLAGS += -D__STATIC_METHOD_BMI_IB__
  372.     IBLIBS := -L@IB_LIBDIR@ \
  373.           -lvapi -lmtl_common -lmosal -lmpga -lpthread -ldl
  374.     LIBS += $(IBLIBS)
  375.     DEPLIBS += $(IBLIBS)
  376.     LIBS_THREADED += $(IBLIBS)
  377.     SERVERLIBS += $(IBLIBS)
  378. endif
  379.  
  380. ifdef BUILD_OPENIB
  381. ifndef BUILD_IB
  382.     CFLAGS += -D__STATIC_METHOD_BMI_IB__
  383. endif
  384.     OPENIBLIBS := -L@OPENIB_LIBDIR@ -libverbs
  385.     LIBS += $(OPENIBLIBS)
  386.     DEPLIBS += $(OPENIBLIBS)
  387.     LIBS_THREADED += $(OPENIBLIBS)
  388.     SERVERLIBS += $(OPENIBLIBS)
  389. endif
  390.  
  391. # Portals
  392. ifdef BUILD_PORTALS
  393.     CFLAGS += -D__STATIC_METHOD_BMI_PORTALS__
  394. ifneq (,@PORTALS_LIBS@)
  395.     PORTALS_LIBS := @PORTALS_LIBS@
  396.     LIBS += $(PORTALS_LIBS)
  397.     DEPLIBS += $(PORTALS_LIBS)
  398.     LIBS_THREADED += $(PORTALS_LIBS)
  399.     SERVERLIBS += $(PORTALS_LIBS)
  400. endif
  401. endif
  402.  
  403. ifdef BUILD_ZOID
  404.     CFLAGS += -D__STATIC_METHOD_BMI_ZOID__
  405. endif
  406.  
  407. # enable mmap-readahead cache (unless disabled by configure)
  408. ifdef MMAP_RA_CACHE
  409. CFLAGS += @MMAP_RA_CACHE@
  410. endif
  411.  
  412. # enable trusted connections (unless disabled by configure)
  413. ifdef TRUSTED_CONNECTIONS
  414. CFLAGS += @TRUSTED_CONNECTIONS@
  415. endif
  416.  
  417. # enable redhat-release patches (if detected and if any)
  418. ifdef REDHAT_RELEASE
  419. CFLAGS += @REDHAT_RELEASE@
  420. endif
  421.  
  422. # Add gcc-specific flags if we know it is a gnu compiler.
  423. ifdef GNUC
  424. CFLAGS += $(GCC_CFLAGS)
  425. endif
  426. ifdef INTELC
  427. CFLAGS += $(INTEL_CFLAGS)
  428. endif
  429.  
  430. #################################################################
  431. # Starter variables 
  432.  
  433. # NOTES: These variables are used to categorize the various source
  434. #    files.  We let the makefile includes append to them so that we
  435. #    gradually build up a list of source files without having to
  436. #    list them all at the top level.
  437.  
  438. # ADMINSRC is source code for administrative programs
  439. ADMINSRC :=
  440. # ADMINSRC_SERVER special version of ADMINSRC for tools that need server 
  441. # library
  442. ADMINSRC_SERVER :=
  443. # usRSRC is source code for userland programs
  444. USERSRC :=
  445. # LIBSRC is source code for libpvfs2
  446. LIBSRC :=
  447. # SERVERSRC is souce code for the pvfs2 server
  448. SERVERSRC :=
  449. ifdef BUILD_BMI_ONLY
  450. # LIBBMISRC is source code for libbmi
  451. LIBBMISRC :=
  452. endif
  453. # SERVERBINSRC is source files that don't get added to the server library but must be added to the server binary
  454. SERVERBINSRC :=
  455. # DOCSRC is source code for documentation
  456. DOCSRC :=
  457. # VISSRC is the source code for visualization tools
  458. VISSRC :=
  459. # VISMISCSRC is a collection of sources that must be built into objects for 
  460. #    visualization tools
  461. VISMISCSRC :=
  462. # KARMASRC is source for the karma gui
  463. KARMASRC :=
  464. # FUSESRC is source for the FUSE interface daemon
  465. FUSESRC :=
  466. # userland helper programs for kernel drivers
  467. KERNAPPSRC :=
  468. KERNAPPTHRSRC :=
  469. # MISCSRC are sources that don't fall into the other categories
  470. MISCSRC := 
  471. # c files generated from state machines
  472. SMCGEN :=
  473. # DEVELSRC is source for development related tools
  474. DEVELSRC :=
  475.  
  476. ################################################################
  477. # Top level (default) targets
  478.  
  479. ifdef BUILD_SERVER
  480. # SERVER_STUB is a wrapper script that export the LD_ASSUME_KERNEL variable for
  481. #    systems with buggy NPTL/Pthread implementations, such as early RedHat
  482. #    EL 3 distributions
  483. SERVER_STUB := src/server/pvfs2-server-stub
  484. # SERVER is the pvfs2 server
  485. SERVER := src/server/pvfs2-server
  486. endif
  487.  
  488. # LIBRARIES is a list of the pvfs2 client libraries that will be installed
  489. LIBRARIES :=
  490. ifdef BUILD_BMI_ONLY
  491. BMILIBRARIES :=
  492. endif
  493. LIBRARIES_THREADED :=
  494. ifeq ($(build_shared),yes)
  495. ifdef BUILD_BMI_ONLY
  496. BMILIBRARIES := lib/libbmi.so
  497. endif
  498. LIBRARIES_SHARED = lib/libpvfs2.so
  499. LIBRARIES += $(LIBRARIES_SHARED)
  500. LIBRARIES_THREADED_SHARED += lib/libpvfs2-threaded.so
  501. LIBRARIES_THREADED += $(LIBRARIES_THREADED_SHARED)
  502. endif
  503. ifeq ($(build_static),yes)
  504. ifdef BUILD_BMI_ONLY
  505. BMILIBRARIES += lib/libbmi.a
  506. endif
  507. LIBRARIES_STATIC = lib/libpvfs2.a
  508. LIBRARIES += $(LIBRARIES_STATIC)
  509. LIBRARIES_THREADED_STATIC += lib/libpvfs2-threaded.a
  510. LIBRARIES_THREADED += $(LIBRARIES_THREADED_STATIC)
  511. endif
  512.  
  513. ################################################################
  514. # Default target forward pointer, to avoid other targets in make stubs
  515. all::
  516.  
  517. ################################################################
  518. # Makefile includes
  519.  
  520. # this is how we pull build information from all of the project
  521. #    subdirectories, make sure to catch top level module.mk as well
  522. include module.mk
  523. include $(patsubst %, %/module.mk, $(MODULES))
  524.  
  525. ################################################################
  526. # Derived file lists
  527.  
  528. # NOTES: At this point, the subdirectory makefile includes have informed
  529. #    us what the source files are.  Now we want to generate some
  530. #    other lists (such as objects, executables, and dependency files)
  531. #    by manipulating the lists of source files
  532.  
  533. # LIBOBJS is a list of objects to put in the client lib
  534. LIBOBJS := $(patsubst %.c,%.o, $(filter %.c,$(LIBSRC)))
  535. # LIBPICOBJS are the same, but compiled for use in a shared library
  536. LIBPICOBJS := $(patsubst %.c,%.po, $(filter %.c,$(LIBSRC)))
  537. # LIBDEPENDS is a list of dependency files for the client lib
  538. LIBDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(LIBSRC)))
  539.  
  540. ifdef BUILD_BMI_ONLY
  541. # LIBBMIOBJS is a list of objects to put in the bmi lib
  542. LIBBMIOBJS := $(patsubst %.c,%.o, $(filter %.c,$(LIBBMISRC)))
  543. # LIBBMIPICOBJS are the same, but compiled for use in a shared library
  544. LIBBMIPICOBJS := $(patsubst %.c,%.po, $(filter %.c,$(LIBBMISRC)))
  545. # LIBBMIDEPENDS is a list of dependency files for the bmi lib
  546. LIBBMIDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(LIBBMISRC)))
  547. endif
  548.  
  549. # LIBTHREADEDOBJS is a list of objects to put in the multithreaded client lib
  550. LIBTHREADEDOBJS := $(patsubst %.c,%-threaded.o, $(filter %.c,$(LIBSRC)))
  551. # LIBTHREADEDPICOBJS are the same, but compiled for use in a shared library
  552. LIBTHREADEDPICOBJS := $(patsubst %.c,%-threaded.po, $(filter %.c,$(LIBSRC)))
  553. # LIBTHREADEDDEPENDS is a list of dependency files for the multithreaded client lib
  554. LIBTHREADEDDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(LIBSRC)))
  555. # ADMINOBJS is a list of admin program objects
  556. ADMINOBJS := $(patsubst %.c,%.o, $(filter %.c,$(ADMINSRC)))
  557. # ADMINTOOLS is a list of admin program executables
  558. ADMINTOOLS := $(patsubst %.c,%, $(filter %.c, $(ADMINSRC)))
  559. # ADMINDEPENDS is a list of dependency files for admin programs
  560. ADMINDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(ADMINSRC)))
  561. #
  562. # USEROBJS is a list of user program objects
  563. USEROBJS := $(patsubst %.c,%.o, $(filter %.c,$(USERSRC)))
  564. # USERTOOLS is a list of user program executables 
  565. USERTOOLS := $(patsubst %.c,%, $(filter %.c, $(USERSRC)))
  566. # USERDEPENDS is a list of dependency files for user programs
  567. USERDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(USERSRC)))
  568.  
  569. ifdef BUILD_SERVER
  570.     ADMINOBJS_SERVER := $(patsubst %.c,%.o, $(filter %.c,$(ADMINSRC_SERVER)))
  571.     ADMINTOOLS_SERVER := $(patsubst %.c,%, $(filter %.c, $(ADMINSRC_SERVER)))
  572.     ADMINDEPENDS_SERVER := $(patsubst %.c,%.d, $(filter %.c,$(ADMINSRC_SERVER)))
  573.     # SERVEROBJS is a list of objects to put into the server
  574.     SERVEROBJS := $(patsubst %.c,%-server.o, $(filter %.c,$(SERVERSRC)))
  575.     # SERVERDEPENDS is a list of dependency files for the server
  576.     SERVERDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(SERVERSRC)))
  577.     # SERVERBINOBJS is a list of objects not in SERVEROBJS to put into the server
  578.     SERVERBINOBJS := $(patsubst %.c,%-server.o, $(filter %.c,$(SERVERBINSRC)))
  579.     SERVERBINDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(SERVERBINSRC)))
  580. endif
  581.  
  582. # MISCOBJS is a list of misc. objects not in the above categories
  583. MISCOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MISCSRC)))
  584. # MISCDEPENDS is a list of dependency files for misc. objects
  585. MISCDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MISCSRC)))
  586.  
  587. # KERNAPPOBJS is a list of kernel driver userland objects
  588. KERNAPPOBJS := $(patsubst %.c,%.o, $(filter %.c,$(KERNAPPSRC))) \
  589.                $(patsubst %.c,%-threaded.o, $(filter %.c,$(KERNAPPTHRSRC)))
  590. # KERNAPPS is a list of kernel driver userland executables
  591. KERNAPPS := $(patsubst %.c,%, $(filter %.c, $(KERNAPPSRC)))
  592. KERNAPPSTHR := $(patsubst %.c,%, $(filter %.c, $(KERNAPPTHRSRC)))
  593. # KERNAPPDEPENDS is a list of dependency files for kernel driver userland
  594. # objects
  595. KERNAPPDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(KERNAPPSRC) $(KERNAPPTHRSRC)))
  596. # Be sure to build/install the threaded lib too; just pick the shared
  597. # one if configure asked for both.
  598. ifneq (,$(KERNAPPSTHR))
  599. ifeq (,$(filter $(firstword $(LIBRARIES_THREADED)),$(LIBRARIES)))
  600. LIBRARIES += $(firstword $(LIBRARIES_THREADED))
  601. endif
  602. endif
  603.  
  604. # VISOBJS is a list of visualization program objects
  605. VISOBJS := $(patsubst %.c,%.o, $(filter %.c,$(VISSRC)))
  606. # VISS is a list of visualization program executables
  607. VISS := $(patsubst %.c,%, $(filter %.c, $(VISSRC)))
  608. # VISDEPENDS is a list of dependency files for visualization programs
  609. VISDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(VISSRC)))
  610. # VISMISCOBJS is a list of misc. vis objects not in the above categories
  611. VISMISCOBJS := $(patsubst %.c,%.o, $(filter %.c,$(VISMISCSRC)))
  612. # VISMISCDEPENDS is a list of dependency files for vis misc. objects
  613. VISMISCDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(VISMISCSRC)))
  614.  
  615. # KARMAOBJS, KARMADEPENDS for the karma gui (requires gtk2.0)
  616. KARMAOBJS := $(patsubst %.c,%.o, $(filter %.c,$(KARMASRC)))
  617. KARMADEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(KARMASRC)))
  618.  
  619. # FUSEOBJS
  620. FUSEOBJS := $(patsubst %.c,%.o, $(filter %.c,$(FUSESRC)))
  621. FUSEDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(FUSESRC)))
  622.  
  623. # state machine generation tool, built for the build machine, not the
  624. # host machine, in the case of cross-compilation
  625. STATECOMPOBJS := $(patsubst %.c,%.o,$(STATECOMPSRC))
  626. STATECOMPDEPS := $(patsubst %.c,%.d,$(STATECOMPSRC))
  627.  
  628. # DOCSPDF, DOCSPS, and DOCSHTML are lists of documentation files generated 
  629. #   from latex
  630. DOCSPDF := $(patsubst %.tex,%.pdf, $(filter %.tex,$(DOCSRC)))
  631. DOCSPS := $(patsubst %.tex,%.ps, $(filter %.tex,$(DOCSRC)))
  632. DOCSHTML := $(patsubst %.tex,%.html, $(filter %.tex,$(DOCSRC)))
  633.  
  634. # DOCSCRUFT is a list of intermediate files generated by latex
  635. DOCSCRUFT := $(patsubst %.tex,%.aux, $(filter %.tex,$(DOCSRC)))
  636. DOCSCRUFT += $(patsubst %.tex,%.dvi, $(filter %.tex,$(DOCSRC)))
  637. DOCSCRUFT += $(patsubst %.tex,%.log, $(filter %.tex,$(DOCSRC)))
  638. DOCSCRUFT += $(patsubst %.tex,%.toc, $(filter %.tex,$(DOCSRC)))
  639.  
  640. # DEVELOBJS is a list of development program objects
  641. DEVELOBJS := $(patsubst %.c,%.o, $(filter %.c,$(DEVELSRC)))
  642. # DEVELTOOLS is a list of development program executables 
  643. DEVELTOOLS := $(patsubst %.c,%, $(filter %.c, $(DEVELSRC)))
  644. # DEVELDEPENDS is a list of dependency files for development programs
  645. DEVELDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(DEVELSRC)))
  646.  
  647. # DEPENDS is a global list of all of our dependency files.  
  648. # NOTE: sort is just a trick to remove duplicates; the order
  649. #   doesn't matter at all.
  650. ifdef BUILD_BMI_ONLY
  651. DEPENDS := $(sort $(LIBBMIDEPENDS))
  652. else
  653. DEPENDS := $(sort $(LIBDEPENDS) $(SERVERDEPENDS) $(SERVERBINDEPENDS) \
  654.     $(MISCDEPENDS) $(USERDEPENDS) \
  655.     $(ADMINDEPENDS) $(ADMINDEPENDS_SERVER) $(KERNAPPDEPENDS) $(VISDEPENDS) \
  656.     $(VISMISCDEPENDS) $(KARMADEPENDS) $(STATECOMPDEPS) $(FUSEDEPENDS))
  657. endif
  658.  
  659. ####################################################################
  660. # Rules and dependencies
  661.  
  662. # default rule builds server, library, and applications
  663. ifdef BUILD_BMI_ONLY
  664. all:: $(BMILIBRARIES)
  665. else
  666. all:: $(SERVER) $(KARMA) $(LIBRARIES) admintools usertools $(VISS) $(KARMA) $(FUSE)
  667. endif
  668.  
  669. # target for building admin tools
  670. admintools: $(ADMINTOOLS) $(ADMINTOOLS_SERVER)
  671.  
  672. #target for building user tools
  673. usertools: $(USERTOOLS)
  674.  
  675. # target for building kernel driver userland programs
  676. kernapps: $(KERNAPPS) $(KERNAPPSTHR)
  677.  
  678. # this is needed for the make dist
  679. statecompgen: $(STATECOMPGEN)
  680.  
  681. # target for builging development tools
  682. develtools: $(DEVELTOOLS)
  683.  
  684. # Build linux-2.6 kernel module if requested.
  685. # Can't use the actual file target since we don't know how to figure out
  686. # dependencies---only the kernel source tree can do that.
  687. ifneq (,$(LINUX_KERNEL_SRC))
  688. .PHONY: kmod
  689. kmod: just_kmod kernapps
  690. just_kmod:
  691.     @$(MAKE) --no-print-directory -C src/kernel/linux-2.6
  692. endif
  693.  
  694. # Build linux-2.4 kernel module if requested.
  695. ifneq (,$(LINUX24_KERNEL_SRC))
  696. .PHONY: kmod24
  697. kmod24: just_kmod24 kernapps
  698. just_kmod24: 
  699.     @$(MAKE) --no-print-directory -C src/kernel/linux-2.4
  700. endif
  701.  
  702. # Just like dir, but strip the slash off the end, to be pretty.
  703. dirname = $(patsubst %/,%,$(dir $(1)))
  704.  
  705. # Generate the canonical in-tree location of a file, given a possibly
  706. # out-of-tree reference.
  707. canonname = $(patsubst $(srcdir)/%,%,$(call dirname,$(1)))
  708.  
  709. # Grab any CFLAGS defined by the make stub for a particular file, and
  710. # for the directory in which the source resides.
  711. # Always add the source directory in question for "local" includes.
  712. # Similar for ldflags.
  713. modcflags = $(MODCFLAGS_$(call canonname,$(1))) \
  714.             $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1))) \
  715.         -I$(srcdir)/$(call dirname,$(1))
  716. modldflags = $(MODLDFLAGS_$(call canonname,$(1))) \
  717.              $(MODLDFLAGS_$(patsubst $(srcdir)/%,%,$(1)))
  718.  
  719. # note: this will look better if you use two tabs instead of spaces between
  720. # SHORT_NAME and the object
  721.  
  722. # rule for building the pvfs2 server
  723. $(SERVER): $(SERVERBINOBJS) lib/libpvfs2-server.a 
  724.     $(Q) "  LD        $@"
  725.     $(E)$(LD) $^ -o $@ $(SERVER_LDFLAGS) $(SERVERLIBS)
  726.  
  727. # special rules for admin tool objects which also require server components
  728. $(ADMINOBJS_SERVER): %.o: %.c
  729.     $(Q) "  CC        $@"
  730.     $(E) $(CC) $(CFLAGS) $(SERVERCFLAGS) $(call modcflags,$<) $< -c -o $@
  731.  
  732. # special rules for admin tools which also require server components
  733. $(ADMINTOOLS_SERVER): %: %.o
  734.     $(Q) "  LD        $@"
  735.     $(E)$(LD) $< $(LDFLAGS) $(SERVER_LDFLAGS) $(SERVERLIBS) -o $@
  736.  
  737. ifdef BUILD_BMI_ONLY
  738. # rule for building the bmi library
  739. lib/libbmi.a: $(LIBBMIOBJS)
  740.     $(Q) "  RANLIB    $@"
  741.     $(E)$(INSTALL) -d lib
  742.     $(E)ar rcs $@ $(LIBBMIOBJS)
  743.  
  744. # rule for building the shared bmi library
  745. lib/libbmi.so: $(LIBBMIPICOBJS)
  746.     $(Q) "  LDSO        $@"
  747.     $(E)$(INSTALL) -d lib
  748.     $(E)$(LDSHARED) -Wl,-soname,libbmi.so -o $@ $(LIBBMIPICOBJS) $(DEPLIBS)
  749. endif
  750.  
  751. # rule for building the pvfs2 library
  752. lib/libpvfs2.a: $(LIBOBJS)
  753.     $(Q) "  RANLIB    $@"
  754.     $(E)$(INSTALL) -d lib
  755.     $(E)ar rcs $@ $(LIBOBJS)
  756.  
  757. # rule for building the _multithreaded_ pvfs2 library
  758. lib/libpvfs2-threaded.a: $(LIBTHREADEDOBJS)
  759.     $(Q) "  RANLIBTHREADED    $@"
  760.     $(E)$(INSTALL) -d lib
  761.     $(E)ar rcs $@ $(LIBTHREADEDOBJS)
  762.  
  763. # rule for building the pvfs2 library
  764. lib/libpvfs2.so: $(LIBPICOBJS)
  765.     $(Q) "  LDSO        $@"
  766.     $(E)$(INSTALL) -d lib
  767.     $(E)$(LDSHARED) -Wl,-soname,libpvfs2.so -o $@ $(LIBPICOBJS) $(DEPLIBS)
  768.  
  769. # rule for building the pvfs2 _multithreaded_ library
  770. lib/libpvfs2-threaded.so: $(LIBTHREADEDPICOBJS)
  771.     $(Q) "  LDSO        $@"
  772.     $(E)$(INSTALL) -d lib
  773.     $(E)$(LDSHARED) -Wl,-soname,libpvfs2-threaded.so -o $@ $(LIBTHREADEDPICOBJS) $(DEPLIBS)
  774.  
  775. # rule for building the pvfs2 server library
  776. lib/libpvfs2-server.a: $(SERVEROBJS)
  777.     $(Q) "  RANLIB    $@"
  778.     $(E)$(INSTALL) -d lib
  779.     $(E)ar rcs $@ $(SERVEROBJS)
  780.  
  781. # rule for building karma gui and its objects
  782. $(KARMA): $(KARMAOBJS) $(LIBRARIES)
  783.     $(Q) "  LD        $@"
  784.     $(E)$(LD) -o $@ $(LDFLAGS) $(KARMAOBJS) $(LIBS) $(call modldflags,$<)
  785.  
  786. # fule for building FUSE interface and its objects
  787. $(FUSE): $(FUSEOBJS) $(LIBRARIES)
  788.     $(Q) " LD         $@"
  789.     $(E)$(LD) -o $@ $(LDFLAGS) $(FUSEOBJS) $(LIBS) $(call modldflags,$<)
  790.  
  791. # rule for building vis executables from object files
  792. $(VISS): %: %.o $(VISMISCOBJS) $(LIBRARIES)
  793.     $(Q) "  LD        $@"
  794.     $(E)$(LD) -o $@ $(LDFLAGS) $< $(VISMISCOBJS) $(LIBS) $(call modldflags,$<)
  795.  
  796. # rule for building development tools and its objects. don't know why db isn't
  797. # already in libs.
  798. $(DEVELTOOLS): $(DEVELOBJS) $(LIBRARIES)
  799.     $(Q) "  LD         $@"
  800.     $(E)$(LD) -o $@ $(LDFLAGS) $(DEVELOBJS) $(LIBS) -ldb $(call modldflags,$<)
  801.  
  802. # default rule for building executables from object files
  803. %: %.o $(LIBRARIES)
  804.     $(Q) "  LD        $@"
  805.     $(E)$(LD) -o $@ $(LDFLAGS) $< $(LIBS) $(call modldflags,$<)
  806.  
  807. %-threaded: %.o $(LIBRARIES)
  808.     $(Q) "  LD              $@"
  809.     $(E)$(LD) -o $@ $(LDFLAGS) $< $(LIBS_THREADED) $(call modldflags,$<)
  810.  
  811. # rule for building server objects
  812. %-server.o: %.c
  813.     $(Q) "  CC        $@"
  814.     $(E)$(CC) $(CFLAGS) $(SERVERCFLAGS) $(call modcflags,$<) $< -c -o $@
  815.  
  816. # default rule for building objects for threaded library
  817. %-threaded.o: %.c
  818.     $(Q) "  CC        $@"
  819.     $(E)$(CC) $(LIBTHREADEDCFLAGS) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -c -o $@
  820.  
  821. # rule for building shared objects for threaded library
  822. %-threaded.po: %.c
  823.     $(Q) "  CCPIC        $@"
  824.     $(E)$(CC) $(LIBTHREADEDCFLAGS) $(CFLAGS) $(PICFLAGS) $(call modcflags,$<) $< -c -o $@
  825.  
  826. # default rule for building objects 
  827. %.o: %.c
  828.     $(Q) "  CC        $@"
  829.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -c -o $@
  830.  
  831. # rule for building shared objects 
  832. %.po: %.c
  833.     $(Q) "  CCPIC        $@"
  834.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(PICFLAGS) $(call modcflags,$<) $< -c -o $@
  835.  
  836. # c++ rule for building server objects
  837. %-server.o: %.cpp
  838.     $(Q) "  CC        $@"
  839.     $(E)$(CC) $(CFLAGS) $(SERVERCFLAGS) $(call modcflags,$<) $< -c -o $@
  840.  
  841. # c++ default rule for building objects for threaded library
  842. %-threaded.o: %.cpp
  843.     $(Q) "  CC        $@"
  844.     $(E)$(CC) $(LIBTHREADEDCFLAGS) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -c -o $@
  845.  
  846. # c++ rule for building shared objects for threaded library
  847. %-threaded.po: %.cpp
  848.     $(Q) "  CCPIC        $@"
  849.     $(E)$(CC) $(LIBTHREADEDCFLAGS) $(CFLAGS) $(PICFLAGS) $(call modcflags,$<) $< -c -o $@
  850.  
  851. # c++ default rule for building objects 
  852. %.o: %.cpp
  853.     $(Q) "  CC        $@"
  854.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -c -o $@
  855.  
  856. # c++ rule for building shared objects 
  857. %.po: %.cpp
  858.     $(Q) "  CCPIC        $@"
  859.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(PICFLAGS) $(call modcflags,$<) $< -c -o $@
  860.  
  861. # bison and yacc
  862. %.c: %.y
  863.     $(Q) "  BISON        $@"
  864.     $(E)$(BISON) -d $< -o $@
  865.  
  866. %.c: %.l
  867.     $(Q) "  FLEX        $@"
  868.     $(E)$(FLEX) -o$@ $<
  869.  
  870. # handy rule to generate cpp-output file, for debugging
  871. .PHONY: FORCE
  872. %-server.i: %.c FORCE
  873.     $(Q) "  CPP        $@"
  874.     $(E)$(CC) $(CFLAGS) $(SERVERCFLAGS) $(call modcflags,$<) $< -E -o $@
  875.  
  876. %.i: %.c FORCE
  877.     $(Q) "  CPP        $@"
  878.     $(E)$(CC) $(LIBCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -E -o $@
  879.  
  880. %-threaded.i: %.c FORCE
  881.     $(Q) "  CPP        $@"
  882.     $(E)$(CC) $(LIBTHREADEDCFLAGS) $(CFLAGS) $(call modcflags,$<) $< -E -o $@
  883.  
  884. # all applications depend on the pvfs2 library
  885. $(ADMINTOOLS): %: %.o $(LIBRARIES)
  886. $(ADMINTOOLS_SERVER): %: %.o $(LIBRARIES) lib/libpvfs2-server.a
  887.  
  888. $(USERTOOLS): %: %.o $(LIBRARIES)
  889.  
  890. $(KERNAPPS): %: %.o $(LIBRARIES)
  891. $(KERNAPPSTHR): %: %.o $(LIBRARIES_THREADED)
  892.     $(Q) "  LD        $@"
  893.     $(E)$(LD) -o $@ $(LDFLAGS) $< $(LIBS_THREADED) $(call modldflags,$<)
  894.  
  895. # special rules to build state machine compiler using build host compiler
  896. $(STATECOMPOBJS): %.o: %.c
  897.     $(Q) "  BUILD_CC    $@"
  898.     $(E)$(BUILD_CC) $(BUILD_CFLAGS) $< -c -o $@ $(call modcflags,$<)
  899.  
  900. $(STATECOMP): $(STATECOMPOBJS)
  901.     $(Q) "  BUILD_LD    $@"
  902.     $(E)$(BUILD_LD) -o $@ $(BUILD_LDFLAGS) $(STATECOMPOBJS) $(call modldflags,$<)
  903.  
  904. # rule for generating cscope information
  905. cscope:
  906.     find @SRC_ABSOLUTE_TOP@ -iname "*.[ch]" -o -iname "*.sm" \
  907.          > $(srcdir)/cscope.files
  908.     ( cd @SRC_ABSOLUTE_TOP@; cscope -be -i @SRC_ABSOLUTE_TOP@/cscope.files )
  909.  
  910. # Build editor tags file over all source files *.[ch] *.sm and
  911. # some known scripts.  Grab the config files from the build dir.
  912. # Ignore all generated C files by echoing them and trusting uniq to
  913. # throw away the duplicates.  Echo them twice so they do not survive
  914. # uniq for out-of-tree builds.
  915. tags:
  916.     ( find $(addprefix $(srcdir)/,$(MODULES)) $(srcdir)/include \
  917.         $(srcdir)/src/kernel/linux-2.6 \
  918.         -maxdepth 1 -name '*.[ch]' -o -name '*.sm' ;\
  919.       find . -maxdepth 1 -name pvfs2-config.h ;\
  920.       echo $(srcdir)/src/apps/admin/pvfs2-genconfig ;\
  921.       echo $(patsubst %,./%,$(SMCGEN) $(SMCGEN)) | tr ' ' '\012' ;\
  922.     ) | sort | uniq -u | ctags -L- --excmd=pattern -B --extra=+f \
  923.       --langmap=c:+.sm -I __hidden,DOTCONF_CB,nested,machine=struct
  924.  
  925. # rule for running code check
  926. codecheck:
  927.     find $(srcdir) -iname "*.[ch]" | xargs -n 1 $(srcdir)/maint/pvfs2codecheck.pl
  928.  
  929. # target for building documentation
  930. docs: $(DOCSPS) $(DOCSPDF) $(DOCSHTML)
  931.  
  932. publish: docs
  933.     $(srcdir)/maint/pvfs2-publish-pages `pwd`/doc
  934.  
  935. # rule for cleaning up documentation
  936. # latex2html puts all its output in a directory
  937. # don't get rid of generated files in dist releases
  938. docsclean: 
  939.     rm -f $(DOCSCRUFT)
  940. ifndef DIST_RELEASE
  941.     rm -f $(DOCSPS) $(DOCSPDF)
  942.     rm -rf $(basename $(DOCSHTML))
  943. endif
  944.  
  945. # top rule for cleaning up tree
  946. clean:: 
  947.     $(Q) "  CLEAN"
  948.     $(E)rm -f $(LIBOBJS) $(LIBTHREADEDOBJS) \
  949.         $(SERVEROBJS) $(SERVERBINOBJS) $(MISCOBJS) \
  950.         $(LIBRARIES) $(LIBRARIES_THREADED) $(DEPENDS) $(SERVER) \
  951.         $(ADMINOBJS) $(ADMINOBJS_SERVER) $(ADMINTOOLS)\
  952.         $(ADMINTOOLS_SERVER) lib/libpvfs2-server.a\
  953.                 $(USERTOOLS) $(USEROBJS) \
  954.         $(KERNAPPOBJS) $(KERNAPPS) $(KERNAPPSTHR) \
  955.         $(VISS) $(VISMISCOBJS) $(VISOBJS) $(VISDEPENDS)\
  956.         $(VISMISCDEPENDS) $(KARMAOBJS) $(LIBPICOBJS) \
  957.         $(STATECOMP) $(STATECOMPOBJS) $(LIBBMIOBJS) $(BMILIBRARIES) $(FUSEOBJS) \
  958.         $(VISMISCDEPENDS) $(KARMAOBJS) $(LIBPICOBJS)\
  959.         $(STATECOMP) $(STATECOMPOBJS) \
  960.         src/server/pvfs2-server-server.o \
  961.         src/apps/karma/karma src/apps/fuse/pvfs2fuse
  962. ifndef DIST_RELEASE
  963.     $(E)rm -f $(STATECOMPGEN) 
  964. endif
  965.  
  966. ifneq (,$(LINUX_KERNEL_SRC))
  967. clean::
  968.     @$(MAKE) --no-print-directory -C src/kernel/linux-2.6 clean
  969. endif
  970.  
  971. ifneq (,$(LINUX24_KERNEL_SRC))
  972. clean::
  973.     @$(MAKE) --no-print-directory -C src/kernel/linux-2.4 clean
  974. endif
  975.  
  976. # builds a tarball of the source tree suitable for distribution
  977. dist: $(SMCGEN) cleaner
  978.     @sh $(srcdir)/maint/make-dist.sh $(srcdir) @PVFS2_VERSION@
  979.  
  980. ifdef BUILD_BMI_ONLY
  981. # builds a tarball of the BMI source tree suitable for distribution
  982. bmidist: cleaner
  983.     @sh $(srcdir)/maint/make-bmi-dist.sh $(srcdir) $(builddir) @PVFS2_VERSION@
  984.     cp -u $(builddir)/config.save $(builddir)/config.status
  985. endif
  986.  
  987. # some stuff that is cleaned in both distclean and dist targets
  988. cleaner: clean
  989.     rm -f tags
  990.     rm -f src/kernel/linux-2.6/Makefile
  991.     rm -f src/kernel/linux-2.4/Makefile
  992.     rm -f maint/mpi-depend.sh
  993.     rm -f examples/pvfs2-server.rc
  994.     rm -f doc/doxygen/pvfs2-doxygen.conf
  995.     rm -f examples/fs.conf
  996.     rm -rf autom4te*.cache
  997.     rm -f pvfs2-config.h.in~
  998.     rm -f $(srcdir)/cscope.out $(srcdir)/cscope.files
  999.     cp -p config.status config.save
  1000.     rm -f config.log config.status config.cache 
  1001.     rm -f pvfs-@PVFS2_VERSION@.tar.gz
  1002.  
  1003. # _really_ clean the tree; should go back to pristine state
  1004. # except, don't remove generated .c files if this is a distributed release
  1005. distclean: cleaner docsclean
  1006.     find . -name "module.mk" -exec rm \{\} \;
  1007.     rm -f Makefile pvfs2-config.h
  1008.     rm -f src/server/simple.conf
  1009.     rm -f src/apps/admin/pvfs2-config
  1010. ifndef DIST_RELEASE
  1011.     rm -f $(SMCGEN)
  1012. endif
  1013.  
  1014. # this is where we include all of our automatic dependencies.
  1015. # NOTE: we wrap this in ifneq's in order to prevent the
  1016. #    dependencies from being generated for special targets that don't 
  1017. #    require them
  1018. ifeq (,$(filter clean distclean dist docs cscope tags nodep,$(MAKECMDGOALS)))
  1019. -include $(DEPENDS)
  1020. endif
  1021. # add this as a make goal to disable rebuilding dependencies
  1022. .PHONY: nodep
  1023. nodep:; @:
  1024.  
  1025. # default rule for generating dependency files
  1026. %.d: %.c
  1027.     $(Q) "  DEP        $@"
  1028.     $(E)CC="$(CC)" $(srcdir)/maint/depend.sh $(call dirname,$*) $(CFLAGS) $(DB_CFLAGS) $(call modcflags,$<) $< > $@
  1029.  
  1030. # default rules for building documents in .tex format:
  1031. # TODO: these documentation rules are a big hack!
  1032. %.dvi: %.tex
  1033.     $(srcdir)/maint/pvfs2latexwrapper.pl -i $< -o $@
  1034. %.ps: %.dvi
  1035.     ( cd $(@D); dvips -t letter $(<F) -o $(@F) )
  1036. %.pdf: %.dvi
  1037.     ( cd $(@D); dvipdf $(<F) $(@F) )
  1038. %.html: %.tex
  1039.     $(srcdir)/maint/pvfs2latexwrapper.pl -html -i $(basename $<).tex -o $@
  1040.     $(srcdir)/maint/pvfs2htmlfixup.sh $(@D)/*/$(@F)
  1041.  
  1042. # rule for automatically generated source files
  1043. %.c: %.sm $(STATECOMP)
  1044.     $(Q) "  SMC        $@"
  1045.     $(E)$(STATECOMP) $< $@
  1046.  
  1047. # if this is not a distribution tarball, then drop some example
  1048. # config files in the server build directory with good defaults for
  1049. # debugging
  1050. ifndef DIST_RELEASE
  1051. all:: src/server/simple.conf
  1052. endif
  1053. src/server/simple.conf: src/apps/admin/pvfs2-genconfig
  1054.     $(Q) "  GENCONFIG     $@"
  1055.     $(E)$(srcdir)/src/apps/admin/pvfs2-genconfig --protocol tcp --port 3334 \
  1056.  --ioservers localhost --metaservers localhost --logfile /tmp/pvfs2-server.log \
  1057.  --storage /tmp/pvfs2-test-space --logging "server,network,storage,flow" \
  1058.  --quiet src/server/simple.conf
  1059.  
  1060. # whether this is a distribution tarball or not, drop some config files
  1061. # into the "examples" subdir of the build dir
  1062. ifndef BUILD_BMI_ONLY
  1063. all:: examples/fs.conf
  1064. examples/fs.conf: src/apps/admin/pvfs2-genconfig
  1065.     $(Q) "  GENCONFIG     $@"
  1066.     $(E)$(srcdir)/src/apps/admin/pvfs2-genconfig --protocol tcp --port 3334 \
  1067.  --ioservers localhost --metaservers localhost --logfile /tmp/pvfs2-server.log \
  1068.  --storage /tmp/pvfs2-test-space \
  1069.  --quiet examples/fs.conf
  1070. endif
  1071.  
  1072. install_doc:
  1073.     install -d $(mandir)/man1
  1074.     install -d $(mandir)/man5
  1075.     install -m 644 $(srcdir)/doc/man/*.1 $(mandir)/man1
  1076.     install -m 644 $(srcdir)/doc/man/*.5 $(mandir)/man5
  1077.  
  1078. ifdef BUILD_BMI_ONLY
  1079. install:: all
  1080.     install -d $(includedir)
  1081.     install -m 644 $(srcdir)/src/io/bmi/bmi.h $(includedir)
  1082.     install -m 644 $(srcdir)/src/io/bmi/bmi-types.h $(includedir)
  1083.  
  1084.     install -d $(libdir)
  1085.     install -m 755 lib/*.* $(libdir)
  1086. else
  1087. install:: all install_doc
  1088.     install -d $(includedir)
  1089.     install -m 644 $(builddir)/include/pvfs2.h $(includedir)
  1090.     install -m 644 $(srcdir)/include/pvfs2-request.h $(includedir)
  1091.     install -m 644 $(srcdir)/include/pvfs2-debug.h $(includedir)
  1092.     install -m 644 $(srcdir)/include/pvfs2-sysint.h $(includedir)
  1093.     install -m 644 $(srcdir)/include/pvfs2-mgmt.h $(includedir)
  1094.     install -m 644 $(srcdir)/include/pvfs2-types.h $(includedir)
  1095.     install -m 644 $(srcdir)/include/pvfs2-util.h $(includedir)
  1096.     install -m 644 $(srcdir)/include/pvfs2-encode-stubs.h $(includedir)
  1097.     install -m 644 $(srcdir)/include/pvfs2-hint.h $(includedir)
  1098.     install -m 644 $(srcdir)/include/pvfs2-compat.h $(includedir)
  1099.     install -m 644 $(srcdir)/include/pvfs2-mirror.h $(includedir)
  1100.  
  1101.     install -d $(libdir)
  1102. ifneq (,$(LIBRARIES_STATIC))
  1103.     for i in $(notdir $(LIBRARIES_STATIC)) ; do \
  1104.         install -m 755 lib/$$i $(libdir) ;\
  1105.     done
  1106. ifneq (,$(KERNAPPSTHR))
  1107.     for i in $(notdir $(LIBRARIES_THREADED_STATIC)) ; do \
  1108.         install -m 755 lib/$$i $(libdir) ;\
  1109.     done
  1110. endif
  1111. endif
  1112. ifneq (,$(LIBRARIES_SHARED))
  1113.     for i in $(notdir $(LIBRARIES_SHARED)) ; do \
  1114.         install -m 755 lib/$$i $(libdir)/$$i.$(SO_FULLVER) ;\
  1115.         $(LN_S) $$i.$(SO_FULLVER) $(libdir)/$$i.$(SO_VER) ;\
  1116.         $(LN_S) $$i.$(SO_VER) $(libdir)/$$i ;\
  1117.     done
  1118. ifneq (,$(KERNAPPSTHR))
  1119.     for i in $(notdir $(LIBRARIES_THREADED_SHARED)) ; do \
  1120.         install -m 755 lib/$$i $(libdir)/$$i.$(SO_FULLVER) ;\
  1121.         $(LN_S) $$i.$(SO_FULLVER) $(libdir)/$$i.$(SO_VER) ;\
  1122.        $(LN_S) $$i.$(SO_VER) $(libdir)/$$i ;\
  1123.     done
  1124. endif
  1125. endif
  1126.  
  1127. ifdef TARGET_OS_DARWIN
  1128. #       TOC needs to be regenerated in libs after they get moved
  1129.     ranlib $(patsubst %,$(prefix)/%,$(LIBRARIES))
  1130. endif
  1131.  
  1132.     install -d $(bindir)
  1133.     install -m 755 $(ADMINTOOLS) $(bindir)
  1134.     install -m 755 $(USERTOOLS) $(bindir)
  1135.     # for compatibility in case anyone really wants "lsplus"
  1136.     $(LN_S) pvfs2-ls $(bindir)/pvfs2-lsplus
  1137.     install -m 755 src/apps/admin/pvfs2-config $(bindir)
  1138.     @# if we ever auto-generate genconfig, remove the $(srcdir)
  1139.     install -m 755 $(srcdir)/src/apps/admin/pvfs2-genconfig $(bindir)
  1140.     install -m 755 $(srcdir)/src/apps/admin/pvfs2-config-convert $(bindir)
  1141.     install -m 755 $(srcdir)/src/apps/admin/pvfs2-getmattr $(bindir)
  1142.     install -m 755 $(srcdir)/src/apps/admin/pvfs2-setmattr $(bindir)
  1143. ifdef BUILD_KARMA
  1144.     install -m 755 $(KARMA) $(bindir)
  1145. endif
  1146.  
  1147. ifdef BUILD_FUSE
  1148.     install -m 755 $(FUSE) $(prefix)/bin
  1149. endif
  1150.  
  1151.     # install any development tools built
  1152.     for i in $(notdir $(DEVELTOOLS)) ; do \
  1153.         if [ -f $(srcdir)/src/apps/devel/$$i ]; then install -m 755 $(srcdir)/src/apps/devel/$$i $(bindir); fi;\
  1154.     done
  1155.  
  1156.     install -d $(sbindir)
  1157.  
  1158. ifdef BUILD_SERVER
  1159.     install -m 755 $(ADMINTOOLS_SERVER) $(bindir)
  1160.     ifeq ($(NPTL_WORKAROUND),)
  1161.     install -m 755 $(SERVER) $(sbindir)
  1162.     else
  1163.     install -m 755 $(srcdir)/$(SERVER_STUB) $(sbindir)/pvfs2-server
  1164.     install -m 755 $(SERVER) $(sbindir)/pvfs2-server.bin
  1165.     endif
  1166. endif
  1167. endif
  1168.  
  1169. ifneq (,$(LINUX_KERNEL_SRC))
  1170.  
  1171. NUM_UTS_LINES := $(shell grep -c UTS_RELEASE $(LINUX_KERNEL_SRC)/include/linux/version.h)
  1172. ifeq ($(NUM_UTS_LINES),1)
  1173.     KERNEL_VERS := $(shell grep UTS_RELEASE $(LINUX_KERNEL_SRC)/include/linux/version.h | cut -d\" -f2)
  1174. else
  1175.     # multiple locations of utsrelease.h, just find and grep so we don't have to change again
  1176.     KERNEL_VERS := $(shell find ${LINUX_KERNEL_SRC}/include -name utsrelease.h -exec grep UTS_RELEASE '{}' \; | cut -d \" -f2 )
  1177. endif
  1178.  
  1179. KMOD_DIR ?= $(DESTDIR)/${kmod_prefix}/lib/modules/$(KERNEL_VERS)/kernel/fs/pvfs2
  1180.  
  1181. .PHONY: just_kmod_install
  1182. just_kmod_install: just_kmod
  1183.     install -d $(KMOD_DIR)
  1184.     install -m 755 src/kernel/linux-2.6/pvfs2.ko $(KMOD_DIR)
  1185.  
  1186. .PHONY: kmod_install
  1187. kmod_install: kmod kernapps just_kmod_install
  1188.     install -d $(sbindir)
  1189.     install -m 755 $(KERNAPPS) $(KERNAPPSTHR) $(sbindir)
  1190. endif
  1191.  
  1192. ifneq (,$(LINUX24_KERNEL_SRC))
  1193.  
  1194. NUM_UTS_LINES := $(shell grep -c UTS_RELEASE $(LINUX24_KERNEL_SRC)/include/linux/version.h)
  1195. ifeq ($(NUM_UTS_LINES),1)
  1196.     KERNEL_VERS := $(shell grep UTS_RELEASE $(LINUX24_KERNEL_SRC)/include/linux/version.h | cut -d\" -f2)
  1197. else
  1198.     KERNEL_VERS := $(shell uname -r)
  1199. endif
  1200. KMOD_DIR := $(DESTDIR)/lib/modules/$(KERNEL_VERS)/kernel/fs/pvfs2
  1201.  
  1202. .PHONY: just_kmod24_install
  1203. just_kmod24_install: just_kmod24
  1204.     install -d $(KMOD_DIR)
  1205.     install -m 755 src/kernel/linux-2.4/pvfs2.o $(KMOD_DIR)
  1206.  
  1207. .PHONY: kmod24_install
  1208. kmod24_install: kmod24 kernapps just_kmod24_install
  1209.     install -d $(sbindir)
  1210.     install -m 755 $(KERNAPPS) $(KERNAPPSTHR) $(sbindir)
  1211.     install -m 755 src/apps/kernel/linux/mount.pvfs2 $(sbindir)
  1212.     @echo ""
  1213.     @echo "For improved linux-2.4 support,"
  1214.     @echo "install $(sbindir)/mount.pvfs2 to /sbin/mount.pvfs2"
  1215.     @echo ""
  1216. endif
  1217.