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 ifeq ($(MOZ_OS2_TOOLS
),VACPP
)
240 LDOPTS
= -NOE
-DEBUG
-nologo
-PMTYPE
:VIO
242 EXTRA_LIBS
= $(OS_LIBS
)
243 LDOPTS
= -Zomf
-Zlinker
/PM
:VIO
-Zlinker
/ST
:0x64000
247 ifneq ($(OS_ARCH
), WINNT
)
248 # Use an absolute pathname as the runtime library path (for the -R
249 # or -rpath linker option or the LD_RUN_PATH environment variable).
250 ifeq (,$(patsubst /%,,$(DIST
)))
251 # $(DIST) is already an absolute pathname.
252 ABSOLUTE_LIB_DIR
= $(dist_libdir
)
254 # $(DIST) is a relative pathname: prepend the current directory.
256 ABSOLUTE_LIB_DIR
= $(PWD
)/$(dist_libdir
)
260 ifeq ($(OS_ARCH
), IRIX
)
261 ifeq ($(USE_CPLUS
), 1)
264 LDOPTS
+= -rpath
$(ABSOLUTE_LIB_DIR
)
266 LDOPTS
+= -Wl
,-rdata_shared
268 LDOPTS
+= -rdata_shared
270 # For 6.x machines, include this flag
271 ifeq ($(basename $(OS_RELEASE
)),6)
279 ifeq ($(USE_PTHREADS
), 1)
280 ifeq ($(OS_RELEASE
), 6.2)
281 LDOPTS
+= -Wl
,-woff
,85
288 ifeq ($(OS_ARCH
), OSF1
)
289 ifeq ($(USE_CPLUS
), 1)
292 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
293 # we do static linking.
294 ifeq (,$(filter-out V2.0 V3.2
,$(OS_RELEASE
)))
295 LIBNSPR
= $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
296 LIBPLC
= $(dist_libdir
)/libplc
$(MOD_MAJOR_VERSION
).a
299 LDOPTS
+= -rpath
$(ABSOLUTE_LIB_DIR
)
303 ifeq ($(OS_ARCH
), HP-UX
)
304 LDOPTS
+= -z
-Wl
,+s
,+b
,$(ABSOLUTE_LIB_DIR
)
308 ifeq ($(USE_PTHREADS
),1)
309 EXTRA_LIBS
= $(LIBPTHREAD
)
314 ifeq ($(OS_ARCH
),AIX
)
315 LDOPTS
+= -blibpath
:$(ABSOLUTE_LIB_DIR
):/usr
/lib
:/lib
316 ifneq ($(OS_ARCH
)$(OS_RELEASE
),AIX4.1
)
323 ifeq ($(OS_ARCH
), SunOS
)
324 ifneq ($(OS_RELEASE
), 4.1.3_U1
)
326 LDOPTS
+= -Xlinker
-R
-Xlinker
$(ABSOLUTE_LIB_DIR
)
328 ifeq ($(USE_CPLUS
), 1)
331 LDOPTS
+= -R
$(ABSOLUTE_LIB_DIR
)
335 ifneq ($(LOCAL_THREADS_ONLY
),1)
337 EXTRA_LIBS
= -lpthread
339 EXTRA_LIBS
= -lthread
341 endif # LOCAL_THREADS_ONLY
344 ifeq ($(OS_ARCH
), NEC
)
345 EXTRA_LIBS
= $(OS_LIBS
)
346 # This hardcodes in the executable programs the directory to find
347 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
348 # option for ld on other platforms.
349 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
352 ifeq ($(OS_ARCH
), NCR
)
353 # NCR needs to link against -lsocket -lnsl -ldl (and -lc, which is
354 # linked implicitly by $(CC)). Note that we did not link with these
355 # system libraries when we built libnspr.so.
356 EXTRA_LIBS
= -lsocket
-lnsl
-ldl
357 # This hardcodes in the executable programs the directory to find
358 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
359 # option for ld on other platforms.
360 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
363 ifeq ($(OS_ARCH
), NEXTSTEP
)
364 # balazs.pataki@sztaki.hu: linkage is done in a different pass in the `tests'
365 # modeul, so we have to pass the `-posix' flag by "hand" to `ld'
369 ifeq ($(OS_ARCH
), NEWS-OS
)
370 # This hardcodes in the executable programs the directory to find
371 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
372 # option for ld on other platforms.
373 #export LD_RUN_PATH = $(ABSOLUTE_LIB_DIR)
374 LIBNSPR
= $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
375 LIBPLC
= $(dist_libdir
)/libplc
$(MOD_MAJOR_VERSION
).a
376 EXTRA_LIBS
= -lsocket
-lnsl
-lgen
-lresolv
379 ifeq (,$(filter-out Linux GNU GNU_
%,$(OS_ARCH
)))
380 LDOPTS
+= -Xlinker
-rpath
$(ABSOLUTE_LIB_DIR
)
381 ifeq ($(USE_PTHREADS
),1)
382 EXTRA_LIBS
= -lpthread
386 ifeq ($(OS_ARCH
), SCOOS
)
387 # SCO Unix needs to link against -lsocket again even though we
388 # already linked with these system libraries when we built libnspr.so.
389 EXTRA_LIBS
= -lsocket
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
),SINIX
)
397 EXTRA_LIBS
= -lsocket
-lnsl
-lresolv
-ldl
398 # This hardcodes in the executable programs the directory to find
399 # libnspr.so etc. at program startup. Equivalent to the -R or -rpath
400 # option for ld on other platforms.
401 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
404 ifeq ($(OS_ARCH
),OpenUNIX
)
405 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
406 ifeq ($(USE_PTHREADS
),1)
411 ifeq ($(OS_ARCH
), UNIXWARE
)
412 export LD_RUN_PATH
= $(ABSOLUTE_LIB_DIR
)
415 ifeq ($(OS_ARCH
),FreeBSD
)
416 ifeq ($(USE_PTHREADS
),1)
419 LDOPTS
+= -Xlinker
-R
$(ABSOLUTE_LIB_DIR
)
422 ifeq ($(OS_ARCH
),OpenBSD
)
423 ifeq ($(USE_PTHREADS
),1)
428 ifeq ($(OS_ARCH
),BSD_OS
)
429 ifneq ($(OS_RELEASE
),1.1)
434 ifeq ($(USE_PTHREADS
),1)
435 LIBPTHREAD
= -lpthread
436 ifeq ($(OS_ARCH
),AIX
)
437 LIBPTHREAD
= -lpthreads
439 ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS QNX Darwin OpenUNIX
,$(OS_ARCH
)))
442 ifeq ($(OS_ARCH
)$(basename $(OS_RELEASE
)),HP-UXB
.10)
448 #####################################################
452 #####################################################
454 include $(topsrcdir
)/config
/rules.mk
457 ifeq ($(OS_ARCH
),AIX
)
458 ifeq ($(OS_RELEASE
),4.1)
459 ifneq ($(USE_PTHREADS
), 1)
465 ifeq ($(AIX_PRE_4_2
),1)
467 # AIX releases prior to 4.2 need a special two-step linking hack
468 # in order to both override the system select() and be able to
469 # get at the original system select().
471 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
472 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
473 # two-step linking hack below.
475 $(OBJDIR
)/%: $(OBJDIR
)/%.
$(OBJ_SUFFIX
)
478 $(CC
) $(AIX_LINK_OPTS
) -o
$(AIX_TMP
) $< $(dist_libdir
)/libnspr
$(MOD_MAJOR_VERSION
).a
479 $(CC
) -o
$@
$(AIX_TMP
) $(AIX_WRAP
)
484 # All platforms that are not AIX pre-4.2.
486 $(OBJDIR
)/%$(PROG_SUFFIX
): $(OBJDIR
)/%.
$(OBJ_SUFFIX
)
488 ifeq ($(NS_USE_GCC
)_
$(OS_ARCH
),_WINNT
)
489 link
$(LDOPTS
) $(EXTRA_LDOPTS
) $< $(LIBPLC
) $(LIBNSPR
) $(EXTRA_LIBS
) -out
:$@
491 @if
test -f
$@.manifest
; then \
492 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
497 ifeq ($(MOZ_OS2_TOOLS
),VACPP
)
498 $(LD
) $(EXEFLAGS
) $(LDOPTS
) $< $(LIBPLC
) $(LIBNSPR
) $(OS_LIBS
) $(EXTRA_LIBS
)
500 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(EXTRA_LIBS
) -o
$@
509 # The following tests call BSD socket functions, so they need to link
510 # with -lsocket on some platforms.
511 ifeq ($(OS_ARCH
),SunOS
)
512 ifneq ($(OS_RELEASE
),4.1.3_U1
)
514 $(OBJDIR
)/gethost
: $(OBJDIR
)/gethost.o
515 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) -lsocket
$(EXTRA_LIBS
) -o
$@
517 $(OBJDIR
)/prpoll
: $(OBJDIR
)/prpoll.o
518 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) -lsocket
$(EXTRA_LIBS
) -o
$@
522 ifeq ($(USE_PTHREADS
), 1)
523 $(OBJDIR
)/attach
: $(OBJDIR
)/attach.o
524 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
525 $(OBJDIR
)/foreign
: $(OBJDIR
)/foreign.o
526 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
527 $(OBJDIR
)/provider
: $(OBJDIR
)/provider.o
528 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
529 $(OBJDIR
)/socket
: $(OBJDIR
)/socket.o
530 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
531 $(OBJDIR
)/testfile
: $(OBJDIR
)/testfile.o
532 $(PURE
) $(CC
) $(XCFLAGS
) $< $(LDOPTS
) $(LIBPLC
) $(LIBNSPR
) $(LIBPTHREAD
) $(EXTRA_LIBS
) -o
$@
536 # Run the test programs with no arguments
538 # Test output goes to the file pointed to by the environment variable
539 # NSPR_TEST_LOGFILE, if set, else to /dev/null
542 PROGRAMS
= $(notdir $(PROGS
))
543 ifdef NSPR_TEST_LOGFILE
544 LOGFILE
= $(NSPR_TEST_LOGFILE
)
546 ifeq (,$(filter-out WINNT OS2
,$(OS_ARCH
)))
553 ifeq ($(OS_TARGET
),Linux
)
559 runtests
:: $(PROGS
) ALWAYS
560 @
$(ECHO
) "\nNSPR Test Results - $(OBJDIR)\n"
561 @
$(ECHO
) "BEGIN\t\t\t`date`"
562 @
$(ECHO
) "NSPR_TEST_LOGFILE\t$(LOGFILE)\n"
563 @
$(ECHO
) "Test\t\t\tResult\n"
564 @cd
$(OBJDIR
); for i in
$(PROGRAMS
); do \
566 .
/$$i >> $(LOGFILE
) 2>&1 ; \
567 if
[ 0 = $$?
] ; then \
568 $(ECHO
) "\t\t\tPassed"; \
570 $(ECHO
) "\t\t\tFAILED"; \
573 @
$(ECHO
) "\nEND\t\t`date`\n"