home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Makefiles / app / bundle.make < prev    next >
Encoding:
Text File  |  1993-07-14  |  9.8 KB  |  261 lines

  1. #
  2. #                                 bundle.make
  3. #
  4. # Inputs from Makefile.preamble (no defaults):
  5. #    BUNDLELDFLAGS - Additional flags passed to ld when linking bundles
  6. #    OTHER_CFLAGS - Flags passed to compiler (in addition to -g, -O, etc.)
  7. #    OTHER_LDFLAGS - Flags passed to ld (in addition to -ObjC, etc.)
  8. #    OTHER_OFILES - Additional relocatables that may be linked in
  9. #    OTHER_PRODUCT_DEPENDS - Other dependencies of this project
  10. #    OTHER_SOURCEFILES - Other source files maintained by .pre/postamble
  11. #    OTHER_GARBAGE - Additional files to be removed by make 'clean' 
  12. #
  13. #    MSGFILES - .msg files that should have msgwrap run on them
  14. #    DEFSFILES - .defs files that should have mig run on them
  15. #    MIGFILES - .mig files (no .defs files) that should have mig run on them
  16. #
  17. #    PRECOMPS - Precompiled headers that should be built before compilation 
  18. #    OTHER_INITIAL_TARGETS - Targets to be built before subprojects, etc.
  19. #
  20. #    DSTROOT - Virtual root directory prepended to $(INSTALLDIR)
  21. #
  22. # Inputs from Makefile.postamble (with defaults set by this file):
  23. #    MAKEFILES - Makefiles this project depends on (default = Makefile)
  24. #    DEFAULT_CFLAGS - All compiler flags for this level (default set below)
  25. #
  26. # Inputs from Makefile (avoid setting these, ProjectBuilder controls them):
  27. #    NAME - name of application
  28. #    LANGUAGE - langage in which the project is written (default "English")
  29. #    LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
  30. #    GLOBAL_RESOURCES - non-localized resources of project
  31. #
  32. #    CLASSES - Class implementation files in project.
  33. #    HFILES - Header files in project.
  34. #    MFILES - Other Objective-C source files in project. 
  35. #    CFILES - Other C source files in project. 
  36. #    PSWFILES - .psw files in the project
  37. #    PSWMFILES - .pswm files in the project
  38. #    SUBPROJECTS - Subprojects of this project
  39. #    BUNDLES - Bundle subprojects of this project
  40. #    OTHERSRCS - Other miscellaneous sources of this project
  41. #    OTHERLINKED - Source files not matching a standard source extention
  42. #    OTHERLINKEDOFILES - Other relocatable files to (always) link in.
  43. #
  44. #    APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles
  45. #    MAKEFILEDIR - Directory in which to find $(MAKEFILE)
  46. #    MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make)
  47. #    INSTALLDIR - Directory app will be installed into by 'install' target
  48. #
  49.  
  50.  
  51. # Defaults for NeXT-specific Release Control options
  52. SRCROOT = .
  53. SYMROOT = .
  54. OBJROOT = .
  55.  
  56. # Set these in case this is a standalone case (much of this cruftiness has to do with sh's inability to operate on $$bun in the common.make subcomponents rule)
  57.  
  58. DOT = .
  59. BUNDLE_DIR = $(SYMROOT)/$(NAME).bproj
  60. PRODUCT_ROOT_WITHOUT_EXT = $(BUNDLE_DIR:.bproj=)
  61. PRODUCT_ROOT = $(PRODUCT_ROOT_WITHOUT_EXT).$(BUNDLE_EXTENSION)
  62. BUNDLE = $(PRODUCT_ROOT)/$(NAME:.bproj=)
  63.  
  64. # ...and relative versions for installing the bundle.
  65. REL_BUNDLE_DIR = $(NAME).bproj
  66. REL_PRODUCT_ROOT = $(REL_BUNDLE_DIR:.bproj=).$(BUNDLE_EXTENSION)
  67. REL_BUNDLE = $(REL_PRODUCT_ROOT)/$(NAME:.bproj=)
  68.  
  69. APP_MAKEFILE_DIR = /NextDeveloper/Makefiles/app
  70. include $(APP_MAKEFILE_DIR)/common.make
  71. include $(APP_MAKEFILE_DIR)/specialrules.make
  72.  
  73. all bundle:: 
  74.     @($(process_target_archs)_obj ; \
  75.     $(set_bundle_ext) ; \
  76.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  77.         language_cflags='' ; \
  78.     else \
  79.         language_cflags='-DKANJI' ; \
  80.     fi ; \
  81.     $(MAKE) actual_project \
  82.         "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  83.         "PROJ_CFLAGS = $(NORMAL_CFLAGS) $$language_cflags" \
  84.         "MAKEFILEDIR = $(MAKEFILEDIR)" \
  85.         "BUNDLE_EXTENSION = $$bundle_ext" \
  86.         "RC_CFLAGS = $$arch_cflags" \
  87.         "RC_ARCHS = $$archs" \
  88.         "SRCROOT = $(SRCROOT)" \
  89.         "OBJROOT = $(OBJROOT)" \
  90.         "PRODUCT_ROOT = $(PRODUCT_ROOT_WITHOUT_EXT).$$bundle_ext" \
  91.         "SYMROOT = $(SYMROOT)/sym" \
  92.         "SYM_DIR = $(SYMROOT)/sym" )
  93.  
  94. debug::
  95.     @($(process_target_archs)_debug_obj ; \
  96.     $(set_bundle_ext) ; \
  97.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  98.         language_cflags='' ; \
  99.     else \
  100.         language_cflags='-DKANJI' ; \
  101.     fi ; \
  102.     $(MAKE) actual_project \
  103.         "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  104.         "PROJ_CFLAGS = $(DEBUG_CFLAGS) $$language_cflags" \
  105.         "MAKEFILEDIR = $(MAKEFILEDIR)" \
  106.         "BUNDLE_EXTENSION = $$bundle_ext" \
  107.         "RC_CFLAGS = $$arch_cflags" \
  108.         "RC_ARCHS = $$archs" \
  109.         "SRCROOT = $(SRCROOT)" \
  110.         "OBJROOT = $(OBJROOT)" \
  111.         "PRODUCT_ROOT = $(PRODUCT_ROOT_WITHOUT_EXT).$$bundle_ext" \
  112.         "SYMROOT = $(SYMROOT)/sym" \
  113.         "SYM_DIR = $(SYMROOT)/sym" )
  114.  
  115. # The 'project' target should set BUNDLE_EXTENSION as appropriate. We need an
  116. # extra level of recursion here to insure this hhappens when this bundle is 
  117. # part of an app.  Note that the variables passed hrough here must match those 
  118. # in the bundle target in common.make.
  119.  
  120. project:: 
  121.     @($(set_bundle_ext) ; \
  122.     $(MAKE) actual_project "NAME = $(NAME)" \
  123.                 "TOP_PRODUCT_ROOT = $(TOP_PRODUCT_ROOT)" \
  124.                        "BUNDLE_DIR = $(BUNDLE_DIR)" \
  125.                        "REL_BUNDLE_DIR = $(REL_BUNDLE_DIR)" \
  126.                "OFILE_DIR = $(OFILE_DIR)" \
  127.                "SYM_DIR = $(SYM_DIR)" \
  128.                "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  129.                "BUNDLE_EXTENSION = $$bundle_ext" \
  130.                "SRCROOT = $(SRCROOT)" \
  131.                "OBJROOT = $(OBJROOT)" \
  132.                "SYMROOT = $(SYMROOT)" \
  133.                "PROJ_CFLAGS = $(PROJ_CFLAGS)" \
  134.                "RC_CFLAGS = $(RC_CFLAGS)" )
  135.  
  136. actual_project:: $(INITIAL_TARGETS) subprojs bundles tools resources $(BUNDLE)
  137.  
  138. TEMP_C_FILE = $(SYM_DIR)/$(NAME:.bproj=)_empty.c
  139.  
  140. $(BUNDLE): $(PRODUCT_DEPENDS) $(PRODUCT_ROOT) $(SYM_DIR)
  141.     @(if [ "`$(ECHO) $(OFILES) $(OTHER_OFILES) | wc -w`" != "       0" ] ; then \
  142.        cmd="$(CC) $(ALL_CFLAGS) -nostdlib $(BUNDLELDFLAGS) $(OFILES) $(OTHER_OFILES) -r -o $(BUNDLE)" ; \
  143.        echo $$cmd ; $$cmd ; \
  144.     else \
  145.        $(ECHO) Warning: Building empty bundle. ; \
  146.        $(RM) -f $(TEMP_C_FILE) ; \
  147.        $(TOUCH) $(TEMP_C_FILE) ; \
  148.        $(CC) $(ALL_CFLAGS) -c $(TEMP_C_FILE) -o $(BUNDLE) ; \
  149.        $(RM) -f $(TEMP_C_FILE) ; \
  150.     fi ; \
  151.     $(CHMOD) a+x $(BUNDLE) )
  152.  
  153. depend:: Makefile.dependencies $(SUBPROJECTS:.subproj=.depend) $(BUNDLES:.bproj=.depend)
  154.  
  155. $(PRODUCT_ROOT) \
  156. $(DSTROOT)$(INSTALLDIR):
  157.     $(MKDIRS) $@
  158.  
  159. THING_TO_STRIP = $(DSTROOT)$(PARENT_DIR)/$(NAME:.bproj=).$$bundle_ext/$(NAME:.bproj=)
  160.  
  161. strip_myself::
  162.     @($(set_bundle_ext) ; \
  163.     if [ -f $(THING_TO_STRIP) ] ; then \
  164.         cmd="$(STRIP) $(RELOCATABLE_STRIP_OPTS) $(THING_TO_STRIP)" ; \
  165.         echo $$cmd ; $$cmd ; \
  166.     else \
  167.         echo Warning: Not able to strip $(THING_TO_STRIP) ; \
  168.     fi)
  169.  
  170. .bproj.strip .tproj.strip:
  171.     @($(set_bundle_ext) ; \
  172.     cd $<; \
  173.     $(MAKE) strip "DSTROOT = $(DSTROOT)" \
  174.               "PARENT_DIR = $(PARENT_DIR)/$(NAME:.bproj=).$$bundle_ext" \
  175.               "NAME=$*")
  176.  
  177.  
  178. before_install:: $(DSTROOT)$(INSTALLDIR)
  179.     @($(set_bundle_ext) ; \
  180.     cmd="$(RM) -rf $(DSTROOT)$(INSTALLDIR)/$(REL_BUNDLE_DIR:.bproj=).$$bundle_ext" ; \
  181.     echo $$cmd ; $$cmd )
  182.  
  183. after_install::
  184.  
  185. # Note that the following will not correctly install a standalone
  186. # bundle under a Jasper build.  
  187.  
  188. install:: bundle before_install installhdrs $(OTHER_INSTALL_DEPENDS)
  189.     @($(set_bundle_ext) ; \
  190.         bundle_dir_name_base=$(REL_BUNDLE_DIR:.bproj=) ; \
  191.     bundle_dir_name=$$bundle_dir_name_base.$$bundle_ext ; \
  192.     $(MKDIRS) $(DSTROOT)$(INSTALLDIR) ; \
  193.     $(ECHO) Tar\'ing $$bundle_dir_name to $(DSTROOT)$(INSTALLDIR) ; \
  194.     (cd $(SYMROOT); $(TAR) chf - $$bundle_dir_name) | \
  195.         (cd $(DSTROOT)$(INSTALLDIR); $(TAR) xf -) ; \
  196.     $(MAKE) strip "DSTROOT = $(DSTROOT)" \
  197.               "PARENT_DIR = $(INSTALLDIR)" ; \
  198.     $(RM) -f $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name/$(CHANGES_FILE); \
  199.     cmd="$(CHOWN) -Rf $(INSTALL_AS_USER).$(INSTALL_AS_GROUP) $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name" ; \
  200.     $(ECHO) $$cmd ; \
  201.     $$cmd || $(ECHO) Couldn\'t chown $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name ; \
  202.     cmd="$(CHMOD) -Rf go-w $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name" ; \
  203.     $(ECHO) $$cmd ; \
  204.     $$cmd || $(ECHO) Couldn\'t chmod $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name ; \
  205.     if [ "$(INSTALL_PERMISSIONS)" != "" ] ; then \
  206.         $(ECHO) $(CHMOD) -f $(INSTALL_PERMISSIONS) \
  207.           $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name; \
  208.         $(CHMOD) -f $(INSTALL_PERMISSIONS) \
  209.           $(DSTROOT)$(INSTALLDIR)/$$bundle_dir_name; \
  210.     fi ; \
  211.     $(process_target_archs)_obj ; \
  212.     $(MAKE) after_install     "DSTROOT=$(DSTROOT)" \
  213.                        "OBJROOT=$(OBJROOT)" \
  214.                        "SYMROOT=$(SYMROOT)" \
  215.                 "INSTALLDIR = $(INSTALLDIR)" \
  216.                 "PRODUCT_ROOT = $(PRODUCT_ROOT)" \
  217.                 "REL_PRODUCT_ROOT = $$bundle_dir_name" \
  218.                 "SYM_DIR = $(SYMROOT)/sym" \
  219.                 "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  220.                 "PROJ_CFLAGS = $(NORMAL_CFLAGS)" \
  221.                 "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  222.                 "BUNDLE_EXTENSION = $$bundle_ext" \
  223.                 "RC_CFLAGS = $$arch_cflags" \
  224.                 "RC_ARCHS = $$archs" )
  225.  
  226.  
  227.  
  228. #.DEFAULT 
  229.  
  230. help:
  231.     @if (test "$<"); then        \
  232.         $(ECHO) 'ERROR: Unrecognized Makefile target "$<"';    \
  233.     fi
  234.     @$(ECHO) 'The following targets are available:'
  235.     @$(ECHO) 
  236.     @$(ECHO) ' all         Makes the bundle target (below).  This is the default target.'
  237.     @$(ECHO) 
  238.     @$(ECHO) ' bundle      Compiles and links an optimized (and debuggable) version of the'
  239.     @$(ECHO) '             bundle into $(NAME).$(BUNDLE_EXTENSION)'
  240.     @$(ECHO)     
  241.     @$(ECHO) ' depend      Generates an optional Makefile.dependencies file for every level'
  242.     @$(ECHO) '             of the bundle to reflect the complete dependency graph'
  243.     @$(ECHO) '             (including headers).'
  244.     @$(ECHO) 
  245.     @$(ECHO) ' install     Builds (if needed) and copies <BundleName>.$(BUNDLE_EXTENSION)'
  246.     @$(ECHO) '             into the installation directory, setting permissions'
  247.     @$(ECHO) '             and owners as appropriate.'
  248.     @$(ECHO)     
  249.     @$(ECHO) ' installsrc  Installs the source files for the bundle into the directory'
  250.     @$(ECHO) '             specified in the SRCROOT variable in a command-line argument.'
  251.     @$(ECHO) '             Note: the target directory will be removed and recreated.'
  252.     @$(ECHO) 
  253.     @$(ECHO) ' installhdrs Installs the header files for the bundle.'
  254.     @$(ECHO) 
  255.     @$(ECHO) ' clean       Removes all files in the bundle derived from previous builds.'
  256.     @$(ECHO) 
  257.     @$(ECHO) ' help        Lists these targets with their descriptions.'
  258.     @$(ECHO) 
  259.     @$(ECHO) 'For more details, see the comments in /NextDeveloper/Makefiles/app/*.make.'
  260.     
  261.