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 < prev    next >
Makefile  |  1991-06-28  |  13KB  |  380 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 ../include/file_types.operation.h
  166. ../include/Substrate_file.h : ../include/file_types.includes.h
  167.  
  168. ../include/file_types.type.h : ../include/file_types.hierarchy
  169.     $(HIERARCHY) -voutput_type=type ../include/file_types.hierarchy > $@
  170.  
  171. ../include/file_types.includes.h : ../include/file_types.hierarchy
  172.     $(HIERARCHY) -voutput_type=general -vpreamble='#include "' \
  173.         -vpostamble='.h"' -vprint_first=1 ../include/file_types.hierarchy > $@
  174.  
  175. ../include/file_types.operation.h : ../include/file_types.hierarchy
  176.     (echo '#define FILE_TYPES_OPERATION(OPERATION)  \' ; \
  177.      $(HIERARCHY) -voutput_type=general -vpreamble='OPERATION(' \
  178.         -vpostamble=') \' -vprint_first=1 ../include/file_types.hierarchy ; \
  179.      echo ; ) | sed 's/\.//g' > $@ ;
  180.  
  181. #******************************************************************************
  182. # source files...
  183.  
  184. HEADERS := $(wildcard $(addprefix $(IDIR)/, $(addsuffix .h, $(USER_TYPES) $(HEADER_FILES))))
  185.  
  186. SOURCES := $(wildcard $(addsuffix .cc, $(USER_TYPES) $(SOURCE_FILES)))
  187.  
  188. OBJECTS := $(patsubst %.cc,%.o,$(SOURCES))
  189.  
  190. #******************************************************************************
  191. # User prototype instantiations
  192.  
  193. USER_PROTO_HEADERS := $(addprefix $(PC)/, $(addsuffix .h, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(IPP)/, $(addsuffix .hP, $(USER_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(USER_PROTO_TYPES)))))
  194.  
  195. USER_PROTO_SOURCES := $(addprefix $(PC)/, $(addsuffix .cc, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(IPP)/, $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(USER_PROTO_TYPES)))))
  196.  
  197. USER_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(USER_PROTO_SOURCES))
  198.  
  199. USER_PROTO_TYPE_SOURCES := $(wildcard $(addprefix $(IPP)/, $(addsuffix .hP, $(USER_BASE_PROTO_TYPES)) $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES))))
  200.  
  201. #******************************************************************************
  202. # libg++ prototype instantiations
  203.  
  204. LIB_PROTO_HEADERS := $(addprefix $(PC)/, $(addsuffix .h, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(LPP)/, $(addsuffix .hP, $(LIB_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(LIB_PROTO_TYPES)))))
  205.  
  206. LIB_PROTO_SOURCES := $(addprefix $(PC)/, $(addsuffix .cc, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(LPP)/, $(addsuffix .ccP, $(LIB_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(LIB_PROTO_TYPES)))))
  207.  
  208. LIB_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(LIB_PROTO_SOURCES))
  209.  
  210. .PHONY : test
  211. test :
  212.     @echo LIB_PROTO_TYPES = "${LIB_PROTO_TYPES}";
  213.     @echo LIB_BASE_PROTO_TYPES = "${LIB_BASE_PROTO_TYPES}" ;
  214.     @echo LIB_PROTO_OBJECTS = "${LIB_PROTO_OBJECTS}" ;
  215.     @echo LIB_PROTO_HEADERS = "${LIB_PROTO_HEADERS}" ;
  216.  
  217. #*****************************************************************************
  218. # main procedures..
  219.  
  220. # example:
  221. foo : foo.o $(OBJECTS) 
  222.     $(C++) $(C++FLAGS) -o $@ foo.o $(OBJECTS) $(LDIRS)
  223.  
  224. sources : $(SOURCES) 
  225.  
  226. #******************************************************************************
  227. # various cleanup stuff...
  228.  
  229. .PHONY : rmback clean realclean
  230.  
  231. rmback : 
  232.     cd .. ; rm -f proto/*~ include/*~ src/*~
  233.  
  234. clean : rmback
  235.     rm -f $(OBJECTS) $(PROTOLIB) $(LIB_PROTO_OBJECTS) $(USER_PROTO_OBJECTS)
  236.  
  237. realclean : clean
  238.     rm -f $(LIB_PROTO_SOURCES) $(USER_PROTO_SOURCES) $(LIB_PROTO_HEADERS) $(USER_PROTO_HEADERS)
  239.  
  240.  
  241. #*****************************************************************************
  242. # debugging actions
  243.  
  244. %.E : %.cc
  245.     $(C++) $(C++FLAGS) -E $(@D)$(basename $(@F)).cc > $@
  246.  
  247. %.s : %.cc
  248.     $(C++) -S $(C++FLAGS