-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.arm
156 lines (131 loc) · 4.11 KB
/
Makefile.arm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# Makefile for building Android based configurations for Linux
# and/or MacOS hosted build environments
#
# See http://www.opensslfoundation.com/fips/2.0/platforms/android/
#
#
# if you get a build error in the openssl-1.0.1c area you can re-run just
# the make portion using the 'remake' target
#
#
# for linux based building:
# openssl-fips-2.0.2
# openssl-1.0.1h
# android-ndk-r8b
# android-sdk-linux
#
# for macos based building:
# openssl-fips-2.0.2
# openssl-1.0.1h
# android-ndk-r8c
# android-sdk-macosx
#
# Note: the makefile depends on wget which you can install a version
# from macports.org or simply use curl rather than wget as curl
# is installed by default
#
# WGET="curl -O" ANDK=android-ndk-r8c ASDK=android-sdk-macosx make
#
#
# for cygwin based build:
# openssl-fips-2.0.2
# openssl-1.0.1h
# TODO
#
# change these versions as required ...
OPENSSL_FIPS_VERSION=2.0.5
OPENSSL_VERSION=1.0.1h
# Android SDK version
ASDK?=$(ANDROID_SDK)
# Android NDK version
ANDK?=$(ANDROID_NDK)
# Android Platform
APLATFORM?=android-9
ADB?=./$(ASDK)/platform-tools/adb
# WGET command
WGET?=wget
all: copy
#
# note: this script has not yet be placed in this location
#
fipsld-crosscompile-fix:
$(WGET) http://www.opensslfoundation.com/fips/2.0/platforms/android/fipsld-crosscompile-fix
fips_hmac.c:
$(WGET) http://www.opensslfoundation.com/fips/2.0/platforms/android/fips_hmac.c
openssl-fips-$(OPENSSL_FIPS_VERSION).tar.gz:
$(WGET) http://www.openssl.org/source/openssl-fips-$(OPENSSL_FIPS_VERSION).tar.gz
openssl-$(OPENSSL_VERSION).tar.gz:
$(WGET) http://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
fips/:
mkdir fips
.PHONY: fips/.done
fips/.done: fips/ fipsld-crosscompile-fix openssl-fips-$(OPENSSL_FIPS_VERSION).tar.gz
gunzip -c openssl-fips-$(OPENSSL_FIPS_VERSION).tar.gz | tar xf -
. ./setenv-android-arm.sh; \
cd openssl-fips-$(OPENSSL_FIPS_VERSION); \
./config; \
make; \
make install INSTALLTOP=$$PWD/../fips; \
cd ..; touch $@
# keep a backup copy of the original fipsld
if [ ! -f fips/bin/fipsld-original ]; then \
cp fips/bin/fipsld fips/bin/fipsld-original; \
fi
# copy in the fixed fipsld which handles cross-compile environments
cp fipsld-crosscompile-fix fips/bin/fipsld
.PHONY: openssl-$(OPENSSL_VERSION)/.done
openssl-$(OPENSSL_VERSION)/.done: fips/.done openssl-$(OPENSSL_VERSION).tar.gz setenv-android-arm.sh
gunzip -c openssl-$(OPENSSL_VERSION).tar.gz | tar xf -
. ./setenv-android-arm.sh; \
cd openssl-$(OPENSSL_VERSION)/; \
./config fips shared --with-fipsdir=$$PWD/../fips; \
make depend; \
make; \
touch .done
remake: openssl-$(OPENSSL_VERSION)/.done
. ./setenv-android-arm.sh; \
cd openssl-$(OPENSSL_VERSION)/; \
make; \
touch .done
libclean: openssl-$(OPENSSL_VERSION)/.done
. ./setenv-android-arm.sh; \
cd openssl-$(OPENSSL_VERSION)/; \
make libclean; \
touch .done
fips_hmac: openssl-$(OPENSSL_VERSION)/.done fips_hmac.c
. ./setenv-android-arm.sh; \
$(CROSS_COMPILE)gcc -o fips_hmac fips_hmac.c -Iopenssl-$(OPENSSL_VERSION)/include/ -Lopenssl-$(OPENSSL_VERSION)/ -lcrypto -Iopenssl-$(OPENSSL_VERSION) -I$(ANDROID_SYSROOT)/usr/include -B$(ANDROID_SYSROOT)/usr/lib
test: fips_hmac
@echo "Copy executable"
$(ADB) push fips_hmac /data/local/tmp/
@echo "Copy shared library"
$(ADB) push openssl-$(OPENSSL_VERSION)/libcrypto.so.1.0.0 /data/local/tmp/
@echo "Run executable"
$(ADB) shell 'cd /data/local/tmp; LD_LIBRARY_PATH=. ./fips_hmac -v fips_hmac'
realclean:
rm -rf fips openssl-fips-$(OPENSSL_FIPS_VERSION) openssl-$(OPENSSL_VERSION) fips_hmac
#
# note: these files should all end up being downloadable from
# http://www.opensslfoundation.com/fips/2.0/platforms/android/
archive:
tar zcvf android-build.tgz \
readme.txt darwin linux \
fipsld-crosscompile-fix \
Makefile fips_hmac.c setenv-android-arm.sh
.PHONY: copy
copy: fips_hmac
cd openssl-$(OPENSSL_VERSION); \
mkdir -p ../lib; \
cp libcrypto.a ../lib/; \
cp libssl.a ../lib/; \
cp libcrypto.so.1.0.0 ../lib/; \
cp libssl.so.1.0.0 ../lib/; \
cp -r include ../
.PHONY: clean
clean:
rm -rf openssl-fips-$(OPENSSL_FIPS_VERSION)
rm -rf openssl-$(OPENSSL_VERSION)
rm -rf include
rm -rf lib
rm -rf fips