Import from 1.9a8 tarball
[mozilla-nss.git] / security / coreconf / rules.mk
blobe8beeb640ac3afda56f5ae844b691e2096152164
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is the Netscape security libraries.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 1994-2000
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK *****
38 #######################################################################
39 ### ###
40 ### R U L E S O F E N G A G E M E N T ###
41 ### ###
42 #######################################################################
44 #######################################################################
45 # Double-Colon rules for utilizing the binary release model. #
46 #######################################################################
48 all:: export libs
50 ifeq ($(AUTOCLEAN),1)
51 autobuild:: clean export private_export libs program install
52 else
53 autobuild:: export private_export libs program install
54 endif
56 platform::
57 @echo $(OBJDIR_NAME)
59 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
60 USE_NT_C_SYNTAX=1
61 endif
63 ifdef XP_OS2_VACPP
64 USE_NT_C_SYNTAX=1
65 endif
68 # IMPORTS will always be associated with a component. Therefore,
69 # the "import" rule will always change directory to the top-level
70 # of a component, and traverse the IMPORTS keyword from the
71 # "manifest.mn" file located at this level only.
73 # note: if there is a trailing slash, the component will be appended
74 # (see import.pl - only used for xpheader.jar)
76 import::
77 @echo "== import.pl =="
78 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/import.pl \
79 "RELEASE_TREE=$(RELEASE_TREE)" \
80 "IMPORTS=$(IMPORTS)" \
81 "VERSION=$(VERSION)" \
82 "OS_ARCH=$(OS_ARCH)" \
83 "PLATFORM=$(PLATFORM)" \
84 "OVERRIDE_IMPORT_CHECK=$(OVERRIDE_IMPORT_CHECK)" \
85 "ALLOW_VERSION_OVERRIDE=$(ALLOW_VERSION_OVERRIDE)" \
86 "SOURCE_RELEASE_PREFIX=$(SOURCE_RELEASE_XP_DIR)" \
87 "SOURCE_MD_DIR=$(SOURCE_MD_DIR)" \
88 "SOURCE_XP_DIR=$(SOURCE_XP_DIR)" \
89 "FILES=$(IMPORT_XPCLASS_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
90 "$(IMPORT_XPCLASS_JAR)=$(IMPORT_XP_DIR)|$(IMPORT_XPCLASS_DIR)|" \
91 "$(XPHEADER_JAR)=$(IMPORT_XP_DIR)|$(SOURCE_XP_DIR)/public/|v" \
92 "$(MDHEADER_JAR)=$(IMPORT_MD_DIR)|$(SOURCE_MD_DIR)/include|" \
93 "$(MDBINARY_JAR)=$(IMPORT_MD_DIR)|$(SOURCE_MD_DIR)|"
94 # On Mac OS X ranlib needs to be rerun after static libs are moved.
95 ifeq ($(OS_TARGET),Darwin)
96 find $(SOURCE_MD_DIR)/lib -name "*.a" -exec $(RANLIB) {} \;
97 endif
99 export::
100 +$(LOOP_OVER_DIRS)
102 private_export::
103 +$(LOOP_OVER_DIRS)
105 release_export::
106 +$(LOOP_OVER_DIRS)
108 release_classes::
109 +$(LOOP_OVER_DIRS)
111 libs program install:: $(TARGETS)
112 ifdef LIBRARY
113 $(INSTALL) -m 664 $(LIBRARY) $(SOURCE_LIB_DIR)
114 endif
115 ifdef SHARED_LIBRARY
116 $(INSTALL) -m 775 $(SHARED_LIBRARY) $(SOURCE_LIB_DIR)
117 ifdef MOZ_DEBUG_SYMBOLS
118 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
119 $(INSTALL) -m 644 $(SHARED_LIBRARY:$(DLL_SUFFIX)=pdb) $(SOURCE_LIB_DIR)
120 endif
121 endif
122 endif
123 ifdef IMPORT_LIBRARY
124 $(INSTALL) -m 775 $(IMPORT_LIBRARY) $(SOURCE_LIB_DIR)
125 endif
126 ifdef PROGRAM
127 $(INSTALL) -m 775 $(PROGRAM) $(SOURCE_BIN_DIR)
128 ifdef MOZ_DEBUG_SYMBOLS
129 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
130 $(INSTALL) -m 644 $(PROGRAM:$(PROG_SUFFIX)=.pdb) $(SOURCE_BIN_DIR)
131 endif
132 endif
133 endif
134 ifdef PROGRAMS
135 $(INSTALL) -m 775 $(PROGRAMS) $(SOURCE_BIN_DIR)
136 endif
137 +$(LOOP_OVER_DIRS)
139 tests::
140 +$(LOOP_OVER_DIRS)
142 clean clobber::
143 rm -rf $(ALL_TRASH)
144 +$(LOOP_OVER_DIRS)
146 realclean clobber_all::
147 rm -rf $(wildcard *.OBJ) dist $(ALL_TRASH)
148 +$(LOOP_OVER_DIRS)
150 #######################################################################
151 # Double-Colon rules for populating the binary release model. #
152 #######################################################################
155 release_clean::
156 rm -rf $(SOURCE_XP_DIR)/release/$(RELEASE_MD_DIR)
158 release:: release_clean release_export release_classes release_policy release_md release_jars release_cpdistdir
160 release_cpdistdir::
161 @echo "== cpdist.pl =="
162 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/cpdist.pl \
163 "RELEASE_TREE=$(RELEASE_TREE)" \
164 "CORE_DEPTH=$(CORE_DEPTH)" \
165 "MODULE=${MODULE}" \
166 "OS_ARCH=$(OS_ARCH)" \
167 "RELEASE=$(RELEASE)" \
168 "PLATFORM=$(PLATFORM)" \
169 "RELEASE_VERSION=$(RELEASE_VERSION)" \
170 "SOURCE_RELEASE_PREFIX=$(SOURCE_RELEASE_XP_DIR)" \
171 "RELEASE_XP_DIR=$(RELEASE_XP_DIR)" \
172 "RELEASE_MD_DIR=$(RELEASE_MD_DIR)" \
173 "FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR) XP_FILES MD_FILES" \
174 "$(XPCLASS_JAR)=$(SOURCE_RELEASE_CLASSES_DIR)|x"\
175 "$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_CLASSES_DBG_DIR)|x"\
176 "$(XPHEADER_JAR)=$(SOURCE_RELEASE_XPHEADERS_DIR)|x" \
177 "$(MDHEADER_JAR)=$(SOURCE_RELEASE_MDHEADERS_DIR)|m" \
178 "$(MDBINARY_JAR)=$(SOURCE_RELEASE_MD_DIR)|m" \
179 "XP_FILES=$(XP_FILES)|xf" \
180 "MD_FILES=$(MD_FILES)|mf"
183 # $(SOURCE_RELEASE_xxx_JAR) is a name like yyy.jar
184 # $(SOURCE_RELEASE_xx_DIR) is a name like
186 release_jars::
187 @echo "== release.pl =="
188 @$(PERL) -I$(CORE_DEPTH)/coreconf $(CORE_DEPTH)/coreconf/release.pl \
189 "RELEASE_TREE=$(RELEASE_TREE)" \
190 "PLATFORM=$(PLATFORM)" \
191 "OS_ARCH=$(OS_ARCH)" \
192 "RELEASE_VERSION=$(RELEASE_VERSION)" \
193 "SOURCE_RELEASE_DIR=$(SOURCE_RELEASE_DIR)" \
194 "FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
195 "$(XPCLASS_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)|b"\
196 "$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)|b"\
197 "$(XPHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_XPHEADERS_DIR)|a" \
198 "$(MDHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MDHEADERS_DIR)|a" \
199 "$(MDBINARY_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MD_DIR)|bi"
201 # Rules for releasing classes.
202 # We have to do some REALLY gross stuff to deal with multiple classes in one
203 # file, as well as nested classes, which have a filename of the form
204 # ContainingClass$NestedClass.class.
205 # RELEASE_CLASSES simply performs a required patsubst on CLASSES
206 # RELEASE_CLASS_PATH is RELEASE_CLASSES with the path (in ns/dist) prepended
207 # RELEASE_NESTED is all the nested classes in RELEASE_CLASS_PATH. We use a
208 # foreach and wildcard to get all the files that start out like one of the
209 # class files, then have a $. So, for each class file, we look for file$*
210 # RELEASE_FILES is the combination of RELEASE_NESTED and the class files
211 # specified by RELEASE_CLASSES which have .class appended to them. Note that
212 # the RELEASE_NESTED don't need to have .class appended because they were
213 # read in from the wildcard as complete filenames.
215 # The _DBG versions are the debuggable ones.
216 ifneq ($(CLASSES),)
218 RELEASE_CLASSES := $(patsubst %,%,$(CLASSES))
220 ifdef BUILD_OPT
221 RELEASE_CLASS_PATH := $(patsubst %,$(SOURCE_CLASSES_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
222 RELEASE_NESTED := $(foreach file,$(RELEASE_CLASS_PATH),$(wildcard $(file)$$*))
223 RELEASE_FILES := $(patsubst %,%.class,$(RELEASE_CLASS_PATH)) $(RELEASE_NESTED)
224 else
225 RELEASE_DBG_CLASS_PATH:= $(patsubst %,$(SOURCE_CLASSES_DBG_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
226 RELEASE_DBG_NESTED := $(foreach file,$(RELEASE_DBG_CLASS_PATH),$(wildcard $(file)$$*))
227 RELEASE_DBG_FILES := $(patsubst %,%.class,$(RELEASE_DBG_CLASS_PATH)) $(RELEASE_DBG_NESTED)
228 endif
230 # Substitute \$ for $ so the shell doesn't choke
231 ifdef BUILD_OPT
232 release_classes::
233 $(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)/$(PACKAGE)
234 else
235 release_classes::
236 $(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_DBG_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)/$(PACKAGE)
237 endif
239 endif
241 release_policy::
242 +$(LOOP_OVER_DIRS)
244 ifndef NO_MD_RELEASE
245 ifdef LIBRARY
246 MD_LIB_RELEASE_FILES += $(LIBRARY)
247 endif
248 ifdef SHARED_LIBRARY
249 MD_LIB_RELEASE_FILES += $(SHARED_LIBRARY)
250 endif
251 ifdef IMPORT_LIBRARY
252 MD_LIB_RELEASE_FILES += $(IMPORT_LIBRARY)
253 endif
254 ifdef PROGRAM
255 MD_BIN_RELEASE_FILES += $(PROGRAM)
256 endif
257 ifdef PROGRAMS
258 MD_BIN_RELEASE_FILES += $(PROGRAMS)
259 endif
260 endif
262 release_md::
263 ifneq ($(MD_LIB_RELEASE_FILES),)
264 $(INSTALL) -m 444 $(MD_LIB_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_LIB_DIR)
265 endif
266 ifneq ($(MD_BIN_RELEASE_FILES),)
267 $(INSTALL) -m 555 $(MD_BIN_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_BIN_DIR)
268 endif
269 +$(LOOP_OVER_DIRS)
272 alltags:
273 rm -f TAGS
274 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
275 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a
277 ifdef XP_OS2_VACPP
278 # list of libs (such as -lnspr4) do not work for our compiler
279 # change it to be $(DIST)/lib/nspr4.lib
280 EXTRA_SHARED_LIBS := $(filter-out -L%,$(EXTRA_SHARED_LIBS))
281 EXTRA_SHARED_LIBS := $(patsubst -l%,$(DIST)/lib/%.$(LIB_SUFFIX),$(EXTRA_SHARED_LIBS))
282 endif
284 $(PROGRAM): $(OBJS) $(EXTRA_LIBS)
285 @$(MAKE_OBJDIR)
286 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
287 $(MKPROG) $(subst /,\\,$(OBJS)) -Fe$@ -link $(LDFLAGS) $(subst /,\\,$(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS))
288 ifdef MT
289 if test -f $@.manifest; then \
290 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
291 rm -f $@.manifest; \
293 endif # MSVC with manifest tool
294 else
295 ifdef XP_OS2_VACPP
296 $(MKPROG) -Fe$@ $(CFLAGS) $(OBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
297 else
298 $(MKPROG) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
299 endif
300 endif
302 get_objs:
303 @echo $(OBJS)
305 $(LIBRARY): $(OBJS)
306 @$(MAKE_OBJDIR)
307 rm -f $@
308 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
309 $(AR) $(subst /,\\,$(OBJS))
310 else
311 $(AR) $(OBJS)
312 endif
313 $(RANLIB) $@
316 ifeq ($(OS_TARGET),OS2)
317 $(IMPORT_LIBRARY): $(MAPFILE)
318 rm -f $@
319 $(IMPLIB) $@ $<
320 $(RANLIB) $@
321 endif
323 ifdef SHARED_LIBRARY_LIBS
324 ifdef BUILD_TREE
325 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(shell $(MAKE) -C $(dir) --no-print-directory get_objs))
326 else
327 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(addprefix $(dir)/,$(shell $(MAKE) -C $(dir) --no-print-directory get_objs)))
328 endif
329 endif
331 $(SHARED_LIBRARY): $(OBJS) $(RES) $(MAPFILE) $(SUB_SHLOBJS)
332 @$(MAKE_OBJDIR)
333 rm -f $@
334 ifeq ($(OS_TARGET)$(OS_RELEASE), AIX4.1)
335 echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
336 nm -B -C -g $(OBJS) \
337 | awk '/ [T,D] / {print $$3}' \
338 | sed -e 's/^\.//' \
339 | sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
340 $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
341 -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS)
342 else
343 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
344 ifdef NS_USE_GCC
345 $(LINK_DLL) $(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES)
346 else
347 $(LINK_DLL) -MAP $(DLLBASE) $(subst /,\\,$(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES))
348 ifdef MT
349 if test -f $@.manifest; then \
350 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;2; \
351 rm -f $@.manifest; \
353 endif # MSVC with manifest tool
354 endif
355 else
356 ifdef XP_OS2_VACPP
357 $(MKSHLIB) $(DLLFLAGS) $(LDFLAGS) $(OBJS) $(SUB_SHLOBJS) $(LD_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
358 else
359 $(MKSHLIB) -o $@ $(OBJS) $(SUB_SHLOBJS) $(LD_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
360 endif
361 chmod +x $@
362 ifeq ($(OS_TARGET),Darwin)
363 ifdef MAPFILE
364 nmedit -s $(MAPFILE) $@
365 endif
366 endif
367 endif
368 endif
370 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
371 $(RES): $(RESNAME)
372 @$(MAKE_OBJDIR)
373 # The resource compiler does not understand the -U option.
374 ifdef NS_USE_GCC
375 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
376 else
377 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
378 endif
379 @echo $(RES) finished
380 endif
382 $(MAPFILE): $(MAPFILE_SOURCE)
383 @$(MAKE_OBJDIR)
384 $(PROCESS_MAP_FILE)
387 $(OBJDIR)/$(PROG_PREFIX)%$(PROG_SUFFIX): $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX)
388 @$(MAKE_OBJDIR)
389 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
390 $(MKPROG) $< -Fe$@ -link \
391 $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
392 ifdef MT
393 if test -f $@.manifest; then \
394 $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
395 rm -f $@.manifest; \
397 endif # MSVC with manifest tool
398 else
399 $(MKPROG) -o $@ $(CFLAGS) $< \
400 $(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
401 endif
403 WCCFLAGS1 := $(subst /,\\,$(CFLAGS))
404 WCCFLAGS2 := $(subst -I,-i=,$(WCCFLAGS1))
405 WCCFLAGS3 := $(subst -D,-d,$(WCCFLAGS2))
407 # Translate source filenames to absolute paths. This is required for
408 # debuggers under Windows & OS/2 to find source files automatically
410 ifeq (,$(filter-out OS2 AIX,$(OS_TARGET)))
411 # OS/2 and AIX
412 NEED_ABSOLUTE_PATH := 1
413 PWD := $(shell pwd)
415 else
416 # Windows
417 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
418 NEED_ABSOLUTE_PATH := 1
419 PWD := $(shell pwd)
420 ifeq (,$(findstring ;,$(PATH)))
421 ifndef USE_MSYS
422 PWD := $(subst \,/,$(shell cygpath -w $(PWD)))
423 endif
424 endif
426 else
427 # everything else
428 PWD := $(shell pwd)
429 endif
430 endif
432 core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1)))
434 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.c
435 @$(MAKE_OBJDIR)
436 ifdef USE_NT_C_SYNTAX
437 $(CC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
438 else
439 ifdef NEED_ABSOLUTE_PATH
440 $(CC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
441 else
442 $(CC) -o $@ -c $(CFLAGS) $<
443 endif
444 endif
446 $(PROG_PREFIX)%$(OBJ_SUFFIX): %.c
447 ifdef USE_NT_C_SYNTAX
448 $(CC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
449 else
450 ifdef NEED_ABSOLUTE_PATH
451 $(CC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
452 else
453 $(CC) -o $@ -c $(CFLAGS) $<
454 endif
455 endif
457 ifndef XP_OS2_VACPP
458 ifneq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
459 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.s
460 @$(MAKE_OBJDIR)
461 $(AS) -o $@ $(ASFLAGS) -c $<
462 endif
463 endif
465 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.asm
466 @$(MAKE_OBJDIR)
467 ifdef XP_OS2_VACPP
468 $(AS) -Fdo:$(OBJDIR) $(ASFLAGS) $(subst /,\\,$<)
469 else
470 $(AS) -Fo$@ $(ASFLAGS) -c $<
471 endif
473 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.S
474 @$(MAKE_OBJDIR)
475 $(AS) -o $@ $(ASFLAGS) -c $<
477 $(OBJDIR)/$(PROG_PREFIX)%: %.cpp
478 @$(MAKE_OBJDIR)
479 ifdef USE_NT_C_SYNTAX
480 $(CCC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
481 else
482 ifdef NEED_ABSOLUTE_PATH
483 $(CCC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
484 else
485 $(CCC) -o $@ -c $(CFLAGS) $<
486 endif
487 endif
490 # Please keep the next two rules in sync.
492 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.cc
493 @$(MAKE_OBJDIR)
494 $(CCC) -o $@ -c $(CFLAGS) $<
496 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.cpp
497 @$(MAKE_OBJDIR)
498 ifdef STRICT_CPLUSPLUS_SUFFIX
499 echo "#line 1 \"$<\"" | cat - $< > $(OBJDIR)/t_$*.cc
500 $(CCC) -o $@ -c $(CFLAGS) $(OBJDIR)/t_$*.cc
501 rm -f $(OBJDIR)/t_$*.cc
502 else
503 ifdef USE_NT_C_SYNTAX
504 $(CCC) -Fo$@ -c $(CFLAGS) $(call core_abspath,$<)
505 else
506 ifdef NEED_ABSOLUTE_PATH
507 $(CCC) -o $@ -c $(CFLAGS) $(call core_abspath,$<)
508 else
509 $(CCC) -o $@ -c $(CFLAGS) $<
510 endif
511 endif
512 endif #STRICT_CPLUSPLUS_SUFFIX
514 %.i: %.cpp
515 $(CCC) -C -E $(CFLAGS) $< > $@
517 %.i: %.c
518 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
519 $(CC) -C /P $(CFLAGS) $<
520 else
521 $(CC) -C -E $(CFLAGS) $< > $@
522 endif
524 ifneq (,$(filter-out WIN%,$(OS_TARGET)))
525 %.i: %.s
526 $(CC) -C -E $(CFLAGS) $< > $@
527 endif
529 %: %.pl
530 rm -f $@; cp $< $@; chmod +x $@
532 %: %.sh
533 rm -f $@; cp $< $@; chmod +x $@
535 ifdef DIRS
536 $(DIRS)::
537 @if test -d $@; then \
538 set $(EXIT_ON_ERROR); \
539 echo "cd $@; $(MAKE)"; \
540 cd $@; $(MAKE); \
541 set +e; \
542 else \
543 echo "Skipping non-directory $@..."; \
544 fi; \
545 $(CLICK_STOPWATCH)
546 endif
548 ################################################################################
549 # Bunch of things that extend the 'export' rule (in order):
550 ################################################################################
552 $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) $(JMCSRCDIR)::
553 @if test ! -d $@; then \
554 echo Creating $@; \
555 rm -rf $@; \
556 $(NSINSTALL) -D $@; \
559 ################################################################################
560 ## IDL_GEN
562 ifneq ($(IDL_GEN),)
564 #export::
565 # $(IDL2JAVA) $(IDL_GEN)
567 #all:: export
569 #clobber::
570 # rm -f $(IDL_GEN:.idl=.class) # XXX wrong!
572 endif
574 ################################################################################
575 ### JSRCS -- for compiling java files
577 ### NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
578 ### replace $(CORE_DEPTH) with $(NETLIBDEPTH).
581 ifneq ($(JSRCS),)
582 ifneq ($(JAVAC),)
583 ifdef NETLIBDEPTH
584 CORE_DEPTH := $(NETLIBDEPTH)
585 endif
587 JAVA_EXPORT_SRCS=$(shell $(PERL) $(CORE_DEPTH)/coreconf/outofdate.pl $(PERLARG) -d $(JAVA_DESTPATH)/$(PACKAGE) $(JSRCS) $(PRIVATE_JSRCS))
589 export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
590 ifneq ($(JAVA_EXPORT_SRCS),)
591 $(JAVAC) $(JAVA_EXPORT_SRCS)
592 endif
594 all:: export
596 clobber::
597 rm -f $(SOURCE_XP_DIR)/classes/$(PACKAGE)/*.class
599 endif
600 endif
603 # JDIRS -- like JSRCS, except you can give a list of directories and it will
604 # compile all the out-of-date java files in those directories.
606 # NOTE: recursing through these can speed things up, but they also cause
607 # some builds to run out of memory
609 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
610 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
612 ifdef JDIRS
613 ifneq ($(JAVAC),)
614 ifdef NETLIBDEPTH
615 CORE_DEPTH := $(NETLIBDEPTH)
616 endif
618 # !!!!! THIS WILL CRASH SHMSDOS.EXE !!!!!
619 # shmsdos does not support shell variables. It will crash when it tries
620 # to parse the '=' character. A solution is to rewrite outofdate.pl so it
621 # takes the Javac command as an argument and executes the command itself,
622 # instead of returning a list of files.
623 export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
624 @echo "!!! THIS COMMAND IS BROKEN ON WINDOWS--SEE rules.mk FOR DETAILS !!!"
625 return -1
626 @for d in $(JDIRS); do \
627 if test -d $$d; then \
628 set $(EXIT_ON_ERROR); \
629 files=`echo $$d/*.java`; \
630 list=`$(PERL) $(CORE_DEPTH)/coreconf/outofdate.pl $(PERLARG) \
631 -d $(JAVA_DESTPATH)/$(PACKAGE) $$files`; \
632 if test "$${list}x" != "x"; then \
633 echo Building all java files in $$d; \
634 echo $(JAVAC) $$list; \
635 $(JAVAC) $$list; \
636 fi; \
637 set +e; \
638 else \
639 echo "Skipping non-directory $$d..."; \
640 fi; \
641 $(CLICK_STOPWATCH); \
642 done
643 endif
644 endif
647 # JDK_GEN -- for generating "old style" native methods
649 # Generate JDK Headers and Stubs into the '_gen' and '_stubs' directory
651 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
652 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
654 ifneq ($(JDK_GEN),)
655 ifneq ($(JAVAH),)
656 ifdef NSBUILDROOT
657 INCLUDES += -I$(JDK_GEN_DIR) -I$(SOURCE_XP_DIR)
658 else
659 INCLUDES += -I$(JDK_GEN_DIR)
660 endif
662 ifdef NETLIBDEPTH
663 CORE_DEPTH := $(NETLIBDEPTH)
664 endif
666 JDK_PACKAGE_CLASSES := $(JDK_GEN)
667 JDK_PATH_CLASSES := $(subst .,/,$(JDK_PACKAGE_CLASSES))
668 JDK_HEADER_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
669 JDK_STUB_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
670 JDK_HEADER_CFILES := $(patsubst %,$(JDK_GEN_DIR)/%.h,$(JDK_GEN))
671 JDK_STUB_CFILES := $(patsubst %,$(JDK_STUB_DIR)/%.c,$(JDK_GEN))
673 $(JDK_HEADER_CFILES): $(JDK_HEADER_CLASSFILES)
674 $(JDK_STUB_CFILES): $(JDK_STUB_CLASSFILES)
676 export::
677 @echo Generating/Updating JDK headers
678 $(JAVAH) -d $(JDK_GEN_DIR) $(JDK_PACKAGE_CLASSES)
679 @echo Generating/Updating JDK stubs
680 $(JAVAH) -stubs -d $(JDK_STUB_DIR) $(JDK_PACKAGE_CLASSES)
681 ifndef NO_MAC_JAVA_SHIT
682 @if test ! -d $(CORE_DEPTH)/lib/mac/Java/; then \
683 echo "!!! You need to have a ns/lib/mac/Java directory checked out."; \
684 echo "!!! This allows us to automatically update generated files for the mac."; \
685 echo "!!! If you see any modified files there, please check them in."; \
687 @echo Generating/Updating JDK headers for the Mac
688 $(JAVAH) -mac -d $(CORE_DEPTH)/lib/mac/Java/_gen $(JDK_PACKAGE_CLASSES)
689 @echo Generating/Updating JDK stubs for the Mac
690 $(JAVAH) -mac -stubs -d $(CORE_DEPTH)/lib/mac/Java/_stubs $(JDK_PACKAGE_CLASSES)
691 endif
692 endif
693 endif
696 # JRI_GEN -- for generating "old style" JRI native methods
698 # Generate JRI Headers and Stubs into the 'jri' directory
700 # NOTE: For backwards compatibility, if $(NETLIBDEPTH) is defined,
701 # replace $(CORE_DEPTH) with $(NETLIBDEPTH).
703 ifneq ($(JRI_GEN),)
704 ifneq ($(JAVAH),)
705 ifdef NSBUILDROOT
706 INCLUDES += -I$(JRI_GEN_DIR) -I$(SOURCE_XP_DIR)
707 else
708 INCLUDES += -I$(JRI_GEN_DIR)
709 endif
711 ifdef NETLIBDEPTH
712 CORE_DEPTH := $(NETLIBDEPTH)
713 endif
715 JRI_PACKAGE_CLASSES := $(JRI_GEN)
716 JRI_PATH_CLASSES := $(subst .,/,$(JRI_PACKAGE_CLASSES))
717 JRI_HEADER_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JRI_PATH_CLASSES))
718 JRI_STUB_CLASSFILES := $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JRI_PATH_CLASSES))
719 JRI_HEADER_CFILES := $(patsubst %,$(JRI_GEN_DIR)/%.h,$(JRI_GEN))
720 JRI_STUB_CFILES := $(patsubst %,$(JRI_GEN_DIR)/%.c,$(JRI_GEN))
722 $(JRI_HEADER_CFILES): $(JRI_HEADER_CLASSFILES)
723 $(JRI_STUB_CFILES): $(JRI_STUB_CLASSFILES)
725 export::
726 @echo Generating/Updating JRI headers
727 $(JAVAH) -jri -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
728 @echo Generating/Updating JRI stubs
729 $(JAVAH) -jri -stubs -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
730 ifndef NO_MAC_JAVA_SHIT
731 @if test ! -d $(CORE_DEPTH)/lib/mac/Java/; then \
732 echo "!!! You need to have a ns/lib/mac/Java directory checked out."; \
733 echo "!!! This allows us to automatically update generated files for the mac."; \
734 echo "!!! If you see any modified files there, please check them in."; \
736 @echo Generating/Updating JRI headers for the Mac
737 $(JAVAH) -jri -mac -d $(CORE_DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
738 @echo Generating/Updating JRI stubs for the Mac
739 $(JAVAH) -jri -mac -stubs -d $(CORE_DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
740 endif
741 endif
742 endif
745 # JNI_GEN -- for generating JNI native methods
747 # Generate JNI Headers into the 'jni' directory
749 ifneq ($(JNI_GEN),)
750 ifneq ($(JAVAH),)
751 JNI_HEADERS := $(patsubst %,$(JNI_GEN_DIR)/%.h,$(JNI_GEN))
753 export::
754 @if test ! -d $(JNI_GEN_DIR); then \
755 echo $(JAVAH) -jni -d $(JNI_GEN_DIR) $(JNI_GEN); \
756 $(JAVAH) -jni -d $(JNI_GEN_DIR) $(JNI_GEN); \
757 else \
758 echo "Checking for out of date header files" ; \
759 $(PERL) $(CORE_DEPTH)/coreconf/jniregen.pl $(PERLARG) \
760 -d $(JAVA_DESTPATH) -j "$(JAVAH) -jni -d $(JNI_GEN_DIR)" $(JNI_GEN);\
762 endif
763 endif
766 # JMC_EXPORT -- for declaring which java classes are to be exported for jmc
768 ifneq ($(JMC_EXPORT),)
769 JMC_EXPORT_PATHS := $(subst .,/,$(JMC_EXPORT))
770 JMC_EXPORT_FILES := $(patsubst %,$(JAVA_DESTPATH)/$(PACKAGE)/%.class,$(JMC_EXPORT_PATHS))
773 # We're doing NSINSTALL -t here (copy mode) because calling INSTALL will pick up
774 # your NSDISTMODE and make links relative to the current directory. This is a
775 # problem because the source isn't in the current directory:
777 export:: $(JMC_EXPORT_FILES) $(JMCSRCDIR)
778 $(NSINSTALL) -t -m 444 $(JMC_EXPORT_FILES) $(JMCSRCDIR)
779 endif
782 # JMC_GEN -- for generating java modules
784 # Provide default export & install rules when using JMC_GEN
786 ifneq ($(JMC_GEN),)
787 ifneq ($(JMC),)
788 INCLUDES += -I$(JMC_GEN_DIR) -I.
789 JMC_HEADERS := $(patsubst %,$(JMC_GEN_DIR)/%.h,$(JMC_GEN))
790 JMC_STUBS := $(patsubst %,$(JMC_GEN_DIR)/%.c,$(JMC_GEN))
791 JMC_OBJS := $(patsubst %,$(OBJDIR)/%$(OBJ_SUFFIX),$(JMC_GEN))
793 $(JMC_GEN_DIR)/M%.h: $(JMCSRCDIR)/%.class
794 $(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)
796 $(JMC_GEN_DIR)/M%.c: $(JMCSRCDIR)/%.class
797 $(JMC) -d $(JMC_GEN_DIR) -module $(JMC_GEN_FLAGS) $(?F:.class=)
799 $(OBJDIR)/M%$(OBJ_SUFFIX): $(JMC_GEN_DIR)/M%.c $(JMC_GEN_DIR)/M%.h
800 @$(MAKE_OBJDIR)
801 $(CC) -o $@ -c $(CFLAGS) $<
803 export:: $(JMC_HEADERS) $(JMC_STUBS)
804 endif
805 endif
808 # Copy each element of EXPORTS to $(SOURCE_XP_DIR)/public/$(MODULE)/
810 PUBLIC_EXPORT_DIR = $(SOURCE_XP_DIR)/public/$(MODULE)
812 ifneq ($(EXPORTS),)
813 $(PUBLIC_EXPORT_DIR)::
814 @if test ! -d $@; then \
815 echo Creating $@; \
816 $(NSINSTALL) -D $@; \
819 export:: $(PUBLIC_EXPORT_DIR)
821 export:: $(EXPORTS)
822 $(INSTALL) -m 444 $^ $(PUBLIC_EXPORT_DIR)
824 export:: $(BUILT_SRCS)
825 endif
827 # Duplicate export rule for private exports, with different directories
829 PRIVATE_EXPORT_DIR = $(SOURCE_XP_DIR)/private/$(MODULE)
831 ifneq ($(PRIVATE_EXPORTS),)
832 $(PRIVATE_EXPORT_DIR)::
833 @if test ! -d $@; then \
834 echo Creating $@; \
835 $(NSINSTALL) -D $@; \
838 private_export:: $(PRIVATE_EXPORT_DIR)
840 private_export:: $(PRIVATE_EXPORTS)
841 $(INSTALL) -m 444 $^ $(PRIVATE_EXPORT_DIR)
842 else
843 private_export::
844 @echo There are no private exports.;
845 endif
847 ##########################################################################
848 ### RULES FOR RUNNING REGRESSION SUITE TESTS
849 ### REQUIRES 'REGRESSION_SPEC' TO BE SET TO THE NAME OF A REGRESSION SPECFILE
850 ### AND RESULTS_SUBDIR TO BE SET TO SOMETHING LIKE SECURITY/PKCS5
851 ##########################################################################
853 TESTS_DIR = $(RESULTS_DIR)/$(RESULTS_SUBDIR)/$(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)
855 ifneq ($(REGRESSION_SPEC),)
857 ifneq ($(BUILD_OPT),)
858 REGDATE = $(subst \ ,, $(shell $(PERL) $(CORE_DEPTH)/$(MODULE)/scripts/now))
859 endif
861 tests:: $(REGRESSION_SPEC)
862 cd $(PLATFORM); \
863 ../$(SOURCE_MD_DIR)/bin/regress$(PROG_SUFFIX) specfile=../$(REGRESSION_SPEC) progress $(EXTRA_REGRESS_OPTIONS); \
864 if test ! -d $(TESTS_DIR); then \
865 echo Creating $(TESTS_DIR); \
866 $(NSINSTALL) -D $(TESTS_DIR); \
868 ifneq ($(BUILD_OPT),)
869 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).sum $(TESTS_DIR); \
870 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).htm $(TESTS_DIR); \
871 echo "Please now make sure your results files are copied to $(TESTS_DIR), "; \
872 echo "then run 'reporter specfile=$(RESULTS_DIR)/rptspec'"
873 endif
874 else
875 tests::
876 @echo Error: you didn't specify REGRESSION_SPEC in your manifest.mn file!;
877 endif
880 # Duplicate export rule for releases, with different directories
882 ifneq ($(EXPORTS),)
883 $(SOURCE_RELEASE_XP_DIR)/include::
884 @if test ! -d $@; then \
885 echo Creating $@; \
886 $(NSINSTALL) -D $@; \
889 release_export:: $(SOURCE_RELEASE_XP_DIR)/include
891 release_export:: $(EXPORTS)
892 $(INSTALL) -m 444 $^ $(SOURCE_RELEASE_XP_DIR)/include
893 endif
898 ################################################################################
900 -include $(DEPENDENCIES)
902 ifneq (,$(filter-out OpenVMS OS2 WIN%,$(OS_TARGET)))
903 # Can't use sed because of its 4000-char line length limit, so resort to perl
904 PERL_DEPENDENCIES_PROGRAM = \
905 open(MD, "< $(DEPENDENCIES)"); \
906 while (<MD>) { \
907 if (m@ \.*/*$< @) { \
908 $$found = 1; \
909 last; \
912 if ($$found) { \
913 print "Removing stale dependency $< from $(DEPENDENCIES)\n"; \
914 seek(MD, 0, 0); \
915 $$tmpname = "$(OBJDIR)/fix.md" . $$$$; \
916 open(TMD, "> " . $$tmpname); \
917 while (<MD>) { \
918 s@ \.*/*$< @ @; \
919 if (!print TMD "$$_") { \
920 unlink(($$tmpname)); \
921 exit(1); \
924 close(TMD); \
925 if (!rename($$tmpname, "$(DEPENDENCIES)")) { \
926 unlink(($$tmpname)); \
928 } elsif ("$<" ne "$(DEPENDENCIES)") { \
929 print "$(MAKE): *** No rule to make target $<. Stop.\n"; \
930 exit(1); \
933 .DEFAULT:
934 @$(PERL) -e '$(PERL_DEPENDENCIES_PROGRAM)'
935 endif
937 #############################################################################
938 # X dependency system
939 #############################################################################
941 ifdef MKDEPENDENCIES
943 # For Windows, $(MKDEPENDENCIES) must be -included before including rules.mk
945 $(MKDEPENDENCIES)::
946 @$(MAKE_OBJDIR)
947 touch $(MKDEPENDENCIES)
948 chmod u+w $(MKDEPENDENCIES)
949 #on NT, the preceeding touch command creates a read-only file !?!?!
950 #which is why we have to explicitly chmod it.
951 $(MKDEPEND) -p$(OBJDIR_NAME)/ -o'$(OBJ_SUFFIX)' -f$(MKDEPENDENCIES) \
952 $(NOMD_CFLAGS) $(YOPT) $(CSRCS) $(CPPSRCS) $(ASFILES)
954 $(MKDEPEND):: $(MKDEPEND_DIR)/*.c $(MKDEPEND_DIR)/*.h
955 cd $(MKDEPEND_DIR); $(MAKE)
957 ifdef OBJS
958 depend:: $(MKDEPEND) $(MKDEPENDENCIES)
959 else
960 depend::
961 endif
962 +$(LOOP_OVER_DIRS)
964 dependclean::
965 rm -f $(MKDEPENDENCIES)
966 +$(LOOP_OVER_DIRS)
968 #-include $(NSINSTALL_DIR)/$(OBJDIR)/depend.mk
970 else
971 depend::
972 endif
974 ################################################################################
975 # Special gmake rules.
976 ################################################################################
979 # Re-define the list of default suffixes, so gmake won't have to churn through
980 # hundreds of built-in suffix rules for stuff we don't need.
982 .SUFFIXES:
983 .SUFFIXES: .out .a .ln .o .obj .c .cc .C .cpp .y .l .s .S .h .sh .i .pl .class .java .html .asm
986 # Don't delete these files if we get killed.
988 .PRECIOUS: .java $(JDK_HEADERS) $(JDK_STUBS) $(JRI_HEADERS) $(JRI_STUBS) $(JMC_HEADERS) $(JMC_STUBS) $(JNI_HEADERS)
991 # Fake targets. Always run these rules, even if a file/directory with that
992 # name already exists.
994 .PHONY: all all_platforms alltags boot clean clobber clobber_all export install libs program realclean release $(OBJDIR) $(DIRS)