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 security libraries.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1994-2000
21 # the Initial Developer. All Rights Reserved.
24 # Stephen Fung <fungstep@hotmail.com> and
25 # Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 #######################################################################
42 # (1) Include initial platform-independent assignments (MANDATORY). #
43 #######################################################################
47 #######################################################################
48 # (2) Include "global" configuration information. (OPTIONAL) #
49 #######################################################################
51 include $(CORE_DEPTH
)/coreconf
/config.mk
53 #######################################################################
54 # (3) Include "component" configuration information. (OPTIONAL) #
55 #######################################################################
59 #######################################################################
60 # (4) Include "local" platform-dependent assignments (OPTIONAL). #
61 #######################################################################
65 # default for all platforms
66 # unset this on those that have multiple freebl libraries
67 FREEBL_BUILD_SINGLE_SHLIB
= 1
70 DEFINES
+= -DNSS_USE_64
74 DEFINES
+= -DNSS_USE_ABI32_FPU
77 # des.c wants _X86_ defined for intel CPUs.
78 # coreconf does this for windows, but not for Linux, FreeBSD, etc.
79 ifeq ($(CPU_ARCH
),x86
)
80 ifneq (,$(filter-out WIN
%,$(OS_TARGET
)))
81 OS_REL_CFLAGS
+= -D_X86_
85 ifeq ($(OS_TARGET
),OSF1
)
86 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_NO_MP_WORD
87 MPI_SRCS
+= mpvalpha.c
90 ifeq (,$(filter-out WINNT WIN95
,$(OS_TARGET
))) #omits WIN16 and WINCE
92 # Ideally, we want to use assembler
94 # DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE \
95 # -DMP_ASSEMBLY_DIV_2DX1D
96 # but we haven't figured out how to make it work, so we are not
97 # using assembler right now.
99 DEFINES
+= -DMP_NO_MP_WORD
-DMP_USE_UINT_DIGIT
101 MPI_SRCS
+= mpi_x86_asm.c
102 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
103 DEFINES
+= -DMP_ASSEMBLY_DIV_2DX1D
-DMP_USE_UINT_DIGIT
-DMP_NO_MP_WORD
105 OPTIMIZER
+= -Ox
# maximum optimization for freebl
110 ifeq ($(OS_TARGET
),WINCE
)
111 DEFINES
+= -DMP_ARGCHK
=0 # no assert in WinCE
112 DEFINES
+= -DSHA_NO_LONG_LONG
# avoid 64-bit arithmetic in SHA512
115 ifeq ($(OS_TARGET
),IRIX
)
118 ifeq ($(NS_USE_GCC
),1)
119 ASFLAGS
= -Wp
,-P
-Wp
,-traditional
-O
-mips3
121 ASFLAGS
= -O
-OPT
:Olimit
=4000 -dollar
-fullwarn
-xansi
-n32
-mips3
123 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
124 DEFINES
+= -DMP_USE_UINT_DIGIT
128 ifeq ($(OS_TARGET
),Linux
)
129 ifeq ($(CPU_ARCH
),x86_64
)
130 ASFILES
= arcfour-amd64-gas.s mpi_amd64_gas.s
131 ASFLAGS
+= -march
=opteron
-m64
-fPIC
132 DEFINES
+= -DNSS_BEVAND_ARCFOUR
-DMPI_AMD64
-DMP_ASSEMBLY_MULTIPLY
133 DEFINES
+= -DNSS_USE_COMBA
134 DEFINES
+= -DMP_CHAR_STORE_SLOW
-DMP_IS_LITTLE_ENDIAN
135 # DEFINES += -DMPI_AMD64_ADD
136 MPI_SRCS
+= mpi_amd64.c mp_comba.c
138 ifeq ($(CPU_ARCH
),x86
)
140 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
141 DEFINES
+= -DMP_ASSEMBLY_DIV_2DX1D
142 DEFINES
+= -DMP_CHAR_STORE_SLOW
-DMP_IS_LITTLE_ENDIAN
143 # The floating point ECC code doesn't work on Linux x86 (bug 311432).
148 ifeq ($(OS_TARGET
),AIX
)
149 DEFINES
+= -DMP_USE_UINT_DIGIT
151 DEFINES
+= -DMP_NO_DIV_WORD
-DMP_NO_ADD_WORD
-DMP_NO_SUB_WORD
155 ifeq ($(OS_TARGET
), HP-UX
)
156 ifneq ($(OS_TEST
), ia64
)
158 ASFILES
+= ret_cr16.s
160 FREEBL_BUILD_SINGLE_SHLIB
=
164 ifdef FREEBL_CHILD_BUILD
165 ifdef USE_ABI32_INT32
166 # build for DA1.1 (HP PA 1.1) 32-bit ABI build with 32-bit arithmetic
167 DEFINES
+= -DMP_USE_UINT_DIGIT
-DMP_NO_MP_WORD
168 DEFINES
+= -DSHA_NO_LONG_LONG
# avoid 64-bit arithmetic in SHA512
171 # this builds for DA2.0W (HP PA 2.0 Wide), the LP64 ABI, using 64-bit digits
173 ASFILES
+= hpma512.s hppa20.s
174 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
176 # this builds for DA2.0 (HP PA 2.0 Narrow) ABI32_FPU model
177 # (the 32-bit ABI with 64-bit registers) using 64-bit digits
179 ASFILES
+= hpma512.s hppa20.s
180 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
181 ARCHFLAG
= -Aa
+e
+DA2.0
+DS2.0
188 # The blapi functions are defined not only in the freebl shared
189 # libraries but also in the shared libraries linked with loader.c
190 # (libsoftokn3.so and libssl3.so). We need to use GNU ld's
191 # -Bsymbolic option or the equivalent option for other linkers
192 # to bind the blapi function references in FREEBLVector vector
193 # (ldvector.c) to the blapi functions defined in the freebl
195 ifeq (,$(filter-out BSD_OS FreeBSD Linux NetBSD OpenBSD
, $(OS_TARGET
)))
196 MKSHLIB
+= -Wl
,-Bsymbolic
199 ifeq ($(OS_TARGET
),SunOS
)
201 # The -R '$ORIGIN' linker option instructs this library to search for its
202 # dependencies in the same directory where it resides.
203 MKSHLIB
+= -R
'$$ORIGIN'
206 MKSHLIB
+= -Wl
,-Bsymbolic
,-z
,now
,-z
,text
208 MKSHLIB
+= -Wl
,-B
,symbolic
,-z
,now
,-z
,text
209 endif # GCC_USE_GNU_LD
211 MKSHLIB
+= -B symbolic
-z now
-z text
214 # Sun's WorkShop defines v8, v8plus and v9 architectures.
215 # gcc on Solaris defines v8 and v9 "cpus".
216 # gcc's v9 is equivalent to Workshop's v8plus.
217 # gcc's -m64 is equivalent to Workshop's v9
218 # We always use Sun's assembler, which uses Sun's naming convention.
219 ifeq ($(CPU_ARCH
),sparc
)
220 FREEBL_BUILD_SINGLE_SHLIB
=
230 SOLARIS_AS
= /usr
/ccs
/bin
/as
231 #### set arch, asm, c flags
233 ifdef USE_ABI32_INT32
234 # default ARCHFLAG=-mcpu=v8 set by coreconf/sunOS5.mk
236 ifdef USE_ABI32_INT64
237 ARCHFLAG
=-mcpu
=v9
-Wa
,-xarch
=v8plus
238 SOLARIS_AS_FLAGS
= -xarch
=v8plus
-K PIC
241 ARCHFLAG
=-mcpu
=v9
-Wa
,-xarch
=v8plusa
242 SOLARIS_AS_FLAGS
= -xarch
=v8plusa
-K PIC
243 endif # USE_ABI32_FPU
245 # this builds for Sparc v9a pure 64-bit architecture
246 ARCHFLAG
+= -mcpu
=v9
-Wa
,-xarch
=v9
247 SOLARIS_AS_FLAGS
= -xarch
=v9
-K PIC
250 # this builds for Sparc v9a pure 64-bit architecture
251 # It uses floating point, and 32-bit word size
252 ARCHFLAG
+= -mcpu
=v9
-Wa
,-xarch
=v9a
253 SOLARIS_AS_FLAGS
= -xarch
=v9a
-K PIC
256 # FPU_TARGET_OPTIMIZER specifies the target processor and cache
257 # properties of the ABI32_FPU and ABI64_FPU architectures for use
259 ifeq (,$(findstring Sun WorkShop
6,$(shell $(CC
) -V
2>&1)))
260 # if the compiler is not Forte 6
261 FPU_TARGET_OPTIMIZER
= -xcache
=64/32/4:1024/64/4 -xchip
=ultra3
263 # Forte 6 C compiler generates incorrect code for rijndael.c
264 # if -xchip=ultra3 is used (Bugzilla bug 333925). So we revert
265 # to what we used in NSS 3.10.
266 FPU_TARGET_OPTIMIZER
= -xchip
=ultra2
268 ifdef USE_ABI32_INT32
269 #ARCHFLAG=-xarch=v8 set in coreconf/sunOS5.mk
271 ifdef USE_ABI32_INT64
272 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
273 # 32-bit ABI, it uses 64-bit words, integer arithmetic,
274 # no FPU (non-VIS cpus).
275 # These flags were suggested by the compiler group for building
280 SOL_CFLAGS
+= -xtarget
=generic
281 ARCHFLAG
= -xarch
=v8plus
282 SOLARIS_AS_FLAGS
= -xarch
=v8plus
-K PIC
285 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
286 # 32-bit ABI, it uses FPU code, and 32-bit word size.
287 # these flags were determined by running cc -### -fast and copying
288 # the generated flag settings
289 SOL_CFLAGS
+= -fsingle
-xmemalign
=8s
291 SOL_CFLAGS
+= -D__MATHERR_ERRNO_DONTCARE
-fsimple
=1
292 SOL_CFLAGS
+= -xalias_level
=basic
-xbuiltin
=%all
293 SOL_CFLAGS
+= $(FPU_TARGET_OPTIMIZER
) -xdepend
294 SOL_CFLAGS
+= -xlibmil
-xO5
296 ARCHFLAG
= -xarch
=v8plusa
297 SOLARIS_AS_FLAGS
= -xarch
=v8plusa
-K PIC
300 # this builds for Sparc v9a pure 64-bit architecture,
301 # no FPU (non-VIS cpus). For building with SunStudio 10.
305 SOL_CFLAGS
+= -xtarget
=generic
307 SOLARIS_AS_FLAGS
= -xarch
=v9
-K PIC
310 # this builds for Sparc v9a pure 64-bit architecture
311 # It uses floating point, and 32-bit word size.
312 # See comment for USE_ABI32_FPU.
313 SOL_CFLAGS
+= -fsingle
-xmemalign
=8s
315 SOL_CFLAGS
+= -D__MATHERR_ERRNO_DONTCARE
-fsimple
=1
316 SOL_CFLAGS
+= -xalias_level
=basic
-xbuiltin
=%all
317 SOL_CFLAGS
+= $(FPU_TARGET_OPTIMIZER
) -xdepend
318 SOL_CFLAGS
+= -xlibmil
-xO5
320 ARCHFLAG
= -xarch
=v9a
321 SOLARIS_AS_FLAGS
= -xarch
=v9a
-K PIC
325 ### set flags for both GCC and Sun cc
326 ifdef USE_ABI32_INT32
327 # this builds for Sparc v8 pure 32-bit architecture
328 DEFINES
+= -DMP_USE_UINT_DIGIT
-DMP_ASSEMBLY_MULTIPLY
329 ASFILES
= mpv_sparcv8x.s
330 DEFINES
+= -DSHA_NO_LONG_LONG
# avoid 64-bit arithmetic in SHA512
332 ifdef USE_ABI32_INT64
333 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
334 # 32-bit ABI, it uses 64-bit words, integer arithmetic, no FPU
335 # best times are with no MP_ flags specified
338 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
339 # 32-bit ABI, it uses FPU code, and 32-bit word size
340 MPI_SRCS
+= mpi_sparc.c
341 ASFILES
= mpv_sparcv8.s montmulfv8.s
342 DEFINES
+= -DMP_NO_MP_WORD
-DMP_USE_UINT_DIGIT
-DMP_ASSEMBLY_MULTIPLY
343 DEFINES
+= -DMP_USING_MONT_MULF
-DMP_MONT_USE_MP_MUL
347 # this builds for Sparc v9a pure 64-bit architecture
348 # best times are with no MP_ flags specified
351 # this builds for Sparc v9a pure 64-bit architecture
352 # It uses floating point, and 32-bit word size
353 MPI_SRCS
+= mpi_sparc.c
354 ASFILES
= mpv_sparcv9.s montmulfv9.s
355 DEFINES
+= -DMP_NO_MP_WORD
-DMP_USE_UINT_DIGIT
-DMP_ASSEMBLY_MULTIPLY
356 DEFINES
+= -DMP_USING_MONT_MULF
-DMP_MONT_USE_MP_MUL
361 # Solaris for non-sparc family CPUs
370 ASFILES
= arcfour-amd64-gas.s mpi_amd64_gas.s
371 ASFLAGS
+= -march
=opteron
-m64
-fPIC
372 MPI_SRCS
+= mp_comba.c
374 ASFILES
= arcfour-amd64-sun.s mpi_amd64_sun.s sha-fast-amd64-sun.s
375 ASFILES
+= mp_comba_amd64_sun.s mpcpucache_amd64.s
376 ASFLAGS
+= -xarch
=generic64
-K PIC
380 DEFINES
+= -DNSS_BEVAND_ARCFOUR
-DMPI_AMD64
-DMP_ASSEMBLY_MULTIPLY
381 DEFINES
+= -DNSS_USE_COMBA
-DMP_CHAR_STORE_SLOW
-DMP_IS_LITTLE_ENDIAN
382 MPI_SRCS
+= mpi_amd64.c
386 DEFINES
+= -DMP_USE_UINT_DIGIT
387 DEFINES
+= -DMP_ASSEMBLY_MULTIPLY
-DMP_ASSEMBLY_SQUARE
388 DEFINES
+= -DMP_ASSEMBLY_DIV_2DX1D
389 ASFILES
= mpi_i86pc.s
392 ASFILES
+= mpcpucache_x86.s
395 endif # Solaris for non-sparc family CPUs
396 endif # target == SunOS
400 #enable floating point ECC code
401 DEFINES
+= -DECL_USE_FP
402 ECL_SRCS
+= ecp_fp160.c ecp_fp192.c ecp_fp224.c ecp_fp.c
405 endif # NSS_ENABLE_ECC
407 #######################################################################
408 # (5) Execute "global" rules. (OPTIONAL) #
409 #######################################################################
411 include $(CORE_DEPTH
)/coreconf
/rules.mk
413 #######################################################################
414 # (6) Execute "component" rules. (OPTIONAL) #
415 #######################################################################
419 #######################################################################
420 # (7) Execute "local" rules. (OPTIONAL). #
421 #######################################################################
423 export:: private_export
426 $(CC
) -o
$(OBJDIR
)/make_rijndael_tab rijndael_tables.c \
427 $(DEFINES
) $(INCLUDES
) $(OBJDIR
)/libfreebl.a
428 $(OBJDIR
)/make_rijndael_tab
434 INCLUDES
+= -Impi
-Iecl
437 DEFINES
+= -DMP_API_COMPATIBLE
439 MPI_USERS
= dh.c pqg.c dsa.c rsa.c ec.c
441 MPI_OBJS
= $(addprefix $(OBJDIR
)/$(PROG_PREFIX
), $(MPI_SRCS
:.c
=$(OBJ_SUFFIX
)))
442 MPI_OBJS
+= $(addprefix $(OBJDIR
)/$(PROG_PREFIX
), $(MPI_USERS
:.c
=$(OBJ_SUFFIX
)))
444 $(MPI_OBJS
): $(MPI_HDRS
)
448 ECL_OBJS
= $(addprefix $(OBJDIR
)/$(PROG_PREFIX
), $(ECL_SRCS
:.c
=$(OBJ_SUFFIX
)) $(ECL_ASM_SRCS
:$(ASM_SUFFIX
)=$(OBJ_SUFFIX
)))
449 ECL_OBJS
+= $(addprefix $(OBJDIR
)/$(PROG_PREFIX
), $(ECL_USERS
:.c
=$(OBJ_SUFFIX
)))
451 $(ECL_OBJS
): $(ECL_HDRS
)
455 $(OBJDIR
)/sysrand
$(OBJ_SUFFIX
): sysrand.c unix_rand.c win_rand.c mac_rand.c os2_rand.c
457 $(OBJDIR
)/$(PROG_PREFIX
)mpprime
$(OBJ_SUFFIX
): primes.c
459 $(OBJDIR
)/ldvector
$(OBJ_SUFFIX
) $(OBJDIR
)/loader
$(OBJ_SUFFIX
) : loader.h
461 ifeq ($(SYSV_SPARC
),1)
463 $(OBJDIR
)/mpv_sparcv8.o
$(OBJDIR
)/mpv_sparcv8x.o
$(OBJDIR
)/montmulfv8.o
: $(OBJDIR
)/%.o
: %.s
465 $(SOLARIS_AS
) -o
$@
$(SOLARIS_AS_FLAGS
) $<
467 $(OBJDIR
)/mpv_sparcv9.o
$(OBJDIR
)/montmulfv9.o
: $(OBJDIR
)/%.o
: %.s
469 $(SOLARIS_AS
) -o
$@
$(SOLARIS_AS_FLAGS
) $<
471 $(OBJDIR
)/mpmontg.o
: mpmontg.c montmulf.h
475 ifndef FREEBL_CHILD_BUILD
477 # Parent build. This is where we decide which shared libraries to build
479 ifdef FREEBL_BUILD_SINGLE_SHLIB
481 ################### Single shared lib stuff #########################
482 SINGLE_SHLIB_DIR
= $(OBJDIR
)/$(OS_TARGET
)_SINGLE_SHLIB
483 ALL_TRASH
+= $(SINGLE_SHLIB_DIR
)
486 -mkdir
$(SINGLE_SHLIB_DIR
)
488 release_md libs
:: $(SINGLE_SHLIB_DIR
)
489 $(MAKE
) FREEBL_CHILD_BUILD
=1 \
490 OBJDIR
=$(SINGLE_SHLIB_DIR
) $@
491 ######################## common stuff #########################
495 # multiple shared libraries
497 ######################## ABI32_FPU stuff #########################
499 ABI32_FPU_DIR
= $(OBJDIR
)/$(OS_TARGET
)_ABI32_FPU
500 ALL_TRASH
+= $(ABI32_FPU_DIR
)
503 -mkdir
$(ABI32_FPU_DIR
)
505 release_md libs
:: $(ABI32_FPU_DIR
)
506 $(MAKE
) FREEBL_CHILD_BUILD
=1 USE_ABI32_FPU
=1 \
507 OBJDIR
=$(ABI32_FPU_DIR
) $@
510 ######################## ABI32_INT32 stuff #########################
511 ifdef HAVE_ABI32_INT32
512 ABI32_INT32_DIR
= $(OBJDIR
)/$(OS_TARGET
)_ABI32_INT32
513 ALL_TRASH
+= $(ABI32_INT32_DIR
)
516 -mkdir
$(ABI32_INT32_DIR
)
518 release_md libs
:: $(ABI32_INT32_DIR
)
519 $(MAKE
) FREEBL_CHILD_BUILD
=1 USE_ABI32_INT32
=1 \
520 OBJDIR
=$(ABI32_INT32_DIR
) $@
523 ######################## ABI32_INT64 stuff #########################
524 ifdef HAVE_ABI32_INT64
525 ABI32_INT64_DIR
= $(OBJDIR
)/$(OS_TARGET
)_ABI32_INT64
526 ALL_TRASH
+= $(ABI32_INT64_DIR
)
529 -mkdir
$(ABI32_INT64_DIR
)
531 release_md libs
:: $(ABI32_INT64_DIR
)
532 $(MAKE
) FREEBL_CHILD_BUILD
=1 USE_ABI32_INT64
=1\
533 OBJDIR
=$(ABI32_INT64_DIR
) $@
536 ######################## END of 32-bit stuff #########################
538 # above is 32-bit builds, below is 64-bit builds
540 ######################## ABI64_FPU stuff #########################
542 ABI64_FPU_DIR
= $(OBJDIR
)/$(OS_TARGET
)_ABI64_FPU
543 ALL_TRASH
+= $(ABI64_FPU_DIR
)
546 -mkdir
$(ABI64_FPU_DIR
)
548 release_md libs
:: $(ABI64_FPU_DIR
)
549 $(MAKE
) FREEBL_CHILD_BUILD
=1 USE_ABI64_FPU
=1 \
550 OBJDIR
=$(ABI64_FPU_DIR
) $@
553 ######################## ABI64_INT stuff #########################
555 ABI64_INT_DIR
= $(OBJDIR
)/$(OS_TARGET
)_ABI64_INT
556 ALL_TRASH
+= $(ABI64_INT_DIR
)
559 -mkdir
$(ABI64_INT_DIR
)
561 release_md libs
:: $(ABI64_INT_DIR
)
562 $(MAKE
) FREEBL_CHILD_BUILD
=1 USE_ABI64_INT
=1 \
563 OBJDIR
=$(ABI64_INT_DIR
) $@
566 endif # FREEBL_CHILD_BUILD
569 # Bugzilla Bug 209827: disable optimization to work around what appears
570 # to be a VACPP optimizer bug.
572 $(OBJDIR
)/alg2268.obj
: alg2268.c
574 $(CC
) -Fo
$@
-c
$(filter-out /O
+, $(CFLAGS
)) $(call core_abspath
,$<)
577 # Bugzilla Bug 333917: the non-x86 code in desblapi.c seems to violate
578 # ANSI C's strict aliasing rules.
579 ifeq ($(OS_TARGET
),Linux
)
580 ifneq ($(CPU_ARCH
),x86
)
581 $(OBJDIR
)/$(PROG_PREFIX
)desblapi
$(OBJ_SUFFIX
): desblapi.c
583 ifdef NEED_ABSOLUTE_PATH
584 $(CC
) -o
$@
-c
$(CFLAGS
) -fno-strict-aliasing
$(call core_abspath
,$<)
586 $(CC
) -o
$@
-c
$(CFLAGS
) -fno-strict-aliasing
$<