home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Makefiles / app / app.make next >
Encoding:
Text File  |  1993-07-15  |  12.6 KB  |  319 lines

  1. #
  2. #                                  app.make
  3. #
  4. # Inputs from Makefile.preamble (no defaults):
  5. #    OTHER_CFLAGS - Flags passed to compiler (in addition to -g, -O, etc.)
  6. #    OTHER_LDFLAGS - Flags passed to ld (in addition to -ObjC, etc.)
  7. #    OTHER_OFILES - Additional relocatables that may be linked in
  8. #    OTHER_LIBS - Libraries to link with when making app target
  9. #    OTHER_DEBUG_LIBS - Libraries to link with when making debug target
  10. #    OTHER_PROF_LIBS - Libraries to link with when making profile target
  11. #    OTHER_JAPANESE_LIBS - 'app' libraries when $(JAPANESE) = "YES"
  12. #    OTHER_JAPANESE_DEBUG_LIBS - 'debug' libraries when $(JAPANESE) = "YES"
  13. #    OTHER_JAPANESE_PROF_LIBS - 'profile' libs when $(JAPANESE) = "YES"
  14. #    OTHER_PRODUCT_DEPENDS - Other dependencies of this project
  15. #    OTHER_SOURCEFILES - Other source files maintained by .pre/postamble
  16. #    OTHER_GARBAGE - Additional files to be removed by make 'clean' 
  17. #
  18. #    MSGFILES - .msg files that should have msgwrap run on them
  19. #    DEFSFILES - .defs files that should have mig run on them
  20. #    MIGFILES - .mig files (no .defs files) that should have mig run on them
  21. #
  22. #    PRECOMPS - Precompiled headers that should be built before compilation 
  23. #    OTHER_INITIAL_TARGETS - Targets to be built before subprojects, etc.
  24. #
  25. #    DSTROOT - Virtual root directory prepended to $(INSTALLDIR)
  26. #
  27. # Inputs from Makefile.postamble (with defaults set in common.make):
  28. #    OPTIMIZATION_CFLAG - Optimization flag passed to compiler (default: -O)
  29. #    NORMAL_CFLAGS - Flags passed to compiler in normal compiles
  30. #    DEBUG_CFLAGS - Flags passed to compiler in 'debug' compiles
  31. #    PROFILE_CFLAGS - Flags passed to compiler in 'profile' compiles
  32. #    INSTALL_AS_USER - User to chown app to at installation (default root)
  33. #    INSTALL_AS_GROUP - Grp to chgrp app to at installation (default wheel)
  34. #    INSTALL_PERMISSIONS - If set, 'install' chmod's executable to this.
  35. #    MAKEFILES - Makefiles this project depends on (default = Makefile)
  36. #
  37. #    RELOCATABLE_STRIP_OPTS - Opts to strip for bundles (default = -x -u)
  38. #    DYLD_APP_STRIP_OPTS - Opts to strip for apps w/ bundles (def. = -A -n)
  39. #    APP_STRIP_OPTS - Opts to strip for apps w/o bundles (no default, but
  40. #          developers doing their own dynamic loading should set this to 
  41. #          $(DYLD_APP_STRIP_OPTS)
  42. #    BUNDLE_EXTENSION - Extension for name of bundle dir (default = bundle)
  43. #
  44. # Inputs from Makefile (avoid setting these, ProjectBuilder controls them):
  45. #    NAME - name of application
  46. #    LANGUAGE - langage in which the project is written (default "English")
  47. #    ENGLISH - boolean flag set iff $(LANGUAGE) = "English"
  48. #    JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese"
  49. #    LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
  50. #    GLOBAL_RESOURCES - non-localized resources of project
  51. #    PROJECTVERSION - version of ProjectBuilder that output Makefile
  52. #    APPICON - application icon file
  53. #    DOCICONS - dock icon files
  54. #    ICONSECTIONS - Specifies icon sections when linking executable 
  55. #
  56. #    CLASSES - Class implementation files in project.
  57. #    HFILES - Header files in project.
  58. #    MFILES - Other Objective-C source files in project. 
  59. #    CFILES - Other C source files in project. 
  60. #    PSWFILES - .psw files in the project
  61. #    PSWMFILES - .pswm files in the project
  62. #    SUBPROJECTS - Subprojects of this project
  63. #    BUNDLES - Bundle subprojects of this project
  64. #    OTHERSRCS - Other miscellaneous sources of this project
  65. #    OTHERLINKED - Source files not matching a standard source extention
  66. #
  67. #    LIBS - Libraries to link with when making app target
  68. #    DEBUG_LIBS - Libraries to link with when making debug target
  69. #    PROF_LIBS - Libraries to link with when making profile target
  70. #    OTHERLINKEDOFILES - Other relocatable files to (always) link in.
  71. #
  72. #    APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles
  73. #    MAKEFILEDIR - Directory in which to find $(MAKEFILE)
  74. #    MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make)
  75. #    INSTALLDIR - Directory app will be installed into by 'install' target
  76. #
  77.  
  78. APPICONFLAGS =  -sectcreate __ICON __header $(NAME).iconheader  \
  79.         -segprot __ICON r r $(ICONSECTIONS) \
  80.                 $(OTHER_ICONSECTIONS)
  81.  
  82. ICONHEADER = $(NAME).iconheader
  83. PRODUCT_ROOT = $(SYMROOT)/$(NAME).app
  84.  
  85. APP_MAKEFILE_DIR = /NextDeveloper/Makefiles/app
  86. include $(APP_MAKEFILE_DIR)/common.make
  87.  
  88.  
  89. all:: app
  90.  
  91.  
  92.     
  93. app::
  94.     @($(MKDIRS) $(SYMROOT)/$(NAME).app ; \
  95.      $(process_target_archs)_obj ; \
  96.     $(set_bundle_ext) ; \
  97.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  98.         language_cflags="" ; \
  99.         libs="$(LIBS)" ; \
  100.         other_libs="$(OTHER_LIBS)" ; \
  101.     else \
  102.         language_cflags="-DKANJI" ; \
  103.         libs="$(LIBS:lNeXT_s=lNeXTJ_s)" ; \
  104.         other_libs="$(OTHER_LIBS:lNeXT_s=lNeXTJ_s)" ; \
  105.     fi ; \
  106.     $(MAKE) project \
  107.         "PRODUCT_ROOT = $(SYMROOT)/$(NAME).app" \
  108.         "TOP_PRODUCT_ROOT = $(SYMROOT)/$(NAME).app" \
  109.         "PRODUCT = $(SYMROOT)/$(NAME).app/$(NAME)" \
  110.         "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  111.         "PROJ_CFLAGS = $(NORMAL_CFLAGS) $$language_cflags" \
  112.         "LIBS = $$libs" \
  113.         "OTHER_LIBS = $$other_libs" \
  114.         "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  115.         "BUNDLE_EXTENSION = $$bundle_ext" \
  116.         "RC_CFLAGS = $$arch_cflags" \
  117.         "RC_ARCHS = $$archs" \
  118.         "SRCROOT = $(SRCROOT)" \
  119.         "OBJROOT = $(OBJROOT)" \
  120.         "SYMROOT = $(SYMROOT)/sym" \
  121.         "SYM_DIR = $(SYMROOT)/sym" )
  122.  
  123. debug::
  124.     @($(MKDIRS) $(NAME).debug ; \
  125.      $(process_target_archs)_debug_obj ; \
  126.     $(set_bundle_ext) ; \
  127.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  128.         language_cflags="" ; \
  129.         libs="$(DEBUG_LIBS)" ; \
  130.         other_libs="$(OTHER_DEBUG_LIBS)" ; \
  131.         other_japanese_libs="" ; \
  132.     else \
  133.         language_cflags="-DKANJI" ; \
  134.         libs="$(DEBUG_LIBS:lNeXT_s=lNeXTJ_s)" ; \
  135.         other_libs="$(OTHER_DEBUG_LIBS:lNeXT_s=lNeXTJ_s)" ; \
  136.         other_japanese_libs="$(OTHER_JAPANESE_DEBUG_LIBS)" ; \
  137.     fi ; \
  138.     $(MAKE) project \
  139.         "PRODUCT_ROOT = $(SYMROOT)/$(NAME).debug" \
  140.         "TOP_PRODUCT_ROOT = $(SYMROOT)/$(NAME).debug" \
  141.         "PRODUCT = $(SYMROOT)/$(NAME).debug/$(NAME)" \
  142.         "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  143.         "PROJ_CFLAGS = $(DEBUG_CFLAGS) $$language_cflags" \
  144.         "LIBS = $$libs" "OTHER_LIBS = $$other_libs" \
  145.         "OTHER_JAPANESE_LIBS = $$other_japanese_libs" \
  146.         "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  147.         "BUNDLE_EXTENSION = $$bundle_ext" \
  148.         "RC_CFLAGS = $$arch_cflags" \
  149.         "RC_ARCHS = $$archs" \
  150.         "SRCROOT = $(SRCROOT)" \
  151.         "OBJROOT = $(OBJROOT)" \
  152.         "SYMROOT = $(SYMROOT)/sym" \
  153.         "SYM_DIR = $(SYMROOT)/sym" )
  154.  
  155. profile::
  156.     @($(MKDIRS) $(NAME).profile ; \
  157.      $(process_target_archs)_profile_obj ; \
  158.     $(set_bundle_ext) ; \
  159.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  160.         language_cflags="" ; \
  161.         libs="$(PROF_LIBS)" ; \
  162.         other_libs="$(OTHER_PROF_LIBS)" ; \
  163.         other_japanese_libs="" ; \
  164.     else \
  165.         language_cflags="-DKANJI" ; \
  166.         libs="$(PROF_LIBS:lNeXT_s=lNeXTJ_s)" ; \
  167.         other_libs="$(OTHER_PROF_LIBS:lNeXT_s=lNeXTJ_s)" ; \
  168.         other_japanese_libs="$(OTHER_JAPANESE_PROF_LIBS)" ; \
  169.     fi ; \
  170.     $(MAKE) project \
  171.         "PRODUCT_ROOT = $(SYMROOT)/$(NAME).profile" \
  172.         "TOP_PRODUCT_ROOT = $(SYMROOT)/$(NAME).profile" \
  173.         "PRODUCT = $(SYMROOT)/$(NAME).profile/$(NAME)" \
  174.         "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  175.         "PROJ_CFLAGS = $(PROFILE_CFLAGS) $$language_cflags" \
  176.         "LIBS = $$libs" "OTHER_LIBS = $$other_libs" \
  177.         "OTHER_JAPANESE_LIBS = $$other_japanese_libs" \
  178.         "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  179.         "BUNDLE_EXTENSION = $$bundle_ext" \
  180.         "RC_CFLAGS = $$arch_cflags" \
  181.         "RC_ARCHS = $$archs" \
  182.         "SRCROOT = $(SRCROOT)" \
  183.         "OBJROOT = $(OBJROOT)" \
  184.         "SYMROOT = $(SYMROOT)/sym" \
  185.         "SYM_DIR = $(SYMROOT)/sym" )
  186.  
  187.  
  188.  
  189. depend:: Makefile.dependencies $(SUBPROJECTS:.subproj=.depend) $(BUNDLES:.bproj=.depend) $(TOOLS:.tproj=.depend)
  190.  
  191. # Note: The order of the following project dependencies is very important.  subcomponents must be after $(PROJECT_OFILES) in case a subcomponent relies upon something (e.g. generated .h file) at the top level, but all subprojects must be built (hopefully by one invocation of make in that subdirectory) before the $(PRODUCT) can be linked.
  192.  
  193. project::   $(INITIAL_TARGETS) toplevel_subcomponents resources $(PRODUCT)
  194.  
  195. toplevel_subcomponents:: subprojs bundles tools
  196.     -@($(RM) -f $(TOP_PRODUCT_ROOT)/$(CHANGES_FILE) ; \
  197.     $(ECHO) "$(OFILE_DIR)" > $(TOP_PRODUCT_ROOT)/$(CHANGES_FILE))
  198.  
  199. $(PRODUCT): $(PRODUCT_DEPENDS) $(OTHER_PRODUCT_DEPENDS)
  200.     @(adaptors="" ; \
  201.     for adaptor in $(OTHERRELOCATABLES) none ; do \
  202.         if [ $$adaptor = "none" ] ; then break; fi ; \
  203.         for path in $(ADAPTOR_SEARCH_PATH) none ; do \
  204.             if [ $$path = "none" ] ; then break; fi ;\
  205.             if [ -r $$path/$$adaptor ] ; then \
  206.             adaptors="$$adaptors $$path/$$adaptor" ; \
  207.             break ; \
  208.         fi ; \
  209.         done ; \
  210.     done ; \
  211.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  212.         other_japanese_libs=""; \
  213.     else \
  214.         other_japanese_libs="$(OTHER_JAPANESE_LIBS)" ; \
  215.     fi ; \
  216.     cmd="$(CC) $(ALL_CFLAGS) $(OBJCFLAG) $(LDFLAGS) $(OTHER_LDFLAGS) \
  217.         $(APPICONFLAGS) -o $(PRODUCT) $(OFILES) $(OTHER_OFILES) \
  218.         $$adaptors $$other_japanese_libs $(OTHER_LIBS) $(LIBS)" ; \
  219.     echo $$cmd ; \
  220.     $$cmd    )
  221.     
  222.  
  223. $(DSTROOT)$(INSTALLDIR):
  224.     $(MKDIRS) $(DSTROOT)$(INSTALLDIR)
  225.  
  226. before_install:: $(DSTROOT)$(INSTALLDIR)
  227.     $(RM) -rf $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  228.  
  229. after_install::
  230.  
  231.  
  232. install:: app before_install installhdrs $(OTHER_INSTALL_DEPENDS)
  233.     (cd $(SYMROOT); $(TAR) chf - $(NAME).app) | (cd $(DSTROOT)$(INSTALLDIR); $(TAR) xf -)
  234.     @somebundles=no; \
  235.     for i in $(BUNDLES:.bproj=) none ; do \
  236.         if [ $$i = none ] ; then continue; fi; \
  237.         if [ -f $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$$i*/$$i ] ; then \
  238.             somebundles=yes; \
  239.         fi ; \
  240.     done; \
  241.     if [ $$somebundles = yes ] ; then \
  242.         cmd="$(STRIP) $(DYLD_APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME)"; \
  243.     else \
  244.         cmd="$(STRIP) $(APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME)"; \
  245.     fi ; \
  246.            echo $$cmd ; $$cmd ; \
  247.     $(MAKE) strip "DSTROOT = $(DSTROOT)" \
  248.               "PARENT_DIR = $(INSTALLDIR)/$(NAME).app" ; \
  249.     $(RM) -f $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(CHANGES_FILE)
  250.     -$(CHOWN) -Rf $(INSTALL_AS_USER).$(INSTALL_AS_GROUP) \
  251.         $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  252.     -$(CHMOD) -Rf go-w $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  253.     @(if [ "$(INSTALL_PERMISSIONS)" != "" ] ; then \
  254.         $(ECHO) $(CHMOD) -f $(INSTALL_PERMISSIONS) \
  255.             $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  256.         $(CHMOD) -f $(INSTALL_PERMISSIONS) \
  257.             $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  258.     fi)
  259.     @($(process_target_archs)_obj ; \
  260.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  261.         language_cflags="" ; \
  262.     else \
  263.         language_cflags="-DKANJI" ; \
  264.     fi ; \
  265.     $(MAKE) after_install     "DSTROOT=$(DSTROOT)" \
  266.                        "OBJROOT=$(OBJROOT)" \
  267.                 "SYMROOT = $(SYMROOT)/sym" \
  268.                 "SYM_DIR = $(SYMROOT)/sym" \
  269.                 "INSTALLDIR = $(INSTALLDIR)" \
  270.                 "PRODUCT_ROOT = $(SYMROOT)/$(NAME).app" \
  271.                 "PRODUCT = $(SYMROOT)/$(NAME).app/$(NAME)" \
  272.                 "OFILE_DIR = $(OBJROOT)/$$obj_dir" \
  273.                 "PROJ_CFLAGS = $(NORMAL_CFLAGS) $$language_cflags" \
  274.                 "APP_MAKEFILE_DIR = $(APP_MAKEFILE_DIR)" \
  275.                 "RC_CFLAGS = $$arch_cflags" \
  276.                 "RC_ARCHS = $$archs" )
  277.                 
  278.  
  279. #.DEFAULT 
  280.  
  281. help:
  282.     @if (test "$<"); then        \
  283.         $(ECHO) 'ERROR: Unrecognized Makefile target "$<"';    \
  284.     fi
  285.     @$(ECHO) 'The following targets are available:'
  286.     @$(ECHO) 
  287.     @$(ECHO) ' all         Makes the app target (below).  This is the default target.'
  288.     @$(ECHO) 
  289.     @$(ECHO) ' app         Compiles and links an optimized (and debuggable) version of the'
  290.     @$(ECHO) '             project, ready to install, into <ProjectName>.app.'
  291.     @$(ECHO)      
  292.     @$(ECHO) ' debug       Compiles (with all warnings and -DDEBUG on) and links a '
  293.     @$(ECHO) '             fully-debuggable version of the project into a <ProjectName>.debug' 
  294.     @$(ECHO) '             "app wrapper".'
  295.     @$(ECHO) 
  296.     @$(ECHO) ' profile     Compiles (with all warnings and -DPROFILE on) and links a'
  297.     @$(ECHO) '             version of the project into <ProjectName>.profile.'
  298.     @$(ECHO) '             "app wrapper" that will, when run, generate a gprof report.'
  299.     @$(ECHO) 
  300.     @$(ECHO) ' depend      Generates an optional Makefile.dependencies file for every level'
  301.     @$(ECHO) '             of the project to reflect the complete dependency graph'
  302.     @$(ECHO) '             (including headers).'
  303.     @$(ECHO) 
  304.     @$(ECHO) ' install     Builds (if needed) and copies <ProjectName>.app into the'
  305.     @$(ECHO) '             installation directory, setting permissions and owners as'
  306.     @$(ECHO) '             appropriate.'
  307.     @$(ECHO) 
  308.     @$(ECHO) ' installsrc  Installs the source files for the project into the directory'
  309.     @$(ECHO) '             specified in the SRCROOT variable in a command-line argument.'
  310.     @$(ECHO) '             Note: the target directory will be removed and recreated.'
  311.     @$(ECHO)        
  312.     @$(ECHO) ' installhdrs Installs the source files for the project.'
  313.     @$(ECHO) 
  314.     @$(ECHO) ' clean       Removes all files in the project derived from previous builds.'
  315.     @$(ECHO)  
  316.     @$(ECHO) ' help        Lists these targets with their descriptions.'
  317.     @$(ECHO) 
  318.     @$(ECHO) 'For more details, see the comments in /NextDeveloper/Makefiles/app/*.make.'
  319.