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