Blame nss/lib/freebl/Makefile

Packit 40b132
#! gmake
Packit 40b132
#
Packit 40b132
# This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
# License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (1) Include initial platform-independent assignments (MANDATORY).   #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
include manifest.mn
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (2) Include "global" configuration information. (OPTIONAL)          #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
include $(CORE_DEPTH)/coreconf/config.mk
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (3) Include "component" configuration information. (OPTIONAL)       #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (4) Include "local" platform-dependent assignments (OPTIONAL).      #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
include config.mk
Packit 40b132
Packit 40b132
# default for all platforms
Packit 40b132
# unset this on those that have multiple freebl libraries
Packit 40b132
FREEBL_BUILD_SINGLE_SHLIB = 1
Packit 40b132
Packit 40b132
ifdef USE_64
Packit 40b132
	DEFINES += -DNSS_USE_64
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifdef USE_ABI32_FPU
Packit 40b132
	DEFINES += -DNSS_USE_ABI32_FPU
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(FREEBL_NO_DEPEND),1)
Packit 40b132
	DEFINES += -DFREEBL_NO_DEPEND
Packit 40b132
	STUBS_SRCS = stubs.c
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(FREEBL_LOWHASH),1)
Packit 40b132
	LOWHASH_SRCS = nsslowhash.c
Packit 40b132
	LOWHASH_EXPORTS = nsslowhash.h
Packit 40b132
	MAPFILE_SOURCE = freebl_hash.def
Packit 40b132
else
Packit 40b132
	MAPFILE_SOURCE = freebl.def
Packit 40b132
endif
Packit 40b132
Packit 40b132
# FREEBL_USE_PRELINK
Packit 40b132
#
Packit 40b132
# Most modern version of Linux support a speed optimization scheme where an
Packit 40b132
# application called prelink modifies programs and shared libraries to quickly
Packit 40b132
# load if they fit into an already designed address space. In short, prelink
Packit 40b132
# scans the list of programs and libraries on your system, assigns them a
Packit 40b132
# predefined space in the the address space, then provides the fixups to the
Packit 40b132
# library.
Packit 40b132
#
Packit 40b132
# The modification of the shared library is correctly detected by the freebl
Packit 40b132
# FIPS checksum scheme where we check a signed hash of the library against the
Packit 40b132
# library itself.
Packit 40b132
#
Packit 40b132
# The prelink command itself can reverse the process of modification and output
Packit 40b132
# the prestine shared library as it was before prelink made it's changes.
Packit 40b132
# This option tells Freebl could use prelink to output the original copy of
Packit 40b132
# the shared library before prelink modified it.
Packit 40b132
#
Packit 40b132
# FREEBL_PRELINK_COMMAND
Packit 40b132
#
Packit 40b132
# This is an optional environment variable which can override the default
Packit 40b132
# prelink command. It could be used on systems that did something similiar to 
Packit 40b132
# prelink but used a different command and syntax. The only requirement is the 
Packit 40b132
# program must take the library as the last argument, the program must output 
Packit 40b132
# the original library to standard out, and the program does not need to take 
Packit 40b132
# any quoted or imbedded spaces in its arguments (except the path to the 
Packit 40b132
# library itself, which can have imbedded spaces or special characters).
Packit 40b132
#
Packit 40b132
ifdef FREEBL_USE_PRELINK
Packit 40b132
	DEFINES += -DFREEBL_USE_PRELINK
Packit 40b132
ifdef LINUX
Packit 40b132
	DEFINES += -D__GNU_SOURCE=1
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
ifdef FREEBL_PRELINK_COMMAND
Packit 40b132
	DEFINES +=-DFREEBL_PRELINK_COMMAND=\"$(FREEBL_PRELINK_COMMAND)\"
Packit 40b132
endif
Packit 40b132
# NSS_X86 means the target is a 32-bits x86 CPU architecture
Packit 40b132
# NSS_X64 means the target is a 64-bits 64 CPU architecture
Packit 40b132
# NSS_X86_OR_X64 means the target is either x86 or x64
Packit 40b132
ifeq (,$(filter-out i386 x386 x86 x86_64,$(CPU_ARCH)))
Packit 40b132
        DEFINES += -DNSS_X86_OR_X64
Packit 40b132
ifneq (,$(USE_64)$(USE_X32))
Packit 40b132
        DEFINES += -DNSS_X64
Packit 40b132
else
Packit 40b132
        DEFINES += -DNSS_X86
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),OSF1)
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_NO_MP_WORD
Packit 40b132
    MPI_SRCS += mpvalpha.c
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq (OS2,$(OS_TARGET))
Packit 40b132
    ASFILES  = mpi_x86_os2.s
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE 
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
Packit 40b132
    DEFINES += -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
