Updated for openjdk-19-internal
[panamaz] / test-api / Makefile
1
2 CFLAGS=-g -fPIC
3
4 JAVA_HOME?=/opt/jdk-foreign/jvm/openjdk-19-internal
5 JAVAC=$(JAVA_HOME)/bin/javac
6 JAVA=$(JAVA_HOME)/bin/java
7
8 JAVACFLAGS=--add-modules jdk.incubator.foreign
9
10 api_SOURCES := $(wildcard ../src/api/*.java)
11 api_demo_SOURCES := $(wildcard src/api/test/*.java)
12
13 all::
14         mkdir -p bin
15
16 all:: bin/demo.built
17
18 bin/api.built: bin/api.gen
19         $(JAVAC) $(JAVACFLAGS) -cp bin/classes -d bin/classes \
20                 $(shell find bin/java -name '*.java')
21         touch $@
22
23 bin/api.gen: bin/api.pm ../src/generate-native $(api_SOURCES)
24         ../src/generate-native -d bin/java -t proto.api ./bin/api.pm
25         touch $@
26
27 bin/api.pm: api.h ../src/export.so
28         gcc -fplugin=../src/export.so -fplugin-arg-export-output=$@~ ./$< -o /dev/null
29         mv $@~ $@
30
31 bin/demo.built: $(api_demo_SOURCES) bin/api.built
32         $(JAVAC) $(JAVACFLAGS) -cp bin/classes -d bin/classes $(api_demo_SOURCES)
33         touch $@
34
35 bin/api.o: api.c api.h
36         $(CC) $(CFLAGS) -c -o $@ $<
37
38 bin/libapi.so: bin/api.o
39         $(CC) -o $@ -shared $^
40
41 demo: bin/demo.built bin/libapi.so
42         $(JAVA) --enable-native-access=ALL-UNNAMED --add-modules jdk.incubator.foreign \
43                 -Djava.library.path=bin -cp bin/classes \
44                 api.test.TestAPI
45
46 clean:
47         rm -rf bin
48
49 .PHONY: demo clean all