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
15 # The Original Code is the Netscape Portable Runtime (NSPR).
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 1998-2000
20 # the Initial Developer. All Rights Reserved.
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 *****
42 topsrcdir
= @top_srcdir@
46 include $(MOD_DEPTH
)/config
/autoconf.mk
48 include $(topsrcdir
)/config
/config.mk
206 ifeq ($(OS_TARGET
),OS2
)
214 ifeq (,$(filter-out WINNT OS2
,$(OS_ARCH
)))
220 PROGS
= $(addprefix $(OBJDIR
)/, $(CSRCS
:.c
=$(PROG_SUFFIX
)))
224 INCLUDES
= -I
$(dist_includedir
) -I
$(topsrcdir
)/pr
/include -I
$(topsrcdir
)/pr
/include/private
226 ifeq ($(OS_ARCH
), WINNT
)
228 EXTRA_LIBS
+= -lwsock32
230 EXTRA_LIBS
+= wsock32.lib
231 LDOPTS
= -NOLOGO
-DEBUG
-DEBUGTYPE
:CV
-INCREMENTAL
:NO
233 LDOPTS
+= -PROFILE
-MAP
238 ifeq ($(OS_ARCH
),OS2
)
239 EXTRA_LIBS
= $(OS_LIBS
)
240 LDOPTS
= -Zomf
-Zlinker
/PM
:VIO
-Zlinker
/ST
:0x64000
243 ifneq ($(OS_ARCH
), WINNT
)
244 # Use an absolute pathname as the runtime library path (for the -R
245 # or -rpath linker option or the LD_RUN_PATH environment variable).
246 ifeq (,$(patsubst /%,,$(DIST
)))
247 # $(DIST) is already an absolute pathname.
248 ABSOLUTE_LIB_DIR
= $(dist_libdir
)
250 # $(DIST) is a relative pathname: prepend the current directory.
252 ABSOLUTE_LIB_DIR
= $(PWD
)/$(dist_libdir
)
256 ifeq ($(OS_ARCH
), IRIX
)
257 ifeq ($(USE_CPLUS
), 1)
260 LDOPTS
+= -rpath
$(ABSOLUTE_LIB_DIR
)
262 LDOPTS
+= -Wl
,-rdata_shared
264 LDOPTS
+= -rdata_shared
266 # For 6.x machines, include this flag
267 ifeq ($(basename $(OS_RELEASE
)),6)
275 ifeq ($(USE_PTHREADS
), 1)
276 ifeq ($(OS_RELEASE
), 6.2)
277 LDOPTS
+= -Wl
,-woff
,85
284 ifeq ($(OS_ARCH
), OSF1
)
285 ifeq ($(USE_CPLUS
), 1)
288 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
289 # we do static linking.
290 ifeq (,$(filter-out V2.0 V3.2
,$(OS_RELEASE
)))
291 LIBNSPR
= $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
292 LIBPLC
= $(dist_libdir
)/libplc
$(MOD_MAJOR_VERSION
).a
295 LDOPTS
+= -rpath
$(ABSOLUTE_LIB_DIR
)
299 ifeq ($(OS_ARCH
), HP-UX
)
300 LDOPTS
+= -z
-Wl
,+s
,+b
,$(ABSOLUTE_LIB_DIR
)
304 ifeq ($(USE_PTHREADS
),1)
305 EXTRA_LIBS
= $(LIBPTHREAD
)
310 ifeq ($(OS_ARCH
),AIX
)
311 LDOPTS
+= -blibpath
:$(ABSOLUTE_LIB_DIR
):/usr
/lib
:/lib
312 ifneq ($(OS_ARCH
)$(OS_RELEASE
),AIX4.1
)
319 ifeq ($(OS_ARCH
), SunOS
)
320 ifneq ($(OS_RELEASE
), 4.1.3_U1
)
322 LDOPTS
+= -Xlinker
-R
-Xlinker
$(ABSOLUTE_LIB_DIR
)
324 ifeq ($(USE_CPLUS
), 1)
327 LDOPTS
+= -R
$(ABSOLUTE_LIB_DIR
)
332 EXTRA_LIBS
= -lpthread
336 ifeq ($(OS_ARCH
), NEC
)
337 EXTRA_LIBS
= $(OS_LIBS
)
338 # This hardcodes in the executable programs the directory to find
339 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
340 # option for ld on other platforms.
341 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
344 ifeq ($(OS_ARCH
), NCR
)
345 # NCR needs to link against -lsocket -lnsl -ldl (and -lc, which is
346 # linked implicitly by $(CC)). Note that we did not link with these
347 # system libraries when we built libnspr.so.
348 EXTRA_LIBS
= -lsocket
-lnsl
-ldl
349 # This hardcodes in the executable programs the directory to find
350 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
351 # option for ld on other platforms.
352 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
355 ifeq ($(OS_ARCH
), NEXTSTEP
)
356 # balazs.pataki@sztaki.hu: linkage is done in a different pass in the `tests'
357 # modeul, so we have to pass the `-posix' flag by "hand" to `ld'
361 ifeq ($(OS_ARCH
), NEWS-OS
)
362 # This hardcodes in the executable programs the directory to find
363 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
364 # option for ld on other platforms.
365 #export LD_RUN_PATH = $(ABSOLUTE_LIB_DIR)
366 LIBNSPR
= $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
367 LIBPLC
= $(dist_libdir
)/libplc
$(MOD_MAJOR_VERSION
).a
368 EXTRA_LIBS
= -lsocket
-lnsl
-lgen
-lresolv
371 ifeq (,$(filter-out Linux GNU GNU_
%,$(OS_ARCH
)))
372 LDOPTS
+= -Xlinker
-rpath
$(ABSOLUTE_LIB_DIR
)
373 ifeq ($(USE_PTHREADS
),1)
374 EXTRA_LIBS
= -lpthread
378 ifeq ($(OS_ARCH
), SCOOS
)
379 # SCO Unix needs to link against -lsocket again even though we
380 # already linked with these system libraries when we built libnspr.so.
381 EXTRA_LIBS
= -lsocket
382 # This hardcodes in the executable programs the directory to find
383 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
384 # option for ld on other platforms.
385 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
388 ifeq ($(OS_ARCH
),SINIX
)
389 EXTRA_LIBS
= -lsocket
-lnsl
-lresolv
-ldl
390 # This hardcodes in the executable programs the directory to find
391 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
392 # option for ld on other platforms.
393 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
396 ifeq ($(OS_ARCH
),OpenUNIX
)
397 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
398 ifeq ($(USE_PTHREADS
),1)
403 ifeq ($(OS_ARCH
), UNIXWARE
)
404 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
407 ifeq ($(OS_ARCH
),FreeBSD
)
408 ifeq ($(USE_PTHREADS
),1)
411 LDOPTS
+= -Xlinker
-R
$(ABSOLUTE_LIB_DIR
)
414 ifeq ($(OS_ARCH
),OpenBSD
)
415 ifeq ($(USE_PTHREADS
),1)
420 ifeq ($(OS_ARCH
),BSD_OS
)
421 ifneq ($(OS_RELEASE
),1.1)
426 ifeq ($(USE_PTHREADS
),1)
427 LIBPTHREAD
= -lpthread
428 ifeq ($(OS_ARCH
),AIX
)
429 LIBPTHREAD
= -lpthreads
431 ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS QNX Darwin OpenUNIX
,$(OS_ARCH
)))
434 ifeq ($(OS_ARCH
)$(basename $(OS_RELEASE
)),HP-UXB
.10)
440 #####################################################
444 #####################################################
446 include $(topsrcdir
)/config
/rules.mk
449 ifeq ($(OS_ARCH
),AIX
)
450 ifeq ($(OS_RELEASE
),4.1)
451 ifneq ($(USE_PTHREADS
), 1)
457 ifeq ($(AIX_PRE_4_2
),1)
459 # AIX releases prior to 4.2 need a special two-step linking hack
460 # in order to both override the system select() and be able to
461 # get at the original system select().
463 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
464 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
465 # two-step linking hack below.
467 $(OBJDIR
)/%: $(OBJDIR
)/%.
$(OBJ_SUFFIX
)
470 $(CC
) $(AIX_LINK_OPTS
) -o
$(AIX_TMP
) $< $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
471 $(CC
) -o
$@
$(AIX_TMP
) $(AIX_WRAP
)
476 # All platforms that are not AIX pre-4.2.
478 $(OBJDIR
)/%$(PROG_SUFFIX
): $(OBJDIR
)/%.
$(OBJ_SUFFIX
)
480 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
481 link
$(LDOPTS
) $(EXTRA_LDOPTS
) $< $(LIBPLC
) $(LIBNSPR
) $(EXTRA_LIBS
) -out
:$@
483 @if
test -f
$@.manifest
; then \
484 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
489 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(EXTRA_LIBS
) -o
$@
497 # The following tests call BSD socket functions, so they need to link
498 # with -lsocket on some platforms.
499 ifeq ($(OS_ARCH
),SunOS
)
500 ifneq ($(OS_RELEASE
),4.1.3_U1
)
502 $(OBJDIR
)/gethost
: $(OBJDIR
)/gethost.o
503 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) -lsocket
$(EXTRA_LIBS
) -o
$@
505 $(OBJDIR
)/prpoll
: $(OBJDIR
)/prpoll.o
506 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) -lsocket
$(EXTRA_LIBS
) -o
$@
510 ifeq ($(USE_PTHREADS
), 1)
511 $(OBJDIR
)/attach
: $(OBJDIR
)/attach.o
512 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
513 $(OBJDIR
)/foreign
: $(OBJDIR
)/foreign.o
514 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
515 $(OBJDIR
)/provider
: $(OBJDIR
)/provider.o
516 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
517 $(OBJDIR
)/socket
: $(OBJDIR
)/socket.o
518 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
519 $(OBJDIR
)/testfile
: $(OBJDIR
)/testfile.o
520 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
524 # Run the test programs with no arguments
526 # Test output goes to the file pointed to by the environment variable
527 # NSPR_TEST_LOGFILE, if set, else to /dev/null
530 PROGRAMS
= $(notdir $(PROGS
))
531 ifdef NSPR_TEST_LOGFILE
532 LOGFILE
= $(NSPR_TEST_LOGFILE
)
534 ifeq (,$(filter-out WINNT OS2
,$(OS_ARCH
)))
541 ifeq ($(OS_TARGET
),Linux
)
547 runtests
:: $(PROGS
) ALWAYS
548 @
$(ECHO
) "\nNSPR Test Results - $(OBJDIR)\n"
549 @
$(ECHO
) "BEGIN\t\t\t`date`"
550 @
$(ECHO
) "NSPR_TEST_LOGFILE\t$(LOGFILE)\n"
551 @
$(ECHO
) "Test\t\t\tResult\n"
552 @cd
$(OBJDIR
); for i in
$(PROGRAMS
); do \
554 .
/$$i >> $(LOGFILE
) 2>&1 ; \
555 if
[ 0 = $$?
] ; then \
556 $(ECHO
) "\t\t\tPassed"; \
558 $(ECHO
) "\t\t\tFAILED"; \
561 @
$(ECHO
) "\nEND\t\t`date`\n"