Packit 40b132
    DEFINES += -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET)))
Packit 40b132
ifndef USE_64
Packit 40b132
# 32-bit Windows
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
# Ideally, we want to use assembler
Packit 40b132
#     ASFILES  = mpi_x86.s
Packit 40b132
#     DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE \
Packit 40b132
#                -DMP_ASSEMBLY_DIV_2DX1D
Packit 40b132
# but we haven't figured out how to make it work, so we are not
Packit 40b132
# using assembler right now.
Packit 40b132
    ASFILES  =
Packit 40b132
    DEFINES += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT
Packit 40b132
else
Packit 40b132
# MSVC
Packit 40b132
    MPI_SRCS += mpi_x86_asm.c
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE 
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
Packit 40b132
    ifdef BUILD_OPT
Packit 40b132
	OPTIMIZER += -Ox  # maximum optimization for freebl
Packit 40b132
    endif
Packit 40b132
    # The Intel AES assembly code requires Visual C++ 2010.
Packit 40b132
    # if $(_MSC_VER) >= 1600 (Visual C++ 2010)
Packit 40b132
    ifeq ($(firstword $(sort $(_MSC_VER) 1600)),1600)
Packit 40b132
	DEFINES += -DUSE_HW_AES -DINTEL_GCM
Packit 40b132
	ASFILES += intel-aes-x86-masm.asm intel-gcm-x86-masm.asm
Packit 40b132
	EXTRA_SRCS += intel-gcm-wrap.c
Packit 40b132
	ifeq ($(CLANG_CL),1)
Packit 40b132
	    INTEL_GCM_CLANG_CL = 1
Packit 40b132
	endif
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
else
Packit 40b132
    # -DMP_NO_MP_WORD
Packit 40b132
    DEFINES += -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
# Ideally, we should use amd64 assembly code, but it's not yet mingw-w64
Packit 40b132
# compatible.
Packit 40b132
else
Packit 40b132
# MSVC
Packit 40b132
    ifdef BUILD_OPT
Packit 40b132
	OPTIMIZER += -Ox  # maximum optimization for freebl
Packit 40b132
    endif
Packit 40b132
    ASFILES  = arcfour-amd64-masm.asm mpi_amd64_masm.asm mp_comba_amd64_masm.asm
Packit 40b132
    DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
Packit 40b132
    DEFINES += -DNSS_USE_COMBA
Packit 40b132
    # The Intel AES assembly code requires Visual C++ 2010 (10.0). The _xgetbv
Packit 40b132
    # compiler intrinsic function requires Visual C++ 2010 (10.0) SP1.
Packit 40b132
    ifeq ($(_MSC_VER_GE_10SP1),1)
Packit 40b132
	DEFINES += -DUSE_HW_AES -DINTEL_GCM
Packit 40b132
	ASFILES += intel-aes-x64-masm.asm intel-gcm-x64-masm.asm
Packit 40b132
	EXTRA_SRCS += intel-gcm-wrap.c
Packit 40b132
    endif
Packit 40b132
    MPI_SRCS += mpi_amd64.c
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),IRIX)
Packit 40b132
ifeq ($(USE_N32),1)
Packit 40b132
    ASFILES  = mpi_mips.s
Packit 40b132
    ifeq ($(NS_USE_GCC),1)
Packit 40b132
	ASFLAGS = -Wp,-P -Wp,-traditional -O -mips3
Packit 40b132
    else
Packit 40b132
	ASFLAGS = -O -OPT:Olimit=4000 -dollar -fullwarn -xansi -n32 -mips3 
Packit 40b132
    endif
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
Packit 40b132
    DEFINES += -DMP_USE_UINT_DIGIT
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),Darwin)
Packit 40b132
ifeq ($(CPU_ARCH),x86)
Packit 40b132
    ASFILES  = mpi_sse2.s
Packit 40b132
    DEFINES += -DMP_USE_UINT_DIGIT
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
Packit 40b132
endif
Packit 40b132
endif # Darwin
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),Linux)
Packit 40b132
ifeq ($(CPU_ARCH),x86_64)
Packit 40b132
    ASFILES  = arcfour-amd64-gas.s mpi_amd64_gas.s
Packit 40b132
    ASFLAGS += -fPIC -Wa,--noexecstack
Packit 40b132
    DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
Packit 40b132
    DEFINES += -DNSS_USE_COMBA
Packit 40b132
    DEFINES += -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
Packit 40b132
#   DEFINES += -DMPI_AMD64_ADD
Packit 40b132
    # comment the next four lines to turn off Intel HW acceleration.
