home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Makefiles / app / common.make < prev    next >
Text File  |  1992-07-07  |  7KB  |  205 lines

  1. #
  2. # Workspace Manager common makefile
  3. #
  4.  
  5.  
  6. all::
  7.  
  8. SUPPORTFILES = IB.nproj Makefile makefile $(NAME).iconheader \
  9.     Makefile.preamble Makefile.postamble *.project SGS_ENV
  10.  
  11. SRCFILES = $(CLASSES) \
  12.     $(MFILES) $(CFILES) $(HFILES) $(PSWFILES) $(PSWMFILES) \
  13.     $(GLOBAL_RESOURCES) \
  14.     $(OTHERSRCS) $(OTHERLINKED) $(OTHER_SOURCEFILES)
  15.  
  16. EARLY_OFILES = $(PSWFILES:.psw=.o) $(PSWMFILES:.pswm=.o) 
  17.  
  18. INITIAL_TARGETS = $(OFILE_DIR) $(EARLY_OFILES) $(PRECOMPS) $(OTHER_INITIAL_TARGETS)
  19.  
  20. OFILES = $(CLASSES:.m=.o) $(MFILES:.m=.o) $(CFILES:.c=.o) \
  21.     $(EARLY_OFILES) $(SUBPROJECTS:.subproj=.o) $(OTHERLINKEDOFILES)
  22.  
  23. MAKEFILES = Makefile 
  24.  
  25. PRODUCT_DEPENDS = $(OFILES) $(OTHER_OFILES) $(ICONHEADER) \
  26.     $(APPICON) $(DOCICONS) $(MAKEFILES) \
  27.     $(OTHER_PRODUCT_DEPENDS)
  28.  
  29. GARBAGE = $(PSWFILES:.psw=.c) $(PSWMFILES:.pswm=.m) \
  30.     $(PSWFILES:.psw=.h) $(PSWMFILES:.pswm=.m) \
  31.     $(NAME) $(NAME).app $(NAME).debug $(NAME).profile $(NAME).bundle \
  32.     obj debug_obj profile_obj res debug_res profile_res \
  33.     Makefile.dependencies $(OTHER_GARBAGE) gmon.out *~ \
  34.     $(PRECOMPS) $(OTHER_INITIAL_TARGETS)
  35.  
  36. # Default name for file to use as "reference time of last build"
  37. CHANGES_FILE = $(PRODUCT_ROOT)/.lastBuildTime
  38.  
  39. # Defaults for who to chown executables to when installing
  40. INSTALL_AS_USER = root
  41. INSTALL_AS_GROUP = wheel
  42.  
  43. # Defaults for options to $(STRIP)
  44. RELOCATABLE_STRIP_OPTS = -x -u
  45. DYLD_APP_STRIP_OPTS = -A -n
  46. APP_STRIP_OPTS =   # Set this to $(DYLD_APP_STRIP_OPTS) when doing dynaloading yourself
  47.  
  48. # Various commands:
  49. SHELL  = /bin/sh
  50. FASTCP = /usr/lib/fastcp
  51. CHANGES = /usr/lib/changes
  52. CHOWN  = /etc/chown
  53. CHMOD  = /bin/chmod
  54. TAR    = /bin/tar
  55. STRIP  = /bin/strip
  56. RM     = /bin/rm
  57. ECHO   = /bin/echo
  58. MKDIRS = /bin/mkdirs
  59. TOUCH  = /usr/bin/touch
  60. AWK    = /bin/awk
  61.  
  62. ADAPTOR_SEARCH_PATH = $(HOME)/Library/Adaptors /LocalLibrary/Adaptors /NextLibrary/Adaptors
  63.  
  64. VPATH = $(OFILE_DIR):$(LANGUAGE).lproj:$(PRODUCT_ROOT)
  65.  
  66. .SUFFIXES: .h .m .c .psw .pswm .bproj .subproj .copy .installsrc .writable .clean .o .3le .depend .lproj
  67.  
  68. .bproj.copy:
  69.     @(cd $*.bproj; $(MAKE) copy "NAME=$*" "DEST=$(DEST)/$*.bproj")
  70. .subproj.copy:
  71.     @(cd $*.subproj; $(MAKE) copy "NAME=$*" "DEST=$(DEST)/$*.subproj")
  72.  
  73. .bproj.clean:
  74.     (cd $*.bproj; $(MAKE) clean "NAME=$*" "DEST=$(DEST)/$*.bproj")
  75. .subproj.clean:
  76.     (cd $*.subproj; $(MAKE) clean "NAME=$*" "DEST=$(DEST)/$*.subproj")
  77.  
  78. .bproj.depend:
  79.     (cd $*.bproj; $(MAKE) depend "NAME=$*")
  80. .subproj.depend:
  81.     (cd $*.subproj; $(MAKE) depend "NAME=$*")
  82.  
  83. # Compilation rules:
  84. .c.o:
  85.     $(CC) $(CFLAGS) -c $*.c -o $(OFILE_DIR)/$*.o
  86. .m.o:
  87.     $(CC) $(CFLAGS) $(OBJCFLAGS) -c $*.m -o $(OFILE_DIR)/$*.o
  88. .h.p:
  89.     $(CC) -precomp $(CFLAGS) $*.h -o $*.p
  90.  
  91. # pswrap-related rules:
  92. .psw.h:
  93.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.c $*.psw
  94. .psw.c:
  95.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.c $*.psw
  96. .psw.o:
  97.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.c $*.psw
  98.     $(CC) $(CFLAGS) -c $*.c -o $(OFILE_DIR)/$*.o
  99. .pswm.h:
  100.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.m $*.pswm
  101. .pswm.m:
  102.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.m $*.pswm
  103. .pswm.o:
  104.     $(PSWRAP) $(PSWFLAGS) -a -h $*.h -o $*.m $*.pswm
  105.     $(CC) $(CFLAGS) $(OBJCFLAGS) -c $*.m -o $(OFILE_DIR)/$*.o
  106.  
  107.  
  108. SRCROOT DEST:
  109.     @if [ -n "${$@}" ]; then exit 0; \
  110.     else $(ECHO) Must define $@; exit 1; fi
  111.  
  112. $(DEST)::
  113.     -$(RM) -rf $(DEST)
  114.     @$(MKDIRS) $(DEST)
  115.  
  116. $(NAME).copy:: DEST $(DEST)
  117.     @if [ "$(PROJECTVERSION)" -lt "1" -o "$(PROJECTVERSION)" = "1.0" ] ; then \
  118.         if [ "$(SRCFILES) $(CLASSES:.m=.h)" != "" ] ; then \
  119.            $(ECHO) "$(TAR) cf - $(SRCFILES) $(CLASSES:.m=.h) | (cd $(DEST); $(TAR) xf -)" ; \
  120.            $(TAR) cf - $(SRCFILES) $(CLASSES:.m=.h) | (cd $(DEST); $(TAR) xf -) ; \
  121.          fi ; \
  122.     else \
  123.         if [ "$(SRCFILES)" != "" ] ; then \
  124.            $(ECHO) "$(TAR) cf - $(SRCFILES) | (cd $(DEST); $(TAR) xf -)" ; \
  125.            $(TAR) cf - $(SRCFILES) | (cd $(DEST); $(TAR) xf -) ; \
  126.         fi ; \
  127.     fi
  128.     @supportfiles=""; \
  129.     $(MKDIRS) $(DEST)/$(LANGUAGE).lproj
  130.     if [ "$(LOCAL_RESOURCES)" != "" ] ; then \
  131.        (cd $(LANGUAGE).lproj; $(TAR) cf - $(LOCAL_RESOURCES)) | (cd $(DEST)/$(LANGUAGE).lproj; $(TAR) xf -) ; \
  132.     fi
  133.     for i in $(SUPPORTFILES) $(APPICON) $(DOCICONS) none ; do \
  134.         if [ -r $$i -a ! -r $(DEST)/$$i ] ; then \
  135.         supportfiles="$$supportfiles $$i" ; \
  136.         fi ; \
  137.     done ; \
  138.     if [ "$$supportfiles" != "" ] ; then \
  139.        $(ECHO) "$(TAR) cf - $$supportfiles | (cd $(DEST); $(TAR) xf -)" ; \
  140.        $(TAR) cf - $$supportfiles |3 $(DEST); $(TAR) xf -) ; \
  141.     fi
  142.  
  143. $(NAME).clean::
  144.     @if [ ! -w . ] ; then $(ECHO) '***' project write-protected; exit 1 ; fi
  145.     $(RM) -rf $(GARBAGE)
  146.  
  147.  
  148. # The following rule actually insures that resources for this particular level in the project hierarchy get copied over to the appropriate place in the PRODUCT_ROOT.  Note that we depend on VPATH including $(LANGUAGE).lproj so that the LOCAL_RESOURCES are found correctly.  FASTCP is used to minimize the copying of files, since most resources are likely to be up to date most of the time.
  149.  
  150. resources: $(LOCAL_RESOURCES) $(GLOBAL_RESOURCES) $(OTHER_RESOURCES)
  151.     @($(MKDIRS) $(PRODUCT_ROOT)/$(LANGUAGE).lproj ; \
  152.     if [ "$(LOCAL_RESOURCES)" != "" ] ; then \
  153.        $(FASTCP) $(LOCAL_RESOURCES) $(PRODUCT_ROOT)/$(LANGUAGE).lproj ; \
  154.     fi ; \
  155.     if [ "$(GLOBAL_RESOURCES)" != "" ] ; then \
  156.        $(FASTCP) $(GLOBAL_RESOURCES) $(PRODUCT_ROOT) ; \
  157.     fi )
  158.  
  159. # The following rule does the recursion into any subprojects or bundles of this (sub)project and does a 'make project' for each one in its respective directories.  This insures that we do not rely on the directory timestamp or "hacK" file to know whether or not something has changed.  
  160.  
  161. subcomponents::
  162.     @(targets=`$(CHANGES) $(CHANGES_FILE) $(SUBPROJECTS)` ; \
  163.     for sub in $$targets none ; do \
  164.        if [ $$sub = "none" ] ; then break; fi ;\
  165.        cd $$sub; $(ECHO) Making $$sub ; \
  166.        $(MAKE) project "NAME = $$sub" "PRODUCT_ROOT = ../$(PRODUCT_ROOT)" "OFILE_DIR = ../$(OFILE_DIR)" "CFLAGS = $(CFLAGS)" ; \
  167.        cd .. ; \
  168.     done ; \
  169.     targets=`$(CHANGES) $(CHANGES_FILE) $(BUNDLES)` ; \
  170.     for bun in $$targets none ; do \
  171.        if [ $$bun = "none" ] ; then break; fi ; \
  172.        cd $$bun; $(ECHO) Making $$bun ; \
  173.        $(MAKE) project "NAME = $$bun" "BUNDLE_DIR = ../$(PRODUCT_ROOT)/$$bun" "OFILE_DIR = $(OFILE_DIR)" "CFLAGS = $(CFLAGS)" ; \
  174.        cd .. ; \
  175.     done ; )
  176.  
  177. # Build a set of dependencies for current level into Makefile.dependencies 
  178.    
  179. Makefile.dependencies:: $(CLASSES) $(MFILES) $(CFILES)
  180.     $(RM) -f Makefile.dependencies
  181.     $(CC) -MM $(CFLAGS) $(CLASSES) $(MFILES) $(CFILES) | \
  182.         $(AWK) '{ if ($$1 != prev) { if (rec != "") print rec; \
  183.         rec = $$0; prev = $$1; } \
  184.         else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
  185.         else rec = rec " " $$2 } } \
  186.         END { print rec }' > Makefile.dependencies
  187.  
  188. copy:: $(NAME).copy $(BUNDLES:.bproj=.copy) $(SUBPR3TS:.subproj=.copy)
  189.  
  190. writable::
  191.     @chmod -R +w *
  192.  
  193. protected::
  194.     @chmod -R a-w *
  195.  
  196. installsrc:: SRCROOT
  197.     @($(MAKE) copy "DEST=$(SRCROOT)")
  198.  
  199. clean:: $(NAME).clean  $(BUNDLES:.bproj=.clean) $(SUBPROJECTS:.subproj=.clean)
  200.  
  201. $(OFILE_DIR):
  202.     @$(MKDIRS) $(OFILE_DIR)
  203.  
  204.  
  205.