forked from nayuki/Native-hashes-for-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (85 loc) · 2.45 KB
/
Makefile
File metadata and controls
104 lines (85 loc) · 2.45 KB
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
#
# Native hash functions for Java
#
# Copyright (c) Project Nayuki. (MIT License)
# https://www.nayuki.io/page/native-hash-functions-for-java
#
# ---- Configuration ----
# Available modes: c, x86, x86-64
MODE = c
CFLAGS += -std=c99
CFLAGS += -I /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/
CFLAGS += -I /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux/
CFLAGS += -Wall
CFLAGS += -O1
# ---- Source files ----
# JNI functions
SRC_FILENAMES = \
md2-jni.c \
md4-jni.c \
md5-jni.c \
ripemd128-jni.c \
ripemd160-jni.c \
ripemd256-jni.c \
ripemd320-jni.c \
sha1-jni.c \
sha256-jni.c \
sha512-jni.c \
tiger-jni.c \
whirlpool-jni.c
# Compression functions for various modes
ifeq "$(MODE)" "c"
SRC_FILENAMES += \
md4-compress.c \
md5-compress.c \
ripemd128-compress.c \
ripemd160-compress.c \
sha1-compress.c \
sha256-compress.c \
sha512-compress.c \
whirlpool-compress.c
else ifeq "$(MODE)" "x86"
SRC_FILENAMES += \
md4-compress-x86.S \
md5-compress-x86.S \
ripemd128-compress-x86.S \
ripemd160-compress-x86.S \
sha1-compress-x86.S \
sha256-compress-x86.S \
sha512-compress-x86.S \
whirlpool-compress-x86.S
else ifeq "$(MODE)" "x86-64"
SRC_FILENAMES += \
md4-compress-x8664.S \
md5-compress-x8664.S \
ripemd128-compress-x8664.S \
ripemd160-compress-x8664.S \
sha1-compress-x8664.S \
sha256-compress-x8664.S \
sha512-compress-x8664.S \
whirlpool-compress-x8664.S
else
$(error Invalid mode "$(MODE)")
endif
# Compressions functions only available in C
SRC_FILENAMES += \
md2-compress.c \
ripemd256-compress.c \
ripemd320-compress.c \
tiger-compress.c
SRC_FILES = $(foreach name, $(SRC_FILENAMES), native/$(name))
# ---- Rules ----
LIBFILE = libnayuki-native-hashes.so
all: $(LIBFILE) classes
$(LIBFILE): $(SRC_FILES)
$(CC) $(CFLAGS) -shared -fPIC -o $@ $(SRC_FILES)
classes: java/bin
cd java/src ; javac -cp ../bin -d ../bin nayuki/nativehash/*.java
cd java/test; javac -cp ../bin -d ../bin nayuki/nativehash/*.java
cd java/demo; javac -cp ../bin -d ../bin nayuki/nativehash/*.java *.java
java/bin:
mkdir $@
clean:
rm -f $(LIBFILE)
rm -rf java/bin
.PHONY: classes clean