9f41193a708a7540b3b65c5a2170da15960e420a
[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.py
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 %.py: %.api
41         $(info Creating Python binding for $@)
42         $(CC) $(CPPFLAGS) -E -P -C -x c $<                              \
43         | vppapigen --input - --python -                                \
44         | pyvppapigen.py --input - > $@
45
46 pyapidir = ${prefix}/vpp_papi_plugins
47 pyapi_DATA = snat/snat.py
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
64 #
65 # Java code generation
66 #
67 jvpp_registry_root = ../../vpp-api/java
68 jvpp_registry_version = 16.12
69 jsnat_jarfile = jvpp-snat-$(PACKAGE_VERSION).jar
70 jvpp_package_dir = io/fd/vpp/jvpp/snat
71 jvpp_root = snat/jvpp
72 jvpp_target_dir = target
73 jvpp_target = $(jvpp_root)/$(jvpp_target_dir)
74 api_file=$(srcdir)/snat/snat.api
75
76 lib_LTLIBRARIES = libjvpp_snat.la
77 libjvpp_snat_la_SOURCES = snat/snat.api.h snat/jvpp_snat.c snat/jvpp/io_fd_vpp_jvpp_snat_JVppSnatImpl.h
78 libjvpp_snat_la_LIBADD = -lvlibmemoryclient -lvlibapi -lvppinfra \
79                       -lpthread -lm -lrt -L$(jvpp_registry_root)/.libs -ljvpp_common
80 libjvpp_snat_la_LDFLAGS = -module
81 libjvpp_snat_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I../ -I$(srcdir)/../
82
83 BUILT_SOURCES += $(jvpp_root)/io_fd_vpp_jvpp_snat_JVppSnatImpl.h
84
85 $(jvpp_root)/io_fd_vpp_jvpp_snat_JVppSnatImpl.h: defs_snat_papi.py
86         dir=`pwd`;                                              \
87         mkdir -p $(jvpp_target); \
88         mkdir -p $(jvpp_root)/$(jvpp_package_dir);              \
89         cd $(jvpp_root)/$(jvpp_package_dir);                    \
90         mkdir -p dto future callfacade callback notification test;      \
91         @srcdir@/$(jvpp_registry_root)/jvpp/gen/jvpp_gen.py -i $${dir}/defs_snat_papi.py --plugin_name snat;            \
92         cd -;                                                   \
93         mv -f $(jvpp_root)/$(jvpp_package_dir)/jvpp_snat_gen.h $(jvpp_root)/jvpp_snat_gen.h;                                                    \
94         cp $(srcdir)/$(jvpp_root)/$(jvpp_package_dir)/test/*.java $(jvpp_root)/$(jvpp_package_dir)/test/;                               \
95         cd $(jvpp_root);                                \
96         $(JAVAC) -classpath .:$(jvpp_target_dir):../../$(jvpp_registry_root)/jvpp-registry-$(jvpp_registry_version).jar -d $(jvpp_target_dir) $(jvpp_package_dir)/*.java \
97                 $(jvpp_package_dir)/dto/*.java \
98                 $(jvpp_package_dir)/callback/*.java \
99                 $(jvpp_package_dir)/notification/*.java \
100                 $(jvpp_package_dir)/future/*.java       \
101                 $(jvpp_package_dir)/callfacade/*.java   \
102                 $(jvpp_package_dir)/test/*.java \
103                 || (echo "snat jvpp compilation failed: $$?"; exit 1);  \
104         $(JAVAH) -classpath .:$(jvpp_target_dir):../../$(jvpp_registry_root)/jvpp-registry-$(jvpp_registry_version).jar -d . io.fd.vpp.jvpp.snat.JVppSnatImpl ;
105
106 $(jsnat_jarfile): libjvpp_snat.la
107         cp .libs/libjvpp_snat.so.0.0.0 $(jvpp_target);                          \
108         cd $(jvpp_target);                              \
109         $(JAR) cfv $(JARFLAGS) ../../../$@ libjvpp_snat.so.0.0.0 $(jvpp_package_dir)/* ; cd ..;
110
111 defs_snat_papi.py:
112         @echo "  jSnat_sfc API"; \
113         vppapigen --input $(api_file) --python defs_snat_papi.py;
114
115 all-local: $(jsnat_jarfile)