-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (65 loc) · 1.8 KB
/
Makefile
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
GRAALVM = $(HOME)/graalvm-ce-java11-19.3.1
JAVA_HOME = $(GRAALVM)
ifneq (,$(findstring java11,$(GRAALVM)))
JAVA_VERSION = 11
else
JAVA_VERSION = 8
endif
INCLUDE_DIRS=$(shell find $(JAVA_HOME)/include -type d)
INCLUDE_ARGS=$(INCLUDE_DIRS:%=-I%) -I.
SOLIB_FILE=libSocketTest.so
DYLIB_FILE=libSocketTest.dylib
C_FILE=src/SocketTest.c
C_HEADER=src/SocketTest.h
UNAME = $(shell uname)
ifeq ($(UNAME),Linux)
LIB_FILE=$(SOLIB_FILE)
else ifeq ($(UNAME),FreeBSD)
LIB_FILE=$(SOLIB_FILE)
else ifeq ($(UNAME),Darwin)
LIB_FILE=$(DYLIB_FILE)
endif
clean:
-rm src/*.class
-rm src/*.h
-rm *.jar
-rm *.so
-rm *.dynlib
-rm sockettest
src/SocketTest.class: src/SocketTest.java
javac src/SocketTest.java
src/SocketTest.h: src/SocketTest.java
ifeq ($(JAVA_VERSION),8)
cd src && javah -o SocketTest.h -cp ./ SocketTest
else
cd src && javac -h ./ SocketTest.java
endif
lib: $(LIB_FILE)
$(SOLIB_FILE): $(C_FILE) $(C_HEADER)
$(CC) $(INCLUDE_ARGS) -shared $(C_FILE) -o $(SOLIB_FILE) -fPIC
$(DYLIB_FILE): $(C_FILE) $(C_HEADER)
$(CC) $(INCLUDE_ARGS) -dynamiclib -undefined suppress -flat_namespace $(C_FILE) -o $(DYLIB_FILE) -fPIC
SocketTest.jar: src/SocketTest.class src/manifest.txt
cd src && jar cfm ../SocketTest.jar manifest.txt SocketTest.class
run-jar-test: SocketTest.jar lib
rm -f socket; \
nc -l -U socket & \
sleep 5; \
LD_LIBRARY_PATH=./ java -jar SocketTest.jar
sockettest: SocketTest.jar lib
$(GRAALVM)/bin/native-image \
-jar SocketTest.jar \
-H:Name=sockettest \
-H:+ReportExceptionStackTraces \
-H:ConfigurationFileDirectories=config-dir \
--initialize-at-build-time \
--verbose \
--no-fallback \
--no-server \
"-J-Xmx1g"
# -H:+TraceClassInitialization -H:+PrintClassInitialization
run-native-test: sockettest lib
rm -f socket; \
nc -l -U socket & \
sleep 5; \
LD_LIBRARY_PATH=./ ./sockettest