e1922eb0a8dfb1ec12ed8c292d60905022c40b93
[vpp.git] / plugins / snat-plugin / Makefile.am
1
2 # Copyright (c) <current-year> <your-organization>
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 AUTOMAKE_OPTIONS = foreign subdir-objects
16
17 AM_CFLAGS = -Wall @DPDK@
18 AM_LDFLAGS = -module -shared -avoid-version
19
20 vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins
21 vpppluginsdir = ${libdir}/vpp_plugins
22
23 vppapitestplugins_LTLIBRARIES = snat_test_plugin.la
24 vppplugins_LTLIBRARIES = snat_plugin.la
25
26 snat_plugin_la_SOURCES = snat/snat.c            \
27         snat/in2out.c                           \
28         snat/out2in.c                           \
29         snat/snat_plugin.api.h
30
31 BUILT_SOURCES = snat/snat.api.h snat/snat.api.json
32
33 SUFFIXES = .api.h .api
34
35 %.api.h: %.api
36         mkdir -p `dirname $@` ; \
37         $(CC) $(CPPFLAGS) -E -P -C -x c $^ \
38         | vppapigen --input - --output $@ --show-name $@
39
40 %.api.json: %.api
41         @echo "  JSON APIGEN  " $@ ;                            \
42         mkdir -p `dirname $@` ;                                 \
43         $(CC) $(CPPFLAGS) -E -P -C -x c $^                      \
44         | vppapigen --input - --json $@
45
46 apidir = $(prefix)/snat/
47 api_DATA = snat.api.json
48
49 noinst_HEADERS =                        \
50   snat/snat_all_api_h.h                 \
51   snat/snat_msg_enum.h                  \
52   snat/snat.api.h
53
54 snat_test_plugin_la_SOURCES = \
55   snat/snat_test.c snat/snat_plugin.api.h
56
57 # Remove *.la files
58 install-data-hook:
59         @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES))
60         @(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES))
61
62 #
63 # Java code generation
64 #
65 jvpp_registry_root = ../../vpp-api/java
66 jvpp_registry_version = 17.04
67 jsnat_jarfile = jvpp-snat-$(PACKAGE_VERSION).jar
68 jvpp_package_dir = io/fd/vpp/jvpp/snat
69 jvpp_root = snat/jvpp
70 jvpp_target_dir = target
71 jvpp_target = $(jvpp_root)/$(jvpp_target_dir)
72 api_file=$(srcdir)/snat/snat.api
73
74 lib_LTLIBRARIES = libjvpp_snat.la
75 libjvpp_snat_la_SOURCES = snat/snat.api.h snat/jvpp_snat.c snat/jvpp/io_fd_vpp_jvpp_snat_JVppSnatImpl.h
76 libjvpp_snat_la_LIBADD = -lvlibmemoryclient -lvlibapi -lvppinfra \
77                       -lpthread -lm -lrt -L$(jvpp_registry_root)/.libs -ljvpp_common
78 libjvpp_snat_la_LDFLAGS = -module
79 libjvpp_snat_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I../ -I$(srcdir)/../
80
81 BUILT_SOURCES += $(jvpp_root)/io_fd_vpp_jvpp_snat_JVppSnatImpl.h
82
83 $(jvpp_root)/io_fd_vpp_jvpp_snat_JVppSnatImpl.h: snat.api.json
84         dir=`pwd`;                                              \
85         mkdir -p $(jvpp_target); \
86         mkdir -p $(jvpp_root)/$(jvpp_package_dir);              \
87         cd $(jvpp_root)/$(jvpp_package_dir);                    \
88         mkdir -p dto future callfacade callback notification test;      \
89         @srcdir@/$(jvpp_registry_root)/jvpp/gen/jvpp_gen.py -i $${dir}/snat.api.json --plugin_name snat;                \
90         cd -;                                                   \
91         mv -f $(jvpp_root)/$(jvpp_package_dir)/jvpp_snat_gen.h $(jvpp_root)/jvpp_snat_gen.h;                                                    \
92         cp $(srcdir)/$(jvpp_root)/$(jvpp_package_dir)/test/*.java $(jvpp_root)/$(jvpp_package_dir)/test/;                               \
93         cd $(jvpp_root);                                \
94         $(JAVAC) -classpath .:$(jvpp_target_dir):../../$(jvpp_registry_root)/jvpp-registry-$(jvpp_registry_version).jar -d $(jvpp_target_dir) $(jvpp_package_dir)/*.java \
95                 $(jvpp_package_dir)/dto/*.java \
96                 $(jvpp_package_dir)/callback/*.java \
97                 $(jvpp_package_dir)/notification/*.java \
98                 $(jvpp_package_dir)/future/*.java       \
99                 $(jvpp_package_dir)/callfacade/*.java   \
100                 $(jvpp_package_dir)/test/*.java \
101                 || (echo "snat jvpp compilation failed: $$?"; exit 1);  \
102         $(JAVAH) -classpath .:$(jvpp_target_dir):../../$(jvpp_registry_root)/jvpp-registry-$(jvpp_registry_version).jar -d . io.fd.vpp.jvpp.snat.JVppSnatImpl ;
103
104 $(jsnat_jarfile): libjvpp_snat.la
105         cp .libs/libjvpp_snat.so.0.0.0 $(jvpp_target);                          \
106         cd $(jvpp_target);                              \
107         $(JAR) cfv $(JARFLAGS) ../../../$@ libjvpp_snat.so.0.0.0 $(jvpp_package_dir)/* ; cd ..;
108
109 snat.api.json:
110         @echo "  jSnat_sfc API"; \
111         vppapigen --input $(api_file) --json snat.api.json;
112
113 all-local: $(jsnat_jarfile)