Packit 40b132
    DEFINES += -DUSE_HW_AES -DINTEL_GCM
Packit 40b132
    ASFILES += intel-aes.s intel-gcm.s
Packit 40b132
    EXTRA_SRCS += intel-gcm-wrap.c
Packit 40b132
    INTEL_GCM = 1
Packit 40b132
    MPI_SRCS += mpi_amd64.c mp_comba.c
Packit 40b132
endif
Packit 40b132
ifeq ($(CPU_ARCH),x86)
Packit 40b132
    ASFILES  = mpi_x86.s
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE 
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D -DMP_USE_UINT_DIGIT
Packit 40b132
    DEFINES += -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
Packit 40b132
    # The floating point ECC code doesn't work on Linux x86 (bug 311432).
Packit 40b132
    #ECL_USE_FP = 1
Packit 40b132
endif
Packit 40b132
ifeq ($(CPU_ARCH),arm)
Packit 40b132
    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE 
Packit 40b132
    DEFINES += -DMP_USE_UINT_DIGIT
Packit 40b132
    DEFINES += -DSHA_NO_LONG_LONG # avoid 64-bit arithmetic in SHA512
Packit 40b132
    MPI_SRCS += mpi_arm.c
Packit 40b132
endif
Packit 40b132
endif # Linux
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),AIX)
Packit 40b132
    DEFINES += -DMP_USE_UINT_DIGIT
Packit 40b132
    ifndef USE_64
Packit 40b132
	DEFINES += -DMP_NO_DIV_WORD -DMP_NO_ADD_WORD -DMP_NO_SUB_WORD
Packit 40b132
    endif
Packit 40b132
endif # AIX
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET), HP-UX)
Packit 40b132
ifneq ($(OS_TEST), ia64)
Packit 40b132
# PA-RISC
Packit 40b132
ASFILES += ret_cr16.s
Packit 40b132
ifndef USE_64
Packit 40b132
    FREEBL_BUILD_SINGLE_SHLIB = 
Packit 40b132
    HAVE_ABI32_INT32 = 1
Packit 40b132
    HAVE_ABI32_FPU = 1
Packit 40b132
endif
Packit 40b132
ifdef FREEBL_CHILD_BUILD
Packit 40b132
ifdef USE_ABI32_INT32
Packit 40b132
# build for DA1.1 (HP PA 1.1) 32-bit ABI build with 32-bit arithmetic
Packit 40b132
    DEFINES  += -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
Packit 40b132
    DEFINES += -DSHA_NO_LONG_LONG # avoid 64-bit arithmetic in SHA512
Packit 40b132
else
Packit 40b132
ifdef USE_64
Packit 40b132
# this builds for DA2.0W (HP PA 2.0 Wide), the LP64 ABI, using 64-bit digits 
Packit 40b132
    MPI_SRCS += mpi_hp.c 
Packit 40b132
    ASFILES  += hpma512.s hppa20.s 
Packit 40b132
    DEFINES  += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
Packit 40b132
else
Packit 40b132
# this builds for DA2.0 (HP PA 2.0 Narrow) ABI32_FPU model 
Packit 40b132
# (the 32-bit ABI with 64-bit registers) using 64-bit digits
Packit 40b132
    MPI_SRCS += mpi_hp.c 
Packit 40b132
    ASFILES  += hpma512.s hppa20.s 
Packit 40b132
    DEFINES  += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
Packit 40b132
ifndef NS_USE_GCC
Packit 40b132
    ARCHFLAG = -Aa +e +DA2.0 +DS2.0
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
# The blapi functions are defined not only in the freebl shared
Packit 40b132
# libraries but also in the shared libraries linked with loader.c
Packit 40b132
# (libsoftokn3.so and libssl3.so).  We need to use GNU ld's
Packit 40b132
# -Bsymbolic option or the equivalent option for other linkers
Packit 40b132
# to bind the blapi function references in FREEBLVector vector
Packit 40b132
# (ldvector.c) to the blapi functions defined in the freebl
Packit 40b132
# shared libraries.
Packit 40b132
ifeq (,$(filter-out BSD_OS FreeBSD Linux NetBSD OpenBSD, $(OS_TARGET)))
Packit 40b132
    MKSHLIB += -Wl,-Bsymbolic
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifeq ($(OS_TARGET),SunOS)
Packit 40b132
Packit 40b132
ifdef NS_USE_GCC
Packit 40b132
    ifdef GCC_USE_GNU_LD
Packit 40b132
	MKSHLIB += -Wl,-Bsymbolic,-z,now,-z,text
