-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathAndroid.mk
805 lines (607 loc) · 25.2 KB
/
Android.mk
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
## Android.mk - Android build file for Crypto++.
##
## Written and placed in public domain by Jeffrey Walton. This
## Android.mk is based on Alex Afanasyev (GitHub @cawka) PR #3,
## https://github.com/weidai11/cryptopp/pull/3.
##
## The Android build system is a wrapper around GNU Make and is
## documented https://developer.android.com/ndk/guides/android_mk.
## The CPU Features library provides caps and is documented at
## https://developer.android.com/ndk/guides/cpu-features.
##
## At Crypto++ 8.5 we added test_shared.hxx and test_shared.cxx to
## produce libtest_shared.so. The test_shared recipe shows you how
## to build a simple shared object, if desired. A couple wiki pages
## refers to it for demonstration purposes. The test_shared recipe
## can be deleted at any time.
##
## At Crypto++ 8.6 we used architecture specific flags like in the
## makefile. The arch specific flags complicated Android.mk because
## we have to build a local library for each source file with an
## arch option. To see Android.mk before the changes checkout
## CRYPTOPP_8_5_0 tag. If you don't want to build like Android.mk
## does, then add -DCRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA=1 to
## CPPFLAGS. The define disables the advanced ISA code paths used
## by Android.
##
## The library's makefile and the 'make distclean' recipe will
## clean the artifacts created by Android.mk, like obj/,
## neon_simd.cpp.neon and rijndael_simd.cpp.neon.
ifeq ($(NDK_LOG),1)
$(info Crypto++: TARGET_ARCH: $(TARGET_ARCH))
$(info Crypto++: TARGET_PLATFORM: $(TARGET_PLATFORM))
endif
LOCAL_PATH := $(call my-dir)
# Check for the test_shared source files. If present,
# build the test shared object.
ifneq ($(wildcard test_shared.hxx),)
ifneq ($(wildcard test_shared.cxx),)
$(info Crypto++: enabling test shared object)
TEST_SHARED_PROJECT := 1
endif
endif
#####################################################################
# Adjust CRYPTOPP_PATH to suit your taste, like ../cryptopp-7.1/.
# If CRYPTOPP_PATH is empty then it means the library files and the
# Android files are side-by-side in the same directory. If
# CRYPTOPP_PATH is not empty then must include the trailing slash.
# The trailing slash is needed because CRYPTOPP_PATH is prepended
# to each source file listed in CRYPTOPP_LIB_FILES.
# CRYPTOPP_PATH ?= ../cryptopp/
CRYPTOPP_PATH ?=
ifeq ($(NDK_LOG),1)
ifeq ($CRYPTOPP_PATH),)
$(info Crypto++: CRYPTOPP_PATH is empty)
else
$(info Crypto++: CRYPTOPP_PATH is $(CRYPTOPP_PATH))
endif
endif
#####################################################################
# Test source files
# Remove adhoc.cpp from this list
CRYPTOPP_TEST_FILES := \
test.cpp bench1.cpp bench2.cpp bench3.cpp datatest.cpp \
dlltest.cpp fipsalgt.cpp validat0.cpp validat1.cpp validat2.cpp \
validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp \
validat8.cpp validat9.cpp validat10.cpp regtest1.cpp regtest2.cpp \
regtest3.cpp regtest4.cpp
CRYPTOPP_TEST_FILES := $(filter-out adhoc.cpp,$(CRYPTOPP_TEST_FILES))
#####################################################################
# Library source files
# The extra gyrations put cryptlib.cpp cpu.cpp integer.cpp at the head
# of the list so their static initializers run first. Sort is used for
# deterministic builds.
CRYPTOPP_INIT_FILES := cryptlib.cpp cpu.cpp integer.cpp
CRYPTOPP_ALL_FILES := $(sort $(filter-out adhoc.cpp,$(wildcard *.cpp)))
CRYPTOPP_LIB_FILES := $(filter-out $(CRYPTOPP_TEST_FILES),$(CRYPTOPP_ALL_FILES))
CRYPTOPP_LIB_FILES := $(filter-out $(CRYPTOPP_INIT_FILES),$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(CRYPTOPP_INIT_FILES) $(CRYPTOPP_LIB_FILES)
#####################################################################
# ARM A-32 source files
ifeq ($(TARGET_ARCH),arm)
CRYPTOPP_ARM_FILES := aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
CRYPTOPP_LIB_FILES := $(CRYPTOPP_LIB_FILES) $(CRYPTOPP_ARM_FILES)
endif
#####################################################################
# Remove unneeded arch specific source files
CRYPTOPP_LIB_FILES := $(filter-out ppc_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out neon_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out sse_simd.cpp,$(CRYPTOPP_LIB_FILES))
ifeq ($(TARGET_ARCH),arm)
CRYPTOPP_LIB_FILES := $(filter-out donna_64.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out %_avx.cpp,$(CRYPTOPP_LIB_FILES))
endif
ifeq ($(TARGET_ARCH),arm64)
CRYPTOPP_LIB_FILES := $(filter-out donna_32.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out %_avx.cpp,$(CRYPTOPP_LIB_FILES))
endif
ifeq ($(TARGET_ARCH),x86)
CRYPTOPP_LIB_FILES := $(filter-out donna_64.cpp,$(CRYPTOPP_LIB_FILES))
endif
ifeq ($(TARGET_ARCH),x86_64)
CRYPTOPP_LIB_FILES := $(filter-out donna_32.cpp,$(CRYPTOPP_LIB_FILES))
endif
#####################################################################
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
CRYPTOPP_LIB_FILES := $(filter-out aria_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out blake2b_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out blake2s_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out chacha_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out chacha_avx.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out crc_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out gcm_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out gf2n_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out lea_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out lsh256_sse.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out lsh512_sse.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out lsh256_avx.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out lsh512_avx.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out rijndael_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out sm4_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out sha_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out shacal2_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out simon128_simd.cpp,$(CRYPTOPP_LIB_FILES))
CRYPTOPP_LIB_FILES := $(filter-out speck128_simd.cpp,$(CRYPTOPP_LIB_FILES))
ifeq ($(NDK_LOG),1)
$(info CRYPTOPP_LIB_FILES ($(TARGET_ARCH)): $(CRYPTOPP_LIB_FILES))
endif
#####################################################################
# ARIA using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
# Check for the aria_simd.cpp source files. If present,
# build the aria_simd object.
ifneq ($(wildcard aria_simd.cpp),)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_aria
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),aria_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
endif
CRYPTOPP_ARIA_SIMD := cryptopp_aria
include $(BUILD_STATIC_LIBRARY)
endif
#####################################################################
# BLAKE2s using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_blake2s
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),blake2s_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# BLAKE2b using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_blake2b
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),blake2b_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# ChaCha using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_chacha
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),chacha_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse2
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# ChaCha using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_chacha_avx
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),chacha_avx.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2
endif
CRYPTOPP_CHACHA_AVX := cryptopp_chacha_avx
include $(BUILD_STATIC_LIBRARY)
endif
#####################################################################
# LEA using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_lea
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lea_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# LSH256 and LSH512 using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_lsh256_sse
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh256_sse.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mssse3
CRYPTOPP_LSH256_SSE := cryptopp_lsh256_sse
include $(BUILD_STATIC_LIBRARY)
#####################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_lsh512_sse
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh512_sse.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mssse3
CRYPTOPP_LSH512_SSE := cryptopp_lsh512_sse
include $(BUILD_STATIC_LIBRARY)
#####################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_lsh256_avx
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh256_avx.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2
CRYPTOPP_LSH256_AVX := cryptopp_lsh256_avx
include $(BUILD_STATIC_LIBRARY)
#####################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_lsh512_avx
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh512_avx.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2
CRYPTOPP_LSH512_AVX := cryptopp_lsh512_avx
include $(BUILD_STATIC_LIBRARY)
endif
#####################################################################
# NEON using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
ifneq ($(filter arm arm64,$(TARGET_ARCH)),)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_neon
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),neon_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
endif
include $(BUILD_STATIC_LIBRARY)
CRYPTOPP_NEON := cryptopp_neon
endif
#####################################################################
# CRC using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_crc
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),crc_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crc
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.2
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.2
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# AES using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_rijndael
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),rijndael_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SM4 using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_sm4
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sm4_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# GCM using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_gcm
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),gcm_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# GF2N using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_gf2n
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),gf2n_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SHA using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_sha
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sha_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SHACAL2 using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_shacal2
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),shacal2_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SIMON using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_simon
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),simon128_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SPECK using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_speck
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),speck128_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon
else ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
else ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# SSE using specific ISA.
# Hack because Android.mk does not allow us to specify arch options
# during compile of a source file. Instead, we have to build a
# local library with the arch options.
# https://github.com/weidai11/cryptopp/issues/1015
ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),)
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_sse
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sse_simd.cpp)
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),x86)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse2
endif
include $(BUILD_STATIC_LIBRARY)
CRYPTOPP_SSE := cryptopp_sse
endif
#####################################################################
# Static library
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_static
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_LIB_FILES))
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
ifeq ($(TARGET_ARCH),arm)
LOCAL_ARM_MODE := arm
LOCAL_FILTER_ASM :=
endif
# Configure for release unless NDK_DEBUG=1
ifeq ($(NDK_DEBUG),1)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG
else
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG
endif
# Include all the local libraries for arch specific compiles.
# https://github.com/weidai11/cryptopp/issues/1015
LOCAL_STATIC_LIBRARIES := cpufeatures \
$(CRYPTOPP_ARIA_SIMD) \
cryptopp_blake2s cryptopp_blake2b \
cryptopp_chacha $(CRYPTOPP_CHACHA_AVX) \
cryptopp_crc \
cryptopp_gcm cryptopp_gf2n \
cryptopp_lea $(CRYPTOPP_NEON) \
cryptopp_rijndael cryptopp_sm4 \
$(CRYPTOPP_LSH256_SSE) $(CRYPTOPP_LSH256_AVX) \
$(CRYPTOPP_LSH512_SSE) $(CRYPTOPP_LSH512_AVX) \
cryptopp_sha cryptopp_shacal2 \
cryptopp_simon cryptopp_speck \
$(CRYPTOPP_SSE)
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# Shared object
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_shared
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_LIB_FILES))
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--exclude-libs,ALL -Wl,--as-needed
ifeq ($(TARGET_ARCH),arm)
LOCAL_ARM_MODE := arm
LOCAL_FILTER_ASM :=
endif
# Configure for release unless NDK_DEBUG=1
ifeq ($(NDK_DEBUG),1)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG
else
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG
endif
# Include all the local libraries for arch specific compiles.
# https://github.com/weidai11/cryptopp/issues/1015
LOCAL_STATIC_LIBRARIES := cpufeatures \
$(CRYPTOPP_ARIA_SIMD) \
cryptopp_blake2s cryptopp_blake2b \
cryptopp_chacha $(CRYPTOPP_CHACHA_AVX) \
cryptopp_crc \
cryptopp_gcm cryptopp_gf2n \
cryptopp_lea $(CRYPTOPP_NEON) \
$(CRYPTOPP_LSH256_SSE) $(CRYPTOPP_LSH256_AVX) \
$(CRYPTOPP_LSH512_SSE) $(CRYPTOPP_LSH512_AVX) \
cryptopp_rijndael cryptopp_sm4 \
cryptopp_sha cryptopp_shacal2 \
cryptopp_simon cryptopp_speck \
$(CRYPTOPP_SSE)
include $(BUILD_SHARED_LIBRARY)
#####################################################################
# Test shared object
# This recipe is for demonstration purposes. It shows you how to
# build your own shared object. It is OK to delete this recipe and
# the source files test_shared.hxx and test_shared.cxx.
ifeq ($(TEST_SHARED_PROJECT),1)
include $(CLEAR_VARS)
LOCAL_MODULE := test_shared
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),test_shared.cxx)
LOCAL_CPPFLAGS := -Wall -fvisibility=hidden
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--exclude-libs,ALL -Wl,--as-needed
ifeq ($(TARGET_ARCH),arm)
LOCAL_ARM_MODE := arm
LOCAL_FILTER_ASM :=
endif
# Configure for release unless NDK_DEBUG=1
ifeq ($(NDK_DEBUG),1)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG
else
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG
endif
LOCAL_STATIC_LIBRARIES := cryptopp_static
include $(BUILD_SHARED_LIBRARY)
endif
#####################################################################
# Test program
include $(CLEAR_VARS)
LOCAL_MODULE := cryptest.exe
LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_TEST_FILES))
LOCAL_CPPFLAGS := -Wall
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--as-needed
ifeq ($(TARGET_ARCH),arm)
LOCAL_ARM_MODE := arm
LOCAL_FILTER_ASM :=
endif
# Configure for release unless NDK_DEBUG=1
ifeq ($(NDK_DEBUG),1)
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG
else
LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG
endif
LOCAL_STATIC_LIBRARIES := cryptopp_static
include $(BUILD_EXECUTABLE)
#####################################################################
# Android cpuFeatures library
$(call import-module,android/cpufeatures)