11cb0ef41Sopenharmony_ci# This Makefile is confirmed to be run only on Linux (CentOS and
21cb0ef41Sopenharmony_ci# Ubuntu). perl5 and gas(>=2.26) are needed.
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciUNAME_S := $(shell uname -s)
51cb0ef41Sopenharmony_ciifneq ($(UNAME_S),Linux)
61cb0ef41Sopenharmony_ci  $(error This can be run only on Linux)
71cb0ef41Sopenharmony_ciendif
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciPERL    = perl
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci# Supported architecture list
121cb0ef41Sopenharmony_ciASM_ARCHS = aix64-gcc-as BSD-x86 BSD-x86_64 \
131cb0ef41Sopenharmony_cidarwin64-x86_64-cc darwin-i386-cc darwin64-arm64-cc linux-aarch64 \
141cb0ef41Sopenharmony_cilinux-armv4 linux-elf linux-x86_64 \
151cb0ef41Sopenharmony_cilinux-ppc64le linux32-s390x linux64-s390x linux64-mips64\
161cb0ef41Sopenharmony_cisolaris-x86-gcc solaris64-x86_64-gcc VC-WIN64A VC-WIN32
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciNO_ASM_ARCHS = VC-WIN64-ARM linux64-riscv64 linux64-loongarch64
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciCC = gcc
211cb0ef41Sopenharmony_ciFAKE_GCC = ../config/fake_gcc.pl
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciCONFIGURE = ./Configure
241cb0ef41Sopenharmony_ci# no-comp: against CRIME attack
251cb0ef41Sopenharmony_ci# no-shared: openssl-cli needs static link
261cb0ef41Sopenharmony_ci# no-afalgeng: old Linux kernel < 4.0 does not support it
271cb0ef41Sopenharmony_ci# enable-ssl-trace: cause the optional SSL_trace API to be built
281cb0ef41Sopenharmony_ciCOPTS =  no-comp no-shared no-afalgeng enable-ssl-trace enable-fips
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci# disable platform check in Configure
311cb0ef41Sopenharmony_ciNO_WARN_ENV = CONFIGURE_CHECKER_WARN=1
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciGENERATE = ./generate_gypi.pl
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciOPSSL_SRC = ../openssl
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci# Header files generated with Configure
381cb0ef41Sopenharmony_ci#INT_CFGS = bn_conf.h dso_conf.h
391cb0ef41Sopenharmony_ciINT_CFG_DIR = $(OPSSL_SRC)/include/crypto
401cb0ef41Sopenharmony_ciGEN_HEADERS = asn1 asn1t bio cmp cms configuration conf crmf crypto ct err    \
411cb0ef41Sopenharmony_ci              ess fipskey lhash ocsp opensslv pkcs12 pkcs7 safestack srp ssl  \
421cb0ef41Sopenharmony_ci	      ui x509 x509v3 x509_vfy conf
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ciCRYPTO_GEN_HEADERS = bn_conf dso_conf
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ciPHONY = all clean replace generate_headers
471cb0ef41Sopenharmony_ci.PHONY: $(PHONY)
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci#all: $(ASM_ARCHS) $(NO_ASM_ARCHS) generate_headers replace
501cb0ef41Sopenharmony_ciall: $(ASM_ARCHS) $(NO_ASM_ARCHS) generate_headers
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci# Configure and generate openssl asm files for each archs
531cb0ef41Sopenharmony_ci$(ASM_ARCHS):
541cb0ef41Sopenharmony_ci	cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(CC) $(PERL) $(CONFIGURE) $(COPTS) $@;
551cb0ef41Sopenharmony_ci	$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
561cb0ef41Sopenharmony_ci# Confgure asm_avx2 and generate upto avx2 support
571cb0ef41Sopenharmony_ci	cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(FAKE_GCC) $(PERL) $(CONFIGURE) \
581cb0ef41Sopenharmony_ci	$(COPTS) $@;
591cb0ef41Sopenharmony_ci	$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm_avx2 $@ "${GEN_HEADERS}" "${CRYTO_GEN_HEADERS}"
601cb0ef41Sopenharmony_ci# Configure no-asm and generate no-asm sources
611cb0ef41Sopenharmony_ci	cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \
621cb0ef41Sopenharmony_ci	no-asm $@;
631cb0ef41Sopenharmony_ci	$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci$(NO_ASM_ARCHS):
661cb0ef41Sopenharmony_ci# Configure no-asm and generate no-asm sources
671cb0ef41Sopenharmony_ci	cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \
681cb0ef41Sopenharmony_ci	no-asm $@;
691cb0ef41Sopenharmony_ci	$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_cigenerate_headers:
721cb0ef41Sopenharmony_ci	@$(PERL) -w -I$(OPSSL_SRC) ./generate_headers.pl "${GEN_HEADERS}" "${CRYPTO_GEN_HEADERS}"
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ciclean:
751cb0ef41Sopenharmony_ci	find archs \( -name \*.S -o -name \*.s -o -name \*.asm -o \
761cb0ef41Sopenharmony_ci	-name \*.gypi -o -name \*.h -o -name \*.pm -o -name \*.rc \) -exec rm "{}" \;
77