home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Makefiles / app / app.make next >
Text File  |  1992-06-19  |  12KB  |  268 lines

  1. #
  2. #                                  app.make
  3. #
  4. # Inputs from Makefile.preamble or Makefile.postamble (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_EARLY_TARGETS - Built before building subprojects/bundles
  16. #    OTHER_SOURCEFILES - Other source files maintained by .pre/postamble
  17. #    OTHER_GARBAGE - Additional files to be removed by make 'clean' 
  18. #
  19. #    DSTROOT - Virtual root directory prepended to $(INSTALLDIR)
  20. #
  21. # Inputs from Makefile.preamble:
  22. #    PRECOMPS - Precompiled headers that should be built before compilation 
  23. #    OTHER_INITIAL_TARGETS - Targets to be built before subprojects, etc.
  24. #
  25. # Inputs from Makefile.postamble (with defaults set in common.make):
  26. #    INSTALL_AS_USER - User to chown app to at installation (default root)
  27. #    INSTALL_AS_GROUP - Grp to chgrp app to at installation (default wheel)
  28. #    INSTALL_PERMISSIONS - If set, 'install' chmod's executable to this.
  29. #    MAKEFILES - Makefiles this project depends on (default = Makefile)
  30. #
  31. #    RELOCATABLE_STRIP_OPTS - Opts to strip for bundles (default = -x -u)
  32. #    DYLD_APP_STRIP_OPTS - Opts to strip for apps w/ bundles (def. = -A -n)
  33. #    APP_STRIP_OPTS - Opts to strip for apps w/o bundles (no default, but
  34. #          developers doing their own dynamic loading should set this to 
  35. #     3 $(DYLD_APP_STRIP_OPTS)
  36. #
  37. # Inputs from Makefile (avoid setting these, ProjectBuilder controls them):
  38. #    NAME - name of application
  39. #    LANGUAGE - langage in which the project is written (default "English")
  40. #    ENGLISH - boolean flag set iff $(LANGUAGE) = "English"
  41. #    JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese"
  42. #    LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
  43. #    GLOBAL_RESOURCES - non-localized resources of project
  44. #    PROJECTVERSION - version of ProjectBuilder that output Makefile
  45. #    APPICON - application icon file
  46. #    DOCICONS - dock icon files
  47. #    ICONSECTIONS - Specifies icon sections when linking executable 
  48. #
  49. #    CLASSES - Class implementation files in project.
  50. #    HFILES - Header files in project.
  51. #    MFILES - Other Objective-C source files in project. 
  52. #    CFILES - Other C source files in project. 
  53. #    PSWFILES - .psw files in the project
  54. #    PSWMFILES - .pswm files in the project
  55. #    SUBPROJECTS - Subprojects of this project
  56. #    BUNDLES - Bundle subprojects of this project
  57. #    OTHERSRCS - Other miscellaneous sources of this project
  58. #    OTHERLINKED - Source files not matching a standard source extention
  59. #
  60. #    LIBS - Libraries to link with when making app target
  61. #    DEBUG_LIBS - Libraries to link with when making debug target
  62. #    PROF_LIBS - Libraries to link with when making profile target
  63. #    OTHERLINKEDOFILES - Other relocatable files to (always) link in.
  64. #
  65. #    MAKEFILEDIR - Directory in which to find this generic set of Makefiles
  66. #    INSTALLDIR - Directory app will be installed into by 'install' target
  67. #    INSTALLFLAGS - not used
  68. #    SOURCEMODE - not used
  69. #
  70. # Outputs from this file to common.make:
  71. #    OFILE_DIR
  72. #
  73.  
  74. APPICONFLAGS =  -sectcreate __ICON __header $(NAME).iconheader  \
  75.         -segprot __ICON r r $(ICONSECTIONS)
  76.  
  77. ICONHEADER = $(NAME).iconheader
  78.  
  79. include $(MAKEFILEDIR)/common.make
  80.  
  81. all:: app
  82.  
  83.     
  84. app::
  85.     @($(MKDIRS) $(NAME).app ; \
  86.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  87.     $(MAKE) project \
  88.         "PRODUCT_ROOT = $(NAME).app" \
  89.         "PRODUCT = $(NAME).app/$(NAME)" \
  90.         "OFILE_DIR=obj" \
  91.         "CFLAGS = -g -O -Wall $(CFLAGS) $(OTHER_CFLAGS)" \
  92.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  93.     else \
  94.     $(MAKE) project \
  95.         "PRODUCT_ROOT = $(NAME).app" \
  96.         "PRODUCT = $(NAME).app/$(NAME)" \
  97.         "OFILE_DIR=obj" \
  98.         "CFLAGS = -g -O -Wall -DKANJI $(CFLAGS) $(OTHER_CFLAGS)" \
  99.         "LIBS = $(LIBS:lNeXT_s=lNeXTJ_s)" \
  100.         "OTHER_3 = $(OTHER_LIBS:lNeXT_s=lNeXTJ_s)" \
  101.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  102.     fi )
  103.  
  104. debug::
  105.     @($(MKDIRS) $(NAME).debug ; \
  106.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  107.     $(MAKE) project \
  108.         "PRODUCT_ROOT = $(NAME).debug" \
  109.         "PRODUCT = $(NAME).debug/$(NAME)" \
  110.         "OFILE_DIR=debug_obj" \
  111.         "CFLAGS = -g -Wall -DDEBUG $(CFLAGS) $(OTHER_CFLAGS)" \
  112.         "LIBS = $(DEBUG_LIBS)" "OTHER_LIBS = $(OTHER_DEBUG_LIBS)" \
  113.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  114.     else \
  115.     $(MAKE) project \
  116.         "PRODUCT_ROOT = $(NAME).debug" \
  117.         "PRODUCT = $(NAME).debug/$(NAME)" \
  118.         "OFILE_DIR=debug_obj" \
  119.         "CFLAGS = -g -Wall -DDEBUG -DKANJI $(CFLAGS) $(OTHER_CFLAGS)" \
  120.         "LIBS = $(DEBUG_LIBS:lNeXT_s=lNeXTJ_s)" \
  121.         "OTHER_LIBS = $(OTHER_DEBUG_LIBS:lNeXT_s=lNeXTJ_s)" \
  122.         "OTHER_JAPANESE_LIBS = $(OTHER_JAPANESE_DEBUG_LIBS)" \
  123.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  124.     fi )
  125.  
  126. profile::
  127.     @($(MKDIRS) $(NAME).profile ; \
  128.     if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  129.     $(MAKE) project \
  130.         "PRODUCT_ROOT = $(NAME).profile" \
  131.         "PRODUCT = $(NAME).profile/$(NAME)" \
  132.         "OFILE_DIR=profile_obj" \
  133.         "CFLAGS = -g -pg -O -Wall -DPROFILE $(CFLAGS) $(OTHER_CFLAGS)" \
  134.         "LIBS = $(PROF_LIBS)" "OTHER_LIBS = $(OTHER_PROF_LIBS)" \
  135.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  136.     else \
  137.     $(MAKE) project \
  138.         "PRODUCT_ROOT = $(NAME).profile" \
  139.         "PRODUCT = $(NAME).profile/$(NAME)" \
  140.         "OFILE_DIR=profile_obj" \
  141.         "CFLAGS = -g -pg -O -Wall -DPROFILE -DKANJI $(CFLAGS) $(OTHER_CFLAGS)" \
  142.         "LIBS = $(PROF_LIBS:lNeXT_s=lNeXTJ_s)" \
  143.         "OTHER_LIBS = $(OTHER_PROF_LIBS:lNeXT_s=lNeXTJ_s)" \
  144.         "OTHER_JAPANESE_LIBS = $(OTHER_JAPANESE_PROF_LIBS)" \
  145.         "MAKEFILEDIR = $(MAKEFILEDIR)" ; \
  146.     fi )
  147.  
  148.  
  149.  
  150. depend:: Makefile.dependencies $(SUBPROJECTS:.subproj=.depend) $(BUNDLES:.bproj=.depend)
  151.  
  152. # 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.
  153.  
  154. project::   $(INITIAL_TARGETS) subcomponents resources $(PRODUCT)
  155.     -@($(RM) -f $(CHANGES_FILE) ; $(TOUCH) $(CHANGES_FILE))
  156.     
  157. $(PRODUCT): $(PRODUCT_DEPENDS) $(OTHER_PRODUCT_DEPENDS) 
  158.     @(adaptors="" ; \
  159.     for adaptor in $(OTHERRELOCATABLES) none ; do \
  160.         if [ $$a3or = "none" ] ; then break; fi ; \
  161.         for path in $(ADAPTOR_SEARCH_PATH) none ; do \
  162.             if [ $$path = "none" ] ; then break; fi ;\
  163.             if [ -r $$path/$$adaptor ] ; then \
  164.             adaptors="$$adaptors $$path/$$adaptor" ; \
  165.             break ; \
  166.         fi ; \
  167.         done ; \
  168.     done ; \
  169.     if [ "$(PROJECTVERSION)" -lt "1" -o "$(PROJECTVERSION)" = "1.0" ] ; then \
  170.         if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  171.         $(ECHO) "$(CC) $(CFLAGS) $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  172.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_LIBS) $(LIBS)" ; \
  173.         $(CC) $(CFLAGS) $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  174.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_LIBS) $(LIBS) ; \
  175.         else \
  176.         $(ECHO) "$(CC) $(CFLAGS) $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  177.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_JAPANESE_LIBS) \
  178.             $(OTHER_LIBS) $(LIBS)" ; \
  179.         $(CC) $(CFLAGS) $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  180.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_JAPANESE_LIBS) \
  181.             $(OTHER_LIBS) $(LIBS) ; \
  182.         fi ; \
  183.     else \
  184.         if [ "$(ENGLISH)" = "YES" -o "$(JAPANESE)" != "YES" ] ; then \
  185.         $(ECHO) "$(CC) $(CFLAGS) -ObjC $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  186.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_LIBS) $(LIBS)" ; \
  187.         $(CC) $(CFLAGS) -ObjC $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  188.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_LIBS) $(LIBS) ; \
  189.         else \
  190.         $(ECHO) "$(CC) $(CFLAGS) -ObjC $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  191.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_JAPANESE_LIBS) \
  192.             $(OTHER_LIBS) $(LIBS)" ; \
  193.         $(CC) $(CFLAGS) -ObjC $(LDFLAGS) $(OTHER_LDFLAGS) $(APPICONFLAGS) -o $(PRODUCT) \
  194.             $(OFILES) $(OTHER_OFILES) $$adaptors $(OTHER_JAPANESE_LIBS) \
  195.             $(OTHER_LIBS) $(LIBS) ; \
  196.         fi ; \
  197.     fi)
  198.  
  199. $(DSTROOT)$(INSTALLDIR):
  200.     $(MKDIRS) $(DSTROOT)$(INSTALLDIR)
  201.  
  202. before_install:: $(DSTROOT)$(INSTALLDIR)
  203.     $(RM) -rf $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  204.  
  205. after_install::
  206.  
  207. install:: app before_install $(OTHER_INSTALL_DEPENDS)
  208.     $(TAR) cf - $(NAME).app | (cd $(DSTROOT)$(INSTALLDIR); $(TAR) xf -)
  209.     @somebundles=no; \
  210.     for i in $(BUNDLES:.bproj=) none ; do \
  211.         if [ $$i = none ] ; then continue; fi; \
  212.         somebundles3    ; \
  213.         $(ECHO) $(STRIP) $(RELOCATABLE_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$$i.bundle/$$i; \
  214.         $(STRIP) $(RELOCATABLE_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$$i.bundle/$$i; \
  215.     done; \
  216.     if [ $$somebundles = yes ] ; then \
  217.         $(ECHO) $(STRIP) $(DYLD_APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  218.         $(STRIP) $(DYLD_APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  219.     else \
  220.         $(ECHO) $(STRIP) $(APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  221.         $(STRIP) $(APP_STRIP_OPTS) $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  222.     fi
  223.     $(RM) -f $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(CHANGES_FILE)
  224.     -$(CHOWN) -Rf $(INSTALL_AS_USER).$(INSTALL_AS_GROUP) \
  225.         $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  226.     -$(CHMOD) -Rf go-w $(DSTROOT)$(INSTALLDIR)/$(NAME).app
  227.     if [ "$(INSTALL_PERMISSIONS)" != "" ] ; then \
  228.         $(CHMOD) -f $(INSTALL_PERMISSIONS) \
  229.             $(DSTROOT)$(INSTALLDIR)/$(NAME).app/$(NAME); \
  230.     fi
  231.     @$(MAKE) after_install
  232.  
  233.  
  234. help::
  235.     @$(ECHO) 'The following targets are available:'
  236.     @$(ECHO) 
  237.     @$(ECHO) ' all        Makes the app target (below).  This is the default target.'
  238.     @$(ECHO) 
  239.     @$(ECHO) ' app        Compiles and links an optimized (and debuggable) version of the'
  240.     @$(ECHO) '            project, ready to install, into <ProjectName>.app.'
  241.     @$(ECHO)      
  242.     @$(ECHO) ' debug      Compiles (with all warnings and -DDEBUG on) and links a '
  243.     @$(ECHO) '            fully-debuggable version of the project into a <ProjectName>.debug' 
  244.     @$(ECHO) '            "app wrapper".'
  245.     @$(ECHO) 
  246.     @$(ECHO) ' profile    Compiles (with all warnings and -DPROFILE on) and links a'
  247.     @$(ECHO) '            version of the project into <ProjectName>.profile.'
  248.     @$(ECHO) '            "app wrapper" that will, when run, generate a gprof report.'
  249.     @$(ECHO) 
  250.     @$(ECHO) ' depend     Generates an optional Makefile.dependencies file for every level'
  251.     @$(ECHO) '            of the project to reflect the complete dependency graph'
  252.     @$(ECHO) '            (including headers).'
  253.     @$(ECHO) 
  254.     @$(ECHO) ' install    Builds (if needed) and copies <ProjectName>.app into the'
  255.     @$(ECHO) '            installation directory, setting permissions and owners as'
  256.     @$(ECHO) '            appropriate.'
  257.     @$(ECHO) 
  258.     @$(ECHO) ' installsrc Installs the source files for the project into the directory'
  259.     @$(ECHO) '            specified in the SRCROOT variab3n a command-line argument.'
  260.     @$(ECHO) '            Note: the target directory will be removed and recreated.'
  261.     @$(ECHO)        
  262.     @$(ECHO) ' clean      Removes all files in the project derived from previous builds.'
  263.     @$(ECHO)  
  264.     @$(ECHO) ' help       Lists these targets with their descriptions.'
  265.     @$(ECHO) 
  266.     @$(ECHO) 'For more details, see the comments in /NextDeveloper/Makefiles/app/*.make.'
  267.