tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Makefile (28468B)


      1 #! gmake
      2 #
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 #######################################################################
      8 # (1) Include initial platform-independent assignments (MANDATORY).   #
      9 #######################################################################
     10 
     11 include manifest.mn
     12 
     13 #######################################################################
     14 # (2) Include "global" configuration information. (OPTIONAL)          #
     15 #######################################################################
     16 
     17 include $(CORE_DEPTH)/coreconf/config.mk
     18 
     19 #######################################################################
     20 # (3) Include "component" configuration information. (OPTIONAL)       #
     21 #######################################################################
     22 
     23 
     24 
     25 #######################################################################
     26 # (4) Include "local" platform-dependent assignments (OPTIONAL).      #
     27 #######################################################################
     28 
     29 include config.mk
     30 
     31 # default for all platforms
     32 # unset this on those that have multiple freebl libraries
     33 FREEBL_BUILD_SINGLE_SHLIB = 1
     34 
     35 ifdef USE_64
     36 DEFINES += -DNSS_USE_64
     37 endif
     38 
     39 ifdef USE_ABI32_FPU
     40 DEFINES += -DNSS_USE_ABI32_FPU
     41 endif
     42 
     43 ifeq ($(FREEBL_NO_DEPEND),1)
     44 DEFINES += -DFREEBL_NO_DEPEND
     45 STUBS_SRCS = stubs.c
     46 endif
     47 
     48 ifeq ($(FREEBL_LOWHASH),1)
     49 DEFINES += -DFREEBL_LOWHASH
     50 LOWHASH_SRCS = nsslowhash.c
     51 LOWHASH_EXPORTS = nsslowhash.h
     52 MAPFILE_SOURCE = freebl_hash_vector.def
     53 NEED_STUB_BUILD = 1
     54 else
     55 MAPFILE_SOURCE = freebl.def
     56 endif
     57 
     58 ifdef USE_STUB_BUILD
     59 CSRCS           = lowhash_vector.c
     60 SIMPLE_OBJS     = $(CSRCS:.c=$(OBJ_SUFFIX))
     61 OBJS            = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(SIMPLE_OBJS))
     62 ALL_TRASH :=    $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \
     63                $(NOSUCHFILE) so_locations
     64 MAPFILE_SOURCE = freebl_hash.def
     65 endif
     66 
     67 # FREEBL_USE_PRELINK
     68 #
     69 # Most modern version of Linux support a speed optimization scheme where an
     70 # application called prelink modifies programs and shared libraries to quickly
     71 # load if they fit into an already designed address space. In short, prelink
     72 # scans the list of programs and libraries on your system, assigns them a
     73 # predefined space in the the address space, then provides the fixups to the
     74 # library.
     75 #
     76 # The modification of the shared library is correctly detected by the freebl
     77 # FIPS checksum scheme where we check a signed hash of the library against the
     78 # library itself.
     79 #
     80 # The prelink command itself can reverse the process of modification and output
     81 # the prestine shared library as it was before prelink made it's changes.
     82 # This option tells Freebl could use prelink to output the original copy of
     83 # the shared library before prelink modified it.
     84 #
     85 # FREEBL_PRELINK_COMMAND
     86 #
     87 # This is an optional environment variable which can override the default
     88 # prelink command. It could be used on systems that did something similiar to
     89 # prelink but used a different command and syntax. The only requirement is the
     90 # program must take the library as the last argument, the program must output
     91 # the original library to standard out, and the program does not need to take
     92 # any quoted or imbedded spaces in its arguments (except the path to the
     93 # library itself, which can have imbedded spaces or special characters).
     94 #
     95 ifdef FREEBL_USE_PRELINK
     96 DEFINES += -DFREEBL_USE_PRELINK
     97 ifdef LINUX
     98 DEFINES += -D__GNU_SOURCE=1
     99 endif
    100 endif
    101 ifdef NSS_NO_INIT_SUPPORT
    102    DEFINES += -DNSS_NO_INIT_SUPPORT
    103 endif
    104 ifdef NSS_STRICT_INTEGRITY
    105    DEFINES += -DNSS_STRICT_INTEGRITY_
    106 endif
    107 
    108 ifdef FREEBL_PRELINK_COMMAND
    109 DEFINES +=-DFREEBL_PRELINK_COMMAND=\"$(FREEBL_PRELINK_COMMAND)\"
    110 endif
    111 # NSS_X86 means the target is a 32-bits x86 CPU architecture
    112 # NSS_X64 means the target is a 64-bits 64 CPU architecture
    113 # NSS_X86_OR_X64 means the target is either x86 or x64
    114 ifeq (,$(filter-out i386 x386 x86 x86_64,$(CPU_ARCH)))
    115        DEFINES += -DNSS_X86_OR_X64
    116        EXTRA_SRCS += gcm-x86.c aes-x86.c
    117 $(OBJDIR)/gcm-x86.o: CFLAGS += -mpclmul -maes
    118 $(OBJDIR)/aes-x86.o: CFLAGS += -mpclmul -maes
    119 ifneq (,$(USE_64)$(USE_X32))
    120        DEFINES += -DNSS_X64
    121 else
    122        DEFINES += -DNSS_X86
    123 endif
    124    ifdef CC_IS_CLANG
    125        EXTRA_SRCS += sha256-x86.c
    126        DEFINES += -DUSE_HW_SHA2
    127    else ifeq (1,$(CC_IS_GCC))
    128        # Old compiler doesn't support Intel SHA extension
    129        ifneq (,$(filter 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
    130            EXTRA_SRCS += sha256-x86.c
    131            DEFINES += -DUSE_HW_SHA2
    132        endif
    133        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    134            EXTRA_SRCS += sha256-x86.c
    135            DEFINES += -DUSE_HW_SHA2
    136        endif
    137    endif
    138 endif
    139 ifeq ($(CPU_ARCH),aarch64)
    140    ifdef CC_IS_CLANG
    141        DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    142        EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
    143    else ifeq (1,$(CC_IS_GCC))
    144        # GCC versions older than 4.9 don't support ARM AES. The check
    145        # is done in two parts, first allows "major.minor" == "4.9",
    146        # and then rejects any major versions prior to 5. Note that
    147        # there has been no GCC 4.10, as it was renamed to GCC 5.
    148        ifneq (,$(filter 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
    149            DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    150            EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
    151        endif
    152        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    153            DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    154            EXTRA_SRCS += aes-armv8.c gcm-aarch64.c sha1-armv8.c sha256-armv8.c
    155        endif
    156    endif
    157 endif
    158 ifeq ($(CPU_ARCH),arm)
    159 ifndef NSS_DISABLE_ARM32_NEON
    160    EXTRA_SRCS += gcm-arm32-neon.c
    161 endif
    162    ifdef CC_IS_CLANG
    163        DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    164        EXTRA_SRCS += aes-armv8.c sha1-armv8.c sha256-armv8.c
    165    else ifeq (1,$(CC_IS_GCC))
    166        # GCC versions older than 4.9 don't support ARM AES. The check
    167        # is done in two parts, first allows "major.minor" == "4.9",
    168        # and then rejects any major versions prior to 5. Note that
    169        # there has been no GCC 4.10, as it was renamed to GCC 5.
    170        ifneq (,$(filter 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
    171            DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    172            EXTRA_SRCS += aes-armv8.c sha1-armv8.c sha256-armv8.c
    173        endif
    174        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    175            DEFINES += -DUSE_HW_AES -DUSE_HW_SHA1 -DUSE_HW_SHA2
    176            EXTRA_SRCS += aes-armv8.c sha1-armv8.c sha256-armv8.c
    177        endif
    178    endif
    179 endif
    180 
    181 ifeq (,$(filter-out WINNT,$(OS_TARGET)))
    182 ifndef USE_64
    183 # 32-bit Windows
    184 ifdef NS_USE_GCC
    185 # Ideally, we want to use assembler
    186 #     ASFILES  = mpi_x86.s
    187 #     DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE \
    188 #                -DMP_ASSEMBLY_DIV_2DX1D
    189 # but we haven't figured out how to make it work, so we are not
    190 # using assembler right now.
    191    ASFILES  =
    192    DEFINES += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT
    193 else
    194 # MSVC
    195    MPI_SRCS += mpi_x86_asm.c
    196    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    197    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
    198    ifdef BUILD_OPT
    199 OPTIMIZER += -Ox  # maximum optimization for freebl
    200    endif
    201    # The Intel AES assembly code requires Visual C++ 2010.
    202    # if $(_MSC_VER) >= 1600 (Visual C++ 2010)
    203    ifeq ($(firstword $(sort $(_MSC_VER) 1600)),1600)
    204 DEFINES += -DUSE_HW_AES -DINTEL_GCM
    205 ASFILES += intel-aes-x86-masm.asm intel-gcm-x86-masm.asm
    206 EXTRA_SRCS += intel-gcm-wrap.c
    207 ifeq ($(CLANG_CL),1)
    208     INTEL_GCM_CLANG_CL = 1
    209 endif
    210    endif
    211    # The Intel SHA extenstion requires Visual C++ 2015.
    212    ifeq ($(_MSC_VER_GE_14),1)
    213        DEFINES += -DUSE_HW_SHA2
    214        EXTRA_SRCS += sha256-x86.c
    215    endif
    216 endif
    217 else
    218 ifdef NS_USE_GCC
    219 # Ideally, we should use amd64 assembly code, but it's not yet mingw-w64
    220 # compatible.
    221 else
    222 # MSVC
    223    ifdef BUILD_OPT
    224 OPTIMIZER += -Ox  # maximum optimization for freebl
    225    endif
    226 ifeq ($(CPU_ARCH),x86_64)
    227    ASFILES  = arcfour-amd64-masm.asm mpi_amd64_masm.asm mp_comba_amd64_masm.asm
    228    DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
    229    DEFINES += -DNSS_USE_COMBA
    230    # The Intel AES assembly code requires Visual C++ 2010 (10.0). The _xgetbv
    231    # compiler intrinsic function requires Visual C++ 2010 (10.0) SP1.
    232    ifeq ($(_MSC_VER_GE_10SP1),1)
    233 DEFINES += -DUSE_HW_AES -DINTEL_GCM
    234 ASFILES += intel-aes-x64-masm.asm intel-gcm-x64-masm.asm
    235 EXTRA_SRCS += intel-gcm-wrap.c
    236 ifeq ($(CLANG_CL),1)
    237     INTEL_GCM_CLANG_CL = 1
    238 endif
    239    endif
    240    # The Intel SHA extenstion requires Visual C++ 2015.
    241    ifeq ($(_MSC_VER_GE_14),1)
    242        DEFINES += -DUSE_HW_SHA2
    243        EXTRA_SRCS += sha256-x86.c
    244    endif
    245    MPI_SRCS += mpi_amd64.c
    246 endif
    247 endif
    248 endif
    249 endif
    250 
    251 ifeq ($(OS_TARGET),Darwin)
    252 ifeq ($(CPU_ARCH),x86_64)
    253    ASFILES  = mpi_amd64_common.s
    254    DEFINES += -DMPI_AMD64
    255    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DNSS_USE_COMBA
    256    MPI_SRCS += mpi_amd64.c mp_comba.c
    257 else ifeq ($(CPU_ARCH),x86)
    258    ASFILES  = mpi_sse2.s
    259    DEFINES += -DMP_USE_UINT_DIGIT
    260    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    261    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
    262 endif
    263 endif # Darwin
    264 
    265 ifeq ($(OS_TARGET),Linux)
    266 ifeq ($(CPU_ARCH),x86_64)
    267    # Lower case s on mpi_amd64_common due to make implicit rules.
    268    ASFILES  = arcfour-amd64-gas.s mpi_amd64_common.s
    269    ASFLAGS += -fPIC -Wa,--noexecstack
    270    DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
    271    DEFINES += -DNSS_USE_COMBA
    272 #   DEFINES += -DMPI_AMD64_ADD
    273    # comment the next four lines to turn off Intel HW acceleration.
    274    DEFINES += -DUSE_HW_AES -DINTEL_GCM
    275    ASFILES += intel-aes.s intel-gcm.s
    276    EXTRA_SRCS += intel-gcm-wrap.c
    277    INTEL_GCM = 1
    278    MPI_SRCS += mpi_amd64.c mp_comba.c
    279 endif
    280 ifeq ($(CPU_ARCH),x86)
    281    ASFILES  = mpi_x86.s
    282    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    283    DEFINES += -DMP_ASSEMBLY_DIV_2DX1D -DMP_USE_UINT_DIGIT
    284 endif
    285 ifeq ($(CPU_ARCH),arm)
    286    DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    287    DEFINES += -DMP_USE_UINT_DIGIT
    288    DEFINES += -DSHA_NO_LONG_LONG # avoid 64-bit arithmetic in SHA512
    289    MPI_SRCS += mpi_arm.c
    290 endif
    291 ifeq ($(CPU_ARCH),ppc)
    292    EXTRA_SRCS += gcm-ppc.c
    293 ifdef USE_64
    294    DEFINES += -DNSS_NO_INIT_SUPPORT
    295    PPC_ABI := $(shell $(CC) -dM -E - < /dev/null | awk '$$2 == "_CALL_ELF" {print $$3}')
    296    ifeq ($(PPC_ABI),2)
    297        ASFILES += sha512-p8.s
    298    ifeq ($(OS_TEST),ppc64le)
    299        DEFINES += -DPPC_GCM
    300        EXTRA_SRCS += chacha20poly1305-ppc.c ppc-gcm-wrap.c
    301        ASFILES += chacha20-ppc64le.s ppc-gcm.s
    302    endif # ppc64le
    303    endif
    304 endif # USE_64
    305 endif # ppc
    306 endif # Linux
    307 
    308 ifeq ($(OS_TARGET),AIX)
    309    DEFINES += -DMP_USE_UINT_DIGIT
    310    ifndef USE_64
    311 DEFINES += -DMP_NO_DIV_WORD -DMP_NO_ADD_WORD -DMP_NO_SUB_WORD
    312    endif
    313 endif # AIX
    314 
    315 ifeq ($(OS_TARGET), HP-UX)
    316 ifneq ($(OS_TEST), ia64)
    317 # PA-RISC
    318 ASFILES += ret_cr16.s
    319 ifndef USE_64
    320    FREEBL_BUILD_SINGLE_SHLIB =
    321    HAVE_ABI32_INT32 = 1
    322    HAVE_ABI32_FPU = 1
    323 endif
    324 ifdef FREEBL_CHILD_BUILD
    325 ifdef USE_ABI32_INT32
    326 # build for DA1.1 (HP PA 1.1) 32-bit ABI build with 32-bit arithmetic
    327    DEFINES  += -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
    328    DEFINES += -DSHA_NO_LONG_LONG # avoid 64-bit arithmetic in SHA512
    329 else
    330 ifdef USE_64
    331 # this builds for DA2.0W (HP PA 2.0 Wide), the LP64 ABI, using 64-bit digits
    332    MPI_SRCS += mpi_hp.c
    333    ASFILES  += hpma512.s hppa20.s
    334    DEFINES  += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    335 else
    336 # this builds for DA2.0 (HP PA 2.0 Narrow) ABI32_FPU model
    337 # (the 32-bit ABI with 64-bit registers) using 64-bit digits
    338    MPI_SRCS += mpi_hp.c
    339    ASFILES  += hpma512.s hppa20.s
    340    DEFINES  += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    341 ifndef NS_USE_GCC
    342    ARCHFLAG = -Aa +e +DA2.0 +DS2.0
    343 endif
    344 endif
    345 endif
    346 endif
    347 endif
    348 endif
    349 
    350 # The blapi functions are defined not only in the freebl shared
    351 # libraries but also in the shared libraries linked with loader.c
    352 # (libsoftokn3.so and libssl3.so).  We need to use GNU ld's
    353 # -Bsymbolic option or the equivalent option for other linkers
    354 # to bind the blapi function references in FREEBLVector vector
    355 # (ldvector.c) to the blapi functions defined in the freebl
    356 # shared libraries.
    357 ifeq (,$(filter-out FreeBSD Linux NetBSD OpenBSD, $(OS_TARGET)))
    358    MKSHLIB += -Wl,-Bsymbolic
    359 endif
    360 
    361 ifeq ($(OS_TARGET),SunOS)
    362 
    363 ifdef NS_USE_GCC
    364    ifdef GCC_USE_GNU_LD
    365 MKSHLIB += -Wl,-Bsymbolic,-z,now,-z,text
    366    else
    367 MKSHLIB += -Wl,-B,symbolic,-z,now,-z,text
    368    endif # GCC_USE_GNU_LD
    369 else
    370    MKSHLIB += -B symbolic -z now -z text
    371 endif # NS_USE_GCC
    372 
    373 # Sun's WorkShop defines v8, v8plus and v9 architectures.
    374 # gcc on Solaris defines v8 and v9 "cpus".
    375 # gcc's v9 is equivalent to Workshop's v8plus.
    376 # gcc's -m64 is equivalent to Workshop's v9
    377 # We always use Sun's assembler, which uses Sun's naming convention.
    378 ifeq ($(CPU_ARCH),sparc)
    379    FREEBL_BUILD_SINGLE_SHLIB=
    380    ifdef USE_64
    381        HAVE_ABI64_INT = 1
    382        HAVE_ABI64_FPU = 1
    383    else
    384        HAVE_ABI32_FPU = 1
    385        HAVE_ABI32_INT64 = 1
    386    endif
    387    SYSV_SPARC = 1
    388    SOLARIS_AS = /usr/ccs/bin/as
    389    #### set arch, asm, c flags
    390    ifdef NS_USE_GCC
    391 ifdef USE_ABI32_INT64
    392     ARCHFLAG=-mcpu=v9 -Wa,-xarch=v8plus
    393     SOLARIS_AS_FLAGS = -xarch=v8plus -K PIC
    394 endif
    395 ifdef USE_ABI32_FPU
    396     ARCHFLAG=-mcpu=v9 -Wa,-xarch=v8plusa
    397     SOLARIS_AS_FLAGS = -xarch=v8plusa -K PIC
    398 endif # USE_ABI32_FPU
    399 ifdef USE_ABI64_INT
    400     # this builds for Sparc v9a pure 64-bit architecture
    401     ARCHFLAG += -mcpu=v9 -Wa,-xarch=v9
    402     SOLARIS_AS_FLAGS = -xarch=v9 -K PIC
    403 endif
    404 ifdef USE_ABI64_FPU
    405     # this builds for Sparc v9a pure 64-bit architecture
    406     # It uses floating point, and 32-bit word size
    407     ARCHFLAG += -mcpu=v9 -Wa,-xarch=v9a
    408     SOLARIS_AS_FLAGS = -xarch=v9a -K PIC
    409 endif
    410    else # NS_USE_GCC
    411 # FPU_TARGET_OPTIMIZER specifies the target processor and cache
    412 # properties of the ABI32_FPU and ABI64_FPU architectures for use
    413 # by the optimizer.
    414 ifeq (,$(findstring Sun WorkShop 6,$(shell $(CC) -V 2>&1)))
    415     # if the compiler is not Forte 6
    416     FPU_TARGET_OPTIMIZER = -xcache=64/32/4:1024/64/4 -xchip=ultra3
    417 else
    418     # Forte 6 C compiler generates incorrect code for rijndael.c
    419     # if -xchip=ultra3 is used (Bugzilla bug 333925).  So we revert
    420     # to what we used in NSS 3.10.
    421     FPU_TARGET_OPTIMIZER = -xchip=ultra2
    422 endif
    423 ifdef USE_ABI32_INT64
    424     # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
    425     # 32-bit ABI, it uses 64-bit words, integer arithmetic,
    426     # no FPU (non-VIS cpus).
    427     # These flags were suggested by the compiler group for building
    428     # with SunStudio 10.
    429     ifdef BUILD_OPT
    430                SOL_CFLAGS += -xO4
    431     endif
    432 	SOL_CFLAGS += -xtarget=generic
    433     ARCHFLAG = -xarch=v8plus
    434     SOLARIS_AS_FLAGS = -xarch=v8plus -K PIC
    435 endif
    436 ifdef USE_ABI32_FPU
    437     # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
    438     # 32-bit ABI, it uses FPU code, and 32-bit word size.
    439     # these flags were determined by running cc -### -fast and copying
    440     # the generated flag settings
    441     SOL_CFLAGS += -fsingle -xmemalign=8s
    442     ifdef BUILD_OPT
    443                SOL_CFLAGS += -D__MATHERR_ERRNO_DONTCARE -fsimple=1
    444                SOL_CFLAGS += -xalias_level=basic -xbuiltin=%all
    445                SOL_CFLAGS += $(FPU_TARGET_OPTIMIZER) -xdepend
    446                SOL_CFLAGS += -xlibmil -xO5
    447     endif
    448     ARCHFLAG = -xarch=v8plusa
    449     SOLARIS_AS_FLAGS = -xarch=v8plusa -K PIC
    450 endif
    451 ifdef USE_ABI64_INT
    452     # this builds for Sparc v9a pure 64-bit architecture,
    453     # no FPU (non-VIS cpus). For building with SunStudio 10.
    454     ifdef BUILD_OPT
    455                SOL_CFLAGS += -xO4
    456     endif
    457 	SOL_CFLAGS += -xtarget=generic
    458     ARCHFLAG = -xarch=v9
    459     SOLARIS_AS_FLAGS = -xarch=v9 -K PIC
    460 endif
    461 ifdef USE_ABI64_FPU
    462     # this builds for Sparc v9a pure 64-bit architecture
    463     # It uses floating point, and 32-bit word size.
    464     # See comment for USE_ABI32_FPU.
    465     SOL_CFLAGS += -fsingle -xmemalign=8s
    466     ifdef BUILD_OPT
    467                SOL_CFLAGS += -D__MATHERR_ERRNO_DONTCARE -fsimple=1
    468                SOL_CFLAGS += -xalias_level=basic -xbuiltin=%all
    469                SOL_CFLAGS += $(FPU_TARGET_OPTIMIZER) -xdepend
    470                SOL_CFLAGS += -xlibmil -xO5
    471     endif
    472     ARCHFLAG = -xarch=v9a
    473     SOLARIS_AS_FLAGS = -xarch=v9a -K PIC
    474 endif
    475    endif # NS_USE_GCC
    476 
    477    ### set flags for both GCC and Sun cc
    478    ifdef USE_ABI32_INT64
    479 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
    480 # 32-bit ABI, it uses 64-bit words, integer arithmetic, no FPU
    481 # best times are with no MP_ flags specified
    482    endif
    483    ifdef USE_ABI32_FPU
    484 # this builds for Sparc v8+a ABI32_FPU architecture, 64-bit registers,
    485 # 32-bit ABI, it uses FPU code, and 32-bit word size
    486 MPI_SRCS += mpi_sparc.c
    487 ASFILES  = mpv_sparcv8.s montmulfv8.s
    488 DEFINES  += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT -DMP_ASSEMBLY_MULTIPLY
    489 DEFINES  += -DMP_USING_MONT_MULF -DMP_MONT_USE_MP_MUL
    490    endif
    491    ifdef USE_ABI64_INT
    492 # this builds for Sparc v9a pure 64-bit architecture
    493 # best times are with no MP_ flags specified
    494    endif
    495    ifdef USE_ABI64_FPU
    496 # this builds for Sparc v9a pure 64-bit architecture
    497 # It uses floating point, and 32-bit word size
    498 MPI_SRCS += mpi_sparc.c
    499 ASFILES   = mpv_sparcv9.s montmulfv9.s
    500 DEFINES  += -DMP_NO_MP_WORD -DMP_USE_UINT_DIGIT -DMP_ASSEMBLY_MULTIPLY
    501 DEFINES  += -DMP_USING_MONT_MULF -DMP_MONT_USE_MP_MUL
    502    endif
    503 
    504 else
    505    # Solaris for non-sparc family CPUs
    506    ifdef NS_USE_GCC
    507 LD = gcc
    508 AS = gcc
    509 ASFLAGS = -x assembler-with-cpp
    510    endif
    511    ifeq ($(USE_64),1)
    512 # Solaris for AMD64
    513 ifdef NS_USE_GCC
    514     ASFILES  = arcfour-amd64-gas.s mpi_amd64_common.s
    515     ASFLAGS += -march=opteron -m64 -fPIC
    516     MPI_SRCS += mp_comba.c
    517     # comment the next four lines to turn off Intel HW acceleration
    518     ASFILES += intel-gcm.s
    519     EXTRA_SRCS += intel-gcm-wrap.c
    520     INTEL_GCM = 1
    521     DEFINES += -DINTEL_GCM
    522 else
    523     ASFILES  = arcfour-amd64-sun.s mpi_amd64_sun.s sha-fast-amd64-sun.s
    524 	ASFILES += mp_comba_amd64_sun.s mpcpucache_amd64.s
    525     ASFLAGS += -xarch=generic64 -K PIC
    526            SOL_CFLAGS += -xprefetch=no
    527     SHA_SRCS =
    528 	MPCPU_SRCS =
    529     # Intel acceleration for GCM does not build currently with Studio
    530 endif
    531 DEFINES += -DNSS_BEVAND_ARCFOUR -DMPI_AMD64 -DMP_ASSEMBLY_MULTIPLY
    532 DEFINES += -DNSS_USE_COMBA
    533 # comment the next two lines to turn off Intel HW acceleration
    534 DEFINES += -DUSE_HW_AES
    535 ASFILES += intel-aes.s
    536 MPI_SRCS += mpi_amd64.c
    537    else
    538 # Solaris x86
    539 DEFINES += -DMP_USE_UINT_DIGIT
    540 DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE
    541 DEFINES += -DMP_ASSEMBLY_DIV_2DX1D
    542 ASFILES  = mpi_i86pc.s
    543 ifndef NS_USE_GCC
    544 	MPCPU_SRCS =
    545 	ASFILES += mpcpucache_x86.s
    546 endif
    547    endif
    548 endif # Solaris for non-sparc family CPUs
    549 endif # target == SunO
    550 
    551 ifdef USE_64
    552 # no __int128 at least up to lcc 1.23 (pretending to be gcc5)
    553 # NB: CC_NAME is not defined here
    554 ifneq ($(shell $(CC) -? 2>&1 >/dev/null </dev/null | sed -e 's/:.*//;1q'),lcc)
    555    ifdef CC_IS_CLANG
    556            HAVE_INT128_SUPPORT = 1
    557            DEFINES += -DHAVE_INT128_SUPPORT
    558    else ifeq (1,$(CC_IS_GCC))
    559        ifneq (,$(filter 4.6 4.7 4.8 4.9,$(word 1,$(GCC_VERSION)).$(word 2,$(GCC_VERSION))))
    560            HAVE_INT128_SUPPORT = 1
    561            DEFINES += -DHAVE_INT128_SUPPORT
    562        endif
    563        ifneq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    564            NSS_DISABLE_AVX2 = 1
    565        endif
    566        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    567            HAVE_INT128_SUPPORT = 1
    568            DEFINES += -DHAVE_INT128_SUPPORT
    569        endif
    570        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(GCC_VERSION))))
    571            NSS_DISABLE_SSE3 = 1
    572            NSS_DISABLE_SSE4_1 = 1
    573            NSS_DISABLE_SSE4_2 = 1
    574        endif
    575    endif
    576 endif # lcc
    577 endif # USE_64
    578 
    579 ifndef HAVE_INT128_SUPPORT
    580    DEFINES += -DKRML_VERIFIED_UINT128
    581 endif
    582 
    583 ifndef NSS_DISABLE_CHACHAPOLY
    584    ifeq ($(CPU_ARCH),x86_64)
    585        ifndef NSS_DISABLE_AVX2
    586            EXTRA_SRCS += Hacl_Poly1305_256.c Hacl_Chacha20_Vec256.c Hacl_Chacha20Poly1305_256.c
    587            DEFINES += -DHACL_CAN_COMPILE_VEC256
    588        endif # NSS_DISABLE_AVX2
    589        ifndef NSS_DISABLE_SSE3
    590            EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c
    591            DEFINES += -DHACL_CAN_COMPILE_VEC128 
    592        endif
    593    endif # x86_64
    594 
    595    VERIFIED_SRCS += Hacl_Poly1305_32.c Hacl_Chacha20.c Hacl_Chacha20Poly1305_32.c
    596 endif # NSS_DISABLE_CHACHAPOLY
    597 
    598 ifndef NSS_DISABLE_KYBER
    599 KYBER_PQCRYSTALS = kyber-pqcrystals-ref.c
    600 endif
    601 
    602 VERIFIED_SRCS += Hacl_Hash_SHA3.c Hacl_P256.c Hacl_P384.c Hacl_P521.c libcrux_sha3_portable.c libcrux_mlkem768_portable.c libcrux_mlkem1024_portable.c libcrux_mlkem_portable.c libcrux_core.c
    603 VERIFIED_SRCS += Hacl_Ed25519.c
    604 VERIFIED_SRCS += Hacl_Curve25519_51.c
    605 
    606 # Bug 1918767 / Bug 1918711 - by setting KRML_MUSTINLINE=inline here, we
    607 # avoid it being defined to `inline __forceinline` (for msvc) or `inline
    608 # __attribute__((always_inline))` (for gcc/clang) in
    609 # verified/karamel/include/krml/internal/target.h. These other
    610 # configurations can cause excessive stack usage.
    611 DEFINES += -DKRML_MUSTINLINE=inline
    612 
    613 ifeq (,$(filter-out x86_64 aarch64,$(CPU_ARCH)))
    614    # All 64-bit architectures get the 64 bit version.
    615    ECL_SRCS += curve25519_64.c
    616 else
    617    # All other architectures get the generic 32 bit implementation
    618    ECL_SRCS += curve25519_32.c
    619 endif
    620 
    621 #######################################################################
    622 # (5) Execute "global" rules. (OPTIONAL)                              #
    623 #######################################################################
    624 
    625 include $(CORE_DEPTH)/coreconf/rules.mk
    626 
    627 #######################################################################
    628 # (6) Execute "component" rules. (OPTIONAL)                           #
    629 #######################################################################
    630 
    631 
    632 
    633 #######################################################################
    634 # (7) Execute "local" rules. (OPTIONAL).                              #
    635 #######################################################################
    636 
    637 
    638 rijndael_tables:
    639 $(CC) -o $(OBJDIR)/make_rijndael_tab rijndael_tables.c \
    640          $(DEFINES) $(INCLUDES) $(OBJDIR)/libfreebl.a
    641 $(OBJDIR)/make_rijndael_tab
    642 
    643 vpath %.h mpi ecl verified deprecated
    644 vpath %.c mpi ecl verified deprecated
    645 vpath %.S mpi ecl
    646 vpath %.s mpi ecl
    647 vpath %.asm mpi ecl
    648 INCLUDES += -Impi -Iecl -Iverified -Iverified/internal -Iverified/karamel/include -Iverified/karamel/krmllib/dist/minimal -Iverified/eurydice -Ideprecated
    649 
    650 
    651 DEFINES += -DMP_API_COMPATIBLE
    652 
    653 MPI_USERS = secmpi.c dh.c pqg.c dsa.c rsa.c ec.c
    654 
    655 MPI_OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_SRCS:.c=$(OBJ_SUFFIX)))
    656 MPI_OBJS += $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(MPI_USERS:.c=$(OBJ_SUFFIX)))
    657 
    658 $(MPI_OBJS): $(MPI_HDRS)
    659 
    660 ECL_USERS = ec.c
    661 
    662 ECL_OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(ECL_SRCS:.c=$(OBJ_SUFFIX)) $(ECL_ASM_SRCS:$(ASM_SUFFIX)=$(OBJ_SUFFIX)))
    663 ECL_OBJS += $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(ECL_USERS:.c=$(OBJ_SUFFIX)))
    664 
    665 $(ECL_OBJS): $(ECL_HDRS)
    666 
    667 $(OBJDIR)/sysrand$(OBJ_SUFFIX): sysrand.c unix_rand.c win_rand.c
    668 
    669 $(OBJDIR)/$(PROG_PREFIX)mpprime$(OBJ_SUFFIX): primes.c
    670 
    671 $(OBJDIR)/ldvector$(OBJ_SUFFIX) $(OBJDIR)/loader$(OBJ_SUFFIX) : loader.h
    672 
    673 ifeq ($(SYSV_SPARC),1)
    674 
    675 $(OBJDIR)/mpv_sparcv8.o $(OBJDIR)/mpv_sparcv8x.o $(OBJDIR)/montmulfv8.o : $(OBJDIR)/%.o : %.s | $$(@D)/d
    676 $(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $<
    677 
    678 $(OBJDIR)/mpv_sparcv9.o $(OBJDIR)/montmulfv9.o : $(OBJDIR)/%.o : %.s | $$(@D)/d
    679 $(SOLARIS_AS) -o $@ $(SOLARIS_AS_FLAGS) $<
    680 
    681 $(OBJDIR)/mpmontg.o: mpmontg.c montmulf.h
    682 
    683 endif
    684 
    685 ifndef FREEBL_CHILD_BUILD
    686 
    687 # Parent build. This is where we decide which shared libraries to build
    688 
    689 # too suppress the SINGLE_SHLIB override warning
    690 FREEBL_OBJDIRS :=
    691 
    692 define target_freebl_SHLIB
    693 ifdef $(2)
    694 $(1)_DIR = $$(OBJDIR)/$$(OS_TARGET)_$(1)
    695 ALL_TRASH += $$($(1)_DIR)
    696 
    697 ifeq (,$$(filter $$($(1)_DIR)/d,$$(FREEBL_OBJDIRS)))
    698 FREEBL_OBJDIRS += $$($(1)_DIR)/d
    699 endif
    700 
    701 release_md:: freebl_$(2)
    702 libs: freebl_$(2)
    703 freebl_$(2): | $$($(1)_DIR)/d
    704 $$(MAKE) FREEBL_CHILD_BUILD=1 $(3)=1 OBJDIR=$$($(1)_DIR) libs
    705 endif
    706 endef # target_freebl_SHLIB
    707 
    708 target_freebl_ABI = $(call target_freebl_SHLIB,$(1),HAVE_$(1),USE_$(1))
    709 
    710 $(eval $(call target_freebl_SHLIB,SINGLE_SHLIB,FREEBL_BUILD_SINGLE_SHLIB,NEEDED_DUMMY))
    711 $(eval $(call target_freebl_SHLIB,SINGLE_SHLIB,NEED_STUB_BUILD,USE_STUB_BUILD))
    712 
    713 $(eval $(call target_freebl_ABI,ABI32_FPU))
    714 $(eval $(call target_freebl_ABI,ABI32_INT32))
    715 $(eval $(call target_freebl_ABI,ABI32_INT64))
    716 $(eval $(call target_freebl_ABI,ABI64_FPU))
    717 $(eval $(call target_freebl_ABI,ABI64_INT))
    718 
    719 endif  # FREEBL_CHILD_BUILD
    720 
    721 
    722 # Bugzilla Bug 333917: the non-x86 code in desblapi.c seems to violate
    723 # ANSI C's strict aliasing rules.
    724 ifeq ($(OS_TARGET),Linux)
    725 ifneq ($(CPU_ARCH),x86)
    726 $(OBJDIR)/$(PROG_PREFIX)desblapi$(OBJ_SUFFIX): desblapi.c | $$(@D)/d
    727 ifdef NEED_ABSOLUTE_PATH
    728 $(CC) -o $@ -c $(CFLAGS) -fno-strict-aliasing $(call core_abspath,$<)
    729 else
    730 $(CC) -o $@ -c $(CFLAGS) -fno-strict-aliasing $<
    731 endif
    732 endif
    733 endif
    734 
    735 ifdef INTEL_GCM
    736 #
    737 # GCM binary needs -mssse3
    738 #
    739 $(OBJDIR)/$(PROG_PREFIX)intel-gcm-wrap$(OBJ_SUFFIX): CFLAGS += -mssse3
    740 endif
    741 
    742 ifdef INTEL_GCM_CLANG_CL
    743 #
    744 # clang-cl needs -mssse3
    745 #
    746 $(OBJDIR)/$(PROG_PREFIX)intel-gcm-wrap$(OBJ_SUFFIX): CFLAGS += -mssse3
    747 endif
    748 
    749 $(OBJDIR)/$(PROG_PREFIX)sha256-x86$(OBJ_SUFFIX): CFLAGS += -msha -mssse3 -msse4.1
    750 
    751 ifeq ($(CPU_ARCH),arm)
    752 # When the compiler uses the softfloat ABI, we want to use the compatible softfp ABI when
    753 # enabling NEON for these objects.
    754 # Confusingly, __SOFTFP__ is the name of the define for the softfloat ABI, not for the softfp ABI.
    755 USES_SOFTFLOAT_ABI := $(shell $(CC) -o - -E -dM - $(CFLAGS) < /dev/null | grep __SOFTFP__ > /dev/null && echo 1)
    756 $(OBJDIR)/$(PROG_PREFIX)aes-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a -mfpu=crypto-neon-fp-armv8$(if $(USES_SOFTFLOAT_ABI), -mfloat-abi=softfp)
    757 $(OBJDIR)/$(PROG_PREFIX)sha1-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a -mfpu=crypto-neon-fp-armv8$(if $(USES_SOFTFLOAT_ABI), -mfloat-abi=softfp)
    758 $(OBJDIR)/$(PROG_PREFIX)sha256-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a -mfpu=crypto-neon-fp-armv8$(if $(USES_SOFTFLOAT_ABI), -mfloat-abi=softfp)
    759 ifndef NSS_DISABLE_ARM32_NEON
    760 $(OBJDIR)/$(PROG_PREFIX)gcm-arm32-neon$(OBJ_SUFFIX): CFLAGS += -mfpu=neon$(if $(USES_SOFTFLOAT_ABI), -mfloat-abi=softfp)
    761 endif
    762 endif
    763 
    764 ifeq ($(CPU_ARCH),aarch64)
    765 $(OBJDIR)/$(PROG_PREFIX)aes-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
    766 $(OBJDIR)/$(PROG_PREFIX)gcm-aarch64$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
    767 $(OBJDIR)/$(PROG_PREFIX)sha1-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
    768 $(OBJDIR)/$(PROG_PREFIX)sha256-armv8$(OBJ_SUFFIX): CFLAGS += -march=armv8-a+crypto
    769 endif
    770 
    771 ifeq ($(CPU_ARCH),ppc)
    772 $(OBJDIR)/$(PROG_PREFIX)sha512$(OBJ_SUFFIX): CFLAGS += -funroll-loops -fpeel-loops
    773 ifneq ($(NSS_DISABLE_ALTIVEC),1)
    774 $(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -maltivec
    775 $(OBJDIR)/$(PROG_PREFIX)gcm$(OBJ_SUFFIX): CFLAGS += -maltivec
    776 $(OBJDIR)/$(PROG_PREFIX)rijndael$(OBJ_SUFFIX): CFLAGS += -maltivec
    777 $(OBJDIR)/$(PROG_PREFIX)sha512$(OBJ_SUFFIX): CFLAGS += -maltivec
    778 $(OBJDIR)/$(PROG_PREFIX)chacha20poly1305-ppc$(OBJ_SUFFIX): CFLAGS += -maltivec
    779 endif
    780 ifneq ($(NSS_DISABLE_CRYPTO_VSX),1)
    781 $(OBJDIR)/$(PROG_PREFIX)gcm-ppc$(OBJ_SUFFIX): CFLAGS += -mcrypto -mvsx
    782 $(OBJDIR)/$(PROG_PREFIX)gcm$(OBJ_SUFFIX): CFLAGS += -mcrypto -mvsx
    783 $(OBJDIR)/$(PROG_PREFIX)rijndael$(OBJ_SUFFIX): CFLAGS += -mcrypto -mvsx
    784 $(OBJDIR)/$(PROG_PREFIX)sha512$(OBJ_SUFFIX): CFLAGS += -mcrypto -mvsx
    785 $(OBJDIR)/$(PROG_PREFIX)chacha20poly1305-ppc$(OBJ_SUFFIX): CFLAGS += -mcrypto -mvsx
    786 endif
    787 endif
    788 
    789 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx
    790 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx
    791 $(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx
    792 
    793 ifndef NSS_DISABLE_AVX2
    794 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx2
    795 $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2
    796 $(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2
    797 endif