Packit 40b132
    else
Packit 40b132
	MKSHLIB += -Wl,-B,symbolic,-z,now,-z,text
Packit 40b132
    endif # GCC_USE_GNU_LD
Packit 40b132
else
Packit 40b132
    MKSHLIB += -B symbolic -z now -z text
Packit 40b132
endif # NS_USE_GCC
Packit 40b132
Packit 40b132
# Sun's WorkShop defines v8, v8plus and v9 architectures.
Packit 40b132
# gcc on Solaris defines v8 and v9 "cpus".  
Packit 40b132
# gcc's v9 is equivalent to Workshop's v8plus.
Packit 40b132
# gcc's -m64 is equivalent to Workshop's v9
Packit 40b132
# We always use Sun's assembler, which uses Sun's naming convention.
Packit 40b132
ifeq ($(CPU_ARCH),sparc)
Packit 40b132
    FREEBL_BUILD_SINGLE_SHLIB=
Packit 40b132
    ifdef USE_64
Packit 40b132
        HAVE_ABI64_INT = 1
Packit 40b132
        HAVE_ABI64_FPU = 1
Packit 40b132
    else
Packit 40b132
        HAVE_ABI32_FPU = 1
Packit 40b132
        HAVE_ABI32_INT64 = 1
Packit 40b132
    endif
Packit 40b132
    SYSV_SPARC = 1
Packit 40b132
    SOLARIS_AS = /usr/ccs/bin/as
Packit 40b132
    #### set arch, asm, c flags
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	ifdef USE_ABI32_INT64
Packit 40b132
	    ARCHFLAG=-mcpu=v9 -Wa,-xarch=v8plus
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v8plus -K PIC
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI32_FPU
Packit 40b132
	    ARCHFLAG=-mcpu=v9 -Wa,-xarch=v8plusa
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v8plusa -K PIC
Packit 40b132
	endif # USE_ABI32_FPU
Packit 40b132
	ifdef USE_ABI64_INT
Packit 40b132
	    # this builds for Sparc v9a pure 64-bit architecture
Packit 40b132
	    ARCHFLAG += -mcpu=v9 -Wa,-xarch=v9
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v9 -K PIC
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI64_FPU
Packit 40b132
	    # this builds for Sparc v9a pure 64-bit architecture
Packit 40b132
	    # It uses floating point, and 32-bit word size
Packit 40b132
	    ARCHFLAG += -mcpu=v9 -Wa,-xarch=v9a
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v9a -K PIC
Packit 40b132
	endif
Packit 40b132
    else # NS_USE_GCC
Packit 40b132
	# FPU_TARGET_OPTIMIZER specifies the target processor and cache
Packit 40b132
	# properties of the ABI32_FPU and ABI64_FPU architectures for use
Packit 40b132
	# by the optimizer.
Packit 40b132
	ifeq (,$(findstring Sun WorkShop 6,$(shell $(CC) -V 2>&1)))
Packit 40b132
	    # if the compiler is not Forte 6
Packit 40b132
	    FPU_TARGET_OPTIMIZER = -xcache=64/32/4:1024/64/4 -xchip=ultra3
Packit 40b132
	else
Packit 40b132
	    # Forte 6 C compiler generates incorrect code for rijndael.c
Packit 40b132
	    # if -xchip=ultra3 is used (Bugzilla bug 333925).  So we revert
Packit 40b132
	    # to what we used in NSS 3.10.
Packit 40b132
	    FPU_TARGET_OPTIMIZER = -xchip=ultra2
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI32_INT64
Packit 40b132
	    # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers, 
Packit 40b132
	    # 32-bit ABI, it uses 64-bit words, integer arithmetic,
Packit 40b132
	    # no FPU (non-VIS cpus).
Packit 40b132
	    # These flags were suggested by the compiler group for building
Packit 40b132
	    # with SunStudio 10.
Packit 40b132
	    ifdef BUILD_OPT
Packit 40b132
                SOL_CFLAGS += -xO4
Packit 40b132
	    endif
Packit 40b132
 	    SOL_CFLAGS += -xtarget=generic
Packit 40b132
	    ARCHFLAG = -xarch=v8plus
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v8plus -K PIC
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI32_FPU
Packit 40b132
	    # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers, 
Packit 40b132
	    # 32-bit ABI, it uses FPU code, and 32-bit word size.
Packit 40b132
	    # these flags were determined by running cc -### -fast and copying
Packit 40b132
	    # the generated flag settings
Packit 40b132
	    SOL_CFLAGS += -fsingle -xmemalign=8s
Packit 40b132
	    ifdef BUILD_OPT
