-
Notifications
You must be signed in to change notification settings - Fork 13
/
makefile.linux
87 lines (69 loc) · 2.5 KB
/
makefile.linux
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
OUT_PATH = lib
SRC_PATH = jni
INC_PATH = $(SRC_PATH)/include
NAME = wolfcrypt-jni
VERSION = $(shell grep 'name="implementation.version"' build.xml | sed -re 's/.*value="(.+)".*/\1/')
ifneq ($(PREFIX),)
INSTALL_DIR = $(DESTDIR)$(PREFIX)
else
INSTALL_DIR = $(DESTDIR)/usr/local
endif
ifeq ($(LIBDIR),)
LIBDIR=lib
endif
ifeq ($(INSTALL),)
INSTALL=install
endif
ifeq ($(WOLFSSL_LIBNAME),)
WOLFSSL_LIBNAME=wolfssl
endif
DIST_FILES = AUTHORS build.xml COPYING examples jni LICENSING makefile makefile.linux makefile.macosx \
pom.xml README_JCE.md README.md rpm src
OBJ_LIST = jni_fips.o jni_native_struct.o jni_pwdbased.o jni_aes.o \
jni_aesgcm.o jni_des3.o jni_md5.o jni_sha.o jni_hmac.o \
jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o jni_ed25519.o \
jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o jni_logging.o \
jni_feature_detect.o jni_wolfobject.o jni_wolfcrypt.o \
jni_wolfssl_cert_manager.o jni_jce_wolfsslkeystore.o
OBJS = $(patsubst %,$(OUT_PATH)/%,$(OBJ_LIST))
TARGET = $(OUT_PATH)/libwolfcryptjni.so
JAVA_HOME ?= $(shell readlink -f /usr/bin/javac | sed "s:/bin/javac::")
CC = gcc
override CCFLAGS += -Wall -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
-I$(INC_PATH) -I$(PREFIX)/include -fPIC
override LDFLAGS += -Wl,--no-as-needed -L$(PREFIX)/$(LIBDIR) -l$(WOLFSSL_LIBNAME) -shared
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^
$(OUT_PATH)/%.o: $(SRC_PATH)/%.c
@mkdir -p $(OUT_PATH)
$(CC) $(CCFLAGS) -c -o $@ $<
dist:
mkdir -p "$(NAME)-$(VERSION)"
cp -pr $(DIST_FILES) "$(NAME)-$(VERSION)"
tar -zcf "$(NAME)-$(VERSION).tar.gz" "$(NAME)-$(VERSION)"
rm -rf "$(NAME)-$(VERSION)"
rpm: dist
@env
@rm -f *.rpm
rpmdev-setuptree
find ~/rpmbuild/RPMS ~/rpmbuild/SRPMS -name "$(PACKAGE)-$(VERSION)*.rpm" | xargs rm -f
@cp "$(NAME)-$(VERSION).tar.gz" ~/rpmbuild/SOURCES/
@cp rpm/spec.in rpm/spec
@sed -i rpm/spec -e "s/@NAME@/$(NAME)/g"
@sed -i rpm/spec -e "s/@VERSION@/$(VERSION)/g"
JUNIT_HOME=lib rpmbuild -ba --clean rpm/spec
@cp ~/rpmbuild/RPMS/*/$(NAME)-$(VERSION)*.rpm .
@cp ~/rpmbuild/SRPMS/$(NAME)-$(VERSION)*.rpm .
lib/wolfcrypt-jni.jar:
ant build-jni-release
install: all lib/wolfcrypt-jni.jar
$(INSTALL) -d $(INSTALL_DIR)/$(LIBDIR)
$(INSTALL) lib/libwolfcryptjni.so $(INSTALL_DIR)/$(LIBDIR)
$(INSTALL) lib/wolfcrypt-jni.jar $(INSTALL_DIR)/$(LIBDIR)
uninstall:
rm -f $(INSTALL_DIR)/$(LIBDIR)/libwolfcryptjni.so
rm -f $(INSTALL_DIR)/$(LIBDIR)/wolfcrypt-jni.jar
.PHONY: clean
clean:
rm -f $(OUT_PATH)/*.o $(TARGET)