home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / libg++-2.6-fsf.lha / libg++-2.6 / libg++ / proto-kit / Makefile.new < prev    next >
Makefile  |  1991-07-30  |  13KB  |  439 lines

  1. #******************************************************************************
  2. #  This GNUmakefile is useful for large and complex projects which involve
  3. # both G++ library prototypes, and prototypes added by the user(s).  It 
  4. # is assumed that certain conventions are followed.
  5. #
  6. # 1) each object has its own source and header files.  For example class W 
  7. #    would have W.h and W.cc
  8. #
  9. # 2) each prototype object has its own source and header files (W.hP and W.ccP)
  10. #
  11. # 3) object header files are contained in directory $(IDIR) (for Include
  12. #    DIRectory)
  13. #
  14. # 4) object source files are contained in the current directory
  15. #
  16. # 5) prototype instantiations are contained in $(PC) (for Prototype C++
  17. #    directory)
  18. #
  19. # 6) user prototype files (both header and source) are contained in $(IPP)
  20. #
  21. # 7) non-class code is contained in .h and .cc files, which live in $(IDIR)
  22. #    and the current directory respectively
  23. #
  24. # *) as an extra, I have added the convention that whenever a W.cc file
  25. #    is being compiled, the macro _W_cc is defined.  This is useful
  26. #    particularly for conditional parts of header files (for example,
  27. #    W.h could have ifdef _W_cc ...
  28. #
  29. # The makefile works in the following manner: the source dependencies are
  30. # contained in .Makefile.S_DEP, while the (machine generated) object 
  31. # dependencies are contained in .Makefile.O_DEP.  The types needed by
  32. # the program are defined by several variables, and the makefile generates
  33. # the necessary dependencies (both source and object) from those variables.
  34. # The prototype lists are contained in .Makefile.TYPES.
  35. # NOTE: in order to create the machine generated files .Makefile.TYPES,
  36. #  .Makefile.S_DEP, and .Makefile.O_DEP, empty versions of these
  37. #  file must exist.  They can be easily created using "touch <file>".
  38. #
  39. #  -- Carl Staelin
  40. #     staelin@princeton.edu
  41. #******************************************************************************
  42.  
  43. #******************************************************************************
  44. # standard Makefile definitions
  45.  
  46. comma := ,
  47. space := $(empty) $(empty)
  48. tab := $(empty)    $(empty)
  49.  
  50. #******************************************************************************
  51. # definitions from environment variables
  52.  
  53. # the CPATH include directories 
  54. cpath-include-directories := $(addprefix -I, $(subst :,$(space),$(CPATH)))
  55.  
  56. # the LPATH load directories 
  57. lpath-load-directories := $(addprefix -L, $(subst :,$(space),$(LPATH)))
  58.  
  59. #******************************************************************************
  60. # Basic definitions
  61.  
  62. HOST := $(shell hostname)
  63.  
  64. BASE := 
  65.  
  66. # CMU Directories
  67. USR  := $(BASE)/usr
  68. MACH := $(BASE)/usr/mach
  69. CS   := $(BASE)/usr/cs
  70.  
  71. # GNU directories
  72. GNULIBDIR := $(BASE)/usr/local/lib
  73. GNUIDIR := $(GNULIBDIR)/g++-include
  74.  
  75. # the g++ library prototypes...
  76. LPP := $(GNUIDIR)
  77. PC := ../libg++
  78.  
  79. # the user's library prototypes...
  80. IPP := ../proto
  81.  
  82. # the include directory
  83. IDIR := ../include
  84.  
  85. # the include directories needed...
  86. IDIRS := -I$(IDIR) -I$(PC) -I$(GNUIDIR) $(cpath-include-directories) 
  87.  
  88. # the directories where the libraries live...
  89. LDIRS := $(lpath-load-directories)
  90.  
  91. #******************************************************************************
  92. # standard function (and associated variables) definitions
  93.  
  94. C++ = g++
  95. C++FLAGS = -pipe -O $(IDIRS) 
  96.         -Dc_plusplus \
  97.         -DDEBUG \
  98.         -D$(strip $(subst .,_, _$(basename $(@F))_cc)) 
  99.  
  100.  
  101. GENCLASS = ../bin/genclass.extnsn
  102. PREPEND  = ../bin/prepend
  103. HIERARCHY    = ../bin/hierarchy
  104. MAKE_TYPES    = ../bin/make-types
  105. PROTOTYPE    = ../bin/prototype
  106.  
  107. #******************************************************************************
  108. # implicit rules
  109.  
  110. %.o : %.cc
  111.     $(C++)    $(C++FLAGS) \
  112.         -c -o $@ $(@D)$(basename $(@F)).cc
  113.  
  114. #******************************************************************************
  115. # User types
  116.  
  117. BASIC_TYPES = \
  118.     int \
  119.     u_int \
  120.     l_int \
  121.     l_u_int 
  122.  
  123. # generated by this make file (initially create an empty .Makefile.TYPES
  124. # so that "make dependencies" can create the real file)
  125. include .Makefile.TYPES
  126.  
  127. #******************************************************************************
  128. # User types (with sample values filled in) 
  129. # NOTE: do NOT add .h to the end of these, MAKE does it for you!
  130.  
  131. HEADER_FILES = \
  132.     disk_set \
  133.     file_types \
  134.     include \
  135.     inode \
  136.     inode_t \
  137.     lib \
  138.     main \
  139.     nfs_functions \
  140.     nfs_mount \
  141.     nfs_params \
  142.     nfs_prot \
  143.     system 
  144.  
  145. SOURCE_FILES = \
  146.     disk_set \
  147.     lib \
  148.     nfs_auxil \
  149.     nfs_dirent \
  150.     nfs_fh \
  151.     nfs_ipcress \
  152.     nfs_links \
  153.     nfs_main \
  154.     nfs_mnt_serv \
  155.     nfs_mount_xdr \
  156.     nfs_prot_xdr \
  157.     nfs_serv1 \
  158.     nfs_serv2 \
  159.     nfs_serv3 \
  160.     nfs_serv4 \
  161.  
  162. #******************************************************************************
  163. # some sample machine generated user-file stuff
  164. #
  165. ../include/file_types.h : ../include/file_types.type.h \
  166.               ../include/file_types.operation.h
  167. ../include/Substrate_file.h : ../include/file_types.includes.h
  168.  
  169. ../include/file_types.type.h : ../include/file_types.hierarchy
  170.     $(HIERARCHY) -voutput_type=type ../include/file_types.hierarchy > $@
  171.  
  172. ../include/file_types.includes.h : ../include/file_types.hierarchy
  173.     $(HIERARCHY) -voutput_type=general -vpreamble='#include "' \
  174.      -vpostamble='.h"' -vprint_first=1 ../include/file_types.hierarchy > $@
  175.  
  176. ../include/file_types.operation.h : ../include/file_types.hierarchy
  177.     (echo '#define FILE_TYPES_OPERATION(OPERATION)  \' ; \
  178.      $(HIERARCHY) -voutput_type=general -vpreamble='OPERATION(' \
  179.       -vpostamble=') \' -vprint_first=1 ../include/file_types.hierarchy ; \
  180.       echo ; ) | sed 's/\.//g' > $@ ;
  181.  
  182. #******************************************************************************
  183. # source files...
  184.  
  185. HEADERS := $(wildcard $(addprefix $(IDIR)/, $(addsuffix .h, \
  186.                                           $(USER_TYPES) $(HEADER_FILES))))
  187.  
  188. SOURCES := $(wildcard $(addsuffix .cc, $(USER_TYPES) $(SOURCE_FILES)))
  189.  
  190. OBJECTS := $(patsubst %.cc,%.o,$(SOURCES))
  191.  
  192. #******************************************************************************
  193. # User prototype instantiations
  194.  
  195. USER_PROTO_HEADERS := \
  196.     $(addprefix $(PC)/,     \
  197.       $(addsuffix .h,       \
  198.         $(foreach type,     \
  199.           $(basename        \
  200.             $(notdir        \
  201.               $(wildcard     \
  202.             $(addprefix $(IPP)/,                     \
  203.                         $(addsuffix .hP,                \
  204.                             $(USER_BASE_PROTO_TYPES)))))),  \
  205.           $(filter %.$(type), $(USER_PROTO_TYPES)))))
  206.  
  207. USER_PROTO_SOURCES := \
  208.     $(addprefix $(PC)/,         \
  209.       $(addsuffix .cc,        \
  210.         $(foreach type,        \
  211.           $(basename         \
  212.             $(notdir        \
  213.           $(wildcard         \
  214.             $(addprefix $(IPP)/,\
  215.                     $(addsuffix .ccP,        \
  216.                   $(USER_BASE_PROTO_TYPES)))))),\
  217.            $(filter %.$(type), $(USER_PROTO_TYPES)))))
  218.  
  219. USER_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(USER_PROTO_SOURCES))
  220.  
  221. USER_PROTO_TYPE_SOURCES := \
  222.     $(wildcard                    \
  223.       $(addprefix $(IPP)/,                \
  224.         $(addsuffix .hP, $(USER_BASE_PROTO_TYPES))  \
  225.         $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES))))
  226.  
  227. #******************************************************************************
  228. # libg++ prototype instantiations
  229.  
  230. LIB_PROTO_HEADERS := \
  231.      $(addprefix $(PC)/,                        \
  232.        $(addsuffix .h,                        \
  233.          $(foreach type,                        \
  234.            $(basename                        \
  235.          $(notdir                        \
  236.            $(wildcard                        \
  237.              $(addprefix $(LPP)/,                \
  238.                $(addsuffix .hP, $(LIB_BASE_PROTO_TYPES)))))),    \
  239.            $(filter %.$(type), $(LIB_PROTO_TYPES)))))
  240.  
  241. LIB_PROTO_SOURCES := \
  242.     $(addprefix $(PC)/,                         \
  243.       $(addsuffix .cc,                        \
  244.         $(foreach type,                        \
  245.           $(basename                        \
  246.             $(notdir                        \
  247.           $(wildcard                        \
  248.             $(addprefix $(LPP)/,                \
  249.               $(addsuffix .ccP, $(LIB_BASE_PROTO_TYPES)))))),
  250.           $(filter %.$(type), $(LIB_PROTO_TYPES)))))
  251.  
  252. LIB_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(LIB_PROTO_SOURCES))
  253.  
  254. .PHONY : test
  255. test :
  256.     @echo LIB_PROTO_TYPES = "${LIB_PROTO_TYPES}";
  257.     @echo LIB_BASE_PROTO_TYPES = "${LIB_BASE_PROTO_TYPES}" ;
  258.     @echo LIB_PROTO_OBJECTS = "${LIB_PROTO_OBJECTS}" ;
  259.     @echo LIB_PROTO_HEADERS = "${LIB_PROTO_HEADERS}" ;
  260.  
  261. #*****************************************************************************
  262. # main procedures..
  263.  
  264. # example:
  265. foo : foo.o $(OBJECTS) 
  266.     $(C++) $(C++FLAGS) -o $@ foo.o $(OBJECTS) $(LDIRS)
  267.  
  268. sources : $(SOURCES) 
  269.  
  270. #******************************************************************************
  271. # various c