Packit 40b132
                SOL_CFLAGS += -D__MATHERR_ERRNO_DONTCARE -fsimple=1
Packit 40b132
                SOL_CFLAGS += -xalias_level=basic -xbuiltin=%all
Packit 40b132
                SOL_CFLAGS += $(FPU_TARGET_OPTIMIZER) -xdepend
Packit 40b132
                SOL_CFLAGS += -xlibmil -xO5
Packit 40b132
	    endif
Packit 40b132
	    ARCHFLAG = -xarch=v8plusa
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v8plusa -K PIC
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI64_INT
Packit 40b132
	    # this builds for Sparc v9a pure 64-bit architecture,
Packit 40b132
	    # no FPU (non-VIS cpus). For building with SunStudio 10.
Packit 40b132
	    ifdef BUILD_OPT
Packit 40b132
                SOL_CFLAGS += -xO4
Packit 40b132
	    endif
Packit 40b132
 	    SOL_CFLAGS += -xtarget=generic
Packit 40b132
	    ARCHFLAG = -xarch=v9
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v9 -K PIC
Packit 40b132
	endif
Packit 40b132
	ifdef USE_ABI64_FPU
Packit 40b132
	    # this builds for Sparc v9a pure 64-bit architecture
Packit 40b132
	    # It uses floating point, and 32-bit word size.
Packit 40b132
	    # See comment for USE_ABI32_FPU.
Packit 40b132
	    SOL_CFLAGS += -fsingle -xmemalign=8s
Packit 40b132
	    ifdef BUILD_OPT
Packit 40b132
                SOL_CFLAGS += -D__MATHERR_ERRNO_DONTCARE -fsimple=1
Packit 40b132
                SOL_CFLAGS += -xalias_level=basic -xbuiltin=%all
Packit 40b132
                SOL_CFLAGS += $(FPU_TARGET_OPTIMIZER) -xdepend
Packit 40b132
                SOL_CFLAGS += -xlibmil -xO5
Packit 40b132
	    endif
Packit 40b132
	    ARCHFLAG = -xarch=v9a
Packit 40b132
	    SOLARIS_AS_FLAGS = -xarch=v9a -K PIC
Packit 40b132
	endif
Packit 40b132
    endif # NS_USE_GCC
Packit 40b132
Packit 40b132
    ### set flags for both GCC and Sun cc
Packit 40b132
    ifdef USE_ABI32_INT64
Packit 40b132
	# this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers, 
Packit 40b132
	# 32-bit ABI, it uses 64-bit words, integer arithmetic, no FPU
Packit 40b132
	# best times are with no MP_ flags specified
Packit 40b132
    endif
Packit 40b132
    ifdef USE_ABI32_FPU
Packit 40b132
	# this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers, 
Packit 40b132
	# 32-bit ABI, it uses FPU code, and 32-bit word size
Packit 40b132
	MPI_SRCS += mpi_sparc.c
Packit 40b132
	ASFILES  = mpv_sparcv8.s montmulfv8.s
Packit 40b132
	DEFINES  += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT -DMP_ASSEMBLY_MULTIPLY
Packit 40b132
	DEFINES  += -DMP_USING_MONT_MULF -DMP_MONT_USE_MP_MUL
Packit 40b132
	ECL_USE_FP = 1
Packit 40b132
    endif
Packit 40b132
    ifdef USE_ABI64_INT
Packit 40b132
	# this builds for Sparc v9a pure 64-bit architecture
Packit 40b132
	# best times are with no MP_ flags specified
Packit 40b132
    endif
Packit 40b132
    ifdef USE_ABI64_FPU
Packit 40b132
	# this builds for Sparc v9a pure 64-bit architecture
Packit 40b132
	# It uses floating point, and 32-bit word size
Packit 40b132
	MPI_SRCS += mpi_sparc.c
Packit 40b132
	ASFILES   = mpv_sparcv9.s montmulfv9.s
Packit 40b132
	DEFINES  += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT -DMP_ASSEMBLY_MULTIPLY
Packit 40b132
	DEFINES  += -DMP_USING_MONT_MULF -DMP_MONT_USE_MP_MUL
Packit 40b132
	ECL_USE_FP = 1
Packit 40b132
    endif
Packit 40b132
Packit 40b132
else
Packit 40b132
    # Solaris for non-sparc family CPUs
Packit 40b132
    ifdef NS_USE_GCC
Packit 40b132
	LD = gcc
Packit 40b132
	AS = gcc
Packit 40b132
	ASFLAGS = -x assembler-with-cpp
Packit 40b132
    endif
Packit 40b132
    ifeq ($(USE_64),1)
