CryptoPkg/OpensslLib: introduce OpensslLibCrypto instance
[mirror_edk2.git] / CryptoPkg / Library / OpensslLib / process_files.sh
1 #!/bin/sh
2 #
3 # This script runs the OpenSSL Configure script, then processes the resulting
4 # file list into our local OpensslLib.inf and OpensslLibCrypto.inf, and also
5 # takes a copy of opensslconf.h.
6 #
7 # This only needs to be done once by a developer when updating to a
8 # new version of OpenSSL (or changing options, etc.). Normal users
9 # do not need to do this, since the results are stored in the EDK2
10 # git repository for them.
11
12 OPENSSL_PATH=$(sed -n '/DEFINE OPENSSL_PATH/{s/.* \(openssl-[0-9.]*[a-z]*\)[[:space:]]*/\1/ p}' OpensslLib.inf)
13 OPENSSL_CRYPTO_PATH=$(sed -n '/DEFINE OPENSSL_PATH/{s/.* \(openssl-[0-9.]*[a-z]*\)[[:space:]]*/\1/ p}' OpensslLibCrypto.inf)
14
15 if [ "$OPENSSL_PATH" != "$OPENSSL_CRYPTO_PATH" ]; then
16     echo "OPENSSL_PATH diverges between OpensslLib.inf and OpensslLibCrypto.inf"
17     exit 1
18 fi
19
20 if ! cd "${OPENSSL_PATH}" ; then
21     echo "Cannot change to OpenSSL directory \"${OPENSSL_PATH}\""
22     exit 1
23 fi
24
25 ./Configure UEFI \
26         no-asm \
27         no-bf \
28         no-camellia \
29         no-capieng \
30         no-cast \
31         no-cms \
32         no-deprecated \
33         no-dgram \
34         no-dsa \
35         no-dynamic-engine \
36         no-ec \
37         no-ecdh \
38         no-ecdsa \
39         no-engine \
40         no-engines \
41         no-err \
42         no-filenames \
43         no-fp-api \
44         no-hw \
45         no-idea \
46         no-jpake \
47         no-krb5 \
48         no-locking \
49         no-mdc2 \
50         no-posix-io \
51         no-rc2 \
52         no-rcs \
53         no-rfc3779 \
54         no-ripemd \
55         no-scrypt \
56         no-sct \
57         no-seed \
58         no-sha0 \
59         no-sock \
60         no-srp \
61         no-ssl \
62         no-stdio \
63         no-threads \
64         no-ts \
65         no-ui \
66         no-whirlpool \
67     || exit 1
68
69 make files
70 cd -
71
72 function filelist ()
73 {
74     SSL_SELECT="$1"
75
76     echo '1,/# Autogenerated files list starts here/p'
77     echo '/# Autogenerated files list ends here/,$p'
78     echo '/# Autogenerated files list starts here/a\'
79
80     while read LINE; do
81         case "$LINE" in
82             RELATIVE_DIRECTORY=*)
83                 eval "$LINE"
84                 ;;
85             LIBSRC=*)
86                 LIBSRC=$(echo "$LINE" | sed s/^LIBSRC=//)
87                 if [ "$RELATIVE_DIRECTORY" != "ssl" ] ||
88                    [ "$SSL_SELECT" = "crypto-and-ssl" ]; then
89                     for FILE in $LIBSRC; do
90                         if [ "$FILE" != "b_print.c" ]; then
91                             echo -e '  $(OPENSSL_PATH)/'$RELATIVE_DIRECTORY/$FILE\\r\\
92                         fi
93                     done
94                 fi
95                 ;;
96         esac
97     done
98     echo -e \\r
99 }
100
101 filelist crypto-and-ssl < "${OPENSSL_PATH}/MINFO" \
102 | sed -n -f - -i OpensslLib.inf
103
104 filelist crypto-only < "${OPENSSL_PATH}/MINFO" \
105 | sed -n -f - -i OpensslLibCrypto.inf
106
107 # We can tell Windows users to put this back manually if they can't run
108 # Configure. For now, until the git repository is fixed to store things
109 # sanely, also convert to DOS line-endings
110 unix2dos -n "${OPENSSL_PATH}/crypto/opensslconf.h" opensslconf.h