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 ### R U L E S O F E N G A G E M E N T ###
9 ### ###
10 #######################################################################
12 #######################################################################
13 # Double-Colon rules for utilizing the binary release model. #
14 #######################################################################
16 all:: export libs
18 ifeq ($(AUTOCLEAN),1)
19 autobuild:: clean export private_export libs program install
20 else
21 autobuild:: export private_export libs program install
22 endif
24 platform::
25 @echo $(OBJDIR_NAME)
27 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
28 USE_NT_C_SYNTAX=1
29 endif
31 #
32 # IMPORTS will always be associated with a component. Therefore,
33 # the "import" rule will always change directory to the top-level
34 # of a component, and traverse the IMPORTS keyword from the
35 # "manifest.mn" file located at this level only.
36 #
37 # note: if there is a trailing slash, the component will be appended
38 # (see import.pl - only used for xpheader.jar)
40 import::
41 @echo "== import.pl =="
42 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/import.pl \
43 "RELEASE_TREE=$(RELEASE_TREE)" \
44 "IMPORTS=$(IMPORTS)" \
45 "VERSION=$(VERSION)" \
46 "OS_ARCH=$(OS_ARCH)" \
47 "PLATFORM=$(PLATFORM)" \
48 "OVERRIDE_IMPORT_CHECK=$(OVERRIDE_IMPORT_CHECK)" \
49 "ALLOW_VERSION_OVERRIDE=$(ALLOW_VERSION_OVERRIDE)" \
50 "SOURCE_RELEASE_PREFIX=$(SOURCE_RELEASE_XP_DIR)" \
51 "SOURCE_MD_DIR=$(SOURCE_MD_DIR)" \
52 "SOURCE_XP_DIR=$(SOURCE_XP_DIR)" \
53 "FILES=$(IMPORT_XPCLASS_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
54 "$(IMPORT_XPCLASS_JAR)=$(IMPORT_XP_DIR)|$(IMPORT_XPCLASS_DIR)|" \
55 "$(XPHEADER_JAR)=$(IMPORT_XP_DIR)|$(SOURCE_XP_DIR)/public/|v" \
56 "$(MDHEADER_JAR)=$(IMPORT_MD_DIR)|$(SOURCE_MD_DIR)/include|" \
57 "$(MDBINARY_JAR)=$(IMPORT_MD_DIR)|$(SOURCE_MD_DIR)|"
58 # On Mac OS X ranlib needs to be rerun after static libs are moved.
59 ifeq ($(OS_TARGET),Darwin)
60 find $(SOURCE_MD_DIR)/lib -name "*.a" -exec $(RANLIB) {} \;
61 endif
63 export::
64 +$(LOOP_OVER_DIRS)
66 private_export::
67 +$(LOOP_OVER_DIRS)
69 release_export::
70 +$(LOOP_OVER_DIRS)
72 release_classes::
73 +$(LOOP_OVER_DIRS)
75 libs program install:: $(TARGETS)
76 ifdef LIBRARY
77 $(INSTALL) -m 664 $(LIBRARY) $(SOURCE_LIB_DIR)
78 endif
79 ifdef SHARED_LIBRARY
80 $(INSTALL) -m 775 $(SHARED_LIBRARY) $(SOURCE_LIB_DIR)
81 ifdef MOZ_DEBUG_SYMBOLS
82 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
83 $(INSTALL) -m 644 $(SHARED_LIBRARY:$(DLL_SUFFIX)=pdb) $(SOURCE_LIB_DIR)
84 endif
85 endif
86 endif
87 ifdef IMPORT_LIBRARY
88 $(INSTALL) -m 775 $(IMPORT_LIBRARY) $(SOURCE_LIB_DIR)
89 endif
90 ifdef PROGRAM
91 $(INSTALL) -m 775 $(PROGRAM) $(SOURCE_BIN_DIR)
92 ifdef MOZ_DEBUG_SYMBOLS
93 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
94 $(INSTALL) -m 644 $(PROGRAM:$(PROG_SUFFIX)=.pdb) $(SOURCE_BIN_DIR)
95 endif
96 endif
97 endif
98 ifdef PROGRAMS
99 $(INSTALL) -m 775 $(PROGRAMS) $(SOURCE_BIN_DIR)
100 endif
101 +$(LOOP_OVER_DIRS)
103 tests::
104 +$(LOOP_OVER_DIRS)
106 clean clobber::
107 rm -rf $(ALL_TRASH)
108 +$(LOOP_OVER_DIRS)
110 realclean clobber_all::
111 rm -rf $(wildcard *.OBJ) dist $(ALL_TRASH)
112 +$(LOOP_OVER_DIRS)
114 #######################################################################
115 # Double-Colon rules for populating the binary release model. #
116 #######################################################################
119 release_clean::
120 rm -rf $(SOURCE_XP_DIR)/release/$(RELEASE_MD_DIR)
122 release:: release_clean release_export release_classes release_policy release_md release_jars release_cpdistdir
124 release_cpdistdir::
125 @echo "== cpdist.pl =="
126 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/cpdist.pl \
127 "RELEASE_TREE=$(RELEASE_TREE)" \
128 "CORE_DEPTH=$(CORE_DEPTH)" \
129 "MODULE=${MODULE}" \
130 "OS_ARCH=$(OS_ARCH)" \
131 "RELEASE=$(RELEASE)" \
132 "PLATFORM=$(PLATFORM)" \
133 "RELEASE_VERSION=$(RELEASE_VERSION)" \
134 "SOURCE_RELEASE_PREFIX=$(SOURCE_RELEASE_XP_DIR)" \
135 "RELEASE_XP_DIR=$(RELEASE_XP_DIR)" \
136 "RELEASE_MD_DIR=$(RELEASE_MD_DIR)" \
137 "FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR) XP_FILES MD_FILES" \
138 "$(XPCLASS_JAR)=$(SOURCE_RELEASE_CLASSES_DIR)|x"\
139 "$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_CLASSES_DBG_DIR)|x"\
140 "$(XPHEADER_JAR)=$(SOURCE_RELEASE_XPHEADERS_DIR)|x" \
141 "$(MDHEADER_JAR)=$(SOURCE_RELEASE_MDHEADERS_DIR)|m" \
142 "$(MDBINARY_JAR)=$(SOURCE_RELEASE_MD_DIR)|m" \
143 "XP_FILES=$(XP_FILES)|xf" \
144 "MD_FILES=$(MD_FILES)|mf"
147 # $(SOURCE_RELEASE_xxx_JAR) is a name like yyy.jar
148 # $(SOURCE_RELEASE_xx_DIR) is a name like
150 release_jars::
151 @echo "== release.pl =="
152 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/release.pl \
153 "RELEASE_TREE=$(RELEASE_TREE)" \
154 "PLATFORM=$(PLATFORM)" \
155 "OS_ARCH=$(OS_ARCH)" \
156 "RELEASE_VERSION=$(RELEASE_VERSION)" \
157 "SOURCE_RELEASE_DIR=$(SOURCE_RELEASE_DIR)" \
158 "FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
159 "$(XPCLASS_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)|b"\
160 "$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)|b"\
161 "$(XPHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_XPHEADERS_DIR)|a" \
162 "$(MDHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MDHEADERS_DIR)|a" \
163 "$(MDBINARY_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MD_DIR)|bi"
165 # Rules for releasing classes.
166 # We have to do some REALLY gross stuff to deal with multiple classes in one
167 # file, as well as nested classes, which have a filename of the form
168 # ContainingClass$NestedClass.class.
169 # RELEASE_CLASSES simply performs a required patsubst on CLASSES
170 # RELEASE_CLASS_PATH is RELEASE_CLASSES with the path (in ns/dist) prepended
171 # RELEASE_NESTED is all the nested classes in RELEASE_CLASS_PATH. We use a
172 # foreach and wildcard to get all the files that start out like one of the
173 # class files, then have a $. So, for each class file, we look for file$*
174 # RELEASE_FILES is the combination of RELEASE_NESTED and the class files
175 # specified by RELEASE_CLASSES which have .class appended to them. Note that
176 # the RELEASE_NESTED don't need to have .class appended because they were
177 # read in from the wildcard as complete filenames.
178 #
179 # The _DBG versions are the debuggable ones.
180 ifneq ($(CLASSES),)
182 RELEASE_CLASSES := $(patsubst %,%,$(CLASSES))
184 ifdef BUILD_OPT
185 RELEASE_CLASS_PATH := $(patsubst %,$(SOURCE_CLASSES_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
186 RELEASE_NESTED := $(foreach file,$(RELEASE_CLASS_PATH),$(wildcard $(file)$$*))
187 RELEASE_FILES := $(patsubst %,%.class,$(RELEASE_CLASS_PATH)) $(RELEASE_NESTED)
188 else
189 RELEASE_DBG_CLASS_PATH:= $(patsubst %,$(SOURCE_CLASSES_DBG_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
190 RELEASE_DBG_NESTED := $(foreach file,$(RELEASE_DBG_CLASS_PATH),$(wildcard $(file)$$*))
191 RELEASE_DBG_FILES := $(patsubst %,%.class,$(RELEASE_DBG_CLASS_PATH)) $(RELEASE_DBG_NESTED)
192 endif
194 # Substitute \$ for $ so the shell doesn't choke
195 ifdef BUILD_OPT
196 release_classes::
197 $(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)/$(PACKAGE)
198 else
199 release_classes::
200 $(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_DBG_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)/$(PACKAGE)
201 endif
203 endif
205 release_policy::
206 +$(LOOP_OVER_DIRS)
208 ifndef NO_MD_RELEASE
209 ifdef LIBRARY
210 MD_LIB_RELEASE_FILES += $(LIBRARY)
211 endif
212 ifdef SHARED_LIBRARY
213 MD_LIB_RELEASE_FILES += $(SHARED_LIBRARY)
214 endif
215 ifdef IMPORT_LIBRARY
216 MD_LIB_RELEASE_FILES += $(IMPORT_LIBRARY)
217 endif
218 ifdef PROGRAM
219 MD_BIN_RELEASE_FILES += $(PROGRAM)
220 endif
221 ifdef PROGRAMS
222 MD_BIN_RELEASE_FILES += $(PROGRAMS)
223 endif
224 endif
226 release_md::
227 ifneq ($(MD_LIB_RELEASE_FILES),)
228 $(INSTALL) -m 444 $(MD_LIB_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_LIB_DIR)
229 endif
230 ifneq ($(MD_BIN_RELEASE_FILES),)
231 $(INSTALL) -m 555 $(MD_BIN_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_BIN_DIR)
232 endif
233 +$(LOOP_OVER_DIRS)
236 alltags:
237 rm -f TAGS
238 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
239 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a
241 $(PROGRAM): $(OBJS) $(EXTRA_LIBS)
242 @$(MAKE_OBJDIR)
243 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
244 $(MKPROG) $(subst /,\\,$(OBJS)) -Fe$@ -link $(LDFLAGS) $(subst /,\\,$(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS))
245 ifdef MT
246 if test -f $@.manifest; then \
247 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
248 rm -f $@.manifest; \
249 fi
250 endif # MSVC with manifest tool
251 else
252 $(MKPROG) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
253 endif
255 get_objs:
256 @echo $(OBJS)
258 $(LIBRARY): $(OBJS)
259 @$(MAKE_OBJDIR)
260 rm -f $@
261 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
262 $(AR) $(subst /,\\,$(OBJS))
263 else
264 $(AR) $(OBJS)
265 endif
266 $(RANLIB) $@
269 ifeq ($(OS_TARGET),OS2)
270 $(IMPORT_LIBRARY): $(MAPFILE)
271 rm -f $@
272 $(IMPLIB) $@ $<
273 $(RANLIB) $@
274 endif
276 ifdef SHARED_LIBRARY_LIBS
277 ifdef BUILD_TREE
278 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(shell $(MAKE) -C $(dir) --no-print-directory get_objs))
279 else
280 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(addprefix $(dir)/,$(shell $(MAKE) -C $(dir) --no-print-directory get_objs)))
281 endif
282 endif
284 $(SHARED_LIBRARY): $(OBJS) $(RES) $(MAPFILE) $(SUB_SHLOBJS)
285 @$(MAKE_OBJDIR)
286 rm -f $@
287 ifeq ($(OS_TARGET)$(OS_RELEASE), AIX4.1)
288 echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
289 nm -B -C -g $(OBJS) \
290 | awk '/ [T,D] / {print $$3}' \
291 | sed -e 's/^\.//' \
292 | sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
293 $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
294 -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS)
295 else
296 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
297 ifdef NS_USE_GCC
298 $(LINK_DLL) $(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES)
299 else
300 $(LINK_DLL) -MAP $(DLLBASE) $(subst /,\\,$(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES))
301 ifdef MT
302 if test -f $@.manifest; then \
303 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;2; \
304 rm -f $@.manifest; \
305 fi
306 endif # MSVC with manifest tool
307 endif
308 else
309 $(MKSHLIB) -o $@ $(OBJS) $(SUB_SHLOBJS) $(LD_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
310 chmod +x $@
311 endif
312 endif
314 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
315 $(RES): $(RESNAME)
316 @$(MAKE_OBJDIR)
317 # The resource compiler does not understand the -U option.
318 ifdef NS_USE_GCC
319 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
320 else
321 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
322 endif
323 @echo $(RES) finished
324 endif
326 $(MAPFILE): $(MAPFILE_SOURCE)
327 @$(MAKE_OBJDIR)
328 $(PROCESS_MAP_FILE)
331 $(OBJDIR)/$(PROG_PREFIX)%$(PROG_SUFFIX): $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX)
332 @$(MAKE_OBJDIR)
333 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
334 $(MKPROG) $< -Fe$@ -link \
335 $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
336 ifdef MT
337 if test -f $@.manifest; then \
338 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
339 rm -f $@.manifest; \
340 fi
341 endif # MSVC with manifest tool
342 else
343 $(MKPROG) -o $@ $(CFLAGS) $< \
344 $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
345 endif
347 WCCFLAGS1 := $(subst /,\\,$(CFLAGS))
348 WCCFLAGS2 := $(subst -I,-i=,$(WCCFLAGS1))
349 WCCFLAGS3 := $(subst -D,-d,$(WCCFLAGS2))
351 # Translate source filenames to absolute paths. This is required for
352 # debuggers under Windows & OS/2 to find source files automatically
354 ifeq (,$(filter-out OS2 AIX,$(OS_TARGET)))
355 # OS/2 and AIX
356 NEED_ABSOLUTE_PATH := 1
357 PWD := $(shell pwd)
359 else
360 # Windows
361 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
362 NEED_ABSOLUTE_PATH := 1
363 ifdef .PYMAKE
364 PWD := $(CURDIR)
365 else
366 PWD := $(shell pwd)
367 ifeq (,$(findstring ;,$(PATH)))
368 ifndef USE_MSYS
369 PWD := $(subst \,/,$(shell cygpath -w $(PWD)))
370 endif
371 endif
372 endif
374 else
375 # everything else
376 PWD := $(shell pwd)
377 endif
378 endif
380 # The quotes allow absolute paths to contain spaces.
381 core_abspath = "$(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1)))"
383 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.c
384 @$(MAKE_OBJDIR)
385 ifdef USE_NT_C_SYNTAX
386 $(CC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
387 else
388 ifdef NEED_ABSOLUTE_PATH
389 $(CC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
390 else
391 $(CC) -o $@ -c $(CFLAGS) $<
392 endif
393 endif
395 $(PROG_PREFIX)%$(OBJ_SUFFIX): %.c
396 ifdef USE_NT_C_SYNTAX
397 $(CC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
398 else
399 ifdef NEED_ABSOLUTE_PATH
400 $(CC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
401 else
402 $(CC) -o $@ -c $(CFLAGS) $<
403 endif
404 endif
406 ifneq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
407 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.s
408 @$(MAKE_OBJDIR)
409 $(AS) -o $@ $(ASFLAGS) -c $<
410 endif
412 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.asm
413 @$(MAKE_OBJDIR)
414 $(AS) -Fo$@ $(ASFLAGS) -c $<
416 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.S
417 @$(MAKE_OBJDIR)
418 $(AS) -o $@ $(ASFLAGS) -c $<
420 $(OBJDIR)/$(PROG_PREFIX)%: %.cpp
421 @$(MAKE_OBJDIR)
422 ifdef USE_NT_C_SYNTAX
423 $(CCC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
424 else
425 ifdef NEED_ABSOLUTE_PATH
426 $(CCC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
427 else
428 $(CCC) -o $@ -c $(CFLAGS) $<
429 endif
430 endif
432 #
433 # Please keep the next two rules in sync.
434 #
435 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.cc
436 @$(MAKE_OBJDIR)
437 $(CCC) -o $@ -c $(CFLAGS) $<
439 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.cpp
440 @$(MAKE_OBJDIR)
441 ifdef STRICT_CPLUSPLUS_SUFFIX
442 echo "#line 1 \"$<\"" | cat - $< > $(OBJDIR)/t_$*.cc
443 $(CCC) -o $@ -c $(CFLAGS) $(OBJDIR)/t_$*.cc
444 rm -f $(OBJDIR)/t_$*.cc
445 else
446 ifdef USE_NT_C_SYNTAX
447 $(CCC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
448 else
449 ifdef NEED_ABSOLUTE_PATH
450 $(CCC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
451 else
452 $(CCC) -o $@ -c $(CFLAGS) $<
453 endif
454 endif
455 endif #STRICT_CPLUSPLUS_SUFFIX
457 %.i: %.cpp
458 $(CCC) -C -E $(CFLAGS) $< > $@
460 %.i: %.c
461 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
462 $(CC) -C /P $(CFLAGS) $<
463 else
464 $(CC) -C -E $(CFLAGS) $< > $@
465 endif
467 ifneq (,$(filter-out WIN%,$(OS_TARGET)))
468 %.i: %.s
469 $(CC) -C -E $(CFLAGS) $< > $@
470 endif
472 %: %.pl
473 rm -f $@; cp $< $@; chmod +x $@
475 %: %.sh
476 rm -f $@; cp $< $@; chmod +x $@
478 ################################################################################
479 # Bunch of things that extend the 'export' rule (in order):
480 ################################################################################
482 $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) $(JMCSRCDIR)::
483 @if test ! -d $@; then \
484 echo Creating $@; \
485 rm -rf $@; \
486 $(NSINSTALL) -D $@; \
487 fi
489 ################################################################################
490 ## IDL_GEN
492 ifneq ($(IDL_GEN),)
494 #export::
495 # $(IDL2JAVA) $(IDL_GEN)
497 #all:: export
499 #clobber::
500 # rm -f $(IDL_GEN:.idl=.class) # XXX wrong!
502 endif
504 ################################################################################
505 ### JSRCS -- for compiling java files
506 ###
507 ### NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
508 ### replace $(CORE_DEPTH) with $(NETLIBDEPTH).
509 ###
511 ifneq ($(JSRCS),)
512 ifneq ($(JAVAC),)
513 ifdef NETLIBDEPTH
514 CORE_DEPTH := $(NETLIBDEPTH)
515 endif
517 JAVA_EXPORT_SRCS=$(shell $(PERL) $(CORE_DEPTH)/coreconf/outofdate.pl $(PERLARG) -d $(JAVA_DESTPATH)/$(PACKAGE) $(JSRCS) $(PRIVATE_JSRCS))
519 export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
520 ifneq ($(JAVA_EXPORT_SRCS),)
521 $(JAVAC) $(JAVA_EXPORT_SRCS)
522 endif
524 all:: export
526 clobber::
527 rm -f $(SOURCE_XP_DIR)/classes/$(PACKAGE)/*.class
529 endif
530 endif
532 #
533 # JDIRS -- like JSRCS, except you can give a list of directories and it will
534 # compile all the out-of-date java files in those directories.
535 #
536 # NOTE: recursing through these can speed things up, but they also cause
537 # some builds to run out of memory
538 #
539 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
540 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
541 #
542 ifdef JDIRS
543 ifneq ($(JAVAC),)
544 ifdef NETLIBDEPTH
545 CORE_DEPTH := $(NETLIBDEPTH)
546 endif
548 # !!!!! THIS WILL CRASH SHMSDOS.EXE !!!!!
549 # shmsdos does not support shell variables. It will crash when it tries
550 # to parse the '=' character. A solution is to rewrite outofdate.pl so it
551 # takes the Javac command as an argument and executes the command itself,
552 # instead of returning a list of files.
553 export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
554 @echo "!!! THIS COMMAND IS BROKEN ON WINDOWS--SEE rules.mk FOR DETAILS !!!"
555 return -1
556 @for d in $(JDIRS); do \
557 if test -d $$d; then \
558 set $(EXIT_ON_ERROR); \
559 files=`echo $$d/*.java`; \
560 list=`$(PERL) $(CORE_DEPTH)/coreconf/outofdate.pl $(PERLARG) \
561 -d $(JAVA_DESTPATH)/$(PACKAGE) $$files`; \
562 if test "$${list}x" != "x"; then \
563 echo Building all java files in $$d; \
564 echo $(JAVAC) $$list; \
565 $(JAVAC) $$list; \
566 fi; \
567 set +e; \
568 else \
569 echo "Skipping non-directory $$d..."; \
570 fi; \
571 $(CLICK_STOPWATCH); \
572 done
573 endif
574 endif
576 #
577 # JDK_GEN -- for generating "old style" native methods
578 #
579 # Generate JDK Headers and Stubs into the '_gen' and '_stubs' directory
580 #
581 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
582 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
583 #
584 ifneq ($(JDK_GEN),)
585 ifneq ($(JAVAH),)
586 ifdef NSBUILDROOT
587 INCLUDES += -I$(JDK_GEN_DIR) -I$(SOURCE_XP_DIR)
588 else
589 INCLUDES += -I$(JDK_GEN_DIR)
590 endif
592 ifdef NETLIBDEPTH
593 CORE_DEPTH := $(NETLIBDEPTH)
594 endif
596 JDK_PACKAGE_CLASSES := $(JDK_GEN)
597 JDK_PATH_CLASSES := $(subst .,/,$(JDK_PACKAGE_CLASSES))
598 JDK_HEADER_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
599 JDK_STUB_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
600 JDK_HEADER_CFILES := $(patsubst %,$(JDK_GEN_DIR)/%.h,$(JDK_GEN))
601 JDK_STUB_CFILES := $(patsubst %,$(JDK_STUB_DIR)/%.c,$(JDK_GEN))
603 $(JDK_HEADER_CFILES): $(JDK_HEADER_CLASSFILES)
604 $(JDK_STUB_CFILES): $(JDK_STUB_CLASSFILES)
606 export::
607 @echo Generating/Updating JDK headers
608 $(JAVAH) -d $(JDK_GEN_DIR) $(JDK_PACKAGE_CLASSES)
609 @echo Generating/Updating JDK stubs
610 $(JAVAH) -stubs -d $(JDK_STUB_DIR) $(JDK_PACKAGE_CLASSES)
611 ifndef NO_MAC_JAVA_SHIT
612 @if test ! -d $(CORE_DEPTH)/lib/mac/Java/; then \
613 echo "!!! You need to have a ns/lib/mac/Java directory checked out."; \
614 echo "!!! This allows us to automatically update generated files for the mac."; \
615 echo "!!! If you see any modified files there, please check them in."; \
616 fi
617 @echo Generating/Updating JDK headers for the Mac
618 $(JAVAH) -mac -d $(CORE_DEPTH)/lib/mac/Java/_gen $(JDK_PACKAGE_CLASSES)
619 @echo Generating/Updating JDK stubs for the Mac
620 $(JAVAH) -mac -stubs -d $(CORE_DEPTH)/lib/mac/Java/_stubs $(JDK_PACKAGE_CLASSES)
621 endif
622 endif
623 endif
625 #
626 # JRI_GEN -- for generating "old style" JRI native methods
627 #
628 # Generate JRI Headers and Stubs into the 'jri' directory
629 #
630 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
631 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
632 #
633 ifneq ($(JRI_GEN),)
634 ifneq ($(JAVAH),)
635 ifdef NSBUILDROOT
636 INCLUDES += -I$(JRI_GEN_DIR) -I$(SOURCE_XP_DIR)
637 else
638 INCLUDES += -I$(JRI_GEN_DIR)
639 endif
641 ifdef NETLIBDEPTH
642 CORE_DEPTH := $(NETLIBDEPTH)
643 endif
645 JRI_PACKAGE_CLASSES := $(JRI_GEN)
646 JRI_PATH_CLASSES := $(subst .,/,$(JRI_PACKAGE_CLASSES))
647 JRI_HEADER_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JRI_PATH_CLASSES))
648 JRI_STUB_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JRI_PATH_CLASSES))
649 JRI_HEADER_CFILES := $(patsubst %,$(JRI_GEN_DIR)/%.h,$(JRI_GEN))
650 JRI_STUB_CFILES := $(patsubst %,$(JRI_GEN_DIR)/%.c,$(JRI_GEN))
652 $(JRI_HEADER_CFILES): $(JRI_HEADER_CLASSFILES)
653 $(JRI_STUB_CFILES): $(JRI_STUB_CLASSFILES)
655 export::
656 @echo Generating/Updating JRI headers
657 $(JAVAH) -jri -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
658 @echo Generating/Updating JRI stubs
659 $(JAVAH) -jri -stubs -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
660 ifndef NO_MAC_JAVA_SHIT
661 @if test ! -d $(CORE_DEPTH)/lib/mac/Java/; then \
662 echo "!!! You need to have a ns/lib/mac/Java directory checked out."; \
663 echo "!!! This allows us to automatically update generated files for the mac."; \
664 echo "!!! If you see any modified files there, please check them in."; \
665 fi
666 @echo Generating/Updating JRI headers for the Mac
667 $(JAVAH) -jri -mac -d $(CORE_DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
668 @echo Generating/Updating JRI stubs for the Mac
669 $(JAVAH) -jri -mac -stubs -d $(CORE_DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
670 endif
671 endif
672 endif
674 #
675 # JNI_GEN -- for generating JNI native methods
676 #
677 # Generate JNI Headers into the 'jni' directory
678 #
679 ifneq ($(JNI_GEN),)
680 ifneq ($(JAVAH),)
681 JNI_HEADERS := $(patsubst %,$(JNI_GEN_DIR)/%.h,$(JNI_GEN))
683 export::
684 @if test ! -d $(JNI_GEN_DIR); then \
685 echo $(JAVAH) -jni -d $(JNI_GEN_DIR) $(JNI_GEN); \
686 $(JAVAH) -jni -d $(JNI_GEN_DIR) $(JNI_GEN); \
687 else \
688 echo "Checking for out of date header files" ; \
689 $(PERL) $(CORE_DEPTH)/coreconf/jniregen.pl $(PERLARG) \
690 -d $(JAVA_DESTPATH) -j "$(JAVAH) -jni -d $(JNI_GEN_DIR)" $(JNI_GEN);\
691 fi
692 endif
693 endif
695 #
696 # JMC_EXPORT -- for declaring which java classes are to be exported for jmc
697 #
698 ifneq ($(JMC_EXPORT),)
699 JMC_EXPORT_PATHS := $(subst .,/,$(JMC_EXPORT))
700 JMC_EXPORT_FILES := $(patsubst %,$(JAVA_DESTPATH)/$(PACKAGE)/%.class,$(JMC_EXPORT_PATHS))
702 #
703 # We're doing NSINSTALL -t here (copy mode) because calling INSTALL will pick up
704 # your NSDISTMODE and make links relative to the current directory. This is a
705 # problem because the source isn't in the current directory:
706 #
707 export:: $(JMC_EXPORT_FILES) $(JMCSRCDIR)
708 $(NSINSTALL) -t -m 444 $(JMC_EXPORT_FILES) $(JMCSRCDIR)
709 endif
711 #
712 # JMC_GEN -- for generating java modules
713 #
714 # Provide default export & install rules when using JMC_GEN
715 #
716 ifneq ($(JMC_GEN),)
717 ifneq ($(JMC),)
718 INCLUDES += -I$(JMC_GEN_DIR) -I.
719 JMC_HEADERS := $(patsubst %,$(JMC_GEN_DIR)/%.h,$(JMC_GEN))
720 JMC_STUBS := $(patsubst %,$(JMC_GEN_DIR)/%.c,$(JMC_GEN))
721 JMC_OBJS := $(patsubst %,$(OBJDIR)/%$(OBJ_SUFFIX),$(JMC_GEN))
723 $(JMC_GEN_DIR)/M%.h: $(JMCSRCDIR)/%.class
724 $(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)
726 $(JMC_GEN_DIR)/M%.c: $(JMCSRCDIR)/%.class
727 $(JMC) -d $(JMC_GEN_DIR) -module $(JMC_GEN_FLAGS) $(?F:.class=)
729 $(OBJDIR)/M%$(OBJ_SUFFIX): $(JMC_GEN_DIR)/M%.c $(JMC_GEN_DIR)/M%.h
730 @$(MAKE_OBJDIR)
731 $(CC) -o $@ -c $(CFLAGS) $<
733 export:: $(JMC_HEADERS) $(JMC_STUBS)
734 endif
735 endif
737 #
738 # Copy each element of EXPORTS to $(SOURCE_XP_DIR)/public/$(MODULE)/
739 #
740 PUBLIC_EXPORT_DIR = $(SOURCE_XP_DIR)/public/$(MODULE)
742 ifneq ($(EXPORTS),)
743 $(PUBLIC_EXPORT_DIR)::
744 @if test ! -d $@; then \
745 echo Creating $@; \
746 $(NSINSTALL) -D $@; \
747 fi
749 export:: $(PUBLIC_EXPORT_DIR)
751 export:: $(EXPORTS)
752 $(INSTALL) -m 444 $^ $(PUBLIC_EXPORT_DIR)
754 export:: $(BUILT_SRCS)
755 endif
757 # Duplicate export rule for private exports, with different directories
759 PRIVATE_EXPORT_DIR = $(SOURCE_XP_DIR)/private/$(MODULE)
761 ifneq ($(PRIVATE_EXPORTS),)
762 $(PRIVATE_EXPORT_DIR)::
763 @if test ! -d $@; then \
764 echo Creating $@; \
765 $(NSINSTALL) -D $@; \
766 fi
768 private_export:: $(PRIVATE_EXPORT_DIR)
770 private_export:: $(PRIVATE_EXPORTS)
771 $(INSTALL) -m 444 $^ $(PRIVATE_EXPORT_DIR)
772 else
773 private_export::
774 @echo There are no private exports.;
775 endif
777 ##########################################################################
778 ### RULES FOR RUNNING REGRESSION SUITE TESTS
779 ### REQUIRES 'REGRESSION_SPEC' TO BE SET TO THE NAME OF A REGRESSION SPECFILE
780 ### AND RESULTS_SUBDIR TO BE SET TO SOMETHING LIKE SECURITY/PKCS5
781 ##########################################################################
783 TESTS_DIR = $(RESULTS_DIR)/$(RESULTS_SUBDIR)/$(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)
785 ifneq ($(REGRESSION_SPEC),)
787 ifneq ($(BUILD_OPT),)
788 REGDATE = $(subst \ ,, $(shell $(PERL) $(CORE_DEPTH)/$(MODULE)/scripts/now))
789 endif
791 tests:: $(REGRESSION_SPEC)
792 cd $(PLATFORM); \
793 ../$(SOURCE_MD_DIR)/bin/regress$(PROG_SUFFIX) specfile=../$(REGRESSION_SPEC) progress $(EXTRA_REGRESS_OPTIONS); \
794 if test ! -d $(TESTS_DIR); then \
795 echo Creating $(TESTS_DIR); \
796 $(NSINSTALL) -D $(TESTS_DIR); \
797 fi
798 ifneq ($(BUILD_OPT),)
799 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).sum $(TESTS_DIR); \
800 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).htm $(TESTS_DIR); \
801 echo "Please now make sure your results files are copied to $(TESTS_DIR), "; \
802 echo "then run 'reporter specfile=$(RESULTS_DIR)/rptspec'"
803 endif
804 else
805 tests::
806 @echo Error: you didn't specify REGRESSION_SPEC in your manifest.mn file!;
807 endif
810 # Duplicate export rule for releases, with different directories
812 ifneq ($(EXPORTS),)
813 $(SOURCE_RELEASE_XP_DIR)/include::
814 @if test ! -d $@; then \
815 echo Creating $@; \
816 $(NSINSTALL) -D $@; \
817 fi
819 release_export:: $(SOURCE_RELEASE_XP_DIR)/include
821 release_export:: $(EXPORTS)
822 $(INSTALL) -m 444 $^ $(SOURCE_RELEASE_XP_DIR)/include
823 endif
828 ################################################################################
830 -include $(DEPENDENCIES)
832 ifneq (,$(filter-out OS2 WIN%,$(OS_TARGET)))
833 # Can't use sed because of its 4000-char line length limit, so resort to perl
834 PERL_DEPENDENCIES_PROGRAM = \
835 open(MD, "< $(DEPENDENCIES)"); \
836 while (<MD>) { \
837 if (m@ \.*/*$< @) { \
838 $$found = 1; \
839 last; \
840 } \
841 } \
842 if ($$found) { \
843 print "Removing stale dependency $< from $(DEPENDENCIES)\n"; \
844 seek(MD, 0, 0); \
845 $$tmpname = "$(OBJDIR)/fix.md" . $$$$; \
846 open(TMD, "> " . $$tmpname); \
847 while (<MD>) { \
848 s@ \.*/*$< @ @; \
849 if (!print TMD "$$_") { \
850 unlink(($$tmpname)); \
851 exit(1); \
852 } \
853 } \
854 close(TMD); \
855 if (!rename($$tmpname, "$(DEPENDENCIES)")) { \
856 unlink(($$tmpname)); \
857 } \
858 } elsif ("$<" ne "$(DEPENDENCIES)") { \
859 print "$(MAKE): *** No rule to make target $<. Stop.\n"; \
860 exit(1); \
861 }
863 .DEFAULT:
864 @$(PERL) -e '$(PERL_DEPENDENCIES_PROGRAM)'
865 endif
867 #############################################################################
868 # X dependency system
869 #############################################################################
871 ifdef MKDEPENDENCIES
873 # For Windows, $(MKDEPENDENCIES) must be -included before including rules.mk
875 $(MKDEPENDENCIES)::
876 @$(MAKE_OBJDIR)
877 touch $(MKDEPENDENCIES)
878 chmod u+w $(MKDEPENDENCIES)
879 #on NT, the preceding touch command creates a read-only file !?!?!
880 #which is why we have to explicitly chmod it.
881 $(MKDEPEND) -p$(OBJDIR_NAME)/ -o'$(OBJ_SUFFIX)' -f$(MKDEPENDENCIES) \
882 $(NOMD_CFLAGS) $(YOPT) $(CSRCS) $(CPPSRCS) $(ASFILES)
884 $(MKDEPEND):: $(MKDEPEND_DIR)/*.c $(MKDEPEND_DIR)/*.h
885 $(MAKE) -C $(MKDEPEND_DIR)
887 ifdef OBJS
888 depend:: $(MKDEPEND) $(MKDEPENDENCIES)
889 else
890 depend::
891 endif
892 +$(LOOP_OVER_DIRS)
894 dependclean::
895 rm -f $(MKDEPENDENCIES)
896 +$(LOOP_OVER_DIRS)
898 #-include $(NSINSTALL_DIR)/$(OBJDIR)/depend.mk
900 else
901 depend::
902 endif
904 #
905 # HACK ALERT
906 #
907 # The only purpose of this rule is to pass Mozilla's Tinderbox depend
908 # builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's
909 # Tinderbox builds NSS continuously as part of the Mozilla client.
910 # Because NSS's make depend is not implemented, whenever we change
911 # an NSS header file, the depend build does not recompile the NSS
912 # files that depend on the header.
913 #
914 # This rule makes all the objects depend on a dummy header file.
915 # Check in a change to this dummy header file to force the depend
916 # build to recompile everything.
917 #
918 # This rule should be removed when make depend is implemented.
919 #
921 DUMMY_DEPEND = $(CORE_DEPTH)/coreconf/coreconf.dep
923 $(filter $(OBJDIR)/%$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%$(OBJ_SUFFIX): $(DUMMY_DEPEND)
925 # END OF HACK
927 ################################################################################
928 # Special gmake rules.
929 ################################################################################
931 #
932 # Re-define the list of default suffixes, so gmake won't have to churn through
933 # hundreds of built-in suffix rules for stuff we don't need.
934 #
935 .SUFFIXES:
936 .SUFFIXES: .out .a .ln .o .obj .c .cc .C .cpp .y .l .s .S .h .sh .i .pl .class .java .html .asm .dep
938 #
939 # Don't delete these files if we get killed.
940 #
941 .PRECIOUS: .java $(JDK_HEADERS) $(JDK_STUBS) $(JRI_HEADERS) $(JRI_STUBS) $(JMC_HEADERS) $(JMC_STUBS) $(JNI_HEADERS)
943 #
944 # Fake targets. Always run these rules, even if a file/directory with that
945 # name already exists.
946 #
947 .PHONY: all all_platforms alltags boot clean clobber clobber_all export install libs program realclean release $(OBJDIR)