Packit 40b132
	# Solaris for AMD64
Packit 40b132
	ifdef NS_USE_GCC
Packit 40b132
	    ASFILES  = arcfour-amd64-gas.s mpi_amd64_gas.s
Packit 40b132
	    ASFLAGS += -march=opteron -m64 -fPIC
Packit 40b132
	    MPI_SRCS += mp_comba.c
Packit 40b132
	    # comment the next four lines to turn off Intel HW acceleration
Packit 40b132
	    ASFILES += intel-gcm.s
Packit 40b132
	    EXTRA_SRCS += intel-gcm-wrap.c
Packit 40b132
	    INTEL_GCM = 1
Packit 40b132
	    DEFINES += -DINTEL_GCM
Packit 40b132
	else
Packit 40b132
	    ASFILES  = arcfour-amd64-sun.s mpi_amd64_sun.s sha-fast-amd64-sun.s
Packit 40b132
 	    ASFILES += mp_comba_amd64_sun.s mpcpucache_amd64.s
Packit 40b132
	    ASFLAGS += -xarch=generic64 -K PIC
Packit 40b132
            SOL_CFLAGS += -xprefetch=no
Packit 40b132
	    SHA_SRCS =
Packit 40b132
 	    MPCPU_SRCS =
Packit 40b132
	    # Intel acceleration for GCM does not build currently with Studio
Packit 40b132
	endif
Packit 40b132
	DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
Packit 40b132
	DEFINES += -DNSS_USE_COMBA -DMP_CHAR_STORE_SLOW -DMP_IS_LITTLE_ENDIAN
Packit 40b132
	# comment the next two lines to turn off Intel HW acceleration
Packit 40b132
	DEFINES += -DUSE_HW_AES
Packit 40b132
	ASFILES += intel-aes.s
Packit 40b132
	MPI_SRCS += mpi_amd64.c
Packit 40b132
    else
Packit 40b132
	# Solaris x86
Packit 40b132
	DEFINES += -DMP_USE_UINT_DIGIT
Packit 40b132
	DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE 
Packit 40b132
	DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
Packit 40b132
	ASFILES  = mpi_i86pc.s
Packit 40b132
 	ifndef NS_USE_GCC
Packit 40b132
 	   MPCPU_SRCS =
Packit 40b132
 	   ASFILES += mpcpucache_x86.s
Packit 40b132
 	endif
Packit 40b132
    endif
Packit 40b132
endif # Solaris for non-sparc family CPUs
Packit 40b132
endif # target == SunOS
Packit 40b132
Packit 40b132
ifndef NSS_DISABLE_ECC
Packit 40b132
    ifdef ECL_USE_FP
Packit 40b132
	#enable floating point ECC code	
Packit 40b132
	DEFINES  += -DECL_USE_FP
Packit 40b132
	ECL_SRCS += ecp_fp160.c ecp_fp192.c ecp_fp224.c ecp_fp.c
Packit 40b132
	ECL_HDRS += ecp_fp.h
Packit 40b132
    endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (5) Execute "global" rules. (OPTIONAL)                              #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
include $(CORE_DEPTH)/coreconf/rules.mk
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (6) Execute "component" rules. (OPTIONAL)                           #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
Packit 40b132
Packit 40b132
#######################################################################
Packit 40b132
# (7) Execute "local" rules. (OPTIONAL).                              #
Packit 40b132
#######################################################################
Packit 40b132
Packit 40b132
export:: private_export
Packit 40b132
Packit 40b132
rijndael_tables:
Packit 40b132
	$(CC) -o $(OBJDIR)/make_rijndael_tab rijndael_tables.c \
Packit 40b132
	         $(DEFINES) $(INCLUDES) $(OBJDIR)/libfreebl.a
Packit 40b132
	$(OBJDIR)/make_rijndael_tab
