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