ruleset.mk 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. #######################################################################
  6. # #
  7. # Parameters to this makefile (set these in this file): #
  8. # #
  9. # a) #
  10. # TARGETS -- the target to create #
  11. # (defaults to $LIBRARY $PROGRAM) #
  12. # b) #
  13. # DIRS -- subdirectories for make to recurse on #
  14. # (the 'all' rule builds $TARGETS $DIRS) #
  15. # c) #
  16. # CSRCS, CPPSRCS -- .c and .cpp files to compile #
  17. # (used to define $OBJS) #
  18. # d) #
  19. # PROGRAM -- the target program name to create from $OBJS #
  20. # ($OBJDIR automatically prepended to it) #
  21. # e) #
  22. # LIBRARY -- the target library name to create from $OBJS #
  23. # ($OBJDIR automatically prepended to it) #
  24. # f) #
  25. # JSRCS -- java source files to compile into class files #
  26. # (if you don't specify this it will default #
  27. # to *.java) #
  28. # g) #
  29. # PACKAGE -- the package to put the .class files into #
  30. # (e.g. netscape/applet) #
  31. # (NOTE: the default definition for this may be #
  32. # overridden if "jdk.mk" is included) #
  33. # h) #
  34. # JMC_EXPORT -- java files to be exported for use by JMC_GEN #
  35. # (this is a list of Class names) #
  36. # i) #
  37. # JRI_GEN -- files to run through javah to generate headers #
  38. # and stubs #
  39. # (output goes into the _jri sub-dir) #
  40. # j) #
  41. # JMC_GEN -- files to run through jmc to generate headers #
  42. # and stubs #
  43. # (output goes into the _jmc sub-dir) #
  44. # k) #
  45. # JNI_GEN -- files to run through javah to generate headers #
  46. # (output goes into the _jni sub-dir) #
  47. # #
  48. #######################################################################
  49. #
  50. # CPU_TAG is now defined in the $(TARGET).mk files
  51. #
  52. ifndef COMPILER_TAG
  53. ifneq ($(DEFAULT_COMPILER), $(notdir $(firstword $(CC))))
  54. #
  55. # Temporary define for the Client; to be removed when binary release is used
  56. #
  57. ifdef MOZILLA_CLIENT
  58. COMPILER_TAG =
  59. else
  60. COMPILER_TAG = _$(notdir $(firstword $(CC)))
  61. endif
  62. else
  63. COMPILER_TAG =
  64. endif
  65. endif
  66. ifeq ($(MKPROG),)
  67. MKPROG = $(CC)
  68. endif
  69. #
  70. # This makefile contains rules for building the following kinds of
  71. # objects:
  72. # - (1) LIBRARY: a static (archival) library
  73. # - (2) SHARED_LIBRARY: a shared (dynamic link) library
  74. # - (3) IMPORT_LIBRARY: an import library, defined in $(OS_TARGET).mk
  75. # - (4) PROGRAM: an executable binary
  76. #
  77. # NOTE: The names of libraries can be generated by simply specifying
  78. # LIBRARY_NAME (and LIBRARY_VERSION in the case of non-static libraries).
  79. # LIBRARY and SHARED_LIBRARY may be defined differently in $(OS_TARGET).mk
  80. #
  81. ifdef LIBRARY_NAME
  82. ifndef LIBRARY
  83. LIBRARY = $(OBJDIR)/$(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
  84. endif
  85. ifndef SHARED_LIBRARY
  86. SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX).$(DLL_SUFFIX)
  87. endif
  88. ifndef MAPFILE_SOURCE
  89. MAPFILE_SOURCE = $(LIBRARY_NAME).def
  90. endif
  91. endif
  92. #
  93. # Common rules used by lots of makefiles...
  94. #
  95. ifdef PROGRAM
  96. PROGRAM := $(addprefix $(OBJDIR)/, $(PROGRAM)$(JDK_DEBUG_SUFFIX)$(PROG_SUFFIX))
  97. endif
  98. ifdef PROGRAMS
  99. PROGRAMS := $(addprefix $(OBJDIR)/, $(PROGRAMS:%=%$(JDK_DEBUG_SUFFIX)$(PROG_SUFFIX)))
  100. endif
  101. ifndef TARGETS
  102. TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM)
  103. endif
  104. # Make both .cpp and .cc work.
  105. CPPSRCS1 = $(CPPSRCS:.cpp=$(OBJ_SUFFIX))
  106. CPPSRCS2 = $(CPPSRCS1:.cc=$(OBJ_SUFFIX))
  107. ifndef OBJS
  108. SIMPLE_OBJS = $(JRI_STUB_CFILES) \
  109. $(addsuffix $(OBJ_SUFFIX), $(JMC_GEN)) \
  110. $(CSRCS:.c=$(OBJ_SUFFIX)) \
  111. $(CPPSRCS2) \
  112. $(ASFILES:$(ASM_SUFFIX)=$(OBJ_SUFFIX)) \
  113. $(BUILT_CSRCS:.c=$(OBJ_SUFFIX)) \
  114. $(BUILT_CPPSRCS:.cpp=$(OBJ_SUFFIX)) \
  115. $(BUILT_ASFILES:$(ASM_SUFFIX)=$(OBJ_SUFFIX))
  116. OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(SIMPLE_OBJS))
  117. endif
  118. ifndef BUILT_SRCS
  119. BUILT_SRCS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), \
  120. $(BUILT_CSRCS) $(BUILT_CPPSRCS) $(BUILT_ASFILES))
  121. endif
  122. ifeq (,$(filter-out WIN%,$(OS_TARGET)))
  123. MAKE_OBJDIR = $(INSTALL) -D $(OBJDIR)
  124. else
  125. define MAKE_OBJDIR
  126. if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
  127. endef
  128. endif
  129. ifndef PACKAGE
  130. PACKAGE = .
  131. endif
  132. ifdef NSBUILDROOT
  133. JDK_GEN_DIR = $(SOURCE_XP_DIR)/_gen
  134. JMC_GEN_DIR = $(SOURCE_XP_DIR)/_jmc
  135. JNI_GEN_DIR = $(SOURCE_XP_DIR)/_jni
  136. JRI_GEN_DIR = $(SOURCE_XP_DIR)/_jri
  137. JDK_STUB_DIR = $(SOURCE_XP_DIR)/_stubs
  138. else
  139. JDK_GEN_DIR = _gen
  140. JMC_GEN_DIR = _jmc
  141. JNI_GEN_DIR = _jni
  142. JRI_GEN_DIR = _jri
  143. JDK_STUB_DIR = _stubs
  144. endif
  145. ALL_TRASH = $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \
  146. so_locations $(BUILT_SRCS) $(NOSUCHFILE)
  147. ifdef NS_USE_JDK
  148. ALL_TRASH += $(JDK_HEADER_CFILES) $(JDK_STUB_CFILES) \
  149. $(JMC_HEADERS) $(JMC_STUBS) $(JMC_EXPORT_FILES) \
  150. $(JNI_HEADERS) \
  151. $(JRI_HEADER_CFILES) $(JRI_STUB_CFILES) \
  152. $(JDK_GEN_DIR) $(JMC_GEN_DIR) $(JNI_GEN_DIR) \
  153. $(JRI_GEN_DIR) $(JDK_STUB_DIR)
  154. ifdef JAVA_DESTPATH
  155. ALL_TRASH += $(wildcard $(JAVA_DESTPATH)/$(PACKAGE)/*.class)
  156. ifdef JDIRS
  157. ALL_TRASH += $(addprefix $(JAVA_DESTPATH)/,$(JDIRS))
  158. endif
  159. else # !JAVA_DESTPATH
  160. ALL_TRASH += $(wildcard $(PACKAGE)/*.class) $(JDIRS)
  161. endif
  162. endif #NS_USE_JDK
  163. ifdef NSS_BUILD_CONTINUE_ON_ERROR
  164. # Try to build everything. I.e., don't exit on errors.
  165. EXIT_ON_ERROR = +e
  166. IGNORE_ERROR = -
  167. CLICK_STOPWATCH = date
  168. else
  169. EXIT_ON_ERROR = -e
  170. IGNORE_ERROR =
  171. CLICK_STOPWATCH = true
  172. endif
  173. ifdef REQUIRES
  174. MODULE_INCLUDES := $(addprefix -I$(SOURCE_XP_DIR)/public/, $(REQUIRES))
  175. INCLUDES += $(MODULE_INCLUDES)
  176. ifeq ($(MODULE), sectools)
  177. PRIVATE_INCLUDES := $(addprefix -I$(SOURCE_XP_DIR)/private/, $(REQUIRES))
  178. INCLUDES += $(PRIVATE_INCLUDES)
  179. endif
  180. endif
  181. ifdef SYSTEM_INCL_DIR
  182. YOPT = -Y$(SYSTEM_INCL_DIR)
  183. endif
  184. ifdef DIRS
  185. define SUBMAKE
  186. +@echo "cd $2; $(MAKE) $1"
  187. $(IGNORE_ERROR)@$(MAKE) -C $(2) $(1)
  188. @$(CLICK_STOPWATCH)
  189. endef
  190. LOOP_OVER_DIRS = $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
  191. endif
  192. MK_RULESET = included