Packit 40b132
Packit 40b132
vpath %.h mpi ecl
Packit 40b132
vpath %.c mpi ecl
Packit 40b132
vpath %.S mpi ecl
Packit 40b132
vpath %.s mpi ecl
Packit 40b132
vpath %.asm mpi ecl
Packit 40b132
INCLUDES += -Impi -Iecl
Packit 40b132
Packit 40b132
Packit 40b132
DEFINES += -DMP_API_COMPATIBLE
Packit 40b132
Packit 40b132
MPI_USERS = dh.c pqg.c dsa.c rsa.c ec.c
Packit 40b132
Packit 40b132
MPI_OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_SRCS:.c=$(OBJ_SUFFIX)))
Packit 40b132
MPI_OBJS += $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_USERS:.c=$(OBJ_SUFFIX)))
Packit 40b132
Packit 40b132
$(MPI_OBJS): $(MPI_HDRS)
Packit 40b132
Packit 40b132
ECL_USERS = ec.c
Packit 40b132
Packit 40b132
ECL_OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(ECL_SRCS:.c=$(OBJ_SUFFIX)) $(ECL_ASM_SRCS:$(ASM_SUFFIX)=$(OBJ_SUFFIX)))
Packit 40b132
ECL_OBJS += $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(ECL_USERS:.c=$(OBJ_SUFFIX)))
Packit 40b132
Packit 40b132
$(ECL_OBJS): $(ECL_HDRS)
Packit 40b132
Packit 40b132
Packit 40b132
Packit 40b132
$(OBJDIR)/sysrand$(OBJ_SUFFIX): sysrand.c unix_rand.c win_rand.c os2_rand.c
Packit 40b132
Packit 40b132
$(OBJDIR)/$(PROG_PREFIX)mpprime$(OBJ_SUFFIX): primes.c
Packit 40b132
Packit 40b132
$(OBJDIR)/ldvector$(OBJ_SUFFIX) $(OBJDIR)/loader$(OBJ_SUFFIX) : loader.h
Packit 40b132
Packit 40b132
ifeq ($(SYSV_SPARC),1)
Packit 40b132
Packit 40b132
$(OBJDIR)/mpv_sparcv8.o $(OBJDIR)/mpv_sparcv8x.o $(OBJDIR)/montmulfv8.o : $(OBJDIR)/%.o : %.s
Packit 40b132
	@$(MAKE_OBJDIR)
