3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is the Netscape Portable Runtime (NSPR).
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998-2000
21 # the Initial Developer. All Rights Reserved.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
39 ################################################################################
40 # We used to have a 4 pass build process. Now we do everything in one pass.
42 # export - Create generated headers and stubs. Publish public headers to
43 # dist/<arch>/include.
44 # Create libraries. Publish libraries to dist/<arch>/lib.
47 # libs - obsolete. Now a synonym of "export".
49 # all - the default makefile target. Now a synonym of "export".
51 # install - Install headers, libraries, and programs on the system.
53 # Parameters to this makefile (set these before including):
56 # TARGETS -- the target to create
57 # (defaults to $LIBRARY $PROGRAM)
59 # DIRS -- subdirectories for make to recurse on
60 # (the 'all' rule builds $TARGETS $DIRS)
62 # CSRCS -- .c files to compile
63 # (used to define $OBJS)
65 # PROGRAM -- the target program name to create from $OBJS
66 # ($OBJDIR automatically prepended to it)
68 # LIBRARY -- the target library name to create from $OBJS
69 # ($OBJDIR automatically prepended to it)
71 ################################################################################
74 topsrcdir
=$(MOD_DEPTH
)
82 include $(topsrcdir
)/config
/config.mk
91 CXXFLAGS
=$(HOST_CXXFLAGS
)
92 LDFLAGS
=$(HOST_LDFLAGS
)
98 # This makefile contains rules for building the following kinds of
100 # - LIBRARY: a static (archival) library
101 # - SHARED_LIBRARY: a shared (dynamic link) library
102 # - IMPORT_LIBRARY: an import library, used only on Windows and OS/2
104 # The names of these libraries can be generated by simply specifying
105 # LIBRARY_NAME and LIBRARY_VERSION.
109 ifeq (,$(filter-out WINNT WINCE OS2
,$(OS_ARCH
)))
112 # Win95 and OS/2 require library names conforming to the 8.3 rule.
113 # other platforms do not.
115 ifeq (,$(filter-out WIN95 WINCE WINMO OS2
,$(OS_TARGET
)))
116 LIBRARY
= $(OBJDIR
)/$(LIBRARY_NAME
)$(LIBRARY_VERSION
)_s.
$(LIB_SUFFIX
)
117 SHARED_LIBRARY
= $(OBJDIR
)/$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(DLL_SUFFIX
)
118 IMPORT_LIBRARY
= $(OBJDIR
)/$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(LIB_SUFFIX
)
119 SHARED_LIB_PDB
= $(OBJDIR
)/$(LIBRARY_NAME
)$(LIBRARY_VERSION
).pdb
121 LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
)_s.
$(LIB_SUFFIX
)
122 SHARED_LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(DLL_SUFFIX
)
123 IMPORT_LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(LIB_SUFFIX
)
124 SHARED_LIB_PDB
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
).pdb
129 LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(LIB_SUFFIX
)
130 ifeq ($(OS_ARCH
)$(OS_RELEASE
), AIX4.1
)
131 SHARED_LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
)_shr.a
134 SHARED_LIBRARY
= $(OBJDIR
)/lib
$(LIBRARY_NAME
)$(LIBRARY_VERSION
).
$(DLL_SUFFIX
)
142 ifeq (,$(filter-out WINNT WINCE OS2
,$(OS_ARCH
)))
143 TARGETS
= $(LIBRARY
) $(SHARED_LIBRARY
) $(IMPORT_LIBRARY
)
144 ifdef MOZ_DEBUG_SYMBOLS
146 ifneq (,$(filter-out 1100 1200,$(MSC_VER
)))
147 TARGETS
+= $(SHARED_LIB_PDB
)
152 TARGETS
= $(LIBRARY
) $(SHARED_LIBRARY
)
157 # OBJS is the list of object files. It can be constructed by
158 # specifying CSRCS (list of C source files) and ASFILES (list
159 # of assembly language source files).
163 OBJS
= $(addprefix $(OBJDIR
)/,$(CSRCS
:.c
=.
$(OBJ_SUFFIX
))) \
164 $(addprefix $(OBJDIR
)/,$(ASFILES
:.
$(ASM_SUFFIX
)=.
$(OBJ_SUFFIX
)))
167 ALL_TRASH
= $(TARGETS
) $(OBJS
) $(RES
) $(filter-out . ..
, $(OBJDIR
)) LOGS TAGS
$(GARBAGE
) \
171 ifndef RELEASE_LIBS_DEST
172 RELEASE_LIBS_DEST
= $(RELEASE_LIB_DIR
)
178 endef # do not remove the blank line!
181 LOOP_OVER_DIRS
= $(foreach dir,$(DIRS
),$(MAKE_IN_DIR
))
184 ################################################################################
194 rm -rf
$(OBJS
) $(RES
) so_locations
$(NOSUCHFILE
) $(GARBAGE
)
198 rm -rf
$(OBJS
) $(RES
) $(TARGETS
) $(filter-out . ..
,$(OBJDIR
)) $(GARBAGE
) so_locations
$(NOSUCHFILE
)
201 realclean clobber_all
::
202 rm -rf
$(wildcard *.OBJ
*.OBJD
) dist $(ALL_TRASH
)
206 rm -rf
$(wildcard *.OBJ
*.OBJD
) dist $(ALL_TRASH
) $(DIST_GARBAGE
)
209 install:: $(RELEASE_BINS
) $(RELEASE_HEADERS
) $(RELEASE_LIBS
)
211 $(NSINSTALL
) -t
-m
0755 $(RELEASE_BINS
) $(DESTDIR
)$(bindir)
213 ifdef RELEASE_HEADERS
214 $(NSINSTALL
) -t
-m
0644 $(RELEASE_HEADERS
) $(DESTDIR
)$(includedir)/$(include_subdir
)
217 $(NSINSTALL
) -t
-m
0755 $(RELEASE_LIBS
) $(DESTDIR
)$(libdir)/$(lib_subdir
)
223 @echo
"Copying executable programs and scripts to release directory"
224 @if
test -z
"$(BUILD_NUMBER)"; then \
225 echo
"BUILD_NUMBER must be defined"; \
230 @if
test ! -d
$(RELEASE_BIN_DIR
); then \
231 rm -rf
$(RELEASE_BIN_DIR
); \
232 $(NSINSTALL
) -D
$(RELEASE_BIN_DIR
);\
236 cp
$(RELEASE_BINS
) $(RELEASE_BIN_DIR
)
239 @echo
"Copying libraries to release directory"
240 @if
test -z
"$(BUILD_NUMBER)"; then \
241 echo
"BUILD_NUMBER must be defined"; \
246 @if
test ! -d
$(RELEASE_LIBS_DEST
); then \
247 rm -rf
$(RELEASE_LIBS_DEST
); \
248 $(NSINSTALL
) -D
$(RELEASE_LIBS_DEST
);\
252 cp
$(RELEASE_LIBS
) $(RELEASE_LIBS_DEST
)
254 ifdef RELEASE_HEADERS
255 @echo
"Copying header files to release directory"
256 @if
test -z
"$(BUILD_NUMBER)"; then \
257 echo
"BUILD_NUMBER must be defined"; \
262 @if
test ! -d
$(RELEASE_HEADERS_DEST
); then \
263 rm -rf
$(RELEASE_HEADERS_DEST
); \
264 $(NSINSTALL
) -D
$(RELEASE_HEADERS_DEST
);\
268 cp
$(RELEASE_HEADERS
) $(RELEASE_HEADERS_DEST
)
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
278 cd
$(@D
); $(MAKE
) $(@F
)
282 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
283 $(CC
) $(OBJS
) -Fe
$@
-link
$(LDFLAGS
) $(OS_LIBS
) $(EXTRA_LIBS
)
285 @if
test -f
$@.manifest
; then \
286 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
289 endif # MSVC with manifest tool
291 $(CC
) -o
$@
$(CFLAGS
) $(OBJS
) $(LDFLAGS
)
292 endif # WINNT && !GCC
300 $(AR
) $(AR_FLAGS
) $(OBJS
) $(AR_EXTRA_ARGS
)
303 ifeq ($(OS_TARGET
), OS2
)
304 $(IMPORT_LIBRARY
): $(MAPFILE
)
306 $(IMPLIB
) $@
$(MAPFILE
)
308 ifeq (,$(filter-out WIN95 WINCE WINMO
,$(OS_TARGET
)))
309 $(IMPORT_LIBRARY
): $(SHARED_LIBRARY
)
313 $(SHARED_LIBRARY
): $(OBJS
) $(RES
) $(MAPFILE
)
316 ifeq ($(OS_ARCH
)$(OS_RELEASE
), AIX4.1
)
317 echo
"#!" > $(OBJDIR
)/lib
$(LIBRARY_NAME
)_syms
318 nm
-B
-C
-g
$(OBJS
) \
319 | awk
'/ [T,D] / {print $$3}' \
321 |
sort -u
>> $(OBJDIR
)/lib
$(LIBRARY_NAME
)_syms
322 $(LD
) $(XCFLAGS
) -o
$@
$(OBJS
) -bE
:$(OBJDIR
)/lib
$(LIBRARY_NAME
)_syms \
323 -bM
:SRE
-bnoentry
$(OS_LIBS
) $(EXTRA_LIBS
)
325 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
326 $(LINK_DLL
) -MAP
$(DLLBASE
) $(DLL_LIBS
) $(EXTRA_LIBS
) $(OBJS
) $(RES
)
328 @if
test -f
$@.manifest
; then \
329 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;2; \
332 endif # MSVC with manifest tool
334 $(MKSHLIB
) $(OBJS
) $(RES
) $(LDFLAGS
) $(EXTRA_LIBS
)
335 endif # WINNT && !GCC
341 ifeq ($(OS_ARCH
),WINNT
)
344 # The resource compiler does not understand the -U option.
346 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
:-I
%=--include-dir
%) -o
$@
$<
348 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
) -Fo
$@
$<
350 @echo
$(RES
) finished
353 $(MAPFILE
): $(LIBRARY_NAME
).def
355 ifeq ($(OS_ARCH
),SunOS
)
357 sed
-e
's,;+,,' -e
's; DATA ;;' -e
's,;;,,' -e
's,;.*,;,' > $@
359 ifeq ($(OS_ARCH
),OS2
)
360 echo LIBRARY
$(LIBRARY_NAME
)$(LIBRARY_VERSION
) INITINSTANCE TERMINSTANCE
> $@
362 echo CODE LOADONCALL MOVEABLE DISCARDABLE
>> $@
363 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED
>> $@
365 grep
-v
';+' $< | grep
-v
';-' | \
366 sed
-e
's; DATA ;;' -e
's,;;,,' -e
's,;.*,,' -e
's,\([\t ]*\),\1_,' | \
367 awk
'BEGIN {ord=1;} { print($$0 " @" ord " RESIDENTNAME"); ord++;}' >> $@
372 # Translate source filenames to absolute paths. This is required for
373 # debuggers under Windows and OS/2 to find source files automatically.
376 ifeq (,$(filter-out AIX OS2
,$(OS_ARCH
)))
377 NEED_ABSOLUTE_PATH
= 1
380 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
381 NEED_ABSOLUTE_PATH
= 1
384 ifdef NEED_ABSOLUTE_PATH
385 # The quotes allow absolute paths to contain spaces.
386 pr_abspath
= "$(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))"
389 $(OBJDIR
)/%.
$(OBJ_SUFFIX
): %.
cpp
391 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
392 $(CCC
) -Fo
$@
-c
$(CCCFLAGS
) $(call pr_abspath
,$<)
394 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINCE
)
395 $(CCC
) -Fo
$@
-c
$(CCCFLAGS
) $<
397 ifdef NEED_ABSOLUTE_PATH
398 $(CCC
) -o
$@
-c
$(CCCFLAGS
) $(call pr_abspath
,$<)
400 $(CCC
) -o
$@
-c
$(CCCFLAGS
) $<
405 WCCFLAGS1
= $(subst /,\\,$(CFLAGS
))
406 WCCFLAGS2
= $(subst -I
,-i
=,$(WCCFLAGS1
))
407 WCCFLAGS3
= $(subst -D
,-d
,$(WCCFLAGS2
))
408 $(OBJDIR
)/%.
$(OBJ_SUFFIX
): %.c
410 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
411 $(CC
) -Fo
$@
-c
$(CFLAGS
) $(call pr_abspath
,$<)
413 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINCE
)
414 $(CC
) -Fo
$@
-c
$(CFLAGS
) $<
416 ifdef NEED_ABSOLUTE_PATH
417 $(CC
) -o
$@
-c
$(CFLAGS
) $(call pr_abspath
,$<)
419 $(CC
) -o
$@
-c
$(CFLAGS
) $<
425 $(OBJDIR
)/%.
$(OBJ_SUFFIX
): %.s
427 $(AS
) -o
$@
$(ASFLAGS
) -c
$<
430 $(CC
) -C
-E
$(CFLAGS
) $< > $*.i
433 rm -f
$@
; cp
$< $@
; chmod
+x
$@
438 # The only purpose of this rule is to pass Mozilla's Tinderbox depend
439 # builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's
440 # Tinderbox builds NSPR continuously as part of the Mozilla client.
441 # Because NSPR's make depend is not implemented, whenever we change
442 # an NSPR header file, the depend build does not recompile the NSPR
443 # files that depend on the header.
445 # This rule makes all the objects depend on a dummy header file.
446 # Touch this dummy header file to force the depend build to recompile
449 # This rule should be removed when make depend is implemented.
452 DUMMY_DEPEND_H
= $(topsrcdir
)/config
/prdepend.h
454 $(filter $(OBJDIR
)/%.
$(OBJ_SUFFIX
),$(OBJS
)): $(OBJDIR
)/%.
$(OBJ_SUFFIX
): $(DUMMY_DEPEND_H
)
458 ################################################################################
459 # Special gmake rules.
460 ################################################################################
463 # Re-define the list of default suffixes, so gmake won't have to churn through
464 # hundreds of built-in suffix rules for stuff we don't need.
467 .SUFFIXES
: .a .
$(OBJ_SUFFIX
) .c .
cpp .s .h .i .pl
470 # Fake targets. Always run these rules, even if a file/directory with that
471 # name already exists.
473 .PHONY
: all alltags
clean export install libs
realclean release
476 # List the target pattern of an implicit rule as a dependency of the
477 # special target .PRECIOUS to preserve intermediate files made by
478 # implicit rules whose target patterns match that file's name.
479 # (See GNU Make documentation, Edition 0.51, May 1996, Sec. 10.4,
482 .PRECIOUS
: $(OBJDIR
)/%.
$(OBJ_SUFFIX
)