Packit 40b132
	$(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $<
Packit 40b132
Packit 40b132
$(OBJDIR)/mpv_sparcv9.o $(OBJDIR)/montmulfv9.o : $(OBJDIR)/%.o : %.s
Packit 40b132
	@$(MAKE_OBJDIR)
Packit 40b132
	$(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $<
Packit 40b132
Packit 40b132
$(OBJDIR)/mpmontg.o: mpmontg.c montmulf.h
Packit 40b132
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifndef FREEBL_CHILD_BUILD
Packit 40b132
Packit 40b132
# Parent build. This is where we decide which shared libraries to build
Packit 40b132
Packit 40b132
ifdef FREEBL_BUILD_SINGLE_SHLIB
Packit 40b132
Packit 40b132
################### Single shared lib stuff #########################
Packit 40b132
SINGLE_SHLIB_DIR = $(OBJDIR)/$(OS_TARGET)_SINGLE_SHLIB
Packit 40b132
ALL_TRASH += $(SINGLE_SHLIB_DIR) 
Packit 40b132
Packit 40b132
$(SINGLE_SHLIB_DIR):
Packit 40b132
	-mkdir $(SINGLE_SHLIB_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(SINGLE_SHLIB_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 \
Packit 40b132
 OBJDIR=$(SINGLE_SHLIB_DIR) $@
Packit 40b132
######################## common stuff #########################
Packit 40b132
Packit 40b132
endif
Packit 40b132
Packit 40b132
# multiple shared libraries
Packit 40b132
Packit 40b132
######################## ABI32_FPU stuff #########################
Packit 40b132
ifdef HAVE_ABI32_FPU
Packit 40b132
ABI32_FPU_DIR = $(OBJDIR)/$(OS_TARGET)_ABI32_FPU
Packit 40b132
ALL_TRASH += $(ABI32_FPU_DIR) 
Packit 40b132
Packit 40b132
$(ABI32_FPU_DIR):
Packit 40b132
	-mkdir $(ABI32_FPU_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(ABI32_FPU_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 USE_ABI32_FPU=1 \
Packit 40b132
 OBJDIR=$(ABI32_FPU_DIR) $@
Packit 40b132
endif
Packit 40b132
Packit 40b132
######################## ABI32_INT32 stuff #########################
Packit 40b132
ifdef HAVE_ABI32_INT32
Packit 40b132
ABI32_INT32_DIR = $(OBJDIR)/$(OS_TARGET)_ABI32_INT32
Packit 40b132
ALL_TRASH += $(ABI32_INT32_DIR) 
Packit 40b132
Packit 40b132
$(ABI32_INT32_DIR):
Packit 40b132
	-mkdir $(ABI32_INT32_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(ABI32_INT32_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 USE_ABI32_INT32=1 \
Packit 40b132
 OBJDIR=$(ABI32_INT32_DIR) $@
Packit 40b132
endif
Packit 40b132
Packit 40b132
######################## ABI32_INT64 stuff #########################
Packit 40b132
ifdef HAVE_ABI32_INT64
Packit 40b132
ABI32_INT64_DIR = $(OBJDIR)/$(OS_TARGET)_ABI32_INT64
Packit 40b132
ALL_TRASH += $(ABI32_INT64_DIR) 
Packit 40b132
Packit 40b132
$(ABI32_INT64_DIR):
Packit 40b132
	-mkdir $(ABI32_INT64_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(ABI32_INT64_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 USE_ABI32_INT64=1\
Packit 40b132
 OBJDIR=$(ABI32_INT64_DIR) $@
Packit 40b132
endif
Packit 40b132
Packit 40b132
######################## END of 32-bit stuff #########################
Packit 40b132
Packit 40b132
# above is 32-bit builds, below is 64-bit builds
Packit 40b132
Packit 40b132
######################## ABI64_FPU stuff #########################
Packit 40b132
ifdef HAVE_ABI64_FPU
Packit 40b132
ABI64_FPU_DIR = $(OBJDIR)/$(OS_TARGET)_ABI64_FPU
Packit 40b132
ALL_TRASH += $(ABI64_FPU_DIR) 
Packit 40b132
Packit 40b132
$(ABI64_FPU_DIR):
Packit 40b132
	-mkdir $(ABI64_FPU_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(ABI64_FPU_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 USE_ABI64_FPU=1 \
Packit 40b132
 OBJDIR=$(ABI64_FPU_DIR) $@
Packit 40b132
endif
Packit 40b132
Packit 40b132
######################## ABI64_INT stuff #########################
Packit 40b132
ifdef HAVE_ABI64_INT
Packit 40b132
ABI64_INT_DIR = $(OBJDIR)/$(OS_TARGET)_ABI64_INT
Packit 40b132
ALL_TRASH += $(ABI64_INT_DIR) 
Packit 40b132
Packit 40b132
$(ABI64_INT_DIR):
Packit 40b132
	-mkdir $(ABI64_INT_DIR)
Packit 40b132
Packit 40b132
release_md libs:: $(ABI64_INT_DIR)
Packit 40b132
	$(MAKE) FREEBL_CHILD_BUILD=1 USE_ABI64_INT=1 \
Packit 40b132
 OBJDIR=$(ABI64_INT_DIR) $@
Packit 40b132
endif
Packit 40b132
Packit 40b132
endif  # FREEBL_CHILD_BUILD
Packit 40b132
Packit 40b132
Packit 40b132
# Bugzilla Bug 333917: the non-x86 code in desblapi.c seems to violate
Packit 40b132
# ANSI C's strict aliasing rules.
Packit 40b132
ifeq ($(OS_TARGET),Linux)
Packit 40b132
ifneq ($(CPU_ARCH),x86)
Packit 40b132
$(OBJDIR)/$(PROG_PREFIX)desblapi$(OBJ_SUFFIX): desblapi.c
Packit 40b132
	@$(MAKE_OBJDIR)
Packit 40b132
ifdef NEED_ABSOLUTE_PATH
Packit 40b132
	$(CC) -o $@ -c $(CFLAGS) -fno-strict-aliasing $(call core_abspath,$<)
Packit 40b132
else
Packit 40b132
	$(CC) -o $@ -c $(CFLAGS) -fno-strict-aliasing $<
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifdef INTEL_GCM
Packit 40b132
#
Packit 40b132
# GCM binary needs -mssse3
Packit 40b132
#
Packit 40b132
$(OBJDIR)/$(PROG_PREFIX)intel-gcm-wrap$(OBJ_SUFFIX): CFLAGS += -mssse3
Packit 40b132
Packit 40b132
# The integrated assembler in Clang 3.2 does not support % in the
Packit 40b132
# expression of a .set directive. intel-gcm.s uses .set to give
Packit 40b132
# symbolic names to registers, for example,
Packit 40b132
#     .set  Htbl, %rdi
Packit 40b132
# So we can't use Clang's integrated assembler with intel-gcm.s.
Packit 40b132
ifneq (,$(findstring clang,$(shell $(AS) --version)))
Packit 40b132
$(OBJDIR)/$(PROG_PREFIX)intel-gcm$(OBJ_SUFFIX): ASFLAGS += -no-integrated-as
Packit 40b132
endif
Packit 40b132
endif
Packit 40b132
Packit 40b132
ifdef INTEL_GCM_CLANG_CL
Packit 40b132
#
Packit 40b132
# clang-cl needs -mssse3
Packit 40b132
#
Packit 40b132
$(OBJDIR)/$(PROG_PREFIX)intel-gcm-wrap$(OBJ_SUFFIX): CFLAGS += -mssse3
Packit 40b132
endif