From e17fdb5ddfdd4275e785bf4266653243e76e000d Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 10 Feb 2016 00:36:06 +0100 Subject: Add Top-Level Wrapper Makefile Change-Id: Ie3431986ddb42db8d331fcb3d34250a6ec9d9a02 Signed-off-by: Damjan Marion --- Makefile | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b7c3e27f --- /dev/null +++ b/Makefile @@ -0,0 +1,141 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +WS_ROOT=$(CURDIR) +BR=$(WS_ROOT)/build-root +CCACHE_DIR?=$(BR)/.ccache +V?=0 +GDB?=gdb + +MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" + +DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache +DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev +DEB_DEPENDS += libconfuse-dev git-review + + +.PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release +.PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm + +help: + @echo "Make Targets:" + @echo " bootstrap - prepare tree for build" + @echo " wipe - wipe all products of debug build " + @echo " wipe-release - wipe all products of release build " + @echo " build - build debug binaries" + @echo " build-release - build release binaries" + @echo " rebuild - wipe and build debug binares" + @echo " rebuild-release - wipe and build release binares" + @echo " run - run debug binary" + @echo " run-release - run release binary" + @echo " debug - run debug binary with debugger" + @echo " debug-release - run release binary with debugger" + @echo " build-vat - build vpp-api-test tool" + @echo " run-vat - run vpp-api-test tool" + @echo " pkg-deb - build DEB packages" + @echo " pkg-rpm - build RPM packages" + @echo "" + @echo "Make Arguments:" + @echo " V=[0|1] - set build verbosity level" + @echo " STARTUP_CONF= - startup configuration file" + @echo " (e.g. /etc/vpp/startup.conf)" + @echo " GDB= - gdb binary to use for debugging" + @echo "" + @echo "Current Argumernt Values:" + @echo " V = $(V)" + @echo " STARTUP_CONF = $(STARTUP_CONF)" + @echo " GDB = $(GDB)" + +$(BR)/.bootstrap.ok: +ifeq ("$(shell lsb_release -si)", "Ubuntu") + @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \ + if [ -n "$$MISSING" ] ; then \ + echo "\nPlease install missing packages: \n$$MISSING\n" ; \ + exit 1 ; \ + fi ; \ + exit 0 +endif + @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk + @echo "#!/bin/bash\n" > $(BR)/path_setup + @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup + @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup + @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup + +ifeq ("$(wildcard /usr/bin/ccache )","") + @echo "WARNING: Please install ccache AYEC and re-run this script" +else + @rm -rf $(BR)/tools/ccache-bin + @mkdir -p $(BR)/tools/ccache-bin + @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc + @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++ +endif + @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install + @touch $@ + +bootstrap: $(BR)/.bootstrap.ok + +define make + @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2) +endef + +build: $(BR)/.bootstrap.ok + $(call make,vpp_debug,vpp-install) + +wipe: $(BR)/.bootstrap.ok + $(call make,vpp_debug,vpp-wipe) + +rebuild: wipe build + +build-release: $(BR)/.bootstrap.ok + $(call make,vpp,vpp-install) + +wipe-release: $(BR)/.bootstrap.ok + $(call make,vpp,vpp-wipe) + +rebuild-release: wipe-release build-release + +ifeq ("$(wildcard $(STARTUP_CONF))","") +define run + @echo "WARNING: STARTUP_CONF not defined or file doesn't exist." + @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n" + @sudo $(1) $(MINIMAL_STARTUP_CONF) +endef +else +define run + @sudo $(1) -c $(STARTUP_CONF) +endef +endif + +run: + $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp) + +run-release: + $(call run, $(BR)/install-vpp-native/vpp/bin/vpp) + +debug: + $(call run, $(GDB) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp) + +debug-release: + $(call run, $(GDB) --args $(BR)/install-vpp-native/vpp/bin/vpp) + +build-vat: + $(call make,vpp_debug,vpp-api-test-install) + +run-vat: + @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test + +pkg-deb: + $(call make,vpp,install-deb) + +pkg-rpm: + $(call make,vpp,install-rpm) -- cgit 1.2.3-korg From eef4d99bcd0ad868145af76ca1ad2595ecc3ad19 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 23 Feb 2016 22:04:50 +0100 Subject: Few improvements in toplevel Makefile Change-Id: I896aed32499cd7159c4b6f3b165cab4e579f6153 Signed-off-by: Damjan Marion --- Makefile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b7c3e27f..35190a1c 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,15 @@ GDB?=gdb MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" +GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" + DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev DEB_DEPENDS += libconfuse-dev git-review +ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"") + STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf +endif .PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release .PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm @@ -49,11 +54,15 @@ help: @echo " V=[0|1] - set build verbosity level" @echo " STARTUP_CONF= - startup configuration file" @echo " (e.g. /etc/vpp/startup.conf)" + @echo " STARTUP_DIR= - startup drectory (e.g. /etc/vpp)" + @echo " It also sets STARTUP_CONF if" + @echo " startup.conf file is present" @echo " GDB= - gdb binary to use for debugging" @echo "" @echo "Current Argumernt Values:" @echo " V = $(V)" @echo " STARTUP_CONF = $(STARTUP_CONF)" + @echo " STARTUP_DIR = $(STARTUP_DIR)" @echo " GDB = $(GDB)" $(BR)/.bootstrap.ok: @@ -104,15 +113,16 @@ wipe-release: $(BR)/.bootstrap.ok rebuild-release: wipe-release build-release +STARTUP_DIR ?= $(PWD) ifeq ("$(wildcard $(STARTUP_CONF))","") define run @echo "WARNING: STARTUP_CONF not defined or file doesn't exist." @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n" - @sudo $(1) $(MINIMAL_STARTUP_CONF) + @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF) endef else define run - @sudo $(1) -c $(STARTUP_CONF) + @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF) endef endif @@ -123,10 +133,10 @@ run-release: $(call run, $(BR)/install-vpp-native/vpp/bin/vpp) debug: - $(call run, $(GDB) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp) + $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp) debug-release: - $(call run, $(GDB) --args $(BR)/install-vpp-native/vpp/bin/vpp) + $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp-native/vpp/bin/vpp) build-vat: $(call make,vpp_debug,vpp-api-test-install) -- cgit 1.2.3-korg From ebb27fb4809a51711e05323faccb15165e610e10 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 25 Feb 2016 16:26:01 +0100 Subject: add install-dep target to toplevel Makefile Change-Id: I9dbe6676086ef083729bec1774f544498d1ec3e5 Signed-off-by: Damjan Marion --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 35190a1c..024a1393 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ endif help: @echo "Make Targets:" @echo " bootstrap - prepare tree for build" + @echo " install-dep - install software dependencies" @echo " wipe - wipe all products of debug build " @echo " wipe-release - wipe all products of release build " @echo " build - build debug binaries" @@ -70,6 +71,7 @@ ifeq ("$(shell lsb_release -si)", "Ubuntu") @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \ if [ -n "$$MISSING" ] ; then \ echo "\nPlease install missing packages: \n$$MISSING\n" ; \ + echo "by executing \"make install-dep\"\n" ; \ exit 1 ; \ fi ; \ exit 0 @@ -93,6 +95,13 @@ endif bootstrap: $(BR)/.bootstrap.ok +install-dep: +ifeq ("$(shell lsb_release -si)", "Ubuntu") + @sudo apt-get install $(DEB_DEPENDS) +else + $(error "This option currently works only on Ubuntu systems") +endif + define make @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2) endef -- cgit 1.2.3-korg From e6f9023ff020cf8faacef17007a19de51e03e30d Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 16 Mar 2016 22:49:05 +0100 Subject: Few additions to top-level Makefile * Added option to specify target platform (e.g. export PLATFORM=vpp_lite) * Added ctags targed to (re)build ctags database * Added cscope targed to (re)build cscope database Change-Id: I93feb7b458abe9fbd93000f75b7be24e3865f089 Signed-off-by: Damjan Marion --- Makefile | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 024a1393..ee40bfeb 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ BR=$(WS_ROOT)/build-root CCACHE_DIR?=$(BR)/.ccache V?=0 GDB?=gdb +PLATFORM?=vpp MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" @@ -23,7 +24,7 @@ GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev -DEB_DEPENDS += libconfuse-dev git-review +DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"") STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf @@ -31,6 +32,7 @@ endif .PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release .PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm +.PHONY: ctags cscope help: @echo "Make Targets:" @@ -50,6 +52,8 @@ help: @echo " run-vat - run vpp-api-test tool" @echo " pkg-deb - build DEB packages" @echo " pkg-rpm - build RPM packages" + @echo " ctags - (re)generate ctags database" + @echo " cscope - (re)generate cscope database" @echo "" @echo "Make Arguments:" @echo " V=[0|1] - set build verbosity level" @@ -59,12 +63,14 @@ help: @echo " It also sets STARTUP_CONF if" @echo " startup.conf file is present" @echo " GDB= - gdb binary to use for debugging" + @echo " PLATFORM= - target platform. default is vpp" @echo "" @echo "Current Argumernt Values:" @echo " V = $(V)" @echo " STARTUP_CONF = $(STARTUP_CONF)" @echo " STARTUP_DIR = $(STARTUP_DIR)" @echo " GDB = $(GDB)" + @echo " PLATFORM = $(PLATFORM)" $(BR)/.bootstrap.ok: ifeq ("$(shell lsb_release -si)", "Ubuntu") @@ -103,22 +109,22 @@ else endif define make - @make -C $(BR) V=$(V) PLATFORM=vpp TAG=$(1) $(2) + @make -C $(BR) V=$(V) PLATFORM=$(PLATFORM) TAG=$(1) $(2) endef build: $(BR)/.bootstrap.ok - $(call make,vpp_debug,vpp-install) + $(call make,$(PLATFORM)_debug,vpp-install) wipe: $(BR)/.bootstrap.ok - $(call make,vpp_debug,vpp-wipe) + $(call make,$(PLATFORM)_debug,vpp-wipe) rebuild: wipe build build-release: $(BR)/.bootstrap.ok - $(call make,vpp,vpp-install) + $(call make,$(PLATFORM),vpp-install) wipe-release: $(BR)/.bootstrap.ok - $(call make,vpp,vpp-wipe) + $(call make,$(PLATFORM),vpp-wipe) rebuild-release: wipe-release build-release @@ -135,26 +141,40 @@ define run endef endif +%.files: .FORCE + @find . \( -name '*\.[chyS]' -o -name '*\.java' -o -name '*\.lex' \) -and \ + \( -not -path './build-root*' -o -path \ + './build-root/build-vpp_debug-native/dpdk*' \) > $@ + +.FORCE: + run: - $(call run, $(BR)/install-vpp_debug-native/vpp/bin/vpp) + $(call run, $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) run-release: - $(call run, $(BR)/install-vpp-native/vpp/bin/vpp) + $(call run, $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) debug: - $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp_debug-native/vpp/bin/vpp) + $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) debug-release: - $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-vpp-native/vpp/bin/vpp) + $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) build-vat: - $(call make,vpp_debug,vpp-api-test-install) + $(call make,$(PLATFORM)_debug,vpp-api-test-install) run-vat: - @sudo $(BR)/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test + @sudo $(BR)/install-$(PLATFORM)_debug-native/vpp-api-test/bin/vpp_api_test pkg-deb: - $(call make,vpp,install-deb) + $(call make,$(PLATFORM),install-deb) pkg-rpm: - $(call make,vpp,install-rpm) + $(call make,$(PLATFORM),install-rpm) + +ctags: ctags.files + @ctags --totals --tag-relative -L $< + @rm $< + +cscope: cscope.files + @cscope -b -q -v -- cgit 1.2.3-korg From 76a66c1f06db0386aff887de6cbd0687256fb17f Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Thu, 17 Mar 2016 20:37:27 -0700 Subject: Add -y to apt-get install for install-dep target This allows install-dep to be run non-interactively Change-Id: I5c3e55958ed16dd3d128bbad9f317d9f2428d41a Signed-off-by: Ed Warnicke --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ee40bfeb..9b387552 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ bootstrap: $(BR)/.bootstrap.ok install-dep: ifeq ("$(shell lsb_release -si)", "Ubuntu") - @sudo apt-get install $(DEB_DEPENDS) + @sudo apt-get -y install $(DEB_DEPENDS) else $(error "This option currently works only on Ubuntu systems") endif -- cgit 1.2.3-korg From 84eda9de0bb3798a86c2c1dac11dd861916a1615 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Tue, 22 Mar 2016 16:09:29 -0500 Subject: Add build-root/*.rpm to .gitignore Change-Id: I88398b5e538271efa4657851bf53c9b76a56b432 Signed-off-by: Ed Warnicke --- .gitignore | 1 + Makefile | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/.gitignore b/.gitignore index b2e2c62e..5d1a597a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /build-root/path_setup /build-root/build-config.mk /build-root/*.deb +/build-root/*.rpm /build-root/*.changes /build-config.mk /dpdk/*.tar.gz diff --git a/Makefile b/Makefile index 9b387552..109ed6d4 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,11 @@ DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope +RPM_DEPENDS_GROUPS = 'Development Tools' +RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel +RPM_DEPENDS += openssl-devel epel-release apr-devel +EPEL_DEPENDS = libconfuse-devel ganglia-devel + ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"") STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf endif @@ -104,8 +109,12 @@ bootstrap: $(BR)/.bootstrap.ok install-dep: ifeq ("$(shell lsb_release -si)", "Ubuntu") @sudo apt-get -y install $(DEB_DEPENDS) +else ifneq ("$(wildcard /etc/redhat-release)","") + @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) + @sudo yum install -y $(RPM_DEPENDS) + @sudo yum install -y --enablerepo=epel $(EPEL_DEPENDS) else - $(error "This option currently works only on Ubuntu systems") + $(error "This option currently works only on Ubuntu or Centos systems") endif define make -- cgit 1.2.3-korg From 3c79e65bd65d574b3f1fefb964101c1f2927369e Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Mon, 28 Mar 2016 14:53:19 -0500 Subject: Fix epl-release in make install-dep for rpm Change-Id: I01a7421dc58ee6683eb84482bb92dd6a519a21e8 Signed-off-by: Ed Warnicke --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 109ed6d4..a9b4d9ab 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope RPM_DEPENDS_GROUPS = 'Development Tools' RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel -RPM_DEPENDS += openssl-devel epel-release apr-devel +RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel EPEL_DEPENDS = libconfuse-devel ganglia-devel ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"") -- cgit 1.2.3-korg From 0df78dda5ae1e1e082c2e0ea282ba5494c3d4b31 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 29 Mar 2016 22:37:02 +0200 Subject: Add DPDK 16.04-rc2 support Can be used by specifying DPDK_VERSION=16.04-rc2 in the make command line Change-Id: I657b44d7ca22f1ef57756e7703088020fab12bc6 Signed-off-by: Damjan Marion --- Makefile | 3 ++- dpdk/Makefile | 5 ++++- vnet/vnet/devices/virtio/vhost-user.h | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a9b4d9ab..31222caf 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel EPEL_DEPENDS = libconfuse-devel ganglia-devel -ifneq ("$(wildcard $(STARTUP_DIR)/startup.conf),"") +ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),) STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf endif @@ -76,6 +76,7 @@ help: @echo " STARTUP_DIR = $(STARTUP_DIR)" @echo " GDB = $(GDB)" @echo " PLATFORM = $(PLATFORM)" + @echo " DPDK_VERSION = $(DPDK_VERSION)" $(BR)/.bootstrap.ok: ifeq ("$(shell lsb_release -si)", "Ubuntu") diff --git a/dpdk/Makefile b/dpdk/Makefile index e6e2b5f8..316efc01 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -29,6 +29,7 @@ DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.gz DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL) DPDK_2.1.0_TARBALL_MD5_CKSUM := 205a0d12bfd6eb717d57506272f43519 DPDK_2.2.0_TARBALL_MD5_CKSUM := 22e2fd68cd5504f43fe9a5a6fd6dd938 +DPDK_16.04-rc2_TARBALL_MD5_CKSUM := a642985d2694d8cf8fdfdf0723be3406 DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION) DPDK_TARGET := x86_64-native-linuxapp-gcc JOBS := $(shell grep processor /proc/cpuinfo | wc -l) @@ -82,7 +83,7 @@ all: build $(B)/custom-config: $(B)/.patch.ok Makefile @echo --- generating custom config from $(DPDK_SOURCE)/config/common_linuxapp --- - @cp $(DPDK_SOURCE)/config/common_linuxapp $@ + @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/common_linuxapp $@ $(call set,RTE_MACHINE,$(DPDK_MACHINE)) $(call set,RTE_ARCH,"x86_64") $(call set,RTE_ARCH_X86_64,y) @@ -145,11 +146,13 @@ $(B)/.extract.ok: $(B)/.download.ok extract: $(B)/.extract.ok $(B)/.patch.ok: $(B)/.extract.ok +ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),) @echo --- patching --- for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \ echo Applying patch: $$(basename $$f) ; \ patch -p1 -d $(DPDK_SOURCE) < $$f ; \ done +endif @touch $@ .PHONY: patch diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h index be011165..d6d55731 100644 --- a/vnet/vnet/devices/virtio/vhost-user.h +++ b/vnet/vnet/devices/virtio/vhost-user.h @@ -78,11 +78,11 @@ typedef struct vhost_user_memory { vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]; } vhost_user_memory_t; -typedef struct vhost_vring_state { +typedef struct { unsigned int index, num; } vhost_vring_state_t; -typedef struct vhost_vring_addr { +typedef struct { unsigned int index, flags; u64 desc_user_addr, used_user_addr, avail_user_addr, log_guest_addr; } vhost_vring_addr_t; -- cgit 1.2.3-korg From 95db5635710ac3239d8bf400e74ef1a4ceca5bc9 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 11 Apr 2016 19:29:39 +0200 Subject: Fix dependency install on Ubuntu 16.04 Change-Id: I2a915a64c65ee78658ee782c0f16963024b8b2eb Signed-off-by: Damjan Marion --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 31222caf..4641b720 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache -DEB_DEPENDS += debhelper dkms openjdk-7-jdk git libtool libganglia1-dev libapr1-dev +DEB_DEPENDS += debhelper dkms default-jdk git libtool libganglia1-dev libapr1-dev DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope RPM_DEPENDS_GROUPS = 'Development Tools' -- cgit 1.2.3-korg From 7a2a378d2dcdba900651b02859b686cafe6dfd22 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 15 Apr 2016 20:24:55 +0200 Subject: dpdk socket-mem handling optimizations - introduces default socket-mem size of 512 MB per socket - default socket-mem value is applied to all discovered CPU sockets - fixes bug when < 1024 socket-mem parameter is specified - for socket-mem < 1024 code prefers 2 MB pages - improves handling of manualy specified socket-mem values Change-Id: I9ef848108d7dd1228fbd82a5be49eb5277a93683 Signed-off-by: Damjan Marion --- Makefile | 2 +- vnet/vnet/devices/dpdk/dpdk_priv.h | 1 - vnet/vnet/devices/dpdk/init.c | 147 ++++++++++++++++++++----------------- 3 files changed, 82 insertions(+), 68 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4641b720..b53941b4 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ V?=0 GDB?=gdb PLATFORM?=vpp -MINIMAL_STARTUP_CONF="unix { interactive } dpdk { no-pci socket-mem 1024 }" +MINIMAL_STARTUP_CONF="unix { interactive }" GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" diff --git a/vnet/vnet/devices/dpdk/dpdk_priv.h b/vnet/vnet/devices/dpdk/dpdk_priv.h index e284503e..a0fa38a4 100644 --- a/vnet/vnet/devices/dpdk/dpdk_priv.h +++ b/vnet/vnet/devices/dpdk/dpdk_priv.h @@ -45,7 +45,6 @@ _(force-ranks, r) _(huge-dir) \ _(proc-type) \ _(file-prefix) \ -_(socket-mem) \ _(vdev) static inline u32 diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 716377c1..58bc7a1e 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -783,38 +783,6 @@ dpdk_bind_devices_to_uio (dpdk_main_t * dm) vec_free (pci_addr); } -static u32 -get_node_free_hugepages_num (u32 node, u32 page_size) -{ - FILE * fp; - u8 * tmp; - - tmp = format (0, "/sys/devices/system/node/node%u/hugepages/hugepages-%ukB/" - "free_hugepages%c", node, page_size, 0); - fp = fopen ((char *) tmp, "r"); - vec_free(tmp); - - if (fp != NULL) - { - u8 * buffer = 0; - u32 pages_avail = 0; - - vec_validate (buffer, 256-1); - if (fgets ((char *)buffer, 256, fp)) - { - unformat_input_t in; - unformat_init_string (&in, (char *) buffer, strlen ((char *) buffer)); - unformat(&in, "%u", &pages_avail); - unformat_free (&in); - } - vec_free(buffer); - fclose(fp); - return pages_avail; - } - - return 0; -} - static clib_error_t * dpdk_config (vlib_main_t * vm, unformat_input_t * input) { @@ -910,6 +878,8 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) ; else if (unformat (input, "uio-driver %s", &dm->uio_driver_name)) ; + else if (unformat (input, "socket-mem %s", &socket_mem)) + ; else if (unformat (input, "vhost-user-coalesce-frames %d", &dm->vhost_coalesce_frames)) ; else if (unformat (input, "vhost-user-coalesce-time %f", &dm->vhost_coalesce_time)) @@ -937,8 +907,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) huge_dir = 1; \ else if (!strncmp(#a, "file-prefix", 11)) \ file_prefix = 1; \ - else if (!strncmp(#a, "socket-mem", 10)) \ - socket_mem = vec_dup (s); \ tmp = format (0, "--%s%c", #a, 0); \ vec_add1 (dm->eal_init_args, tmp); \ vec_add1 (s, 0); \ @@ -982,56 +950,97 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) } if (!dm->uio_driver_name) - dm->uio_driver_name = format (0, "igb_uio"); + dm->uio_driver_name = format (0, "igb_uio%c", 0); /* * Use 1G huge pages if available. */ if (!no_huge && !huge_dir) { - uword * mem_by_socket = hash_create (0, sizeof (uword)); - uword c; + u32 x, * mem_by_socket = 0; + uword c = 0; u8 use_1g = 1; u8 use_2m = 1; + u8 less_than_1g = 1; int rv; umount(DEFAULT_HUGE_DIR); /* Process "socket-mem" parameter value */ if (vec_len (socket_mem)) - { - unformat_input_t in; - unformat_init_vector(&in, socket_mem); - unformat(&in, "%U", unformat_socket_mem, &mem_by_socket); - unformat_free(&in); - } + { + unformat_input_t in; + unformat_init_vector(&in, socket_mem); + while (unformat_check_input (&in) != UNFORMAT_END_OF_INPUT) + { + if (unformat (&in, "%u,", &x)) + ; + else if (unformat (&in, "%u", &x)) + ; + else if (unformat (&in, ",")) + x = 0; + else + break; + + vec_add1(mem_by_socket, x); + + if (x > 1023) + less_than_1g = 0; + } + unformat_free(&in); + } else - use_1g = 0; + { + clib_bitmap_foreach (c, tm->cpu_socket_bitmap, ( + { + vec_validate(mem_by_socket, c); + mem_by_socket[c] = 512; /* default per-socket mem */ + } + )); + } /* check if available enough 1GB pages for each socket */ - clib_bitmap_foreach (c, tm->cpu_socket_bitmap, ({ - uword * p = hash_get (mem_by_socket, c); - if (p) - { - u32 mem = p[0]; - if (mem) - { - u32 pages_num_1g = mem / 1024; - u32 pages_num_2m = mem / 2; - u32 pages_avail; - - pages_avail = get_node_free_hugepages_num(c, 1048576); - if (!pages_avail || !(pages_avail >= pages_num_1g)) - use_1g = 0; - - pages_avail = get_node_free_hugepages_num(c, 2048); - if (!pages_avail || !(pages_avail >= pages_num_2m)) - use_2m = 0; - } - } + clib_bitmap_foreach (c, tm->cpu_socket_bitmap, ( + { + u32 pages_avail, page_size, mem; + u8 *s = 0; + char * path = "/sys/devices/system/node/node%u/hugepages/" + "hugepages-%ukB/free_hugepages%c"; + + vec_validate(mem_by_socket, c); + mem = mem_by_socket[c]; + + page_size = 1024; + pages_avail = 0; + s = format (s, path, c, page_size * 1024, 0); + read_sys_fs ((char *) s, "%u", &pages_avail); + vec_reset_length (s); + + if (page_size * pages_avail < mem) + use_1g = 0; + + page_size = 2; + pages_avail = 0; + s = format (s, path, c, page_size * 1024, 0); + read_sys_fs ((char *) s, "%u", &pages_avail); + vec_reset_length (s); + + if (page_size * pages_avail < mem) + use_2m = 0; + + vec_free(s); })); + _vec_len (mem_by_socket) = c + 1; - hash_free (mem_by_socket); + /* regenerate socket_mem string */ + vec_free (socket_mem); + vec_foreach_index (x, mem_by_socket) + socket_mem = format (socket_mem, "%s%u", + socket_mem ? "," : "", + mem_by_socket[x]); + socket_mem = format (socket_mem, "%c", 0); + + vec_free (mem_by_socket); rv = mkdir(VPP_RUN_DIR, 0755); if (rv && errno != EEXIST) @@ -1049,7 +1058,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) goto done; } - if (use_1g) + if (use_1g && !(less_than_1g && use_2m)) { rv = mount("none", DEFAULT_HUGE_DIR, "hugetlbfs", 0, "pagesize=1G"); } @@ -1156,6 +1165,12 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) tmp = format (0, "%u%c", tm->main_lcore, 0); vec_add1 (dm->eal_init_args, tmp); + /* set socket-mem */ + tmp = format (0, "--socket-mem%c", 0); + vec_add1 (dm->eal_init_args, tmp); + tmp = format (0, "%s%c", socket_mem, 0); + vec_add1 (dm->eal_init_args, tmp); + /* NULL terminate the "argv" vector, in case of stupidity */ vec_add1 (dm->eal_init_args, 0); _vec_len(dm->eal_init_args) -= 1; -- cgit 1.2.3-korg From 6855f6cdfee8c479f1e0ae440ce87a91ff41a708 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Sat, 9 Apr 2016 03:16:30 +0200 Subject: Python-API: Inital commit of Python bindings for the VPP API. See: https://wiki.fd.io/view/VPP/Python_API Change-Id: If135fc32208c7031787e1935b399d930e0e1ea1f Signed-off-by: Ole Troan --- Makefile | 2 +- build-data/packages/vpp-api.mk | 23 + build-data/packages/vpp-japi.mk | 23 - build-data/platforms/virl.mk | 2 +- build-data/platforms/vpp.mk | 2 +- build-data/platforms/vpp_lite.mk | 2 +- vlib-api/vlibmemory/api.h | 7 + vlib-api/vlibmemory/memory_shared.c | 14 +- vnet/vnet/map/examples/test_map.py | 141 + vpp-api/Makefile.am | 2 + vpp-api/configure.ac | 15 + vpp-api/java/Makefile.am | 93 + vpp-api/java/configure.ac | 19 + .../japi/org/openvpp/vppjapi/vppApiCallbacks.java | 35 + .../openvpp/vppjapi/vppBridgeDomainDetails.java | 30 + .../vppjapi/vppBridgeDomainInterfaceDetails.java | 21 + vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java | 237 + .../japi/org/openvpp/vppjapi/vppIPv4Address.java | 26 + .../japi/org/openvpp/vppjapi/vppIPv6Address.java | 27 + .../org/openvpp/vppjapi/vppInterfaceCounters.java | 77 + .../org/openvpp/vppjapi/vppInterfaceDetails.java | 71 + .../java/japi/org/openvpp/vppjapi/vppL2Fib.java | 35 + .../java/japi/org/openvpp/vppjapi/vppVersion.java | 31 + .../org/openvpp/vppjapi/vppVxlanTunnelDetails.java | 33 + vpp-api/java/japi/test/demo.java | 170 + vpp-api/java/japi/test/vppApi.java | 52 + vpp-api/java/japi/vppjni.c | 1900 ++++ vpp-api/java/japi/vppjni.h | 308 + vpp-api/java/japi/vppjni_bridge_domain.h | 510 + vpp-api/java/japi/vppjni_env.c | 111 + vpp-api/java/japi/vppjni_env.h | 118 + vpp-api/java/m4/ax_check_java_home.m4 | 80 + vpp-api/java/m4/ax_check_java_plugin.m4 | 101 + vpp-api/java/m4/ax_java_check_class.m4 | 85 + vpp-api/java/m4/ax_java_options.m4 | 48 + vpp-api/java/m4/ax_libgcj_jar.m4 | 83 + vpp-api/java/m4/ax_prog_jar.m4 | 49 + vpp-api/java/m4/ax_prog_java.m4 | 115 + vpp-api/java/m4/ax_prog_java_cc.m4 | 104 + vpp-api/java/m4/ax_prog_java_works.m4 | 134 + vpp-api/java/m4/ax_prog_javac.m4 | 79 + vpp-api/java/m4/ax_prog_javac_works.m4 | 72 + vpp-api/java/m4/ax_prog_javadoc.m4 | 50 + vpp-api/java/m4/ax_prog_javah.m4 | 64 + vpp-api/java/m4/ax_try_compile_java.m4 | 55 + vpp-api/java/m4/ax_try_run_java.m4 | 56 + vpp-api/python/Makefile.am | 49 + vpp-api/python/README.rst | 0 vpp-api/python/pneum/api-gen.py | 337 + vpp-api/python/pneum/pneum.c | 239 + vpp-api/python/pneum/pneum.h | 24 + vpp-api/python/pneum/test_pneum.c | 136 + vpp-api/python/setup.py | 21 + vpp-api/python/tests/test_papi.py | 125 + vpp-api/python/vpp_papi/__init__.py | 2 + vpp-api/python/vpp_papi/pneum_wrap.c | 120 + vpp-japi/Makefile.am | 93 - vpp-japi/configure.ac | 19 - .../japi/org/openvpp/vppjapi/vppApiCallbacks.java | 35 - .../openvpp/vppjapi/vppBridgeDomainDetails.java | 30 - .../vppjapi/vppBridgeDomainInterfaceDetails.java | 21 - vpp-japi/japi/org/openvpp/vppjapi/vppConn.java | 237 - .../japi/org/openvpp/vppjapi/vppIPv4Address.java | 26 - .../japi/org/openvpp/vppjapi/vppIPv6Address.java | 27 - .../org/openvpp/vppjapi/vppInterfaceCounters.java | 77 - .../org/openvpp/vppjapi/vppInterfaceDetails.java | 71 - vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java | 35 - vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java | 31 - .../org/openvpp/vppjapi/vppVxlanTunnelDetails.java | 33 - vpp-japi/japi/test/demo.java | 170 - vpp-japi/japi/test/vppApi.java | 52 - vpp-japi/japi/vppjni.c | 1900 ---- vpp-japi/japi/vppjni.h | 308 - vpp-japi/japi/vppjni_bridge_domain.h | 510 - vpp-japi/japi/vppjni_env.c | 111 - vpp-japi/japi/vppjni_env.h | 118 - vpp-japi/libtool | 10083 ------------------- vpp-japi/m4/ax_check_java_home.m4 | 80 - vpp-japi/m4/ax_check_java_plugin.m4 | 101 - vpp-japi/m4/ax_java_check_class.m4 | 85 - vpp-japi/m4/ax_java_options.m4 | 48 - vpp-japi/m4/ax_libgcj_jar.m4 | 83 - vpp-japi/m4/ax_prog_jar.m4 | 49 - vpp-japi/m4/ax_prog_java.m4 | 115 - vpp-japi/m4/ax_prog_java_cc.m4 | 104 - vpp-japi/m4/ax_prog_java_works.m4 | 134 - vpp-japi/m4/ax_prog_javac.m4 | 79 - vpp-japi/m4/ax_prog_javac_works.m4 | 72 - vpp-japi/m4/ax_prog_javadoc.m4 | 50 - vpp-japi/m4/ax_prog_javah.m4 | 64 - vpp-japi/m4/ax_try_compile_java.m4 | 55 - vpp-japi/m4/ax_try_run_java.m4 | 56 - vpp/api/api.c | 18 +- vppapigen/lex.c | 33 +- vppapigen/node.c | 59 +- vppapigen/node.h | 1 + 96 files changed, 6428 insertions(+), 15210 deletions(-) create mode 100644 build-data/packages/vpp-api.mk delete mode 100644 build-data/packages/vpp-japi.mk create mode 100755 vnet/vnet/map/examples/test_map.py create mode 100644 vpp-api/Makefile.am create mode 100644 vpp-api/configure.ac create mode 100644 vpp-api/java/Makefile.am create mode 100644 vpp-api/java/configure.ac create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java create mode 100644 vpp-api/java/japi/test/demo.java create mode 100644 vpp-api/java/japi/test/vppApi.java create mode 100644 vpp-api/java/japi/vppjni.c create mode 100644 vpp-api/java/japi/vppjni.h create mode 100644 vpp-api/java/japi/vppjni_bridge_domain.h create mode 100644 vpp-api/java/japi/vppjni_env.c create mode 100644 vpp-api/java/japi/vppjni_env.h create mode 100644 vpp-api/java/m4/ax_check_java_home.m4 create mode 100644 vpp-api/java/m4/ax_check_java_plugin.m4 create mode 100644 vpp-api/java/m4/ax_java_check_class.m4 create mode 100644 vpp-api/java/m4/ax_java_options.m4 create mode 100644 vpp-api/java/m4/ax_libgcj_jar.m4 create mode 100644 vpp-api/java/m4/ax_prog_jar.m4 create mode 100644 vpp-api/java/m4/ax_prog_java.m4 create mode 100644 vpp-api/java/m4/ax_prog_java_cc.m4 create mode 100644 vpp-api/java/m4/ax_prog_java_works.m4 create mode 100644 vpp-api/java/m4/ax_prog_javac.m4 create mode 100644 vpp-api/java/m4/ax_prog_javac_works.m4 create mode 100644 vpp-api/java/m4/ax_prog_javadoc.m4 create mode 100644 vpp-api/java/m4/ax_prog_javah.m4 create mode 100644 vpp-api/java/m4/ax_try_compile_java.m4 create mode 100644 vpp-api/java/m4/ax_try_run_java.m4 create mode 100644 vpp-api/python/Makefile.am create mode 100644 vpp-api/python/README.rst create mode 100755 vpp-api/python/pneum/api-gen.py create mode 100644 vpp-api/python/pneum/pneum.c create mode 100644 vpp-api/python/pneum/pneum.h create mode 100644 vpp-api/python/pneum/test_pneum.c create mode 100644 vpp-api/python/setup.py create mode 100755 vpp-api/python/tests/test_papi.py create mode 100644 vpp-api/python/vpp_papi/__init__.py create mode 100644 vpp-api/python/vpp_papi/pneum_wrap.c delete mode 100644 vpp-japi/Makefile.am delete mode 100644 vpp-japi/configure.ac delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppConn.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java delete mode 100644 vpp-japi/japi/test/demo.java delete mode 100644 vpp-japi/japi/test/vppApi.java delete mode 100644 vpp-japi/japi/vppjni.c delete mode 100644 vpp-japi/japi/vppjni.h delete mode 100644 vpp-japi/japi/vppjni_bridge_domain.h delete mode 100644 vpp-japi/japi/vppjni_env.c delete mode 100644 vpp-japi/japi/vppjni_env.h delete mode 100755 vpp-japi/libtool delete mode 100644 vpp-japi/m4/ax_check_java_home.m4 delete mode 100644 vpp-japi/m4/ax_check_java_plugin.m4 delete mode 100644 vpp-japi/m4/ax_java_check_class.m4 delete mode 100644 vpp-japi/m4/ax_java_options.m4 delete mode 100644 vpp-japi/m4/ax_libgcj_jar.m4 delete mode 100644 vpp-japi/m4/ax_prog_jar.m4 delete mode 100644 vpp-japi/m4/ax_prog_java.m4 delete mode 100644 vpp-japi/m4/ax_prog_java_cc.m4 delete mode 100644 vpp-japi/m4/ax_prog_java_works.m4 delete mode 100644 vpp-japi/m4/ax_prog_javac.m4 delete mode 100644 vpp-japi/m4/ax_prog_javac_works.m4 delete mode 100644 vpp-japi/m4/ax_prog_javadoc.m4 delete mode 100644 vpp-japi/m4/ax_prog_javah.m4 delete mode 100644 vpp-japi/m4/ax_try_compile_java.m4 delete mode 100644 vpp-japi/m4/ax_try_run_java.m4 (limited to 'Makefile') diff --git a/Makefile b/Makefile index b53941b4..68652836 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ endif @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup - + ifeq ("$(wildcard /usr/bin/ccache )","") @echo "WARNING: Please install ccache AYEC and re-run this script" else diff --git a/build-data/packages/vpp-api.mk b/build-data/packages/vpp-api.mk new file mode 100644 index 00000000..f1841648 --- /dev/null +++ b/build-data/packages/vpp-api.mk @@ -0,0 +1,23 @@ +vpp-api_configure_depend = \ + vppinfra-install \ + svm-install \ + vlib-api-install \ + vlib-install \ + vnet-install \ + vpp-install + +vpp-api_CPPFLAGS = $(call installed_includes_fn, \ + vppinfra \ + svm \ + vlib \ + vlib-api \ + vnet \ + vpp) + +vpp-api_LDFLAGS = $(call installed_libs_fn, \ + vppinfra \ + svm \ + vlib \ + vlib-api) + +vpp-api_CPPFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include diff --git a/build-data/packages/vpp-japi.mk b/build-data/packages/vpp-japi.mk deleted file mode 100644 index 6f69baa0..00000000 --- a/build-data/packages/vpp-japi.mk +++ /dev/null @@ -1,23 +0,0 @@ -vpp-japi_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install - -vpp-japi_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp) - -vpp-japi_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api) - -vpp-japi_CPPFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include diff --git a/build-data/platforms/virl.mk b/build-data/platforms/virl.mk index f47f3691..3d5274a8 100644 --- a/build-data/platforms/virl.mk +++ b/build-data/platforms/virl.mk @@ -18,7 +18,7 @@ virl_native_tools = vppapigen virl_uses_dpdk = yes virl_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ - vpp-japi + vpp-api vpp_configure_args_virl = --with-dpdk vnet_configure_args_virl = --with-dpdk --with-virl diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 04a697d3..c381be19 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -21,7 +21,7 @@ vpp_uses_dpdk = yes # vpp_enable_tests = yes vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-japi gmod + vpp-api gmod vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk index 9376aa35..4183700e 100644 --- a/build-data/platforms/vpp_lite.mk +++ b/build-data/platforms/vpp_lite.mk @@ -18,7 +18,7 @@ vpp_lite_native_tools = vppapigen vpp_lite_uses_dpdk = no vpp_lite_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-japi gmod + vpp-api gmod vlib_configure_args_vpp_lite = --with-pre-data=128 diff --git a/vlib-api/vlibmemory/api.h b/vlib-api/vlibmemory/api.h index 117bf433..516d321f 100644 --- a/vlib-api/vlibmemory/api.h +++ b/vlib-api/vlibmemory/api.h @@ -86,6 +86,13 @@ typedef struct vl_shmem_hdr_ { } vl_shmem_hdr_t; +/* Note that the size of the structure is 16 bytes, with 4 bytes of padding after data[0]. */ +typedef struct msgbuf_ { + unix_shared_memory_queue_t *q; + u32 data_len; + u8 data[0]; +} msgbuf_t; + #define VL_SHM_VERSION 2 #define VL_API_EPOCH_MASK 0xFF diff --git a/vlib-api/vlibmemory/memory_shared.c b/vlib-api/vlibmemory/memory_shared.c index ecd5cff7..a3219431 100644 --- a/vlib-api/vlibmemory/memory_shared.c +++ b/vlib-api/vlibmemory/memory_shared.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -38,11 +39,6 @@ #include #undef vl_typedefs -typedef struct msgbuf_ { - unix_shared_memory_queue_t *q; - u8 data[0]; -} msgbuf_t; - static inline void *vl_msg_api_alloc_internal(int nbytes, int pool) { int i; @@ -119,12 +115,13 @@ static inline void *vl_msg_api_alloc_internal(int nbytes, int pool) pthread_mutex_lock (&am->vlib_rp->mutex); oldheap = svm_push_data_heap (am->vlib_rp); - rv = clib_mem_alloc(nbytes + sizeof(msgbuf_t)); + rv = clib_mem_alloc(nbytes); rv->q = 0; svm_pop_heap (oldheap); pthread_mutex_unlock (&am->vlib_rp->mutex); out: + rv->data_len = htonl(nbytes - sizeof(msgbuf_t)); return(rv->data); } @@ -152,7 +149,8 @@ void vl_msg_api_free(void *a) void *oldheap; api_main_t *am = &api_main; - rv = (msgbuf_t *)(((u8 *)a) - sizeof(*rv)); + rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data)); + /* * Here's the beauty of the scheme. Only one proc/thread has * control of a given message buffer. To free a buffer, we just clear the @@ -176,7 +174,7 @@ static void vl_msg_api_free_nolock (void *a) void *oldheap; api_main_t *am = &api_main; - rv = (msgbuf_t *)(((u8 *)a) - sizeof(*rv)); + rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data)); /* * Here's the beauty of the scheme. Only one proc/thread has * control of a given message buffer. To free a buffer, we just clear the diff --git a/vnet/vnet/map/examples/test_map.py b/vnet/vnet/map/examples/test_map.py new file mode 100755 index 00000000..21388d49 --- /dev/null +++ b/vnet/vnet/map/examples/test_map.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python + +import time,argparse,sys,cmd, unittest +from ipaddress import * + +parser = argparse.ArgumentParser(description='VPP MAP test') +parser.add_argument('-i', nargs='*', action="store", dest="inputdir") +args = parser.parse_args() + +for dir in args.inputdir: + sys.path.append(dir) +from vpp_papi import * + +# +# 1:1 Shared IPv4 address, shared BR (16) VPP CLI +# +def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + ip4_pfx = ip_network(ip4_pfx_str) + ip6_src = ip_address(ip6_src_str) + ip6_dst = ip_network(ip6_pfx_str) + ip6_nul = IPv6Address(u'0::0') + mod = ip4_pfx.num_addresses / 1024 + + for i in range(ip4_pfx.num_addresses): + a = time.clock() + t = map_add_domain(0, ip6_nul.packed, ip4_pfx[i].packed, ip6_src.packed, 0, 32, 128, ea_bits_len, psid_offset, psid_len, 0, 0) + #print "Return from map_add_domain", t + if t == None: + print "map_add_domain failed" + continue + if t.retval != 0: + print "map_add_domain failed", t + continue + for psid in range(0x1 << int(psid_len)): + r = map_add_del_rule(0, t.index, 1, (ip6_dst[(i * (0x1<H', msg[0:2]) + size = unpack('>H', msg[2:4]) + print "Received", id, "of size", size + i += 1 + #del msg + continue + + #time.sleep(0.001) + return + +# Create RX thread +rxthread = RXThread() +rxthread.setDaemon(True) + +print "Connect", connect_to_vpe("client124") +import timeit +rxthread.start() +print "After thread started" + +#pneum_kill_thread() +print "After thread killed" + +#t = show_version(0) +#print "Result from show version", t + +print timeit.timeit('t = show_version(0)', number=1000, setup="from __main__ import show_version") +time.sleep(10) +#print timeit.timeit('control_ping(0)', number=10, setup="from __main__ import control_ping") + + +disconnect_from_vpe() +sys.exit() + + +print t.program, t.version,t.builddate,t.builddirectory + +''' + +t = map_domain_dump(0) +if not t: + print('show map domain failed') + +for d in t: + print("IP6 prefix:",str(IPv6Address(d.ip6prefix))) + print( "IP4 prefix:",str(IPv4Address(d.ip4prefix))) +''' + +suite = unittest.TestLoader().loadTestsFromTestCase(TestMAP) +unittest.TextTestRunner(verbosity=2).run(suite) + +disconnect_from_vpe() + + diff --git a/vpp-api/Makefile.am b/vpp-api/Makefile.am new file mode 100644 index 00000000..5b326540 --- /dev/null +++ b/vpp-api/Makefile.am @@ -0,0 +1,2 @@ +AUTOMAKE_OPTIONS = foreign +SUBDIRS = java python diff --git a/vpp-api/configure.ac b/vpp-api/configure.ac new file mode 100644 index 00000000..31ee6656 --- /dev/null +++ b/vpp-api/configure.ac @@ -0,0 +1,15 @@ +AC_INIT(vpp-api, 1.0.0) +LT_INIT +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SUBDIRS([java]) +AM_INIT_AUTOMAKE +AM_SILENT_RULES + +AM_PROG_AS +AC_PROG_CC +AM_PROG_CC_C_O + +AC_OUTPUT([python/Makefile]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT + diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am new file mode 100644 index 00000000..0e16b72b --- /dev/null +++ b/vpp-api/java/Makefile.am @@ -0,0 +1,93 @@ +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = -Wall + +noinst_PROGRAMS = +BUILT_SOURCES = +bin_PROGRAMS = +CLEANFILES = +lib_LTLIBRARIES = + +nobase_include_HEADERS = \ + japi/org_openvpp_vppjapi_vppApi.h \ + japi/org_openvpp_vppjapi_vppConn.h + +lib_LTLIBRARIES += libvppjni.la + +libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c +libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ + -lpthread -lm -lrt +libvppjni_la_LDFLAGS = -module +libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux + +jarfile = vppjapi-$(PACKAGE_VERSION).jar +packagedir = org/openvpp/vppjapi +JAVAROOT = . + +$(jarfile): libvppjni.la + cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd .. + +BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c + +japi/org_openvpp_vppjapi_vppConn.h: \ + japi/org/openvpp/vppjapi/vppVersion.java \ + japi/org/openvpp/vppjapi/vppInterfaceDetails.java \ + japi/org/openvpp/vppjapi/vppInterfaceCounters.java \ + japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java \ + japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java \ + japi/org/openvpp/vppjapi/vppL2Fib.java \ + japi/org/openvpp/vppjapi/vppIPv4Address.java \ + japi/org/openvpp/vppjapi/vppIPv6Address.java \ + japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \ + japi/org/openvpp/vppjapi/vppConn.java \ + japi/org/openvpp/vppjapi/vppApiCallbacks.java \ + ../../vpp/api/vpe.api.h + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ; + +japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h + pushd .. ; dir=`pwd` ; popd ; \ + instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \ + vppapigen --input $${instdir}/../vpp/api/vpe.api --jni japi/vppapi.c --app vpe ; \ + vppapigen --input $${instdir}/../vpp/api/vpe.api --java japi/vppApi.java --app vpe ; \ + $(JAVAC) -classpath . -d . japi/vppApi.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ; + +demo = japi/test/demo.class +$(demo): $(jarfile) + $(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java + +all-local: $(jarfile) $(demo) diff --git a/vpp-api/java/configure.ac b/vpp-api/java/configure.ac new file mode 100644 index 00000000..1607061d --- /dev/null +++ b/vpp-api/java/configure.ac @@ -0,0 +1,19 @@ +AC_INIT(vpp-japi, 1.0.0) +LT_INIT +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE +AM_SILENT_RULES + +AM_PROG_AS +AC_PROG_CC +AM_PROG_CC_C_O + +AX_PROG_JAVAC +AX_PROG_JAVAH +AX_PROG_JAR +AX_PROG_JAVADOC +AX_PROG_JAVA +AX_CHECK_JAVA_HOME + +AC_OUTPUT([Makefile]) + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java new file mode 100644 index 00000000..df5b9533 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import java.io.IOException; +import org.openvpp.vppjapi.vppApi; + +public abstract class vppApiCallbacks extends vppApi { + public vppApiCallbacks(String clientName) throws IOException { + super(clientName); + } +/* Disabled! + * + * public abstract void interfaceDetails( + int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, + byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed, + int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId, + byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny, + int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2); + */ + +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java new file mode 100644 index 00000000..db859a07 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails; + +public final class vppBridgeDomainDetails { + public String name; + public int bdId; + public boolean flood; + public boolean uuFlood; + public boolean forward; + public boolean learn; + public boolean arpTerm; + public String bviInterfaceName; + public vppBridgeDomainInterfaceDetails[] interfaces; +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java new file mode 100644 index 00000000..ab99ee45 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppBridgeDomainInterfaceDetails { + public String interfaceName; + public byte splitHorizonGroup; +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java new file mode 100644 index 00000000..3e8c12a9 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.Set; + +import org.openvpp.vppjapi.vppVersion; +import org.openvpp.vppjapi.vppInterfaceDetails; +import org.openvpp.vppjapi.vppInterfaceCounters; +import org.openvpp.vppjapi.vppBridgeDomainDetails; +import org.openvpp.vppjapi.vppIPv4Address; +import org.openvpp.vppjapi.vppIPv6Address; +import org.openvpp.vppjapi.vppVxlanTunnelDetails; + +public class vppConn implements AutoCloseable { + private static final String LIBNAME = "libvppjni.so.0.0.0"; + + static { + try { + loadLibrary(); + } catch (Exception e) { + System.out.printf("Can't find vpp jni library: %s\n", LIBNAME); + throw new ExceptionInInitializerError(e); + } + } + + private static void loadStream(final InputStream is) throws IOException { + final Set perms = PosixFilePermissions.fromString("rwxr-x---"); + final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); + try { + Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); + + try { + Runtime.getRuntime().load(p.toString()); + } catch (UnsatisfiedLinkError e) { + throw new IOException(String.format("Failed to load library %s", p), e); + } + } finally { + try { + Files.deleteIfExists(p); + } catch (IOException e) { + } + } + } + + private static void loadLibrary() throws IOException { + try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) { + if (is == null) { + throw new IOException(String.format("Failed to open library resource %s", + LIBNAME)); + } + loadStream(is); + } + } + + private static vppConn currentConnection = null; + private final String clientName; + private volatile boolean disconnected = false; + + // Hidden on purpose to prevent external instantiation + vppConn(final String clientName) throws IOException { + this.clientName = clientName; + + synchronized (vppConn.class) { + if (currentConnection != null) { + throw new IOException("Already connected as " + currentConnection.clientName); + } + + final int ret = clientConnect(clientName); + if (ret != 0) { + throw new IOException("Connection returned error " + ret); + } + + currentConnection = this; + } + } + + @Override + public synchronized final void close() { + if (!disconnected) { + disconnected = true; + + synchronized (vppConn.class) { + clientDisconnect(); + currentConnection = null; + } + } + } + + /** + * Check if this instance is connected. + * + * @throws IllegalStateException if this instance was disconnected. + */ + protected final void checkConnected() { + if (disconnected) { + throw new IllegalStateException("Disconnected client " + clientName); + } + } + + public final int getRetval(int context, int release) { + checkConnected(); + return getRetval0(context, release); + } + + public final String getInterfaceList (String nameFilter) { + checkConnected(); + return getInterfaceList0(nameFilter); + } + + public final int swIfIndexFromName (String interfaceName) { + checkConnected(); + return swIfIndexFromName0(interfaceName); + } + + public final String interfaceNameFromSwIfIndex (int swIfIndex) { + checkConnected(); + return interfaceNameFromSwIfIndex0(swIfIndex); + } + + public final void clearInterfaceTable () { + checkConnected(); + clearInterfaceTable0(); + } + + public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) { + checkConnected(); + return swInterfaceDump0(nameFilterValid, nameFilter); + } + + public final int bridgeDomainIdFromName(String bridgeDomain) { + checkConnected(); + return bridgeDomainIdFromName0(bridgeDomain); + } + + public final int findOrAddBridgeDomainId(String bridgeDomain) { + checkConnected(); + return findOrAddBridgeDomainId0(bridgeDomain); + } + + public final vppVersion getVppVersion() { + checkConnected(); + return getVppVersion0(); + } + + public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) { + checkConnected(); + return getInterfaceCounters0(swIfIndex); + } + + public final int[] bridgeDomainDump(int bdId) { + checkConnected(); + return bridgeDomainDump0(bdId); + } + + public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) { + checkConnected(); + return getBridgeDomainDetails0(bdId); + } + + public final vppL2Fib[] l2FibTableDump(int bdId) { + checkConnected(); + return l2FibTableDump0(bdId); + } + + public final int bridgeDomainIdFromInterfaceName(String interfaceName) { + checkConnected(); + return bridgeDomainIdFromInterfaceName0(interfaceName); + } + + public final vppIPv4Address[] ipv4AddressDump(String interfaceName) { + checkConnected(); + return ipv4AddressDump0(interfaceName); + } + + public final vppIPv6Address[] ipv6AddressDump(String interfaceName) { + checkConnected(); + return ipv6AddressDump0(interfaceName); + } + + public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) { + checkConnected(); + return vxlanTunnelDump0(swIfIndex); + } + + public final int setInterfaceDescription(String ifName, String ifDesc) { + checkConnected(); + return setInterfaceDescription0(ifName, ifDesc); + } + + public final String getInterfaceDescription(String ifName) { + checkConnected(); + return getInterfaceDescription0(ifName); + } + + private static native int clientConnect(String clientName); + private static native void clientDisconnect(); + private static native int getRetval0(int context, int release); + private static native String getInterfaceList0(String nameFilter); + private static native int swIfIndexFromName0(String interfaceName); + private static native String interfaceNameFromSwIfIndex0(int swIfIndex); + private static native void clearInterfaceTable0(); + private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter); + private static native int bridgeDomainIdFromName0(String bridgeDomain); + private static native int findOrAddBridgeDomainId0(String bridgeDomain); + private static native vppVersion getVppVersion0(); + private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex); + private static native int[] bridgeDomainDump0(int bdId); + private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId); + private static native vppL2Fib[] l2FibTableDump0(int bdId); + private static native int bridgeDomainIdFromInterfaceName0(String interfaceName); + private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName); + private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName); + private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex); + private static native int setInterfaceDescription0(String ifName, String ifDesc); + private static native String getInterfaceDescription0(String ifName); +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java new file mode 100644 index 00000000..046ceab5 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppIPv4Address { + public final int ip; + public final byte prefixLength; + + public vppIPv4Address(int ip, byte prefixLength) { + this.ip = ip; + this.prefixLength = prefixLength; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java new file mode 100644 index 00000000..6690a5db --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public class vppIPv6Address { + // FIXME: this is dangerous + public final byte[] ip; + public final byte prefixLength; + + public vppIPv6Address(byte[] ip, byte prefixLength) { + this.ip = ip; + this.prefixLength = prefixLength; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java new file mode 100644 index 00000000..b2687fb8 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppInterfaceCounters { + + public final long rxOctets; + public final long rxIp4; + public final long rxIp6; + public final long rxUnicast; + public final long rxMulticast; + public final long rxBroadcast; + public final long rxDiscard; + public final long rxFifoFull; + public final long rxError; + public final long rxUnknownProto; + public final long rxMiss; + + public final long txOctets; + public final long txIp4; + public final long txIp6; + public final long txUnicast; + public final long txMulticast; + public final long txBroadcast; + public final long txDiscard; + public final long txFifoFull; + public final long txError; + public final long txUnknownProto; + public final long txMiss; + + public vppInterfaceCounters( + long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti, + long rxBcast, long rxDiscard, long rxFifoFull, long rxError, + long rxUnknownProto, long rxMiss, + long txOctets, long txIp4, long txIp6, long txUni, long txMulti, + long txBcast, long txDiscard, long txFifoFull, long txError, + long txUnknownProto, long txMiss) + { + this.rxOctets = rxOctets; + this.rxIp4 = rxIp4; + this.rxIp6 = rxIp6; + this.rxUnicast = rxUni; + this.rxMulticast = rxMulti; + this.rxBroadcast = rxBcast; + this.rxDiscard = rxDiscard; + this.rxFifoFull = rxFifoFull; + this.rxError = rxError; + this.rxUnknownProto = rxUnknownProto; + this.rxMiss = rxMiss; + + this.txOctets = txOctets; + this.txIp4 = txIp4; + this.txIp6 = txIp6; + this.txUnicast = txUni; + this.txMulticast = txMulti; + this.txBroadcast = txBcast; + this.txDiscard = txDiscard; + this.txFifoFull = txFifoFull; + this.txError = txError; + this.txUnknownProto = txUnknownProto; + this.txMiss = txMiss; + } +} + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java new file mode 100644 index 00000000..742dd25a --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppInterfaceDetails { + public final int ifIndex; + public final String interfaceName; + public final int supIfIndex; + // FIXME: this is dangerous + public final byte[] physAddr; + public final byte adminUp; + public final byte linkUp; + public final byte linkDuplex; + public final byte linkSpeed; + public final int subId; + public final byte subDot1ad; + public final byte subNumberOfTags; + public final int subOuterVlanId; + public final int subInnerVlanId; + public final byte subExactMatch; + public final byte subDefault; + public final byte subOuterVlanIdAny; + public final byte subInnerVlanIdAny; + public final int vtrOp; + public final int vtrPushDot1q; + public final int vtrTag1; + public final int vtrTag2; + public final int linkMtu; + + public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp, + byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags, + int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, + byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu) + { + this.ifIndex = ifIndex; + this.interfaceName = interfaceName; + this.supIfIndex = supIfIndex; + this.physAddr = physAddr; + this.adminUp = adminUp; + this.linkUp = linkUp; + this.linkDuplex = linkDuplex; + this.linkSpeed = linkSpeed; + this.subId = subId; + this.subDot1ad = subDot1ad; + this.subNumberOfTags = subNumberOfTags; + this.subOuterVlanId = subOuterVlanId; + this.subInnerVlanId = subInnerVlanId; + this.subExactMatch = subExactMatch; + this.subDefault = subDefault; + this.subOuterVlanIdAny = subOuterVlanIdAny; + this.subInnerVlanIdAny = subInnerVlanIdAny; + this.vtrOp = vtrOp; + this.vtrPushDot1q = vtrPushDot1q; + this.vtrTag1 = vtrTag1; + this.vtrTag2 = vtrTag2; + this.linkMtu = linkMtu; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java new file mode 100644 index 00000000..b38d801e --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppL2Fib { + // FIXME: this is dangerous + public final byte[] physAddress; + public final boolean staticConfig; + public final String outgoingInterface; + public final boolean filter; + public final boolean bridgedVirtualInterface; + + public vppL2Fib(byte[] physAddress, boolean staticConfig, + String outgoingInterface, boolean filter, + boolean bridgedVirtualInterface) { + this.physAddress = physAddress; + this.staticConfig = staticConfig; + this.outgoingInterface = outgoingInterface; + this.filter = filter; + this.bridgedVirtualInterface = bridgedVirtualInterface; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java new file mode 100644 index 00000000..6408dee2 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppVersion { + public final String programName; + public final String buildDirectory; + public final String gitBranch; + public final String buildDate; + + public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) { + this.programName = progName; + this.buildDirectory = buildDir; + this.gitBranch = gitBranch; + this.buildDate = buildDate; + } +} + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java new file mode 100644 index 00000000..dd81e98c --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppVxlanTunnelDetails { + public final int srcAddress; + public final int dstAddress; + public final int encapVrfId; + public final int vni; + public final int decapNextIndex; + + public vppVxlanTunnelDetails(int srcAddress, int dstAddress, + int encapVrfId, int vni, int decapNextIndex) { + this.srcAddress = srcAddress; + this.dstAddress = dstAddress; + this.encapVrfId = encapVrfId; + this.vni = vni; + this.decapNextIndex = decapNextIndex; + } +} diff --git a/vpp-api/java/japi/test/demo.java b/vpp-api/java/japi/test/demo.java new file mode 100644 index 00000000..ea1db84b --- /dev/null +++ b/vpp-api/java/japi/test/demo.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.openvpp.vppjapi.*; + +public class demo { + public static void main (String[] args) throws Exception { + vppApi api = new vppApi ("JavaTest"); + System.out.printf ("Connected OK..."); + + String intlist; + int [] contexts; + int i, limit; + int trips; + int rv, errors, saved_error; + long before, after; + + if (false) + { + intlist = api.getInterfaceList (""); + System.out.printf ("Unfiltered interface list:\n%s", intlist); + + trips = 0; + + contexts = new int[6]; + + for (i = 0; i < 6; i++) + { + contexts[i] = api.swInterfaceSetFlags + (5 + i /* sw_if_index */, + (byte)1 /* admin_up */, + (byte)1 /* link_up (ignored) */, + (byte)0 /* deleted */); + } + + /* Thread.sleep (1); */ + errors = 0; + saved_error = 0; + + for (i = 0; i < 6; i ++) + { + while (true) + { + rv = api.getRetval (contexts[i], 1 /* release */); + if (rv != -77) + break; + Thread.sleep (1); + trips++; + } + if (rv < 0) + { + saved_error = rv; + errors++; + } + } + + if (errors == 0) + System.out.printf ("intfcs up...\n"); + else + System.out.printf + ("%d errors, last error %d...\n", errors, saved_error); + } + + limit = 250000; + saved_error = 0; + errors = 0; + contexts = new int [limit]; + byte [] address = new byte [4]; + byte [] zeros = new byte [4]; + + address[0] = (byte)192; + address[1] = (byte)168; + address[2] = (byte)2; + address[3] = (byte)1; + + for (i = 0; i < 4; i++) + zeros[i] = 0; + + System.out.printf ("start %d route ops ...", limit); + + before = System.currentTimeMillis(); + + for (i = 0; i < limit; i++) { + contexts[i] = api.ipAddDelRoute + (0 /* int nextHopSwIfIndex */, + 0 /* int vrfId */, + 0 /* int lookupInVrf */, + 0 /* int resolveAttempts */, + 0 /* int classifyTableIndex */, + (byte)0 /* byte createVrfIfNeeded */, + (byte)0 /* byte resolveIfNeeded */, + (byte)1 /* byte isAdd */, + (byte)1 /* byte isDrop */, + (byte)0 /* byte isIpv6 */, + (byte)0 /* byte isLocal */, + (byte)0 /* byte isClassify */, + (byte)0 /* byte isMultipath */, + (byte)0 /* byte notLast */, + (byte)0 /* byte nextHopWeight */, + (byte)32 /* byte dstAddressLength */, + address, + zeros); + + address[3] += 1; + if (address[3] == 0) + { + address[2] += 1; + if (address[2] == 0) + { + address[1] += 1; + { + if (address[1] == 0) + { + address[0] += 1; + } + } + } + } + } + + trips = 0; + + for (i = 0; i < limit; i++) + { + while (true) + { + rv = api.getRetval (contexts[i], 1 /* release */); + if (rv != -77) + break; + Thread.sleep (1); + trips++; + } + if (rv < 0) + { + saved_error = rv; + errors++; + } + } + + after = System.currentTimeMillis(); + + + if (errors == 0) + System.out.printf ("done %d route ops (all OK)...\n", limit); + else + System.out.printf + ("%d errors, last error %d...\n", errors, saved_error); + + System.out.printf ("result in %d trips\n", trips); + + System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n", + limit, after - before, + limit / (after - before)); + + api.close(); + System.out.printf ("Done...\n"); + } +} diff --git a/vpp-api/java/japi/test/vppApi.java b/vpp-api/java/japi/test/vppApi.java new file mode 100644 index 00000000..87af3292 --- /dev/null +++ b/vpp-api/java/japi/test/vppApi.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.net.InetAddress; +import org.openvpp.vppjapi.*; + +public class vppApi { + + native int controlPing(); + native void test (byte[] array, byte[] array2); + + public static void main (String[] args) throws Exception { + vppConn api = new vppConn (); + String ipv6 = "db01::feed"; + String ipv4 = "192.168.1.1"; + InetAddress addr6 = InetAddress.getByName(ipv6); + InetAddress addr4 = InetAddress.getByName(ipv4); + byte[] ip4bytes = addr4.getAddress(); + byte[] ip6bytes = addr6.getAddress(); + int rv; + + api.test(ip4bytes,ip6bytes); + + rv = api.clientConnect ("JavaTest"); + if (rv == 0) + System.out.printf ("Connected OK..."); + else + { + System.out.printf ("clientConnect returned %d\n", rv); + System.exit (1); + } + rv = api.controlPing(); + System.out.printf ("data plane pid is %d\n", rv); + + Thread.sleep (5000); + + api.clientDisconnect(); + System.out.printf ("Done...\n"); + } +} diff --git a/vpp-api/java/japi/vppjni.c b/vpp-api/java/japi/vppjni.c new file mode 100644 index 00000000..9c9437d2 --- /dev/null +++ b/vpp-api/java/japi/vppjni.c @@ -0,0 +1,1900 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define _GNU_SOURCE /* for strcasestr(3) */ +#include + +#define vl_api_version(n,v) static u32 vpe_api_version = (v); +#include +#undef vl_api_version + +#include +#include +#include +#include +#include +#include + +#include +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +#define vl_endianfun +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +#define VPPJNI_DEBUG 0 + +#if VPPJNI_DEBUG == 1 + #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) +#else + #define DEBUG_LOG(...) +#endif + +static int connect_to_vpe(char *name); + +/* + * The Java runtime isn't compile w/ -fstack-protector, + * so we have to supply missing external references for the + * regular vpp libraries. Weak reference in case folks get religion + * at a later date... + */ +void __stack_chk_guard (void) __attribute__((weak)); +void __stack_chk_guard (void) { } + +BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V"); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood); +BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId); +BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name); +BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName); +BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;"); + +BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V"); +BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup); +BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName); + +BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V"); +BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V"); +BIND_JAPI_CLASS(vppIPv4Address, "(IB)V"); +BIND_JAPI_CLASS(vppIPv6Address, "([BB)V"); +BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V"); +BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); +BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V"); + +void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) +{ + /* + * Send the main API signature in slot 0. This bit of code must + * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). + */ + mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); +} + +/* Note: non-static, called once to set up the initial intfc table */ +static int sw_interface_dump (vppjni_main_t * jm) +{ + vl_api_sw_interface_dump_t *mp; + f64 timeout; + hash_pair_t * p; + name_sort_t * nses = 0, * ns; + sw_interface_subif_t * sub = NULL; + + /* Toss the old name table */ + hash_foreach_pair (p, jm->sw_if_index_by_interface_name, + ({ + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + })); + + hash_free (jm->sw_if_index_by_interface_name); + + vec_foreach (ns, nses) + vec_free (ns->name); + + vec_free (nses); + + vec_foreach (sub, jm->sw_if_subif_table) { + vec_free (sub->interface_name); + } + vec_free (jm->sw_if_subif_table); + + /* recreate the interface name hash table */ + jm->sw_if_index_by_interface_name + = hash_create_string (0, sizeof(uword)); + + /* Get list of ethernets */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter-1)); + S; + + /* and local / loopback interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter-1)); + S; + + /* and vxlan tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter-1)); + S; + + /* and tap tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter-1)); + S; + + /* and host (af_packet) interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter-1)); + S; + + /* and l2tpv3 tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", + sizeof(mp->name_filter-1)); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + W; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0 + (JNIEnv *env, jobject obj) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 11); + jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name); + jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory); + jstring version = (*env)->NewStringUTF(env, (char *)jm->version); + jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date); + vppjni_unlock (jm); + + return vppVersionObject(env, progName, buildDir, version, buildDate); +} + +static int jm_show_version (vppjni_main_t *jm) +{ + int rv; + vl_api_show_version_t *mp; + f64 timeout; + + vppjni_lock (jm, 10); + M(SHOW_VERSION, show_version); + + S; + vppjni_unlock (jm); + WNR; + return rv; +} + +static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable) +{ + vl_api_want_stats_t * mp; + f64 timeout; + int rv; + + vppjni_lock (jm, 13); + + M(WANT_STATS, want_stats); + + mp->enable_disable = enable; + + S; + vppjni_unlock (jm); + WNR; + + // already subscribed / already disabled (it's ok) + if (rv == -2 || rv == -3) + rv = 0; + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0 + (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc) +{ + int rv = 0; + vppjni_main_t * jm = &vppjni_main; + uword * p; + u32 sw_if_index = ~0; + sw_if_config_t *cfg; + + const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); + const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0); + + vppjni_lock (jm, 23); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); + if (p == 0) { + rv = -1; + goto out; + } + sw_if_index = (jint) p[0]; + + u8 *if_desc = 0; + vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str)); + (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str); + + p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); + if (p != 0) { + cfg = (sw_if_config_t *) (p[0]); + if (cfg->desc) + vec_free(cfg->desc); + } else { + cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t)); + hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg); + } + + cfg->desc = if_desc; + +out: + (*env)->ReleaseStringUTFChars (env, ifName, if_name_str); + vppjni_unlock (jm); + return rv; +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0 +(JNIEnv * env, jobject obj, jstring ifName) +{ + vppjni_main_t * jm = &vppjni_main; + u32 sw_if_index = ~0; + uword * p; + jstring ifDesc = NULL; + const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); + if (!if_name_str) + return NULL; + + vppjni_lock (jm, 24); + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); + if (p == 0) + goto out; + + sw_if_index = (jint) p[0]; + + p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); + if (p == 0) + goto out; + + sw_if_config_t *cfg = (sw_if_config_t *) (p[0]); + u8 * s = format (0, "%s%c", cfg->desc, 0); + ifDesc = (*env)->NewStringUTF(env, (char *)s); + +out: + vppjni_unlock (jm); + + return ifDesc; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect + (JNIEnv *env, jobject obj, jstring clientName) +{ + int rv; + const char *client_name; + void vl_msg_reply_handler_hookup(void); + vppjni_main_t * jm = &vppjni_main; + api_main_t * am = &api_main; + u8 * heap; + mheap_t * h; + f64 timeout; + + /* + * Bail out now if we're not running as root + */ + if (geteuid() != 0) + return -1; + + if (jm->is_connected) + return -2; + + client_name = (*env)->GetStringUTFChars(env, clientName, 0); + if (!client_name) + return -3; + + if (jm->heap == 0) + clib_mem_init (0, 128<<20); + + heap = clib_mem_get_per_cpu_heap(); + h = mheap_header (heap); + + clib_time_init (&jm->clib_time); + + rv = connect_to_vpe ((char *) client_name); + + if (rv < 0) + clib_warning ("connection failed, rv %d", rv); + + (*env)->ReleaseStringUTFChars (env, clientName, client_name); + + if (rv == 0) { + vl_msg_reply_handler_hookup (); + jm->is_connected = 1; + /* make the main heap thread-safe */ + h->flags |= MHEAP_FLAG_THREAD_SAFE; + + jm->reply_hash = hash_create (0, sizeof (uword)); + //jm->callback_hash = hash_create (0, sizeof (uword)); + //jm->ping_hash = hash_create (0, sizeof (uword)); + jm->api_main = am; + vjbd_main_init(&jm->vjbd_main); + jm->sw_if_index_by_interface_name = + hash_create_string (0, sizeof (uword)); + jm->sw_if_config_by_sw_if_index = + hash_create (0, sizeof (uword)); + + { + // call control ping first to attach rx thread to java thread + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + WNR; + + if (rv != 0) { + clib_warning ("first control ping failed: %d", rv); + } + } + rv = jm_show_version(jm); + if (rv != 0) + clib_warning ("unable to retrieve vpp version (rv: %d)", rv); + rv = sw_interface_dump(jm); + if (rv != 0) + clib_warning ("unable to retrieve interface list (rv: %d)", rv); + rv = jm_stats_enable_disable(jm, 1); + if (rv != 0) + clib_warning ("unable to subscribe to stats (rv: %d)", rv); + } + DEBUG_LOG ("clientConnect result: %d", rv); + + return rv; +} + +JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect + (JNIEnv *env, jobject obj) +{ + u8 *save_heap; + vppjni_main_t * jm = &vppjni_main; + vl_client_disconnect_from_vlib(); + + save_heap = jm->heap; + memset (jm, 0, sizeof (*jm)); + jm->heap = save_heap; +} + +void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp) +{ + api_main_t * am = &api_main; + u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id); + trace_cfg_t *cfgp; + i32 retval = clib_net_to_host_u32 (mp->retval); + int total_bytes = sizeof(mp); + vppjni_main_t * jm = &vppjni_main; + u8 * saved_reply = 0; + u32 context = clib_host_to_net_u32 (mp->context); + + cfgp = am->api_trace_cfg + msg_id; + + if (!cfgp) + clib_warning ("msg id %d: no trace configuration\n", msg_id); + else + total_bytes = cfgp->size; + + jm->context_id_received = context; + + DEBUG_LOG ("Received generic reply for msg id %d", msg_id); + + /* A generic reply, successful, we're done */ + if (retval >= 0 && total_bytes == sizeof(*mp)) + return; + + /* Save the reply */ + vec_validate (saved_reply, total_bytes - 1); + memcpy (saved_reply, mp, total_bytes); + + vppjni_lock (jm, 2); + hash_set (jm->reply_hash, context, saved_reply); + jm->saved_reply_count ++; + vppjni_unlock (jm); +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0 +(JNIEnv * env, jobject obj, jint context, jint release) +{ + vppjni_main_t * jm = &vppjni_main; + vl_api_generic_reply_t * mp; + uword * p; + int rv = 0; + + /* Dunno yet? */ + if (context > jm->context_id_received) + return (VNET_API_ERROR_RESPONSE_NOT_READY); + + vppjni_lock (jm, 1); + p = hash_get (jm->reply_hash, context); + + /* + * Two cases: a generic "yes" reply - won't be in the hash table + * or "no", or "more data" which will be in the table. + */ + if (p == 0) + goto out; + + mp = (vl_api_generic_reply_t *) (p[0]); + rv = clib_net_to_host_u32 (mp->retval); + + if (release) { + u8 * free_me = (u8 *) mp; + vec_free (free_me); + hash_unset (jm->reply_hash, context); + jm->saved_reply_count --; + } + +out: + vppjni_unlock (jm); + return (rv); +} + +static int +name_sort_cmp (void * a1, void * a2) +{ + name_sort_t * n1 = a1; + name_sort_t * n2 = a2; + + return strcmp ((char *)n1->name, (char *)n2->name); +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0 + (JNIEnv * env, jobject obj, jstring name_filter) +{ + vppjni_main_t * jm = &vppjni_main; + jstring rv; + hash_pair_t * p; + name_sort_t * nses = 0, * ns; + const char *this_name; + u8 * s = 0; + const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL); + if (!nf) + return NULL; + + vppjni_lock (jm, 4); + + hash_foreach_pair (p, jm->sw_if_index_by_interface_name, + ({ + this_name = (const char *)(p->key); + if (strlen (nf) == 0 || strcasestr (this_name, nf)) { + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + } + })); + + vec_sort_with_function (nses, name_sort_cmp); + + vec_foreach (ns, nses) + s = format (s, "%s: %d, ", ns->name, ns->value); + + _vec_len (s) = vec_len (s) - 2; + vec_terminate_c_string (s); + vppjni_unlock (jm); + + vec_free (nses); + + (*env)->ReleaseStringUTFChars (env, name_filter, nf); + + rv = (*env)->NewStringUTF (env, (char *) s); + vec_free (s); + + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0 + (JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + if (if_name) { + uword * p; + + vppjni_lock (jm, 5); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + + if (p != 0) + rv = (jint) p[0]; + + vppjni_unlock (jm); + + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + } + + return rv; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_stats_t *s; + u32 sw_if_index = swIfIndex; + jobject result = NULL; + + vppjni_lock (jm, 16); + + if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) { + goto out; + } + s = &jm->sw_if_stats_by_sw_if_index[sw_if_index]; + if (!s->valid) { + goto out; + } + + result = vppInterfaceCountersObject(env, + s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast, + s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard, + s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto, + s->rx.pkts.miss, + s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast, + s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard, + s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto, + s->tx.pkts.miss); + +out: + vppjni_unlock (jm); + return result; +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_details_t *sw_if_details; + u32 sw_if_index; + jstring ifname = NULL; + + vppjni_lock (jm, 8); + + sw_if_index = swIfIndex; + + if (sw_if_index >= vec_len(jm->sw_if_table)) { + goto out; + } + sw_if_details = &jm->sw_if_table[sw_if_index]; + if (!sw_if_details->valid) { + goto out; + } + + u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); + ifname = (*env)->NewStringUTF(env, (char *)s); + +out: + vppjni_unlock (jm); + + return ifname; +} + +JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0 +(JNIEnv * env, jobject obj) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 21); + + vec_reset_length(jm->sw_if_table); + + vppjni_unlock (jm); +} + +static jobjectArray sw_if_dump_get_interfaces (); + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0 +(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter) +{ + vppjni_main_t *jm = &vppjni_main; + f64 timeout; + vl_api_sw_interface_dump_t * mp; + u32 my_context_id; + int rv; + rv = vppjni_sanity_check (jm); + if (rv) { + clib_warning("swInterfaceDump sanity_check rv = %d", rv); + return NULL; + } + + vppjni_lock (jm, 7); + my_context_id = vppjni_get_context_id (jm); + jsize cnt = (*env)->GetArrayLength (env, name_filter); + + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->name_filter_valid = name_filter_valid; + + if (cnt > sizeof(mp->name_filter)) + cnt = sizeof(mp->name_filter); + + (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter); + + DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt); + + jm->collect_indices = 1; + + S; + { + // now send control ping so we know when it ends + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + mp->context = clib_host_to_net_u32 (my_context_id); + + S; + } + vppjni_unlock (jm); + WNR; + + vppjni_lock (jm, 7); + jobjectArray result = sw_if_dump_get_interfaces(env); + vppjni_unlock (jm); + return result; +} + +static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_details_t *sw_if_details; + u32 i; + + int len = vec_len(jm->sw_if_dump_if_indices); + + jobjectArray ifArray = vppInterfaceDetailsArray(env, len); + + for (i = 0; i < len; i++) { + u32 sw_if_index = jm->sw_if_dump_if_indices[i]; + ASSERT(sw_if_index < vec_len(jm->sw_if_table)); + sw_if_details = &jm->sw_if_table[sw_if_index]; + ASSERT(sw_if_details->valid); + + u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); + + jstring ifname = (*env)->NewStringUTF(env, (char *)s); + jint ifIndex = sw_if_details->sw_if_index; + jint supIfIndex = sw_if_details->sup_sw_if_index; + jbyteArray physAddr = (*env)->NewByteArray(env, + sw_if_details->l2_address_length); + (*env)->SetByteArrayRegion(env, physAddr, 0, + sw_if_details->l2_address_length, + (signed char*)sw_if_details->l2_address); + jint subId = sw_if_details->sub_id; + jint subOuterVlanId = sw_if_details->sub_outer_vlan_id; + jint subInnerVlanId = sw_if_details->sub_inner_vlan_id; + jint vtrOp = sw_if_details->vtr_op; + jint vtrPushDot1q = sw_if_details->vtr_push_dot1q; + jint vtrTag1 = sw_if_details->vtr_tag1; + jint vtrTag2 = sw_if_details->vtr_tag2; + jint linkMtu = sw_if_details->link_mtu; + + jbyte adminUpDown = sw_if_details->admin_up_down; + jbyte linkUpDown = sw_if_details->link_up_down; + jbyte linkDuplex = sw_if_details->link_duplex; + jbyte linkSpeed = sw_if_details->link_speed; + jbyte subDot1ad = sw_if_details->sub_dot1ad; + jbyte subNumberOfTags = sw_if_details->sub_number_of_tags; + jbyte subExactMatch = sw_if_details->sub_exact_match; + jbyte subDefault = sw_if_details->sub_default; + jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any; + jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any; + + jobject ifObj = vppInterfaceDetailsObject(env, + ifIndex, ifname, + supIfIndex, physAddr, adminUpDown, linkUpDown, + linkDuplex, linkSpeed, subId, subDot1ad, + subNumberOfTags, subOuterVlanId, subInnerVlanId, + subExactMatch, subDefault, subOuterVlanIdAny, + subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu); + (*env)->SetObjectArrayElement(env, ifArray, i, ifObj); + } + + jm->collect_indices = 0; + vec_reset_length(jm->sw_if_dump_if_indices); + return ifArray; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0 + (JNIEnv * env, jobject obj, jstring bridgeDomain) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); + if (bdName) { + static u8 * bd_name = 0; + + vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); + (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); + + vppjni_lock (jm, 6); + rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name); + vppjni_unlock (jm); + + _vec_len(bd_name) = 0; + } + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0 + (JNIEnv * env, jobject obj, jstring bridgeDomain) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); + if (bdName) { + static u8 * bd_name = 0; + + vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); + (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); + + vppjni_lock (jm, 20); + rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name); + vppjni_unlock (jm); + + _vec_len(bd_name) = 0; + } + + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0 + (JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t * jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 sw_if_index; + jint rv = -1; + const char * if_name; + uword * p; + + if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + + vppjni_lock (jm, 14); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + + if (p != 0) { + sw_if_index = (jint) p[0]; + p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index); + if (p != 0) { + rv = (jint) p[0]; + } + } + + vppjni_unlock (jm); + + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + + return rv; +} + +/* + * Special-case: build the interface table, maintain + * the next loopback sw_if_index vbl. + */ +static void vl_api_sw_interface_details_t_handler +(vl_api_sw_interface_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + static sw_interface_details_t empty_sw_if_details = {0,}; + sw_interface_details_t *sw_if_details; + u32 sw_if_index; + + vppjni_lock (jm, 1); + + sw_if_index = ntohl (mp->sw_if_index); + + u8 * s = format (0, "%s%c", mp->interface_name, 0); + + if (jm->collect_indices) { + u32 pos = vec_len(jm->sw_if_dump_if_indices); + vec_validate(jm->sw_if_dump_if_indices, pos); + jm->sw_if_dump_if_indices[pos] = sw_if_index; + } + + vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details); + sw_if_details = &jm->sw_if_table[sw_if_index]; + sw_if_details->valid = 1; + + snprintf((char *)sw_if_details->interface_name, + sizeof(sw_if_details->interface_name), "%s", (char *)s); + sw_if_details->sw_if_index = sw_if_index; + sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index); + sw_if_details->l2_address_length = ntohl (mp->l2_address_length); + ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address)); + memcpy(sw_if_details->l2_address, mp->l2_address, + sw_if_details->l2_address_length); + sw_if_details->sub_id = ntohl (mp->sub_id); + sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id); + sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id); + sw_if_details->vtr_op = ntohl (mp->vtr_op); + sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q); + sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1); + sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2); + + sw_if_details->admin_up_down = mp->admin_up_down; + sw_if_details->link_up_down = mp->link_up_down; + sw_if_details->link_duplex = mp->link_duplex; + sw_if_details->link_speed = mp->link_speed; + sw_if_details->sub_dot1ad = mp->sub_dot1ad; + sw_if_details->sub_number_of_tags = mp->sub_number_of_tags; + sw_if_details->sub_exact_match = mp->sub_exact_match; + sw_if_details->sub_default = mp->sub_default; + sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; + sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; + + hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index); + DEBUG_LOG ("Got interface %s", (char *)s); + + /* In sub interface case, fill the sub interface table entry */ + if (mp->sw_if_index != mp->sup_sw_if_index) { + sw_interface_subif_t * sub = NULL; + + vec_add2(jm->sw_if_subif_table, sub, 1); + + vec_validate(sub->interface_name, strlen((char *)s) + 1); + strncpy((char *)sub->interface_name, (char *)s, + vec_len(sub->interface_name)); + sub->sw_if_index = ntohl(mp->sw_if_index); + sub->sub_id = ntohl(mp->sub_id); + + sub->sub_dot1ad = mp->sub_dot1ad; + sub->sub_number_of_tags = mp->sub_number_of_tags; + sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id); + sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id); + sub->sub_exact_match = mp->sub_exact_match; + sub->sub_default = mp->sub_default; + sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; + sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; + + /* vlan tag rewrite */ + sub->vtr_op = ntohl(mp->vtr_op); + sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q); + sub->vtr_tag1 = ntohl(mp->vtr_tag1); + sub->vtr_tag2 = ntohl(mp->vtr_tag2); + } + vppjni_unlock (jm); +} + +static void vl_api_sw_interface_set_flags_t_handler +(vl_api_sw_interface_set_flags_t * mp) +{ + /* $$$ nothing for the moment */ +} + +static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 *buf = NULL; + u32 i; + + if (bd_id != ~0) { + vec_add1(buf, bd_id); + } else { + for (i = 0; i < vec_len(bdm->bd_oper); i++) { + u32 bd_id = bdm->bd_oper[i].bd_id; + vec_add1(buf, bd_id); + } + } + + jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf)); + if (!bdidArray) { + goto out; + } + + (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf); + +out: + vec_free(buf); + return bdidArray; +} + +static void bridge_domain_oper_free(void) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t *bdm = &jm->vjbd_main; + u32 i; + + for (i = 0; i < vec_len(bdm->bd_oper); i++) { + vec_free(bdm->bd_oper->l2fib_oper); + } + vec_reset_length(bdm->bd_oper); + hash_free(bdm->bd_id_by_sw_if_index); + hash_free(bdm->oper_bd_index_by_bd_id); +} + +JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0 +(JNIEnv * env, jobject obj, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_bridge_domain_dump_t * mp; + u32 my_context_id; + f64 timeout; + int rv; + rv = vppjni_sanity_check (jm); + if (rv) return NULL; + + vppjni_lock (jm, 15); + + if (~0 == bd_id) { + bridge_domain_oper_free(); + } + + my_context_id = vppjni_get_context_id (jm); + M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->bd_id = clib_host_to_net_u32(bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + return NULL; + } + + jintArray ret = create_array_of_bd_ids(env, bd_id); + + vppjni_unlock (jm); + + return ret; +} + +static void +vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vjbd_oper_t * bd_oper; + u32 bd_id, bd_index; + + bd_id = ntohl (mp->bd_id); + + bd_index = vec_len(bdm->bd_oper); + vec_validate (bdm->bd_oper, bd_index); + bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index); + + hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index); + + bd_oper->bd_id = bd_id; + bd_oper->flood = mp->flood != 0; + bd_oper->forward = mp->forward != 0; + bd_oper->learn = mp->learn != 0; + bd_oper->uu_flood = mp->uu_flood != 0; + bd_oper->arp_term = mp->arp_term != 0; + bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index); + bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs); + + bd_oper->bd_sw_if_oper = 0; +} + +static void +vl_api_bridge_domain_sw_if_details_t_handler +(vl_api_bridge_domain_sw_if_details_t * mp) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + bd_sw_if_oper_t * bd_sw_if_oper; + u32 bd_id, sw_if_index; + + bd_id = ntohl (mp->bd_id); + sw_if_index = ntohl (mp->sw_if_index); + + uword *p; + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id); + return; + } + u32 oper_bd_index = (jint) p[0]; + vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + + u32 len = vec_len(bd_oper->bd_sw_if_oper); + vec_validate(bd_oper->bd_sw_if_oper, len); + bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len]; + bd_sw_if_oper->bd_id = bd_id; + bd_sw_if_oper->sw_if_index = sw_if_index; + bd_sw_if_oper->shg = mp->shg; + + hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id); +} + +static const char* interface_name_from_sw_if_index(u32 sw_if_index) +{ + vppjni_main_t *jm = &vppjni_main; + + if (sw_if_index >= vec_len(jm->sw_if_table)) { + return NULL; + } + if (!jm->sw_if_table[sw_if_index].valid) { + return NULL; + } + return (const char*)jm->sw_if_table[sw_if_index].interface_name; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0 +(JNIEnv * env, jobject obj, jint bdId) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 oper_bd_index; + u32 bd_id = bdId; + jobject rv = NULL; + uword *p; + + vppjni_lock (jm, 16); + + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + rv = NULL; + goto out; + } + oper_bd_index = (jint) p[0]; + + vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + + + /* setting BridgeDomainDetails */ + + jobject bddObj = vppBridgeDomainDetailsObject(env); + + u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id); + if (NULL == vec_bd_name) { + rv = NULL; + goto out; + } + char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0); + vec_free(vec_bd_name); + jstring bdName = (*env)->NewStringUTF(env, str_bd_name); + vec_free(str_bd_name); + if (NULL == bdName) { + rv = NULL; + goto out; + } + + set_vppBridgeDomainDetails_name(env, bddObj, bdName); + set_vppBridgeDomainDetails_bdId(env, bddObj, bdId); + set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood); + set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood); + set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward); + set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn); + set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term); + + jstring bviInterfaceName = NULL; + if (~0 != bd_oper->bvi_sw_if_index) { + const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index); + if (NULL == str_if_name) { + clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index); + rv = NULL; + goto out; + } + bviInterfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == bviInterfaceName) { + rv = NULL; + goto out; + } + } + + set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName); + + /* setting BridgeDomainInterfaceDetails */ + + u32 len = vec_len(bd_oper->bd_sw_if_oper); + ASSERT(len == bd_oper->n_sw_ifs); + + jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len); + + u32 i; + for (i = 0; i < len; i++) { + bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i]; + + jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env); + (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj); + + u32 sw_if_index = sw_if_oper->sw_if_index; + const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); + if (NULL == str_if_name) { + rv = NULL; + goto out; + } + jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == interfaceName) { + rv = NULL; + goto out; + } + + set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName); + set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg); + } + + set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray); + + rv = bddObj; + +out: + + vppjni_unlock (jm); + + return rv; +} + +static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib) +{ + u32 sw_if_index = l2_fib->sw_if_index; + const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); + if (NULL == str_if_name) { + return NULL; + } + jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == interfaceName) { + return NULL; + } + + jbyteArray physAddr = (*env)->NewByteArray(env, 6); + (*env)->SetByteArrayRegion(env, physAddr, 0, 6, + (signed char*)l2_fib->mac_addr.fields.mac); + jboolean staticConfig = !l2_fib->learned; + jstring outgoingInterface = interfaceName; + jboolean filter = l2_fib->filter; + jboolean bridgedVirtualInterface = l2_fib->bvi; + + return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface); +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0 +(JNIEnv * env, jobject obj, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vl_api_l2_fib_table_dump_t *mp; + jobjectArray l2FibArray = NULL; + vjbd_oper_t *bd_oper; + u32 oper_bd_index; + uword *p; + f64 timeout; + int rv; + u32 i; + + vppjni_lock (jm, 17); + + //vjbd_l2fib_oper_reset (bdm); + + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + goto done; + } + oper_bd_index = p[0]; + bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + vec_reset_length (bd_oper->l2fib_oper); + + /* Get list of l2 fib table entries */ + M(L2_FIB_TABLE_DUMP, l2_fib_table_dump); + mp->bd_id = ntohl(bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + goto done; + } + + u32 count = vec_len(bd_oper->l2fib_oper); + bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper; + + l2FibArray = vppL2FibArray(env, count); + for (i = 0; i < count; i++) { + bd_l2fib_oper_t *l2_fib = &l2fib_oper[i]; + jobject l2FibObj = l2_fib_create_object(env, l2_fib); + (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj); + } + +done: + vppjni_unlock (jm); + + return l2FibArray; +} + +static void +vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp) +{ + //static u8 * mac_addr; + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vjbd_oper_t * bd_oper; + u32 bd_id, oper_bd_index; + //uword mhash_val_l2fi; + bd_l2fib_oper_t * l2fib_oper; + l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac; + + bd_id = ntohl (mp->bd_id); + + uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + return; + } + oper_bd_index = (jint) p[0]; + bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + +#if 0 + vec_validate (mac_addr, MAC_ADDRESS_SIZE); + memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE); + mhash_val_l2fi = vec_len (bd_oper->l2fib_oper); + if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0) + mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); + mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0); +#endif + + vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1); + + l2fib_oper->bd_id = bd_id; + l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac); + l2fib_oper->sw_if_index = ntohl (mp->sw_if_index); + l2fib_oper->learned = !mp->static_mac; + l2fib_oper->filter = mp->filter_mac; + l2fib_oper->bvi = mp->bvi_mac; +} + +static int ipAddressDump +(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_ip_address_dump_t * mp; + const char *if_name; + u32 my_context_id; + u32 sw_if_index; + f64 timeout; + uword *p; + int rv = 0; + + if (NULL == interfaceName) { + return -1; + } + + if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + if (!if_name) { + return -1; + } + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + if (p == 0) { + return -1; + } + sw_if_index = (u32) p[0]; + + rv = vppjni_sanity_check (jm); + if (0 != rv) { + return rv; + } + + my_context_id = vppjni_get_context_id (jm); + M(IP_ADDRESS_DUMP, ip_address_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->sw_if_index = clib_host_to_net_u32(sw_if_index); + mp->is_ipv6 = isIPv6; + jm->is_ipv6 = isIPv6; + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + + return rv; +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0 +(JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t *jm = &vppjni_main; + jobject returnArray = NULL; + int i; + + vppjni_lock (jm, 18); + + vec_reset_length(jm->ipv4_addresses); + + if (0 != ipAddressDump(env, obj, interfaceName, 0)) { + goto done; + } + + u32 count = vec_len(jm->ipv4_addresses); + ipv4_address_t *ipv4_address = jm->ipv4_addresses; + + jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count); + + for (i = 0; i < count; i++) { + ipv4_address_t *address = &ipv4_address[i]; + + jint ip = address->ip; + jbyte prefixLength = address->prefix_length; + + jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength); + + (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj); + } + + returnArray = ipv4AddressArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0 +(JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t *jm = &vppjni_main; + jobject returnArray = NULL; + int i; + + vppjni_lock (jm, 19); + + vec_reset_length(jm->ipv6_addresses); + + if (0 != ipAddressDump(env, obj, interfaceName, 1)) { + goto done; + } + + u32 count = vec_len(jm->ipv6_addresses); + ipv6_address_t *ipv6_address = jm->ipv6_addresses; + + jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count); + + for (i = 0; i < count; i++) { + ipv6_address_t *address = &ipv6_address[i]; + + jbyteArray ip = (*env)->NewByteArray(env, 16); + (*env)->SetByteArrayRegion(env, ip, 0, 16, + (signed char*)address->ip); + + jbyte prefixLength = address->prefix_length; + + jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength); + + (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj); + } + + returnArray = ipv6AddressArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + + if (!jm->is_ipv6) { + ipv4_address_t *address = 0; + vec_add2(jm->ipv4_addresses, address, 1); + memcpy(&address->ip, mp->ip, 4); + address->prefix_length = mp->prefix_length; + } else { + ipv6_address_t *address = 0; + vec_add2(jm->ipv6_addresses, address, 1); + memcpy(address->ip, mp->ip, 16); + address->prefix_length = mp->prefix_length; + } +} + +#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel" + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_vxlan_tunnel_dump_t * mp; + jobjectArray returnArray = NULL; + u32 my_context_id; + f64 timeout; + int rv = 0; + int i; + + vppjni_lock (jm, 22); + + vec_reset_length(jm->vxlan_tunnel_details); + + my_context_id = vppjni_get_context_id (jm); + M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->sw_if_index = clib_host_to_net_u32 (swIfIndex); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + goto done; + } + + u32 count = vec_len(jm->vxlan_tunnel_details); + + jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count); + + for (i = 0; i < count; i++) { + vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i]; + + jint src_address = details->src_address; + jint dst_address = details->dst_address; + jint encap_vrf_id = details->encap_vrf_id; + jint vni = details->vni; + jint decap_next_index = details->decap_next_index; + + jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env, + src_address, dst_address, encap_vrf_id, vni, decap_next_index); + + (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i, + vxlanTunnelDetailsObj); + } + + returnArray = vxlanTunnelDetailsArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +static void vl_api_vxlan_tunnel_details_t_handler +(vl_api_vxlan_tunnel_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + vxlan_tunnel_details_t *tunnel_details; + + vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1); + tunnel_details->src_address = ntohl(mp->src_address); + tunnel_details->dst_address = ntohl(mp->dst_address); + tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id); + tunnel_details->vni = ntohl(mp->vni); + tunnel_details->decap_next_index = ntohl(mp->decap_next_index); +} + +/* cleanup handler for RX thread */ +static void cleanup_rx_thread(void *arg) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 99); + + int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); + if (getEnvStat == JNI_EVERSION) { + clib_warning ("Unsupported JNI version\n"); + jm->retval = -999; + goto out; + } else if (getEnvStat != JNI_EDETACHED) { + (*jm->jvm)->DetachCurrentThread(jm->jvm); + } +out: + vppjni_unlock (jm); +} + +static void +vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + i32 retval = ntohl(mp->retval); + + if (retval >= 0) { + DEBUG_LOG ("show version request succeeded(%d)"); + strncpy((char*)jm->program_name, (const char*)mp->program, + sizeof(jm->program_name)-1); + jm->program_name[sizeof(jm->program_name)-1] = 0; + + strncpy((char*)jm->build_directory, (const char*)mp->build_directory, + sizeof(jm->build_directory)-1); + jm->build_directory[sizeof(jm->build_directory)-1] = 0; + + strncpy((char*)jm->version, (const char*)mp->version, + sizeof(jm->version)-1); + jm->version[sizeof(jm->version)-1] = 0; + + strncpy((char*)jm->build_date, (const char*)mp->build_date, + sizeof(jm->build_date)-1); + jm->build_date[sizeof(jm->build_date)-1] = 0; + } else { + clib_error ("show version request failed(%d)", retval); + } + jm->retval = retval; + jm->result_ready = 1; +} + +static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval + jm->result_ready = 1; +} + +// control ping needs to be very first thing called +// to attach rx thread to java thread +static void vl_api_control_ping_reply_t_handler +(vl_api_control_ping_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + i32 retval = ntohl(mp->retval); + jm->retval = retval; + + // attach to java thread if not attached + int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); + if (getEnvStat == JNI_EDETACHED) { + if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) { + clib_warning("Failed to attach thread\n"); + jm->retval = -999; + goto out; + } + + // workaround as we can't use pthread_cleanup_push + pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread); + // destructor is only called if the value of key is non null + pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1); + } else if (getEnvStat == JNI_EVERSION) { + clib_warning ("Unsupported JNI version\n"); + jm->retval = -999; + goto out; + } + // jm->jenv is now stable global reference that can be reused (only within RX thread) + +#if 0 + // ! callback system removed for now + // + // get issuer msg-id + p = hash_get (jm->ping_hash, context); + if (p != 0) { // ping marks end of some dump call + JNIEnv *env = jm->jenv; + u16 msg_id = (u16)p[0]; + + // we will no longer need this + hash_unset (jm->ping_hash, context); + + // get original caller obj + p = hash_get (jm->callback_hash, context); + + if (p == 0) // don't have callback stored + goto out; + + jobject obj = (jobject)p[0]; // object that called original call + + switch (msg_id) { + case VL_API_SW_INTERFACE_DUMP: + if (0 != sw_if_dump_call_all_callbacks(obj)) { + goto out2; + } + break; + default: + clib_warning("Unhandled control ping issuer msg-id: %d", msg_id); + goto out2; + break; + } +out2: + // free the saved obj + hash_unset (jm->callback_hash, context); + // delete global reference + (*env)->DeleteGlobalRef(env, obj); + } +#endif + +out: + jm->result_ready = 1; +} + +#define VPPJNI_DEBUG_COUNTERS 0 + +static void vl_api_vnet_interface_counters_t_handler +(vl_api_vnet_interface_counters_t *mp) +{ + vppjni_main_t *jm = &vppjni_main; + CLIB_UNUSED(char *counter_name); + u32 count, sw_if_index; + int i; + static sw_interface_stats_t empty_stats = {0, }; + + vppjni_lock (jm, 12); + count = ntohl (mp->count); + sw_if_index = ntohl (mp->first_sw_if_index); + if (mp->is_combined == 0) { + u64 * vp, v; + vp = (u64 *) mp->data; + + for (i = 0; i < count; i++) { + sw_interface_details_t *sw_if = NULL; + + v = clib_mem_unaligned (vp, u64); + v = clib_net_to_host_u64 (v); + vp++; + + if (sw_if_index < vec_len(jm->sw_if_table)) + sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); + + if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) { + vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); + sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); + + s->sw_if_index = sw_if_index; + s->valid = 1; + + switch (mp->vnet_counter_type) { + case VNET_INTERFACE_COUNTER_DROP: + counter_name = "drop"; + s->rx.pkts.discard = v; + break; + case VNET_INTERFACE_COUNTER_PUNT: + counter_name = "punt"; + s->rx.pkts.unknown_proto = v; + break; + case VNET_INTERFACE_COUNTER_IP4: + counter_name = "ip4"; + s->rx.pkts.ip4 = v; + break; + case VNET_INTERFACE_COUNTER_IP6: + counter_name = "ip6"; + s->rx.pkts.ip6 = v; + break; + case VNET_INTERFACE_COUNTER_RX_NO_BUF: + counter_name = "rx-no-buf"; + s->rx.pkts.fifo_full = v; + break; + case VNET_INTERFACE_COUNTER_RX_MISS: + counter_name = "rx-miss"; + s->rx.pkts.miss = v; + break; + case VNET_INTERFACE_COUNTER_RX_ERROR: + counter_name = "rx-error"; + s->rx.pkts.error = v; + break; + case VNET_INTERFACE_COUNTER_TX_ERROR: + counter_name = "tx-error (fifo-full)"; + s->tx.pkts.fifo_full = v; + break; + default: + counter_name = "bogus"; + break; + } + +#if VPPJNI_DEBUG_COUNTERS == 1 + clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index, + counter_name, v); +#endif + } + sw_if_index++; + } + } else { + vlib_counter_t *vp; + u64 packets, bytes; + vp = (vlib_counter_t *) mp->data; + + for (i = 0; i < count; i++) { + sw_interface_details_t *sw_if = NULL; + + packets = clib_mem_unaligned (&vp->packets, u64); + packets = clib_net_to_host_u64 (packets); + bytes = clib_mem_unaligned (&vp->bytes, u64); + bytes = clib_net_to_host_u64 (bytes); + vp++; + + if (sw_if_index < vec_len(jm->sw_if_table)) + sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); + + if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) { + vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); + sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); + + s->valid = 1; + s->sw_if_index = sw_if_index; + + switch (mp->vnet_counter_type) { + case VNET_INTERFACE_COUNTER_RX: + s->rx.pkts.unicast = packets; + s->rx.octets = bytes; + counter_name = "rx"; + break; + + case VNET_INTERFACE_COUNTER_TX: + s->tx.pkts.unicast = packets; + s->tx.octets = bytes; + counter_name = "tx"; + break; + + default: + counter_name = "bogus"; + break; + } + +#if VPPJNI_DEBUG_COUNTERS == 1 + clib_warning ("%s (%d): %s.packets %lld\n", + sw_if->interface_name, + sw_if_index, counter_name, packets); + clib_warning ("%s (%d): %s.bytes %lld\n", + sw_if->interface_name, + sw_if_index, counter_name, bytes); +#endif + } + sw_if_index++; + } + } + vppjni_unlock (jm); +} + +jint JNI_OnLoad(JavaVM *vm, void *reserved) { + vppjni_main_t * jm = &vppjni_main; + JNIEnv* env; + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + + if (vppjni_init(env) != 0) { + return JNI_ERR; + } + + jm->jvm = vm; + return JNI_VERSION_1_6; +} + +void JNI_OnUnload(JavaVM *vm, void *reserved) { + vppjni_main_t * jm = &vppjni_main; + JNIEnv* env; + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { + return; + } + + vppjni_uninit(env); + + jm->jenv = NULL; + jm->jvm = NULL; +} + +#define foreach_vpe_api_msg \ +_(CONTROL_PING_REPLY, control_ping_reply) \ +_(SW_INTERFACE_DETAILS, sw_interface_details) \ +_(SHOW_VERSION_REPLY, show_version_reply) \ +_(WANT_STATS_REPLY, want_stats_reply) \ +_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \ +_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ +_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \ +_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \ +_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ +_(IP_ADDRESS_DETAILS, ip_address_details) \ +_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) + +static int connect_to_vpe(char *name) +{ + vppjni_main_t * jm = &vppjni_main; + api_main_t * am = &api_main; + + if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0) + return -1; + + jm->my_client_index = am->my_client_index; + jm->vl_input_queue = am->shmem_hdr->vl_input_queue; + +#define _(N,n) \ + vl_msg_api_set_handlers(VL_API_##N, #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_vpe_api_msg; +#undef _ + + return 0; +} + +/* Format an IP6 address. */ +u8 * format_ip6_address (u8 * s, va_list * args) +{ + ip6_address_t * a = va_arg (*args, ip6_address_t *); + u32 max_zero_run = 0, this_zero_run = 0; + int max_zero_run_index = -1, this_zero_run_index=0; + int in_zero_run = 0, i; + int last_double_colon = 0; + + /* Ugh, this is a pain. Scan forward looking for runs of 0's */ + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { + if (a->as_u16[i] == 0) { + if (in_zero_run) { + this_zero_run++; + } else { + in_zero_run = 1; + this_zero_run =1; + this_zero_run_index = i; + } + } else { + if (in_zero_run) { + /* offer to compress the biggest run of > 1 zero */ + if (this_zero_run > max_zero_run && this_zero_run > 1) { + max_zero_run_index = this_zero_run_index; + max_zero_run = this_zero_run; + } + } + in_zero_run = 0; + this_zero_run = 0; + } + } + + if (in_zero_run) { + if (this_zero_run > max_zero_run && this_zero_run > 1) { + max_zero_run_index = this_zero_run_index; + max_zero_run = this_zero_run; + } + } + + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { + if (i == max_zero_run_index) { + s = format (s, "::"); + i += max_zero_run - 1; + last_double_colon = 1; + } else { + s = format (s, "%s%x", + (last_double_colon || i == 0) ? "" : ":", + clib_net_to_host_u16 (a->as_u16[i])); + last_double_colon = 0; + } + } + + return s; +} + +/* Format an IP4 address. */ +u8 * format_ip4_address (u8 * s, va_list * args) +{ + u8 * a = va_arg (*args, u8 *); + return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); +} + + diff --git a/vpp-api/java/japi/vppjni.h b/vpp-api/java/japi/vppjni.h new file mode 100644 index 00000000..bd0683ae --- /dev/null +++ b/vpp-api/java/japi/vppjni.h @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_vppjni_h__ +#define __included_vppjni_h__ + +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + u8 * name; + u32 value; +} name_sort_t; + +typedef struct { + u8 valid; // used in a vector of sw_interface_details_t + + u8 interface_name[64]; + u32 sw_if_index; + u32 sup_sw_if_index; + u32 l2_address_length; + u8 l2_address[8]; + u8 admin_up_down; + u8 link_up_down; + u8 link_duplex; + u8 link_speed; + u16 link_mtu; + u32 sub_id; + u8 sub_dot1ad; + u8 sub_number_of_tags; + u16 sub_outer_vlan_id; + u16 sub_inner_vlan_id; + u8 sub_exact_match; + u8 sub_default; + u8 sub_outer_vlan_id_any; + u8 sub_inner_vlan_id_any; + u32 vtr_op; + u32 vtr_push_dot1q; + u32 vtr_tag1; + u32 vtr_tag2; +} sw_interface_details_t; + +typedef struct { + u8 * interface_name; + u32 sw_if_index; + /* + * Subinterface ID. A number 0-N to uniquely identify + * this subinterface under the super interface + */ + u32 sub_id; + + /* 0 = dot1q, 1=dot1ad */ + u8 sub_dot1ad; + + /* Number of tags 0-2 */ + u8 sub_number_of_tags; + u16 sub_outer_vlan_id; + u16 sub_inner_vlan_id; + u8 sub_exact_match; + u8 sub_default; + u8 sub_outer_vlan_id_any; + u8 sub_inner_vlan_id_any; + + /* vlan tag rewrite */ + u32 vtr_op; + u32 vtr_push_dot1q; + u32 vtr_tag1; + u32 vtr_tag2; +} sw_interface_subif_t; + +typedef struct { + u8 *desc; +} sw_if_config_t; + +typedef struct { + u32 ip; + u8 prefix_length; +} ipv4_address_t; + +typedef struct { + u8 ip[16]; + u8 prefix_length; +} ipv6_address_t; + +typedef struct { + u64 ip4; + u64 ip6; + u64 unicast; + u64 multicast; + u64 broadcast; + u64 discard; + u64 fifo_full; + u64 error; + u64 unknown_proto; + u64 miss; +} packet_counters_t; + +typedef struct { + u64 octets; + packet_counters_t pkts; +} if_counters_t; + +typedef struct { + u8 valid; + u32 sw_if_index; + if_counters_t rx; + if_counters_t tx; +} sw_interface_stats_t; + +typedef struct { + u32 src_address; + u32 dst_address; + u32 encap_vrf_id; + u32 vni; + u32 decap_next_index; +} vxlan_tunnel_details_t; + + +typedef struct { + /* Context IDs */ + volatile u32 context_id_sent; + volatile u32 context_id_received; + + /* Spinlock */ + volatile u32 lock; + u32 tag; + + /* To recycle pseudo-synchronous message code from vpp_api_test... */ + volatile u32 result_ready; + volatile i32 retval; + volatile u8 *shmem_result; + + /* thread cleanup */ + pthread_key_t cleanup_rx_thread_key; + /* attachment of rx thread to java thread */ + JNIEnv *jenv; + JavaVM *jvm; + uword *callback_hash; // map context_id => jobject + uword *ping_hash; // map ping context_id => msg type called + + /* Timestamp */ + clib_time_t clib_time; + + /* connected indication */ + u8 is_connected; + + /* context -> non-trivial reply hash */ + uword * reply_hash; + u32 saved_reply_count; + + /* interface name map */ + uword * sw_if_index_by_interface_name; + + /* interface counters */ + sw_interface_stats_t * sw_if_stats_by_sw_if_index; + + /* interface table */ + sw_interface_details_t * sw_if_table; + + uword * sw_if_config_by_sw_if_index; + + /* interface indices of responses to one sw_if_dump request */ + u8 collect_indices; + u32 * sw_if_dump_if_indices; + + /* program name, build_dir, version */ + u8 program_name[32]; + u8 build_directory[256]; + u8 version[32]; + u8 build_date[32]; + + /* subinterface table */ + sw_interface_subif_t * sw_if_subif_table; + + /* used in ip_address_dump request and response handling */ + ipv4_address_t *ipv4_addresses; + ipv6_address_t *ipv6_addresses; + u8 is_ipv6; + + /* used in vxlan_tunnel_dump request and response handling */ + vxlan_tunnel_details_t *vxlan_tunnel_details; + + /* main heap */ + u8 * heap; + + /* convenience */ + unix_shared_memory_queue_t * vl_input_queue; + api_main_t * api_main; + u32 my_client_index; + + vjbd_main_t vjbd_main; +} vppjni_main_t; + +vppjni_main_t vppjni_main __attribute__((aligned (64))); + + +static inline u32 vppjni_get_context_id (vppjni_main_t * jm) +{ + u32 my_context_id; + my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1); + return my_context_id; +} + +static inline void vppjni_lock (vppjni_main_t * jm, u32 tag) +{ + while (__sync_lock_test_and_set (&jm->lock, 1)) + ; + jm->tag = tag; +} + +static inline void vppjni_unlock (vppjni_main_t * jm) +{ + jm->tag = 0; + CLIB_MEMORY_BARRIER(); + jm->lock = 0; +} + +static inline f64 vppjni_time_now (vppjni_main_t *jm) +{ + return clib_time_now (&jm->clib_time); +} + +static inline int vppjni_sanity_check (vppjni_main_t * jm) +{ + if (!jm->is_connected) + return VNET_API_ERROR_NOT_CONNECTED; + return 0; +} + +#define __PACKED(x) x __attribute__((packed)) + +typedef __PACKED(struct _vl_api_generic_reply { + u16 _vl_msg_id; + u32 context; + i32 retval; + u8 data[0]; +}) vl_api_generic_reply_t; + +void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp); + +/* M: construct, but don't yet send a message */ + +#define M(T,t) \ +do { \ + jm->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = jm->my_client_index; \ + } while(0); + +#define M2(T,t,n) \ +do { \ + jm->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = jm->my_client_index; \ + } while(0); + + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ + do { \ + timeout = vppjni_time_now (jm) + 1.0; \ + \ + while (vppjni_time_now (jm) < timeout) { \ + if (jm->result_ready == 1) { \ + return (jm->retval); \ + } \ + } \ + return -99; \ +} while(0); + +/* WNR: wait for results, with timeout (without returning) */ +#define WNR \ + do { \ + timeout = vppjni_time_now (jm) + 1.0; \ + \ + rv = -99; \ + while (vppjni_time_now (jm) < timeout) { \ + if (jm->result_ready == 1) { \ + rv = (jm->retval); \ + break; \ + } \ + } \ +} while(0); + +#endif /* __included_vppjni_h__ */ diff --git a/vpp-api/java/japi/vppjni_bridge_domain.h b/vpp-api/java/japi/vppjni_bridge_domain.h new file mode 100644 index 00000000..b614a5be --- /dev/null +++ b/vpp-api/java/japi/vppjni_bridge_domain.h @@ -0,0 +1,510 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2009-2014 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------- + */ + +#ifndef __included_vppjni_bridge_domain_h__ +#define __included_vppjni_bridge_domain_h__ + +#include +#include +#include + +/* + * The L2fib key is the mac address and bridge domain ID + */ +#define MAC_ADDRESS_SIZE 6 + +typedef struct { + union { + struct { + u16 unused1; + u8 mac[MAC_ADDRESS_SIZE]; + } fields; + u64 raw; + }; +} l2fib_u64_mac_t; + +/* + * The l2fib entry results + */ +typedef struct { + u32 bd_id; + l2fib_u64_mac_t mac_addr; + u32 sw_if_index; + u8 learned:1; + u8 bvi:1; + u8 filter:1; // drop packets to/from this mac + u8 unused1:5; +} bd_l2fib_oper_t; + +typedef struct { + u32 bd_id; + u8 * bd_name; +} bd_local_cfg_t; + +typedef struct { + u32 bd_id; + u32 sw_if_index; + u32 shg; +} bd_sw_if_oper_t; + +typedef struct { + u32 bd_id; + u8 flood:1; + u8 forward:1; + u8 learn:1; + u8 uu_flood:1; + u8 arp_term:1; + u8 unused1:3; + u32 bvi_sw_if_index; + u32 n_sw_ifs; + bd_sw_if_oper_t * bd_sw_if_oper; + f64 last_sync_time; + mhash_t l2fib_index_by_mac; + bd_l2fib_oper_t * l2fib_oper; // vector indexed by l2fib_index +} vjbd_oper_t; + +#define BD_OPER_REFRESH_INTERVAL 2.0 +#define BD_OPER_L2FIB_REFRESH_INTERVAL 5.0 + +typedef struct { + u32 next_bd_id; + uword * bd_index_bitmap; + uword * bd_index_by_id; + mhash_t bd_id_by_name; + bd_local_cfg_t * local_cfg; // vector indexed by bd_index + vjbd_oper_t * bd_oper; // vector indexed by oper_bd_index + f64 bd_oper_last_sync_all_time; + bd_sw_if_oper_t * sw_if_oper; // vector indexed by sw_if_index + f64 l2fib_oper_last_sync_time; + uword * bd_id_by_sw_if_index; + uword * oper_bd_index_by_bd_id; +} vjbd_main_t; + +extern vjbd_main_t vjbd_main; + +always_inline +u64 l2fib_mac_to_u64 (u8 * mac_address) { + u64 temp; + + // The mac address in memory is A:B:C:D:E:F + // The bd id in register is H:L +#if CLIB_ARCH_IS_LITTLE_ENDIAN + // Create the in-register key as F:E:D:C:B:A:H:L + // In memory the key is L:H:A:B:C:D:E:F + temp = *((u64 *)(mac_address - 2)); + temp = (temp & ~0xffff); +#else + // Create the in-register key as H:L:A:B:C:D:E:F + // In memory the key is H:L:A:B:C:D:E:F + temp = *((u64 *)(mac_address)) >> 16; +#endif + + return temp; +} + +static_always_inline void vjbd_main_init (vjbd_main_t *bdm) +{ + bdm->bd_index_by_id = hash_create (0, sizeof(uword)); + mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32)); + bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32)); + bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32)); +} + +static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id) +{ + return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id)); +} + +static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index) +{ + u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; + + return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) && + (bd_index < vec_len (bdm->local_cfg)) && + ((bd_id == 0) || (bd_id == ~0))); +} + +static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index) +{ + return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) && + (bd_index < vec_len (bdm->local_cfg))); +} + +static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm, + const u8 * bd_name) +{ + u32 bd_id; + uword * p; + + ASSERT (vec_c_string_is_terminated (bd_name)); + + if (bdm->next_bd_id == 0) + return ~0; + + p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name); + if (p) + { + bd_id = p[0]; + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + } + else + bd_id = ~0; + + return bd_id; +} + +static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + uword * p; + u16 bd_index; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + p = hash_get (bdm->bd_index_by_id, bd_id); + + ASSERT (p); // there is always an index associated with a valid bd_id + bd_index = p[0]; + + ASSERT (vjbd_index_is_valid (bdm, bd_index)); + + return bd_index; +} + +static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index) +{ + u32 bd_id; + + ASSERT (vjbd_index_is_valid (bdm, bd_index)); + + bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + return bd_id; +} + +static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + + return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name; +} + +static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + if (vjbd_id_is_valid (bdm, bd_id)) { + return format(0, "%s", vjbd_name_from_id(bdm, bd_id)); + } else { + return format(0, "BridgeDomainOper%d", bd_id); + } +} + +static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm, + u32 bd_id) +{ + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + return vec_elt_at_index (bdm->bd_oper, bd_index); +} + +static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm, + u32 bd_id) +{ +#ifdef VPPJNI_OPER + vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); + + if (bd_id == ~0) + { + if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) > + BD_OPER_REFRESH_INTERVAL) + { + ovam_bridge_domain_dump (bd_id); + bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam); + } + } + + else + { + vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id); + + if ((ovam_time_now (ovam) - bd_oper->last_sync_time) > + BD_OPER_REFRESH_INTERVAL) + { + ovam_bridge_domain_dump (bd_id); + + bd_oper->last_sync_time = ovam_time_now (ovam); + } + } +#endif +} + +static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm, + u32 sw_if_index) +{ + bd_sw_if_oper_t * bd_sw_if_oper; + u32 bd_id = ~0; + + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); + if (sw_if_index < vec_len (bdm->sw_if_oper)) + { + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); + bd_id = bd_sw_if_oper->bd_id; + } + + return bd_id; +} + +static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm, + u32 sw_if_index) +{ + u32 bd_id, bd_index; + u8 * bd_name = 0; + + /* DAW-FIXME: + ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index)); + */ + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); + bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index); + if (vjbd_id_is_valid (bdm, bd_id)) + { + bd_index = vjbd_index_from_id (bdm, bd_id); + bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name; + } + + return bd_name; +} + +static_always_inline u32 +vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac) +{ + u32 l2fib_index; + uword * p; + + p = mhash_get (&bd_oper->l2fib_index_by_mac, mac); + if (p) + { + l2fib_index = p[0]; + ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper)); + } + else + l2fib_index = ~0; + + return l2fib_index; +} + +static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm, + u32 bd_id) +{ + u32 i, end = vec_len (bdm->local_cfg); + u32 next_bd_id = 0; + + if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id)) + for (i = 0; i < end; i++) + { + u32 curr_bd_id = bdm->local_cfg[i].bd_id; + if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) && + ((next_bd_id == 0) || (curr_bd_id < next_bd_id))) + next_bd_id = curr_bd_id; + } + + return next_bd_id; +} + +static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm, + u32 start, u32 bd_id) +{ + u32 i, end = vec_len (bdm->sw_if_oper); + + if (vjbd_id_is_valid (bdm, bd_id)) + for (i = start; i < end; i++) + if (bdm->sw_if_oper[i].bd_id == bd_id) + return i; + + return ~0; +} + +static_always_inline void +vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm) +{ +#ifdef VPPJNI_OPER + vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); + if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) > + BD_OPER_L2FIB_REFRESH_INTERVAL) + { + ovam_l2fib_table_dump (); + bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam); + } +#endif +} + +static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm) +{ + vjbd_oper_t * bd_oper; + + vec_foreach (bd_oper, bdm->bd_oper) + { + mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); + vec_reset_length (bd_oper->l2fib_oper); + } +} + +static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index; + u32 si, len; + vjbd_oper_t * bd_oper; + u32 end; + + if (!bdm->bd_oper) + { + ASSERT (vec_len (bdm->sw_if_oper) == 0); + return; + } + + if (bd_id == ~0) + { + bdm->bd_oper_last_sync_all_time = 0.0; + bd_index = 0; + end = vec_len (bdm->bd_oper); + } + else + { + bd_index = vjbd_index_from_id (bdm, bd_id); + end = bd_index + 1; + } + + for (; bd_index < end; bd_index++) + { + bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); + bd_oper->last_sync_time = 0.0; + + len = vec_len (bdm->sw_if_oper); + for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id); + (si != ~0) && (si < len); + si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id)) + { + bd_sw_if_oper_t * bd_sw_if_oper; + + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si); + bd_sw_if_oper->bd_id = ~0; + } + } +} + +static_always_inline void +vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add) +{ + vjbd_main_t * bdm = &vjbd_main; + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); + bd_sw_if_oper_t * bd_sw_if_oper; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + /* DAW-FIXME + ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index)); + */ + + vec_validate (bdm->sw_if_oper, sw_if_index); + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); + if (is_add) + { + bd_sw_if_oper->bd_id = bd_id; + bd_sw_if_oper->shg = shg; + bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0; + } + else + { + bd_sw_if_oper->bd_id = 0; + bd_sw_if_oper->shg = 0; + if (bd_oper->bvi_sw_if_index == sw_if_index) + bd_oper->bvi_sw_if_index = ~0; + } +} + +static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id) +{ + u32 count = 0, i, end = vec_len (bdm->sw_if_oper); + + if (vjbd_id_is_valid (bdm, bd_id)) + for (count = i = 0; i < end; i++) + if (bdm->sw_if_oper[i].bd_id == bd_id) + count++; + + return count; +} + +static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name) +{ + u16 bd_index; + u32 bd_id; + bd_local_cfg_t * bd_local_cfg; + uword mhash_val_bd_id; + + bd_id = vjbd_id_from_name (bdm, bd_name); + if (bd_id != ~0) + return bd_id; + + mhash_val_bd_id = bd_id = ++bdm->next_bd_id; + mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0); + + bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap); + vec_validate (bdm->local_cfg, bd_index); + vec_validate (bdm->bd_oper, bd_index); + + ASSERT (vjbd_index_is_free (bdm, bd_index)); + + bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); + bd_local_cfg->bd_id = bd_id; + vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name, + vec_len (bd_name) - 1); + hash_set (bdm->bd_index_by_id, bd_id, bd_index); + bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, + bd_index, 1); + return bd_id; +} + +static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index; + bd_local_cfg_t * bd_local_cfg; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + // bd must not have any members before deleting + ASSERT (!vjbd_id_sw_if_count (bdm, bd_id)); + + bd_index = vjbd_index_from_id (bdm, bd_id); + bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); + vjbd_oper_reset (bdm, bd_id); + + mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0); + bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, + bd_index, 0); + hash_unset (bdm->bd_index_by_id, bd_id); + bd_local_cfg->bd_id = ~0; + vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0); + + if (clib_bitmap_is_zero (bdm->bd_index_bitmap)) + { + vec_reset_length (bdm->local_cfg); + vec_reset_length (bdm->bd_oper); + } + + /* Force a resync of all bd_oper data. */ + bdm->bd_oper_last_sync_all_time = 0.0; + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); +} + +#endif /* __included_vppjni_vpp_bridge_domain_h__ */ diff --git a/vpp-api/java/japi/vppjni_env.c b/vpp-api/java/japi/vppjni_env.c new file mode 100644 index 00000000..1c4ea6eb --- /dev/null +++ b/vpp-api/java/japi/vppjni_env.c @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include "vppjni_env.h" + +// Head of the class registration list. +static vppjni_class_t *class_head; +// Head of the class registration list. +static vppjni_field_t *field_head; + +void vppjni_register_class(vppjni_class_t *ptr) +{ + vppjni_class_t **where = &class_head; + while (*where != NULL) { + where = &((*where)->next); + } + *where = ptr; +} + +void vppjni_register_field(vppjni_field_t *ptr) { + vppjni_field_t **where = &field_head; + while (*where != NULL) { + where = &((*where)->next); + } + *where = ptr; +} + +jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) { + jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + return NULL; + } + + return obj; +} + +int vppjni_init(JNIEnv *env) +{ + vppjni_class_t *cwlk; + vppjni_field_t *fwlk; + + for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { + jclass cls; + jmethodID method; + + cls = (*env)->FindClass(env, cwlk->fqcn); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + + method = (*env)->GetMethodID(env, cls, "", cwlk->init_sig); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + + cwlk->jclass = (*env)->NewGlobalRef(env, cls); + if (cwlk->jclass == NULL) { + vppjni_uninit(env); + return JNI_ERR; + } + cwlk->jinit = method; + } + + for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { + fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + } + + return 0; +} + +void vppjni_uninit(JNIEnv *env) { + vppjni_class_t *cwlk; + vppjni_field_t *fwlk; + + for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { + fwlk->jfield = NULL; + } + + for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { + if (cwlk->jclass != NULL ) { + (*env)->DeleteGlobalRef(env, cwlk->jclass); + } + + cwlk->jclass = NULL; + cwlk->jinit = NULL; + } +} + diff --git a/vpp-api/java/japi/vppjni_env.h b/vpp-api/java/japi/vppjni_env.h new file mode 100644 index 00000000..44029c2c --- /dev/null +++ b/vpp-api/java/japi/vppjni_env.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Utilities for accessing Java classes/method/fields in an efficient + * manner. + */ + +/* + * A potentially-uninitialized reference to a Java class + */ +typedef struct vppjni_class { + // Fully-Qualified Class Name + const char *fqcn; + // Constructor signature + const char *init_sig; + // Global reference to class handle + jclass jclass; + // Constructor method handle + jmethodID jinit; + // Next item in linked list + struct vppjni_class *next; +} vppjni_class_t; + +typedef struct jenv_field { + // Field name + const char *name; + // Field type + const char *type; + // Defining class reference + const vppjni_class_t *clsref; + // Field handle + jfieldID jfield; + // Next item in linked list + struct jenv_field *next; +} vppjni_field_t; + +#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name +#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init +#define BIND_JAPI_CLASS(name, sig) \ + static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \ + static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \ + static void VPPJNI_CLASS_INIT(name)() \ + { \ + VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \ + VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \ + vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \ + } \ + static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \ + { \ + return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \ + } \ + static jobject name##Object(JNIEnv *env, ...) \ + { \ + va_list ap; \ + va_start(ap, env); \ + jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \ + va_end(ap); \ + return obj; \ + } + +#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name +#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init +#define BIND_JAPI_FIELD(cls, field, sig) \ + static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \ + static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \ + static void VPPJNI_FIELD_INIT(cls, field)() \ + { \ + VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \ + VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \ + VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \ + vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \ + } +#define BIND_JAPI_BOOL_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "Z"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \ + { \ + (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_BYTE_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "B"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \ + { \ + (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_INT_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "I"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \ + { \ + (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \ + BIND_JAPI_FIELD(cls, field, sig); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \ + { \ + (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_STRING_FIELD(cls, field) \ + BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;") + +jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden"))); +void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden"))); +void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden"))); +int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden"))); +void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden"))); + diff --git a/vpp-api/java/m4/ax_check_java_home.m4 b/vpp-api/java/m4/ax_check_java_home.m4 new file mode 100644 index 00000000..cfe8f589 --- /dev/null +++ b/vpp-api/java/m4/ax_check_java_home.m4 @@ -0,0 +1,80 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_JAVA_HOME +# +# DESCRIPTION +# +# Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in. +# If found, set environment variable JAVA_HOME = Java installation home, +# else left JAVA_HOME untouch, which in most case means JAVA_HOME is +# empty. +# +# LICENSE +# +# Copyright (c) 2008 Gleen Salmon +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) + +AC_DEFUN([AX_CHECK_JAVA_HOME], +[AC_MSG_CHECKING([for JAVA_HOME]) +# We used a fake loop so that we can use "break" to exit when the result +# is found. +while true +do + # If the user defined JAVA_HOME, don't touch it. + test "${JAVA_HOME+set}" = set && break + + # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get + # the value of JAVA_HOME to use. + # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html). + JAVA_HOME=`/usr/libexec/java_home 2>/dev/null` + test x"$JAVA_HOME" != x && break + + # See if we can find the java executable, and compute from there. + TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1` + if test x$TRY_JAVA_HOME != x; then + PATH=$PATH:$TRY_JAVA_HOME/bin + fi + AC_PATH_PROG([JAVA_PATH_NAME], [java]) + if test "x$JAVA_PATH_NAME" != x; then + JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"` + break + fi + + AC_MSG_NOTICE([Could not compute JAVA_HOME]) + break +done +AC_MSG_RESULT([$JAVA_HOME]) +]) diff --git a/vpp-api/java/m4/ax_check_java_plugin.m4 b/vpp-api/java/m4/ax_check_java_plugin.m4 new file mode 100644 index 00000000..920753e5 --- /dev/null +++ b/vpp-api/java/m4/ax_check_java_plugin.m4 @@ -0,0 +1,101 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_JAVA_PLUGIN() +# +# DESCRIPTION +# +# This macro sets to empty on failure and to a compatible +# version of plugin.jar otherwise. Directories searched are /usr/java/* +# and /usr/local/java/*, which are assumed to be j{dk,re} installations. +# Apply the shell variable as you see fit. If sun changes things so +# /lib/plugin.jar is not the magic file it will stop working. +# +# This macro assumes that unzip, zipinfo or pkzipc is available (and can +# list the contents of the jar archive). The first two are assumed to work +# similarly enough to the infozip versisonms. The pkzipc version is +# assumed to work if I undertstand the documentation on pkware's site but +# YMMV. I do not have access to pwkware's version to test it. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN]) +AC_DEFUN([AX_CHECK_JAVA_PLUGIN], +[AC_REQUIRE([AC_PROG_AWK]) +AC_REQUIRE([AC_PROG_FGREP]) +AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc]) +AC_MSG_CHECKING([for the java plugin]) +case "x$ZIPINFO" in +[*/zipinfo)] + zipinf="zipinfo -1" ;; +[*/unzip)] + zipinf="unzip -l";; +[*/pkzipc)] + ziping="unzipc -view";; +[x*)] + AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found]) + AC_SUBST($1,[]) + zipinf="";; +esac +if test "x$zipinf" != "x"; then +jplugin="" +for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do +for jfile in lib/plugin.jar jre/lib/plugin.jar; do +if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then +eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null +if test $? -eq 0; then +dnl Some version of gcj (and javac) refuse to work with some files +dnl that pass this test. To stop this problem make sure that the compiler +dnl still works with this jar file in the classpath +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then +jplugin="$jhome/$jfile" +fi +rm -f Test.java Test.class +fi; fi; done; done +if test "x$jplugin" != "x"; then +AC_SUBST($1,$jplugin) +AC_MSG_RESULT($jplugin) +else +AC_MSG_RESULT([java plugin not found]) +AC_SUBST($1,[]) +fi +fi +]) diff --git a/vpp-api/java/m4/ax_java_check_class.m4 b/vpp-api/java/m4/ax_java_check_class.m4 new file mode 100644 index 00000000..917638ae --- /dev/null +++ b/vpp-api/java/m4/ax_java_check_class.m4 @@ -0,0 +1,85 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JAVA_CHECK_CLASS(,,) +# +# DESCRIPTION +# +# Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This +# version uses a cache variable which is both compiler, options and +# classpath dependent (so if you switch from javac to gcj it correctly +# notices and redoes the test). +# +# The macro tries to compile a minimal program importing . Some +# newer compilers moan about the failure to use this but fail or produce a +# class file anyway. All moaing is sunk to /dev/null since I only wanted +# to know if the class could be imported. This is a recommended followup +# to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) +AC_DEFUN([AX_JAVA_CHECK_CLASS],[ +m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")]) +if test "x$CLASSPATH" != "x"; then +xtra=" with classpath ${CLASSPATH}" +xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'` +xopts="-classpath $xopts" +else xtra=""; xopts=""; fi +cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}]) +AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]xline __oline__ "configure" */ +import $1; +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then + eval "${cache_var}=yes" +else + eval "${cache_var}=no" + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +if eval 'test "x$'${cache_var}'" = "xyes"'; then +$2 +true; else +$3 +false; fi]) diff --git a/vpp-api/java/m4/ax_java_options.m4 b/vpp-api/java/m4/ax_java_options.m4 new file mode 100644 index 00000000..36c10d92 --- /dev/null +++ b/vpp-api/java/m4/ax_java_options.m4 @@ -0,0 +1,48 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_java_options.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JAVA_OPTIONS +# +# DESCRIPTION +# +# AX_JAVA_OPTIONS adds configure command line options used for Java m4 +# macros. This Macro is optional. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) +AC_DEFUN([AX_JAVA_OPTIONS],[ +AC_ARG_WITH(java-prefix, + [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) +AC_ARG_WITH(javac-flags, + [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) +AC_ARG_WITH(java-flags, + [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) +JAVAPREFIX=$with_java_prefix +JAVACFLAGS=$with_javac_flags +JAVAFLAGS=$with_java_flags +AC_SUBST(JAVAPREFIX)dnl +AC_SUBST(JAVACFLAGS)dnl +AC_SUBST(JAVAFLAGS)dnl +AC_SUBST(JAVA)dnl +AC_SUBST(JAVAC)dnl +]) diff --git a/vpp-api/java/m4/ax_libgcj_jar.m4 b/vpp-api/java/m4/ax_libgcj_jar.m4 new file mode 100644 index 00000000..5e942857 --- /dev/null +++ b/vpp-api/java/m4/ax_libgcj_jar.m4 @@ -0,0 +1,83 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_libgcj_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIBGCJ_JAR +# +# DESCRIPTION +# +# Locate libgcj.jar so you can place it before everything else when using +# gcj. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([DPS_LIBGCJ_JAR], [AX_LIBGCJ_JAR]) +AC_DEFUN([AX_LIBGCJ_JAR], +[ +AC_REQUIRE([AC_EXEEXT]) +AC_REQUIRE([AX_PROG_JAVAC]) +AC_REQUIRE([AC_PROG_FGREP]) +AC_PROG_SED +if test "x$SED" = "x"; then +AC_MSG_WARN([sed not avaiable, so libgcj.jar test skipped]) +else +AC_MSG_CHECKING([if $JAVAC is gcj]); +jc=`eval "[echo x$JAVAC | $SED 's/^x.*\\/\\([^/]*\\)\$/x\\1/;s/^ *\\([^ ]*\\) .*$/\\1/;s/"$EXEEXT"$//']"` +if test "x$jc" != "xxgcj"; then +AC_MSG_RESULT(no) +else +AC_MSG_RESULT(yes) +AC_MSG_CHECKING([libgcj.jar location]) +save_cp="$CLASSPATH"; +unset CLASSPATH; +AC_MSG_CHECKING([gcj default classpath]) +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +lgcj=`eval "[$JAVAC -v -C Test.java 2>&1 | $FGREP \\(system\\) | $SED 's/^ *\\([^ ]*\\) .*$/\\1/;s/\\.jar\\//.jar/']"`; +if test -f Test.class && test "x$lgcj" != "x"; then +AC_MSG_RESULT($lgcj) +$1="$lgcj:" +else +AC_MSG_RESULT(failed) +$1="" +fi +if test "x$save_cp" != "x"; then CLASSPATH="$save_cp"; fi +rm -f Test.java Test.class +fi +fi +]) diff --git a/vpp-api/java/m4/ax_prog_jar.m4 b/vpp-api/java/m4/ax_prog_jar.m4 new file mode 100644 index 00000000..3c60fcaf --- /dev/null +++ b/vpp-api/java/m4/ax_prog_jar.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAR +# +# DESCRIPTION +# +# AX_PROG_JAR tests for an existing jar program. It uses the environment +# variable JAR then tests in sequence various common jar programs. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAR=yourcompiler before calling +# AX_PROG_JAR +# +# - at the configure level, setenv JAR +# +# You can use the JAR variable in your Makefile.in, with @JAR@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) +AC_DEFUN([AX_PROG_JAR],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) +test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_java.m4 b/vpp-api/java/m4/ax_prog_java.m4 new file mode 100644 index 00000000..03961db5 --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java.m4 @@ -0,0 +1,115 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA +# +# DESCRIPTION +# +# Here is a summary of the main macros: +# +# AX_PROG_JAVAC: finds a Java compiler. +# +# AX_PROG_JAVA: finds a Java virtual machine. +# +# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). +# +# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops +# otherwise. +# +# AX_TRY_COMPILE_JAVA: attempt to compile user given source. +# +# AX_TRY_RUN_JAVA: attempt to compile and run user given source. +# +# AX_JAVA_OPTIONS: adds Java configure options. +# +# AX_PROG_JAVA tests an existing Java virtual machine. It uses the +# environment variable JAVA then tests in sequence various common Java +# virtual machines. For political reasons, it starts with the free ones. +# You *must* call [AX_PROG_JAVAC] before. +# +# If you want to force a specific VM: +# +# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA +# +# (but after AC_INIT) +# +# - at the configure level, setenv JAVA +# +# You can use the JAVA variable in your Makefile.in, with @JAVA@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude virtual machines (rationale: most Java programs +# cannot run with some VM like kaffe). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# A Web page, with a link to the latest CVS snapshot is at +# . +# +# This is a sample configure.in Process this file with autoconf to produce +# a configure script. +# +# AC_INIT(UnTag.java) +# +# dnl Checks for programs. +# AC_CHECK_CLASSPATH +# AX_PROG_JAVAC +# AX_PROG_JAVA +# +# dnl Checks for classes +# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) +# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) +# +# AC_OUTPUT(Makefile) +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) +AC_DEFUN([AX_PROG_JAVA],[ +m4_define([m4_ax_prog_java_list], [kaffe java])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) +test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) +m4_undefine([m4_ax_prog_java_list])dnl +AX_PROG_JAVA_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_java_cc.m4 b/vpp-api/java/m4/ax_prog_java_cc.m4 new file mode 100644 index 00000000..3df064ff --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java_cc.m4 @@ -0,0 +1,104 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_CC +# +# DESCRIPTION +# +# Finds the appropriate java compiler on your path. By preference the java +# compiler is gcj, then jikes then javac. +# +# The macro can take one argument specifying a space separated list of +# java compiler names. +# +# For example: +# +# AX_PROG_JAVA_CC(javac, gcj) +# +# The macro also sets the compiler options variable: JAVA_CC_OPTS to +# something sensible: +# +# - for GCJ it sets it to: @GCJ_OPTS@ +# (if GCJ_OPTS is not yet defined then it is set to "-C") +# +# - no other compiler has applicable options yet +# +# Here's an example configure.in: +# +# AC_INIT(Makefile.in) +# AX_PROG_JAVA_CC() +# AC_OUTPUT(Makefile) +# dnl End. +# +# And here's the start of the Makefile.in: +# +# PROJECT_ROOT := @srcdir@ +# # Tool definitions. +# JAVAC := @JAVA_CC@ +# JAVAC_OPTS := @JAVA_CC_OPTS@ +# JAR_TOOL := @jar_tool@ +# +# LICENSE +# +# Copyright (c) 2008 Nic Ferrier +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +# AX_PROG_JAVA_CC([COMPILER ...]) +# -------------------------- +# COMPILER ... is a space separated list of java compilers to search for. +# This just gives the user an opportunity to specify an alternative +# search list for the java compiler. +AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC]) +AC_DEFUN([AX_PROG_JAVA_CC], +[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl +AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl +m4_ifval([$1], + [AC_CHECK_TOOLS(JAVA_CC, [$1])], +[AC_CHECK_TOOL(JAVA_CC, gcj) +if test -z "$JAVA_CC"; then + AC_CHECK_TOOL(JAVA_CC, javac) +fi +if test -z "$JAVA_CC"; then + AC_CHECK_TOOL(JAVA_CC, jikes) +fi +]) + +if test "$JAVA_CC" = "gcj"; then + if test "$GCJ_OPTS" = ""; then + AC_SUBST(GCJ_OPTS,-C) + fi + AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@, + [Define the compilation options for GCJ]) +fi +test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH]) +])# AX_PROG_JAVA_CC diff --git a/vpp-api/java/m4/ax_prog_java_works.m4 b/vpp-api/java/m4/ax_prog_java_works.m4 new file mode 100644 index 00000000..54e132af --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java_works.m4 @@ -0,0 +1,134 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) +AC_DEFUN([AX_PROG_JAVA_WORKS], [ +AC_PATH_PROG(UUDECODE, uudecode, [no]) +if test x$UUDECODE != xno; then +AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ +dnl /** +dnl * Test.java: used to test if java compiler works. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s +YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG +aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB +AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB +AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= +==== +EOF +if $UUDECODE Test.uue; then + ac_cv_prog_uudecode_base64=yes +else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD + echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD + cat Test.uue >&AS_MESSAGE_LOG_FD + ac_cv_prog_uudecode_base64=no +fi +rm -f Test.uue]) +fi +if test x$ac_cv_prog_uudecode_base64 != xyes; then + rm -f Test.class + AC_MSG_WARN([I have to compile Test.class from scratch]) + if test x$ac_cv_prog_javac_works = xno; then + AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) + fi + if test x$ac_cv_prog_javac_works = x; then + AX_PROG_JAVAC + fi +fi +AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +TEST=Test +changequote(, )dnl +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +public static void main (String args[]) { + System.exit (0); +} } +EOF +changequote([, ])dnl +if test x$ac_cv_prog_uudecode_base64 != xyes; then + if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then + : + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) + fi +fi +if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then + ac_cv_prog_java_works=yes +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) +fi +rm -fr $JAVA_TEST $CLASS_TEST Test.uue +]) +AC_PROVIDE([$0])dnl +] +) diff --git a/vpp-api/java/m4/ax_prog_javac.m4 b/vpp-api/java/m4/ax_prog_javac.m4 new file mode 100644 index 00000000..d061243c --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javac.m4 @@ -0,0 +1,79 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC +# +# DESCRIPTION +# +# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment +# variable JAVAC then tests in sequence various common Java compilers. For +# political reasons, it starts with the free ones. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AX_PROG_JAVAC +# +# - at the configure level, setenv JAVAC +# +# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude compilers (rationale: most Java programs cannot +# compile with some compilers like guavac). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) +AC_DEFUN([AX_PROG_JAVAC],[ +m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) +m4_undefine([m4_ax_prog_javac_list])dnl +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AX_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javac_works.m4 b/vpp-api/java/m4/ax_prog_javac_works.m4 new file mode 100644 index 00000000..7dfa1e37 --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javac_works.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) +AC_DEFUN([AX_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javadoc.m4 b/vpp-api/java/m4/ax_prog_javadoc.m4 new file mode 100644 index 00000000..bcb6045a --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javadoc.m4 @@ -0,0 +1,50 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVADOC +# +# DESCRIPTION +# +# AX_PROG_JAVADOC tests for an existing javadoc generator. It uses the +# environment variable JAVADOC then tests in sequence various common +# javadoc generator. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVADOC=yourgenerator before calling +# AX_PROG_JAVADOC +# +# - at the configure level, setenv JAVADOC +# +# You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) +AC_DEFUN([AX_PROG_JAVADOC],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc])], + [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc], [], [$JAVAPREFIX/bin])]) +test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javah.m4 b/vpp-api/java/m4/ax_prog_javah.m4 new file mode 100644 index 00000000..cefc616d --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javah.m4 @@ -0,0 +1,64 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAH +# +# DESCRIPTION +# +# AX_PROG_JAVAH tests the availability of the javah header generator and +# looks for the jni.h header file. If available, JAVAH is set to the full +# path of javah and CPPFLAGS is updated accordingly. +# +# LICENSE +# +# Copyright (c) 2008 Luc Maisonobe +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) +AC_DEFUN([AX_PROG_JAVAH],[ +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_PATH_PROG(JAVAH,javah) +AS_IF([test -n "$ac_cv_path_JAVAH"], + [ + AC_TRY_CPP([#include ],,[ + ac_save_CPPFLAGS="$CPPFLAGS" + _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") + ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])` + ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include" + AS_CASE([$build_os], + [cygwin*], + [ac_machdep=win32], + [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) + CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" + AC_TRY_CPP([#include ], + ac_save_CPPFLAGS="$CPPFLAGS", + AC_MSG_WARN([unable to include ])) + CPPFLAGS="$ac_save_CPPFLAGS"]) + ]) +]) + +AC_DEFUN([_ACJAVAH_FOLLOW_SYMLINKS],[ +# find the include directory relative to the javac executable +_cur="$1" +while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do + AC_MSG_CHECKING([symlink for $_cur]) + _slink=`ls -ld "$_cur" | sed 's/.* -> //'` + case "$_slink" in + /*) _cur="$_slink";; + # 'X' avoids triggering unwanted echo options. + *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; + esac + AC_MSG_RESULT([$_cur]) +done +_ACJAVAH_FOLLOWED="$_cur" +]) diff --git a/vpp-api/java/m4/ax_try_compile_java.m4 b/vpp-api/java/m4/ax_try_compile_java.m4 new file mode 100644 index 00000000..a8ed6b2a --- /dev/null +++ b/vpp-api/java/m4/ax_try_compile_java.m4 @@ -0,0 +1,55 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_COMPILE_JAVA +# +# DESCRIPTION +# +# AX_TRY_COMPILE_JAVA attempt to compile user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) +AC_DEFUN([AX_TRY_COMPILE_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [import $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/vpp-api/java/m4/ax_try_run_java.m4 b/vpp-api/java/m4/ax_try_run_java.m4 new file mode 100644 index 00000000..c680f03f --- /dev/null +++ b/vpp-api/java/m4/ax_try_run_java.m4 @@ -0,0 +1,56 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_RUN_JAVA +# +# DESCRIPTION +# +# AX_TRY_RUN_JAVA attempt to compile and run user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) +AC_DEFUN([AX_TRY_RUN_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +AC_REQUIRE([AX_PROG_JAVA])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [include $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/vpp-api/python/Makefile.am b/vpp-api/python/Makefile.am new file mode 100644 index 00000000..b96ff3d9 --- /dev/null +++ b/vpp-api/python/Makefile.am @@ -0,0 +1,49 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = -Wall + +BUILT_SOURCES = +bin_PROGRAMS = +CLEANFILES = +lib_LTLIBRARIES = +noinst_PROGRAMS = test_pneum +nobase_include_HEADERS = pneum/pneum.h + +# +# Python binding +# +lib_LTLIBRARIES += libpneum.la +libpneum_la_SOURCES = pneum/pneum.c +libpneum_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra -lpthread -lm -lrt +libpneum_la_LDFLAGS = -module +libpneum_la_CPPFLAGS = + +BUILT_SOURCES += vpp_papi.py + +vpp_papi.py: $(prefix)/../vpp/api/vpe.api pneum/api-gen.py + @echo " PYTHON API"; \ + $(CC) $(CPPFLAGS) -E -P -C -x c $< \ + | vppapigen --input - --python defs_$@; \ + echo "#include " \ + | $(CC) $(CPPFLAGS) -E -P -x c - | grep VL_API \ + | @srcdir@/pneum/api-gen.py -i defs_$@ > @srcdir@/vpp_papi/$@ + +# +# Test client +# +noinst_PROGRAMS += test_pneum +test_pneum_SOURCES = pneum/pneum.c pneum/test_pneum.c +test_pneum_LDADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra -lpthread -lm -lrt diff --git a/vpp-api/python/README.rst b/vpp-api/python/README.rst new file mode 100644 index 00000000..e69de29b diff --git a/vpp-api/python/pneum/api-gen.py b/vpp-api/python/pneum/api-gen.py new file mode 100755 index 00000000..bbc9c329 --- /dev/null +++ b/vpp-api/python/pneum/api-gen.py @@ -0,0 +1,337 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import argparse, sys, os, importlib, pprint + +parser = argparse.ArgumentParser(description='VPP Python API generator') +parser.add_argument('-i', action="store", dest="inputfile") +parser.add_argument('-c', '--cfile', action="store") +args = parser.parse_args() + +sys.path.append(".") + +inputfile = args.inputfile.replace('.py', '') +cfg = importlib.import_module(inputfile, package=None) + +# https://docs.python.org/3/library/struct.html +format_struct = {'u8': 'B', + 'u16' : 'H', + 'u32' : 'I', + 'i32' : 'i', + 'u64' : 'Q', + 'f64' : 'd', + 'vl_api_ip4_fib_counter_t' : 'IBQQ', + 'vl_api_ip6_fib_counter_t' : 'QQBQQ', + }; +type_size = {'u8': 1, + 'u16' : 2, + 'u32' : 4, + 'i32' : 4, + 'u64' : 8, + 'f64' : 8, + 'vl_api_ip4_fib_counter_t' : 21, + 'vl_api_ip6_fib_counter_t' : 33, +}; + +def get_args(t): + args = None + for i in t: + arg = i[1] + arg = arg.replace('_','') + if args == None: + args = arg + continue + args = args + ', ' + arg + return args + +def get_pack(t): + bytecount = 0 + pack = '>' + tup = u'' + j = -1 + for i in t: + j += 1 + if len(i) is 3: + size = type_size[i[0]] + bytecount += size * int(i[2]) + if i[2] == '0': + tup += 'msg[' + str(bytecount) + ':],' + continue + if size == 1: + n = i[2] * size + pack += str(n) + 's' + tup += 'tr[' + str(j) + '],' + continue + pack += format_struct[i[0]] * int(i[2]) + tup += 'tr[' + str(j) + ':' + str(j + int(i[2])) + '],' + j += int(i[2]) - 1 + else: + bytecount += type_size[i[0]] + pack += format_struct[i[0]] + tup += 'tr[' + str(j) + '],' + return pack, bytecount, tup + +def get_reply_func(f): + if f['name']+'_reply' in func_name: + return func_name[f['name']+'_reply'] + if f['name'].find('_dump') > 0: + r = f['name'].replace('_dump','_details') + if r in func_name: + return func_name[r] + return None + +def get_enums(): + # Read enums from stdin + enums_by_name = {} + enums_by_index = {} + i = 1 + for l in sys.stdin: + l = l.replace(',\n','') + print l, "=", i + + l = l.replace('VL_API_','').lower() + enums_by_name[l] = i + enums_by_index[i] = l + + i += 1 + return enums_by_name, enums_by_index + +def get_definitions(): + # Pass 1 + func_list = [] + func_name = {} + i = 1 + for a in cfg.vppapidef: + pack, packlen, tup = get_pack(a[1:]) + func_name[a[0]] = dict([('name', a[0]), ('args', get_args(a[4:])), ('full_args', get_args(a[1:])), ('pack', pack), ('packlen', packlen), ('tup', tup)]) + func_list.append(func_name[a[0]]) # Indexed by name + return func_list, func_name + +def generate_c_macros(func_list, enums_by_name): + file = open(args.cfile, 'w+') + print >>file, "#define foreach_api_msg \\" + for f in func_list: + if not f['name'] in enums_by_name: + continue + print >>file, "_(" + f['name'].upper() + ", " + f['name'] + ") \\" + print >>file, ''' +void pneum_set_handlers(void) { +#define _(N,n) \\ + api_func_table[VL_API_##N] = sizeof(vl_api_##n##_t); + foreach_api_msg; +#undef _ +} + ''' + +# +# XXX:Deal with empty arrays +# Print array with a hash of 'decode' and 'multipart' +# Simplify to do only decode for now. And deduce multipart from _dump? +# +def decode_function_print(name, args, pack, packlen, tup): + + print(u'def ' + name + u'_decode(msg):') + print(u" n = namedtuple('" + name + "', '" + args + "')" + + ''' + if not n: + return None + ''') + print(u" tr = unpack('" + pack + "', msg[:" + str(packlen) + "])") + print(u" r = n._make((" + tup + "))" + + ''' + if not r: + return None + return r + ''') + +def function_print(name, id, args, pack, multipart): + if not args: + args = "" + print "def", name + "(async = False):" + else: + print "def", name + "(" + args + ",async = False):" + print " global waiting_for_reply" + print " context = get_context(" + id + ")" + + print ''' + results[context] = {} + results[context]['e'] = threading.Event() + results[context]['e'].clear() + results[context]['r'] = [] + waiting_for_reply = True + ''' + if multipart == True: + print " results[context]['m'] = True" + + print " vpp_api.write(pack('" + pack + "', " + id + ", 0, context, " + args + "))" + + if multipart == True: + print " vpp_api.write(pack('>HII', VL_API_CONTROL_PING, 0, context))" + + print ''' + if not async: + results[context]['e'].wait(5) + return results[context]['r'] + return context + ''' + +# +# Should dynamically create size +# +def api_table_print (name, msg_id): + f = name + '_decode' + print('api_func_table[' + msg_id + '] = ' + f) + +# +# Generate the main Python file +# + +print '''#!/usr/bin/env python3 + +import sys, time, threading, signal, os, logging +from struct import * +from collections import namedtuple + +# +# Import C API shared object +# +import vpp_api + +context = 0 +results = {} +waiting_for_reply = False + +# +# XXX: Make this return a unique number +# +def get_context(id): + global context + context += 1 + return context + +def msg_handler(msg): + global result, context, event_callback, waiting_for_reply + if not msg: + logging.warning('vpp_api.read failed') + return + + id = unpack('>H', msg[0:2]) + logging.debug('Received message', id[0]) + if id[0] == VL_API_RX_THREAD_EXIT: + logging.info("We got told to leave") + return; + + # + # Decode message and returns a tuple. + # + logging.debug('api_func', api_func_table[id[0]]) + r = api_func_table[id[0]](msg) + if not r: + logging.warning('Message decode failed', id[0]) + return + + if 'context' in r._asdict(): + if r.context > 0: + context = r.context + + # + # XXX: Call provided callback for event + # Are we guaranteed to not get an event during processing of other messages? + # How to differentiate what's a callback message and what not? Context = 0? + # + logging.debug('R:', context, r, waiting_for_reply) + if waiting_for_reply == False: + event_callback(r) + return + + # + # Collect results until control ping + # + if id[0] == VL_API_CONTROL_PING_REPLY: + results[context]['e'].set() + waiting_for_reply = False + return + if not context in results: + logging.warning('Not expecting results for this context', context) + return + if 'm' in results[context]: + results[context]['r'].append(r) + return + + results[context]['r'] = r + results[context]['e'].set() + waiting_for_reply = False + +def connect(name): + signal.alarm(3) # 3 second + rv = vpp_api.connect(name, msg_handler) + signal.alarm(0) + logging.info("Connect:", rv) + return rv + +def disconnect(): + rv = vpp_api.disconnect() + logging.info("Disconnected") + return rv + +def register_event_callback(callback): + global event_callback + event_callback = callback +''' + +enums_by_name, enums_by_index = get_enums() +func_list, func_name = get_definitions() + +# +# Not needed with the new msg_size field. +# generate_c_macros(func_list, enums_by_name) +# + +pp = pprint.PrettyPrinter(indent=4) +#print 'enums_by_index =', pp.pprint(enums_by_index) +#print 'func_name =', pp.pprint(func_name) + +# Pass 2 + +# +# 1) The VPE API lacks a clear definition of what messages are reply messages +# 2) Length is missing, and has to be pre-known or in case of variable sized ones calculated per message type +# +for f in func_list: + #if f['name'].find('_reply') > 0 or f['name'].find('_details') > 0: + decode_function_print(f['name'], f['full_args'], f['pack'], f['packlen'], f['tup']) + + #r = get_reply_func(f) + #if not r: + # # + # # XXX: Functions here are not taken care of. E.g. events + # # + # print('Missing function', f) + # continue + + if f['name'].find('_dump') > 0: + f['multipart'] = True + else: + f['multipart'] = False + msg_id_in = 'VL_API_' + f['name'].upper() + function_print(f['name'], msg_id_in, f['args'], f['pack'], f['multipart']) + + +print "api_func_table = [0] * 10000" +for f in func_list: + # if f['name'].find('_reply') > 0 or f['name'].find('_details') > 0: + msg_id_in = 'VL_API_' + f['name'].upper() + api_table_print(f['name'], msg_id_in) diff --git a/vpp-api/python/pneum/pneum.c b/vpp-api/python/pneum/pneum.c new file mode 100644 index 00000000..971c79bf --- /dev/null +++ b/vpp-api/python/pneum/pneum.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "pneum.h" + +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +typedef struct { + u8 rx_thread_jmpbuf_valid; + u8 connected_to_vlib; + jmp_buf rx_thread_jmpbuf; + pthread_t rx_thread_handle; +} pneum_main_t; + +pneum_main_t pneum_main; + +extern int wrap_pneum_callback(char *data, int len); + +/* + * Satisfy external references when -lvlib is not available. + */ +void vlib_cli_output (struct vlib_main_t * vm, char * fmt, ...) +{ + clib_warning ("vlib_cli_output callled..."); +} + +#define vl_api_version(n,v) static u32 vpe_api_version = v; +#include +#undef vl_api_version +void +vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) +{ + /* + * Send the main API signature in slot 0. This bit of code must + * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). + */ + mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); +} + +static void +pneum_api_handler (void *msg) +{ + u16 id = ntohs(*((u16 *)msg)); + + if (id == VL_API_RX_THREAD_EXIT) { + pneum_main_t *pm = &pneum_main; + vl_msg_api_free(msg); + longjmp(pm->rx_thread_jmpbuf, 1); + } + msgbuf_t *msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data)); + int l = ntohl(msgbuf->data_len); + if (l == 0) + clib_warning("Message ID %d has wrong length: %d\n", id, l); + + /* Call Python callback */ + (void)wrap_pneum_callback(msg, l); + vl_msg_api_free(msg); +} + +static void * +pneum_rx_thread_fn (void *arg) +{ + unix_shared_memory_queue_t *q; + pneum_main_t *pm = &pneum_main; + api_main_t *am = &api_main; + uword msg; + + q = am->vl_input_queue; + + /* So we can make the rx thread terminate cleanly */ + if (setjmp(pm->rx_thread_jmpbuf) == 0) { + pm->rx_thread_jmpbuf_valid = 1; + while (1) + while (!unix_shared_memory_queue_sub(q, (u8 *)&msg, 0)) + pneum_api_handler((void *)msg); + } + pthread_exit(0); +} + +int +pneum_connect (char *name) +{ + int rv = 0; + pneum_main_t *pm = &pneum_main; + + /* + * Bail out now if we're not running as root + */ + if (geteuid() != 0) + return (-1); + + if ((rv = vl_client_api_map("/vpe-api"))) { + clib_warning ("vl_client_api map rv %d", rv); + return rv; + } + + if (vl_client_connect(name, 0, 32) < 0) { + vl_client_api_unmap(); + return (-1); + } + + /* Start the rx queue thread */ + rv = pthread_create(&pm->rx_thread_handle, NULL, pneum_rx_thread_fn, 0); + if (rv) { + clib_warning("pthread_create returned %d", rv); + vl_client_api_unmap(); + return (-1); + } + + pm->connected_to_vlib = 1; + + return (0); +} + +int +pneum_disconnect (void) +{ + api_main_t *am = &api_main; + pneum_main_t *pm = &pneum_main; + + fformat (stdout,"disconnecting from vpe \n"); + + if (pm->rx_thread_jmpbuf_valid) { + vl_api_rx_thread_exit_t *ep; + uword junk; + ep = vl_msg_api_alloc (sizeof (*ep)); + ep->_vl_msg_id = ntohs(VL_API_RX_THREAD_EXIT); + vl_msg_api_send_shmem(am->vl_input_queue, (u8 *)&ep); + pthread_join(pm->rx_thread_handle, (void **) &junk); + } + if (pm->connected_to_vlib) { + vl_client_disconnect(); + vl_client_api_unmap(); + } + memset (pm, 0, sizeof (*pm)); + + return (0); +} + +int +pneum_read (char **p, int *l) +{ + unix_shared_memory_queue_t *q; + api_main_t *am = &api_main; + uword msg; + + *l = 0; + + if (am->our_pid == 0) return (-1); + + q = am->vl_input_queue; + int rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0); + if (rv == 0) { + u16 msg_id = ntohs(*((u16 *)msg)); + msgbuf_t *msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data)); + *l = ntohl(msgbuf->data_len); + if (*l == 0) { + printf("Unregistered API message: %d\n", msg_id); + return (-1); + } + *p = (char *)msg; + } else { + printf("Read failed with %d\n", rv); + } + return (rv); +} + +/* + * XXX: Makes the assumption that client_index is the first member + */ +typedef VL_API_PACKED(struct _vl_api_header { + u16 _vl_msg_id; + u32 client_index; +}) vl_api_header_t; + +static unsigned int +pneum_client_index (void) +{ + return (api_main.my_client_index); +} + +int +pneum_write (char *p, int l) +{ + int rv = -1; + api_main_t *am = &api_main; + vl_api_header_t *mp = vl_msg_api_alloc(l); + unix_shared_memory_queue_t *q; + + if (!mp) return (-1); + memcpy(mp, p, l); + mp->client_index = pneum_client_index(); + q = am->shmem_hdr->vl_input_queue; + rv = unix_shared_memory_queue_add(q, (u8 *)&mp, 0); + if (rv != 0) { + printf("vpe_api_write fails: %d\n", rv); + /* Clear message */ + vl_msg_api_free(mp); + } + return (rv); +} diff --git a/vpp-api/python/pneum/pneum.h b/vpp-api/python/pneum/pneum.h new file mode 100644 index 00000000..b99cbd4e --- /dev/null +++ b/vpp-api/python/pneum/pneum.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_pneum_h__ +#define __included_pneum_h__ + +unsigned int vpe_client_index(void); +int pneum_connect(char *name); +int pneum_disconnect(void); +int pneum_read(char **data, int *l); +int pneum_write(char *data, int len); + +#endif diff --git a/vpp-api/python/pneum/test_pneum.c b/vpp-api/python/pneum/test_pneum.c new file mode 100644 index 00000000..18627b3f --- /dev/null +++ b/vpp-api/python/pneum/test_pneum.c @@ -0,0 +1,136 @@ +/* + *------------------------------------------------------------------ + * test_pneum.c + * + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* time_t, time (for timestamp in second) */ +#include /* ftime, timeb (for timestamp in millisecond) */ +#include /* gettimeofday, timeval (for timestamp in microsecond) */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "pneum.h" + +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +volatile int sigterm_received = 0; +volatile u32 result_ready; +volatile u16 result_msg_id; + +/* M_NOALLOC: construct, but don't yet send a message */ + +#define M_NOALLOC(T,t) \ + do { \ + result_ready = 0; \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = am->my_client_index; \ + } while(0); + + + +int +wrap_pneum_callback (char *data, int len) +{ + //printf("Callback %d\n", len); + result_ready = 1; + result_msg_id = ntohs(*((u16 *)data)); + return (0); +} + +int main (int argc, char ** argv) +{ + api_main_t * am = &api_main; + vl_api_show_version_t message; + vl_api_show_version_t *mp; + int async = 1; + int rv = pneum_connect("pneum_client"); + + if (rv != 0) { + printf("Connect failed: %d\n", rv); + exit(rv); + } + + struct timeb timer_msec; + long long int timestamp_msec_start; /* timestamp in millisecond. */ + if (!ftime(&timer_msec)) { + timestamp_msec_start = ((long long int) timer_msec.time) * 1000ll + + (long long int) timer_msec.millitm; + } + else { + timestamp_msec_start = -1; + } + + + /* + * Test vpe_api_write and vpe_api_read to send and recv message for an + * API + */ + int i; + long int no_msgs = 10000; + mp = &message; + + for (i = 0; i < no_msgs; i++) { + /* Construct the API message */ + M_NOALLOC(SHOW_VERSION, show_version); + pneum_write((char *)mp, sizeof(*mp)); + if (!async) + while (result_ready == 0); + } + if (async) { + vl_api_control_ping_t control; + vl_api_control_ping_t *mp; + mp = &control; + M_NOALLOC(CONTROL_PING, control_ping); + pneum_write((char *)mp, sizeof(*mp)); + + while (result_msg_id != VL_API_CONTROL_PING_REPLY); + } + + long long int timestamp_msec_end; /* timestamp in millisecond. */ + if (!ftime(&timer_msec)) { + timestamp_msec_end = ((long long int) timer_msec.time) * 1000ll + + (long long int) timer_msec.millitm; + } + else { + timestamp_msec_end = -1; + } + + printf("Took %lld msec, %lld msgs/msec \n", (timestamp_msec_end - timestamp_msec_start), + no_msgs/(timestamp_msec_end - timestamp_msec_start)); + fformat(stdout, "Exiting...\n"); + pneum_disconnect(); + exit (0); +} diff --git a/vpp-api/python/setup.py b/vpp-api/python/setup.py new file mode 100644 index 00000000..d890ba70 --- /dev/null +++ b/vpp-api/python/setup.py @@ -0,0 +1,21 @@ +from distutils.core import setup, Extension + +module1 = Extension('vpp_api', + define_macros = [('MAJOR_VERSION', '1'), + ('MINOR_VERSION', '0')], + include_dirs = ['pneum'], + libraries = ['pneum'], + library_dirs = ['../../build-root/install-vpp_debug-native/vpp-api/lib64'], + sources = ['vpp_papi/pneum_wrap.c']) + +setup (name = 'vpp_papi', + version = '1.0', + description = 'VPP Python binding', + author = 'Ole Troan', + author_email = 'ot@cisco.com', + #url = 'https://docs.python.org/extending/building', + packages=['vpp_papi'], + long_description = ''' +VPP Python language binding. +''', + ext_modules = [module1]) diff --git a/vpp-api/python/tests/test_papi.py b/vpp-api/python/tests/test_papi.py new file mode 100755 index 00000000..ec51f093 --- /dev/null +++ b/vpp-api/python/tests/test_papi.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 + +import vpp_papi +import unittest, sys, time, threading, struct, logging +from ipaddress import * + +papi_event = threading.Event() +def papi_event_handler(result): + if result.vlmsgid == vpp_papi.VL_API_SW_INTERFACE_SET_FLAGS: + papi_event.set() + return + if result.vlmsgid == vpp_papi.VL_API_VNET_INTERFACE_COUNTERS: + format = '>' + str(int(len(result.data) / 8)) + 'Q' + counters = struct.unpack(format, result.data) + print('Counters:', counters) + return + + print('Unknown message id:', result.vlmsgid) + +class TestPAPI(unittest.TestCase): + + def setUp(self): + r = vpp_papi.connect("test_papi") + self.assertEqual(r, 0) + + def tearDown(self): + r = vpp_papi.disconnect() + self.assertEqual(r, 0) + + def test_show_version(self): + t = vpp_papi.show_version() + program = t.program.decode().rstrip('\x00') + self.assertEqual('vpe', program) + + # + # Add a few MAP domains, then dump them later + # + def test_map(self): + t = vpp_papi.map_summary_stats() + print(t) + ip6 = IPv6Address(u'2001:db8::1').packed + ip4 = IPv4Address(u'10.0.0.0').packed + ip6_src = IPv6Address(u'2001:db9::1').packed + t = vpp_papi.map_add_domain(ip6, ip4, ip6_src, 32, 24, 128, 0, 0, 6, 0, 0) + print(t) + self.assertEqual(t.retval, 0) + + ip4 = IPv4Address(u'10.0.1.0').packed + t = vpp_papi.map_add_domain(ip6, ip4, ip6_src, 32, 24, 128, 0, 0, 6, 0, 0) + print(t) + self.assertEqual(t.retval, 0) + + t = vpp_papi.map_summary_stats() + print(t) + self.assertEqual(t.totalbindings, 2) + + t = vpp_papi.map_domain_dump() + print (t) + self.assertEqual(len(t), 2) + + def test_sw_interface_dump(self): + # + # Dump interfaces + # + t = vpp_papi.sw_interface_dump(0, b'ignored') + for interface in t: + if interface.vlmsgid == vpp_papi.VL_API_SW_INTERFACE_DETAILS: + print(interface.interfacename.decode()) + + def test_want_interface_events(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_interface_events(True, pid) + print (t) + print('Setting interface up') + t = vpp_papi.sw_interface_set_flags(0, 1, 1, 0) + print (t) + self.assertEqual(papi_event.wait(5), True) + t = vpp_papi.sw_interface_set_flags(0, 0, 0, 0) + print (t) + self.assertEqual(papi_event.wait(5), True) + + @unittest.skip("not quite ready yet") + def test_want_stats(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_stats(True, pid) + + print (t) + + # + # Wait for some stats + # + self.assertEqual(papi_event.wait(30), True) + t = vpp_papi.want_stats(False, pid) + print (t) + + def test_tap(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_stats(True, pid) + + print (t) + + t = vpp_papi.tap_connect(1, b'tap', b'foo', 1, 0) + print (t) + self.assertEqual(t.retval, 0) + swifindex = t.swifindex + + t = vpp_papi.sw_interface_set_flags(swifindex, 1, 1, 0) + print (t) + self.assertEqual(t.retval, 0) + + ip6 = IPv6Address(u'2001:db8::1').packed + t = vpp_papi.sw_interface_add_del_address(swifindex, 1, 1, 0, 16, ip6) + print (t) + time.sleep(40) + + +if __name__ == '__main__': + #logging.basicConfig(level=logging.DEBUG) + unittest.main() diff --git a/vpp-api/python/vpp_papi/__init__.py b/vpp-api/python/vpp_papi/__init__.py new file mode 100644 index 00000000..8be644d7 --- /dev/null +++ b/vpp-api/python/vpp_papi/__init__.py @@ -0,0 +1,2 @@ +__import__('pkg_resources').declare_namespace(__name__) +from .vpp_papi import * diff --git a/vpp-api/python/vpp_papi/pneum_wrap.c b/vpp-api/python/vpp_papi/pneum_wrap.c new file mode 100644 index 00000000..09d972d4 --- /dev/null +++ b/vpp-api/python/vpp_papi/pneum_wrap.c @@ -0,0 +1,120 @@ +#include +#include "pneum.h" + +static PyObject *pneum_callback = NULL; + +int +wrap_pneum_callback (char *data, int len) +{ + PyGILState_STATE gstate; + PyObject *result;//, *arglist; + + gstate = PyGILState_Ensure(); + + /* Time to call the callback */ + result = PyObject_CallFunction(pneum_callback, "y#", data, len); + if (result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); + return (0); +} + +static PyObject * +wrap_connect (PyObject *self, PyObject *args) +{ + char *name; + int rv; + PyObject *temp; + + if (!PyArg_ParseTuple(args, "sO:set_callback", &name, &temp)) + return (NULL); + + if (!PyCallable_Check(temp)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + return NULL; + } + + Py_XINCREF(temp); /* Add a reference to new callback */ + Py_XDECREF(pneum_callback); /* Dispose of previous callback */ + pneum_callback = temp; /* Remember new callback */ + + Py_BEGIN_ALLOW_THREADS + rv = pneum_connect(name); + Py_END_ALLOW_THREADS + return PyLong_FromLong(rv); +} + +static PyObject * +wrap_disconnect (PyObject *self, PyObject *args) +{ + int rv; + Py_BEGIN_ALLOW_THREADS + rv = pneum_disconnect(); + Py_END_ALLOW_THREADS + return PyLong_FromLong(rv); +} +static PyObject * +wrap_write (PyObject *self, PyObject *args) +{ + char *data; + int len, rv; + + if (!PyArg_ParseTuple(args, "s#", &data, &len)) + return NULL; + Py_BEGIN_ALLOW_THREADS + rv = pneum_write(data, len); + Py_END_ALLOW_THREADS + + return PyLong_FromLong(rv); +} + +void vl_msg_api_free(void *); + +static PyObject * +wrap_read (PyObject *self, PyObject *args) +{ + char *data; + int len, rv; + + Py_BEGIN_ALLOW_THREADS + rv = pneum_read(&data, &len); + Py_END_ALLOW_THREADS + + if (rv != 0) { Py_RETURN_NONE; } + + PyObject *ret = Py_BuildValue("y#", data, len); + if (!ret) { Py_RETURN_NONE; } + + vl_msg_api_free(data); + return ret; +} + +static PyMethodDef vpp_api_Methods[] = { + {"connect", wrap_connect, METH_VARARGS, "Connect to the VPP API."}, + {"disconnect", wrap_disconnect, METH_VARARGS, "Disconnect from the VPP API."}, + {"write", wrap_write, METH_VARARGS, "Write data to the VPP API."}, + {"read", wrap_read, METH_VARARGS, "Read data from the VPP API."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +static struct PyModuleDef vpp_api_module = { + PyModuleDef_HEAD_INIT, + "vpp_api", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + vpp_api_Methods +}; + +PyMODINIT_FUNC +PyInit_vpp_api (void) +{ + /* Ensure threading is initialised */ + if (!PyEval_ThreadsInitialized()) { + PyEval_InitThreads(); + } + return PyModule_Create(&vpp_api_module); +} diff --git a/vpp-japi/Makefile.am b/vpp-japi/Makefile.am deleted file mode 100644 index f1eb37da..00000000 --- a/vpp-japi/Makefile.am +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2015 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign subdir-objects -ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Wall - -noinst_PROGRAMS = -BUILT_SOURCES = -bin_PROGRAMS = -CLEANFILES = -lib_LTLIBRARIES = - -nobase_include_HEADERS = \ - japi/org_openvpp_vppjapi_vppApi.h \ - japi/org_openvpp_vppjapi_vppConn.h - -lib_LTLIBRARIES += libvppjni.la - -libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c -libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ - -lpthread -lm -lrt -libvppjni_la_LDFLAGS = -module -libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux - -jarfile = vppjapi-$(PACKAGE_VERSION).jar -packagedir = org/openvpp/vppjapi -JAVAROOT = . - -$(jarfile): libvppjni.la - cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd .. - -BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c - -japi/org_openvpp_vppjapi_vppConn.h: \ - japi/org/openvpp/vppjapi/vppVersion.java \ - japi/org/openvpp/vppjapi/vppInterfaceDetails.java \ - japi/org/openvpp/vppjapi/vppInterfaceCounters.java \ - japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java \ - japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java \ - japi/org/openvpp/vppjapi/vppL2Fib.java \ - japi/org/openvpp/vppjapi/vppIPv4Address.java \ - japi/org/openvpp/vppjapi/vppIPv6Address.java \ - japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \ - japi/org/openvpp/vppjapi/vppConn.java \ - japi/org/openvpp/vppjapi/vppApiCallbacks.java \ - ../vpp/api/vpe.api.h - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ; - -japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h - pushd .. ; dir=`pwd` ; popd ; \ - instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \ - vppapigen --input $${instdir}/vpp/api/vpe.api --jni japi/vppapi.c --app vpe ; \ - vppapigen --input $${instdir}/vpp/api/vpe.api --java japi/vppApi.java --app vpe ; \ - $(JAVAC) -classpath . -d . japi/vppApi.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ; - -demo = japi/test/demo.class -$(demo): $(jarfile) - $(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java - -all-local: $(jarfile) $(demo) diff --git a/vpp-japi/configure.ac b/vpp-japi/configure.ac deleted file mode 100644 index 1607061d..00000000 --- a/vpp-japi/configure.ac +++ /dev/null @@ -1,19 +0,0 @@ -AC_INIT(vpp-japi, 1.0.0) -LT_INIT -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE -AM_SILENT_RULES - -AM_PROG_AS -AC_PROG_CC -AM_PROG_CC_C_O - -AX_PROG_JAVAC -AX_PROG_JAVAH -AX_PROG_JAR -AX_PROG_JAVADOC -AX_PROG_JAVA -AX_CHECK_JAVA_HOME - -AC_OUTPUT([Makefile]) - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java deleted file mode 100644 index df5b9533..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import java.io.IOException; -import org.openvpp.vppjapi.vppApi; - -public abstract class vppApiCallbacks extends vppApi { - public vppApiCallbacks(String clientName) throws IOException { - super(clientName); - } -/* Disabled! - * - * public abstract void interfaceDetails( - int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, - byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed, - int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId, - byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny, - int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2); - */ - -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java deleted file mode 100644 index db859a07..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails; - -public final class vppBridgeDomainDetails { - public String name; - public int bdId; - public boolean flood; - public boolean uuFlood; - public boolean forward; - public boolean learn; - public boolean arpTerm; - public String bviInterfaceName; - public vppBridgeDomainInterfaceDetails[] interfaces; -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java deleted file mode 100644 index ab99ee45..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppBridgeDomainInterfaceDetails { - public String interfaceName; - public byte splitHorizonGroup; -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java b/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java deleted file mode 100644 index 3e8c12a9..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.Set; - -import org.openvpp.vppjapi.vppVersion; -import org.openvpp.vppjapi.vppInterfaceDetails; -import org.openvpp.vppjapi.vppInterfaceCounters; -import org.openvpp.vppjapi.vppBridgeDomainDetails; -import org.openvpp.vppjapi.vppIPv4Address; -import org.openvpp.vppjapi.vppIPv6Address; -import org.openvpp.vppjapi.vppVxlanTunnelDetails; - -public class vppConn implements AutoCloseable { - private static final String LIBNAME = "libvppjni.so.0.0.0"; - - static { - try { - loadLibrary(); - } catch (Exception e) { - System.out.printf("Can't find vpp jni library: %s\n", LIBNAME); - throw new ExceptionInInitializerError(e); - } - } - - private static void loadStream(final InputStream is) throws IOException { - final Set perms = PosixFilePermissions.fromString("rwxr-x---"); - final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); - try { - Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); - - try { - Runtime.getRuntime().load(p.toString()); - } catch (UnsatisfiedLinkError e) { - throw new IOException(String.format("Failed to load library %s", p), e); - } - } finally { - try { - Files.deleteIfExists(p); - } catch (IOException e) { - } - } - } - - private static void loadLibrary() throws IOException { - try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) { - if (is == null) { - throw new IOException(String.format("Failed to open library resource %s", - LIBNAME)); - } - loadStream(is); - } - } - - private static vppConn currentConnection = null; - private final String clientName; - private volatile boolean disconnected = false; - - // Hidden on purpose to prevent external instantiation - vppConn(final String clientName) throws IOException { - this.clientName = clientName; - - synchronized (vppConn.class) { - if (currentConnection != null) { - throw new IOException("Already connected as " + currentConnection.clientName); - } - - final int ret = clientConnect(clientName); - if (ret != 0) { - throw new IOException("Connection returned error " + ret); - } - - currentConnection = this; - } - } - - @Override - public synchronized final void close() { - if (!disconnected) { - disconnected = true; - - synchronized (vppConn.class) { - clientDisconnect(); - currentConnection = null; - } - } - } - - /** - * Check if this instance is connected. - * - * @throws IllegalStateException if this instance was disconnected. - */ - protected final void checkConnected() { - if (disconnected) { - throw new IllegalStateException("Disconnected client " + clientName); - } - } - - public final int getRetval(int context, int release) { - checkConnected(); - return getRetval0(context, release); - } - - public final String getInterfaceList (String nameFilter) { - checkConnected(); - return getInterfaceList0(nameFilter); - } - - public final int swIfIndexFromName (String interfaceName) { - checkConnected(); - return swIfIndexFromName0(interfaceName); - } - - public final String interfaceNameFromSwIfIndex (int swIfIndex) { - checkConnected(); - return interfaceNameFromSwIfIndex0(swIfIndex); - } - - public final void clearInterfaceTable () { - checkConnected(); - clearInterfaceTable0(); - } - - public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) { - checkConnected(); - return swInterfaceDump0(nameFilterValid, nameFilter); - } - - public final int bridgeDomainIdFromName(String bridgeDomain) { - checkConnected(); - return bridgeDomainIdFromName0(bridgeDomain); - } - - public final int findOrAddBridgeDomainId(String bridgeDomain) { - checkConnected(); - return findOrAddBridgeDomainId0(bridgeDomain); - } - - public final vppVersion getVppVersion() { - checkConnected(); - return getVppVersion0(); - } - - public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) { - checkConnected(); - return getInterfaceCounters0(swIfIndex); - } - - public final int[] bridgeDomainDump(int bdId) { - checkConnected(); - return bridgeDomainDump0(bdId); - } - - public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) { - checkConnected(); - return getBridgeDomainDetails0(bdId); - } - - public final vppL2Fib[] l2FibTableDump(int bdId) { - checkConnected(); - return l2FibTableDump0(bdId); - } - - public final int bridgeDomainIdFromInterfaceName(String interfaceName) { - checkConnected(); - return bridgeDomainIdFromInterfaceName0(interfaceName); - } - - public final vppIPv4Address[] ipv4AddressDump(String interfaceName) { - checkConnected(); - return ipv4AddressDump0(interfaceName); - } - - public final vppIPv6Address[] ipv6AddressDump(String interfaceName) { - checkConnected(); - return ipv6AddressDump0(interfaceName); - } - - public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) { - checkConnected(); - return vxlanTunnelDump0(swIfIndex); - } - - public final int setInterfaceDescription(String ifName, String ifDesc) { - checkConnected(); - return setInterfaceDescription0(ifName, ifDesc); - } - - public final String getInterfaceDescription(String ifName) { - checkConnected(); - return getInterfaceDescription0(ifName); - } - - private static native int clientConnect(String clientName); - private static native void clientDisconnect(); - private static native int getRetval0(int context, int release); - private static native String getInterfaceList0(String nameFilter); - private static native int swIfIndexFromName0(String interfaceName); - private static native String interfaceNameFromSwIfIndex0(int swIfIndex); - private static native void clearInterfaceTable0(); - private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter); - private static native int bridgeDomainIdFromName0(String bridgeDomain); - private static native int findOrAddBridgeDomainId0(String bridgeDomain); - private static native vppVersion getVppVersion0(); - private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex); - private static native int[] bridgeDomainDump0(int bdId); - private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId); - private static native vppL2Fib[] l2FibTableDump0(int bdId); - private static native int bridgeDomainIdFromInterfaceName0(String interfaceName); - private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName); - private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName); - private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex); - private static native int setInterfaceDescription0(String ifName, String ifDesc); - private static native String getInterfaceDescription0(String ifName); -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java deleted file mode 100644 index 046ceab5..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppIPv4Address { - public final int ip; - public final byte prefixLength; - - public vppIPv4Address(int ip, byte prefixLength) { - this.ip = ip; - this.prefixLength = prefixLength; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java deleted file mode 100644 index 6690a5db..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public class vppIPv6Address { - // FIXME: this is dangerous - public final byte[] ip; - public final byte prefixLength; - - public vppIPv6Address(byte[] ip, byte prefixLength) { - this.ip = ip; - this.prefixLength = prefixLength; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java deleted file mode 100644 index b2687fb8..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppInterfaceCounters { - - public final long rxOctets; - public final long rxIp4; - public final long rxIp6; - public final long rxUnicast; - public final long rxMulticast; - public final long rxBroadcast; - public final long rxDiscard; - public final long rxFifoFull; - public final long rxError; - public final long rxUnknownProto; - public final long rxMiss; - - public final long txOctets; - public final long txIp4; - public final long txIp6; - public final long txUnicast; - public final long txMulticast; - public final long txBroadcast; - public final long txDiscard; - public final long txFifoFull; - public final long txError; - public final long txUnknownProto; - public final long txMiss; - - public vppInterfaceCounters( - long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti, - long rxBcast, long rxDiscard, long rxFifoFull, long rxError, - long rxUnknownProto, long rxMiss, - long txOctets, long txIp4, long txIp6, long txUni, long txMulti, - long txBcast, long txDiscard, long txFifoFull, long txError, - long txUnknownProto, long txMiss) - { - this.rxOctets = rxOctets; - this.rxIp4 = rxIp4; - this.rxIp6 = rxIp6; - this.rxUnicast = rxUni; - this.rxMulticast = rxMulti; - this.rxBroadcast = rxBcast; - this.rxDiscard = rxDiscard; - this.rxFifoFull = rxFifoFull; - this.rxError = rxError; - this.rxUnknownProto = rxUnknownProto; - this.rxMiss = rxMiss; - - this.txOctets = txOctets; - this.txIp4 = txIp4; - this.txIp6 = txIp6; - this.txUnicast = txUni; - this.txMulticast = txMulti; - this.txBroadcast = txBcast; - this.txDiscard = txDiscard; - this.txFifoFull = txFifoFull; - this.txError = txError; - this.txUnknownProto = txUnknownProto; - this.txMiss = txMiss; - } -} - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java deleted file mode 100644 index 742dd25a..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppInterfaceDetails { - public final int ifIndex; - public final String interfaceName; - public final int supIfIndex; - // FIXME: this is dangerous - public final byte[] physAddr; - public final byte adminUp; - public final byte linkUp; - public final byte linkDuplex; - public final byte linkSpeed; - public final int subId; - public final byte subDot1ad; - public final byte subNumberOfTags; - public final int subOuterVlanId; - public final int subInnerVlanId; - public final byte subExactMatch; - public final byte subDefault; - public final byte subOuterVlanIdAny; - public final byte subInnerVlanIdAny; - public final int vtrOp; - public final int vtrPushDot1q; - public final int vtrTag1; - public final int vtrTag2; - public final int linkMtu; - - public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp, - byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags, - int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, - byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu) - { - this.ifIndex = ifIndex; - this.interfaceName = interfaceName; - this.supIfIndex = supIfIndex; - this.physAddr = physAddr; - this.adminUp = adminUp; - this.linkUp = linkUp; - this.linkDuplex = linkDuplex; - this.linkSpeed = linkSpeed; - this.subId = subId; - this.subDot1ad = subDot1ad; - this.subNumberOfTags = subNumberOfTags; - this.subOuterVlanId = subOuterVlanId; - this.subInnerVlanId = subInnerVlanId; - this.subExactMatch = subExactMatch; - this.subDefault = subDefault; - this.subOuterVlanIdAny = subOuterVlanIdAny; - this.subInnerVlanIdAny = subInnerVlanIdAny; - this.vtrOp = vtrOp; - this.vtrPushDot1q = vtrPushDot1q; - this.vtrTag1 = vtrTag1; - this.vtrTag2 = vtrTag2; - this.linkMtu = linkMtu; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java deleted file mode 100644 index b38d801e..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppL2Fib { - // FIXME: this is dangerous - public final byte[] physAddress; - public final boolean staticConfig; - public final String outgoingInterface; - public final boolean filter; - public final boolean bridgedVirtualInterface; - - public vppL2Fib(byte[] physAddress, boolean staticConfig, - String outgoingInterface, boolean filter, - boolean bridgedVirtualInterface) { - this.physAddress = physAddress; - this.staticConfig = staticConfig; - this.outgoingInterface = outgoingInterface; - this.filter = filter; - this.bridgedVirtualInterface = bridgedVirtualInterface; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java deleted file mode 100644 index 6408dee2..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppVersion { - public final String programName; - public final String buildDirectory; - public final String gitBranch; - public final String buildDate; - - public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) { - this.programName = progName; - this.buildDirectory = buildDir; - this.gitBranch = gitBranch; - this.buildDate = buildDate; - } -} - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java deleted file mode 100644 index dd81e98c..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppVxlanTunnelDetails { - public final int srcAddress; - public final int dstAddress; - public final int encapVrfId; - public final int vni; - public final int decapNextIndex; - - public vppVxlanTunnelDetails(int srcAddress, int dstAddress, - int encapVrfId, int vni, int decapNextIndex) { - this.srcAddress = srcAddress; - this.dstAddress = dstAddress; - this.encapVrfId = encapVrfId; - this.vni = vni; - this.decapNextIndex = decapNextIndex; - } -} diff --git a/vpp-japi/japi/test/demo.java b/vpp-japi/japi/test/demo.java deleted file mode 100644 index ea1db84b..00000000 --- a/vpp-japi/japi/test/demo.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.openvpp.vppjapi.*; - -public class demo { - public static void main (String[] args) throws Exception { - vppApi api = new vppApi ("JavaTest"); - System.out.printf ("Connected OK..."); - - String intlist; - int [] contexts; - int i, limit; - int trips; - int rv, errors, saved_error; - long before, after; - - if (false) - { - intlist = api.getInterfaceList (""); - System.out.printf ("Unfiltered interface list:\n%s", intlist); - - trips = 0; - - contexts = new int[6]; - - for (i = 0; i < 6; i++) - { - contexts[i] = api.swInterfaceSetFlags - (5 + i /* sw_if_index */, - (byte)1 /* admin_up */, - (byte)1 /* link_up (ignored) */, - (byte)0 /* deleted */); - } - - /* Thread.sleep (1); */ - errors = 0; - saved_error = 0; - - for (i = 0; i < 6; i ++) - { - while (true) - { - rv = api.getRetval (contexts[i], 1 /* release */); - if (rv != -77) - break; - Thread.sleep (1); - trips++; - } - if (rv < 0) - { - saved_error = rv; - errors++; - } - } - - if (errors == 0) - System.out.printf ("intfcs up...\n"); - else - System.out.printf - ("%d errors, last error %d...\n", errors, saved_error); - } - - limit = 250000; - saved_error = 0; - errors = 0; - contexts = new int [limit]; - byte [] address = new byte [4]; - byte [] zeros = new byte [4]; - - address[0] = (byte)192; - address[1] = (byte)168; - address[2] = (byte)2; - address[3] = (byte)1; - - for (i = 0; i < 4; i++) - zeros[i] = 0; - - System.out.printf ("start %d route ops ...", limit); - - before = System.currentTimeMillis(); - - for (i = 0; i < limit; i++) { - contexts[i] = api.ipAddDelRoute - (0 /* int nextHopSwIfIndex */, - 0 /* int vrfId */, - 0 /* int lookupInVrf */, - 0 /* int resolveAttempts */, - 0 /* int classifyTableIndex */, - (byte)0 /* byte createVrfIfNeeded */, - (byte)0 /* byte resolveIfNeeded */, - (byte)1 /* byte isAdd */, - (byte)1 /* byte isDrop */, - (byte)0 /* byte isIpv6 */, - (byte)0 /* byte isLocal */, - (byte)0 /* byte isClassify */, - (byte)0 /* byte isMultipath */, - (byte)0 /* byte notLast */, - (byte)0 /* byte nextHopWeight */, - (byte)32 /* byte dstAddressLength */, - address, - zeros); - - address[3] += 1; - if (address[3] == 0) - { - address[2] += 1; - if (address[2] == 0) - { - address[1] += 1; - { - if (address[1] == 0) - { - address[0] += 1; - } - } - } - } - } - - trips = 0; - - for (i = 0; i < limit; i++) - { - while (true) - { - rv = api.getRetval (contexts[i], 1 /* release */); - if (rv != -77) - break; - Thread.sleep (1); - trips++; - } - if (rv < 0) - { - saved_error = rv; - errors++; - } - } - - after = System.currentTimeMillis(); - - - if (errors == 0) - System.out.printf ("done %d route ops (all OK)...\n", limit); - else - System.out.printf - ("%d errors, last error %d...\n", errors, saved_error); - - System.out.printf ("result in %d trips\n", trips); - - System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n", - limit, after - before, - limit / (after - before)); - - api.close(); - System.out.printf ("Done...\n"); - } -} diff --git a/vpp-japi/japi/test/vppApi.java b/vpp-japi/japi/test/vppApi.java deleted file mode 100644 index 87af3292..00000000 --- a/vpp-japi/japi/test/vppApi.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.net.InetAddress; -import org.openvpp.vppjapi.*; - -public class vppApi { - - native int controlPing(); - native void test (byte[] array, byte[] array2); - - public static void main (String[] args) throws Exception { - vppConn api = new vppConn (); - String ipv6 = "db01::feed"; - String ipv4 = "192.168.1.1"; - InetAddress addr6 = InetAddress.getByName(ipv6); - InetAddress addr4 = InetAddress.getByName(ipv4); - byte[] ip4bytes = addr4.getAddress(); - byte[] ip6bytes = addr6.getAddress(); - int rv; - - api.test(ip4bytes,ip6bytes); - - rv = api.clientConnect ("JavaTest"); - if (rv == 0) - System.out.printf ("Connected OK..."); - else - { - System.out.printf ("clientConnect returned %d\n", rv); - System.exit (1); - } - rv = api.controlPing(); - System.out.printf ("data plane pid is %d\n", rv); - - Thread.sleep (5000); - - api.clientDisconnect(); - System.out.printf ("Done...\n"); - } -} diff --git a/vpp-japi/japi/vppjni.c b/vpp-japi/japi/vppjni.c deleted file mode 100644 index 9c9437d2..00000000 --- a/vpp-japi/japi/vppjni.c +++ /dev/null @@ -1,1900 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#define _GNU_SOURCE /* for strcasestr(3) */ -#include - -#define vl_api_version(n,v) static u32 vpe_api_version = (v); -#include -#undef vl_api_version - -#include -#include -#include -#include -#include -#include - -#include -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -#define VPPJNI_DEBUG 0 - -#if VPPJNI_DEBUG == 1 - #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) -#else - #define DEBUG_LOG(...) -#endif - -static int connect_to_vpe(char *name); - -/* - * The Java runtime isn't compile w/ -fstack-protector, - * so we have to supply missing external references for the - * regular vpp libraries. Weak reference in case folks get religion - * at a later date... - */ -void __stack_chk_guard (void) __attribute__((weak)); -void __stack_chk_guard (void) { } - -BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V"); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood); -BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId); -BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name); -BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName); -BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;"); - -BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V"); -BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup); -BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName); - -BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V"); -BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V"); -BIND_JAPI_CLASS(vppIPv4Address, "(IB)V"); -BIND_JAPI_CLASS(vppIPv6Address, "([BB)V"); -BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V"); -BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); -BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V"); - -void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) -{ - /* - * Send the main API signature in slot 0. This bit of code must - * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). - */ - mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); -} - -/* Note: non-static, called once to set up the initial intfc table */ -static int sw_interface_dump (vppjni_main_t * jm) -{ - vl_api_sw_interface_dump_t *mp; - f64 timeout; - hash_pair_t * p; - name_sort_t * nses = 0, * ns; - sw_interface_subif_t * sub = NULL; - - /* Toss the old name table */ - hash_foreach_pair (p, jm->sw_if_index_by_interface_name, - ({ - vec_add2 (nses, ns, 1); - ns->name = (u8 *)(p->key); - ns->value = (u32) p->value[0]; - })); - - hash_free (jm->sw_if_index_by_interface_name); - - vec_foreach (ns, nses) - vec_free (ns->name); - - vec_free (nses); - - vec_foreach (sub, jm->sw_if_subif_table) { - vec_free (sub->interface_name); - } - vec_free (jm->sw_if_subif_table); - - /* recreate the interface name hash table */ - jm->sw_if_index_by_interface_name - = hash_create_string (0, sizeof(uword)); - - /* Get list of ethernets */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter-1)); - S; - - /* and local / loopback interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter-1)); - S; - - /* and vxlan tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter-1)); - S; - - /* and tap tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter-1)); - S; - - /* and host (af_packet) interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter-1)); - S; - - /* and l2tpv3 tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", - sizeof(mp->name_filter-1)); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - W; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0 - (JNIEnv *env, jobject obj) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 11); - jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name); - jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory); - jstring version = (*env)->NewStringUTF(env, (char *)jm->version); - jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date); - vppjni_unlock (jm); - - return vppVersionObject(env, progName, buildDir, version, buildDate); -} - -static int jm_show_version (vppjni_main_t *jm) -{ - int rv; - vl_api_show_version_t *mp; - f64 timeout; - - vppjni_lock (jm, 10); - M(SHOW_VERSION, show_version); - - S; - vppjni_unlock (jm); - WNR; - return rv; -} - -static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable) -{ - vl_api_want_stats_t * mp; - f64 timeout; - int rv; - - vppjni_lock (jm, 13); - - M(WANT_STATS, want_stats); - - mp->enable_disable = enable; - - S; - vppjni_unlock (jm); - WNR; - - // already subscribed / already disabled (it's ok) - if (rv == -2 || rv == -3) - rv = 0; - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0 - (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc) -{ - int rv = 0; - vppjni_main_t * jm = &vppjni_main; - uword * p; - u32 sw_if_index = ~0; - sw_if_config_t *cfg; - - const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); - const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0); - - vppjni_lock (jm, 23); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); - if (p == 0) { - rv = -1; - goto out; - } - sw_if_index = (jint) p[0]; - - u8 *if_desc = 0; - vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str)); - (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str); - - p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); - if (p != 0) { - cfg = (sw_if_config_t *) (p[0]); - if (cfg->desc) - vec_free(cfg->desc); - } else { - cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t)); - hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg); - } - - cfg->desc = if_desc; - -out: - (*env)->ReleaseStringUTFChars (env, ifName, if_name_str); - vppjni_unlock (jm); - return rv; -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0 -(JNIEnv * env, jobject obj, jstring ifName) -{ - vppjni_main_t * jm = &vppjni_main; - u32 sw_if_index = ~0; - uword * p; - jstring ifDesc = NULL; - const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); - if (!if_name_str) - return NULL; - - vppjni_lock (jm, 24); - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); - if (p == 0) - goto out; - - sw_if_index = (jint) p[0]; - - p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); - if (p == 0) - goto out; - - sw_if_config_t *cfg = (sw_if_config_t *) (p[0]); - u8 * s = format (0, "%s%c", cfg->desc, 0); - ifDesc = (*env)->NewStringUTF(env, (char *)s); - -out: - vppjni_unlock (jm); - - return ifDesc; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect - (JNIEnv *env, jobject obj, jstring clientName) -{ - int rv; - const char *client_name; - void vl_msg_reply_handler_hookup(void); - vppjni_main_t * jm = &vppjni_main; - api_main_t * am = &api_main; - u8 * heap; - mheap_t * h; - f64 timeout; - - /* - * Bail out now if we're not running as root - */ - if (geteuid() != 0) - return -1; - - if (jm->is_connected) - return -2; - - client_name = (*env)->GetStringUTFChars(env, clientName, 0); - if (!client_name) - return -3; - - if (jm->heap == 0) - clib_mem_init (0, 128<<20); - - heap = clib_mem_get_per_cpu_heap(); - h = mheap_header (heap); - - clib_time_init (&jm->clib_time); - - rv = connect_to_vpe ((char *) client_name); - - if (rv < 0) - clib_warning ("connection failed, rv %d", rv); - - (*env)->ReleaseStringUTFChars (env, clientName, client_name); - - if (rv == 0) { - vl_msg_reply_handler_hookup (); - jm->is_connected = 1; - /* make the main heap thread-safe */ - h->flags |= MHEAP_FLAG_THREAD_SAFE; - - jm->reply_hash = hash_create (0, sizeof (uword)); - //jm->callback_hash = hash_create (0, sizeof (uword)); - //jm->ping_hash = hash_create (0, sizeof (uword)); - jm->api_main = am; - vjbd_main_init(&jm->vjbd_main); - jm->sw_if_index_by_interface_name = - hash_create_string (0, sizeof (uword)); - jm->sw_if_config_by_sw_if_index = - hash_create (0, sizeof (uword)); - - { - // call control ping first to attach rx thread to java thread - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - WNR; - - if (rv != 0) { - clib_warning ("first control ping failed: %d", rv); - } - } - rv = jm_show_version(jm); - if (rv != 0) - clib_warning ("unable to retrieve vpp version (rv: %d)", rv); - rv = sw_interface_dump(jm); - if (rv != 0) - clib_warning ("unable to retrieve interface list (rv: %d)", rv); - rv = jm_stats_enable_disable(jm, 1); - if (rv != 0) - clib_warning ("unable to subscribe to stats (rv: %d)", rv); - } - DEBUG_LOG ("clientConnect result: %d", rv); - - return rv; -} - -JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect - (JNIEnv *env, jobject obj) -{ - u8 *save_heap; - vppjni_main_t * jm = &vppjni_main; - vl_client_disconnect_from_vlib(); - - save_heap = jm->heap; - memset (jm, 0, sizeof (*jm)); - jm->heap = save_heap; -} - -void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp) -{ - api_main_t * am = &api_main; - u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id); - trace_cfg_t *cfgp; - i32 retval = clib_net_to_host_u32 (mp->retval); - int total_bytes = sizeof(mp); - vppjni_main_t * jm = &vppjni_main; - u8 * saved_reply = 0; - u32 context = clib_host_to_net_u32 (mp->context); - - cfgp = am->api_trace_cfg + msg_id; - - if (!cfgp) - clib_warning ("msg id %d: no trace configuration\n", msg_id); - else - total_bytes = cfgp->size; - - jm->context_id_received = context; - - DEBUG_LOG ("Received generic reply for msg id %d", msg_id); - - /* A generic reply, successful, we're done */ - if (retval >= 0 && total_bytes == sizeof(*mp)) - return; - - /* Save the reply */ - vec_validate (saved_reply, total_bytes - 1); - memcpy (saved_reply, mp, total_bytes); - - vppjni_lock (jm, 2); - hash_set (jm->reply_hash, context, saved_reply); - jm->saved_reply_count ++; - vppjni_unlock (jm); -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0 -(JNIEnv * env, jobject obj, jint context, jint release) -{ - vppjni_main_t * jm = &vppjni_main; - vl_api_generic_reply_t * mp; - uword * p; - int rv = 0; - - /* Dunno yet? */ - if (context > jm->context_id_received) - return (VNET_API_ERROR_RESPONSE_NOT_READY); - - vppjni_lock (jm, 1); - p = hash_get (jm->reply_hash, context); - - /* - * Two cases: a generic "yes" reply - won't be in the hash table - * or "no", or "more data" which will be in the table. - */ - if (p == 0) - goto out; - - mp = (vl_api_generic_reply_t *) (p[0]); - rv = clib_net_to_host_u32 (mp->retval); - - if (release) { - u8 * free_me = (u8 *) mp; - vec_free (free_me); - hash_unset (jm->reply_hash, context); - jm->saved_reply_count --; - } - -out: - vppjni_unlock (jm); - return (rv); -} - -static int -name_sort_cmp (void * a1, void * a2) -{ - name_sort_t * n1 = a1; - name_sort_t * n2 = a2; - - return strcmp ((char *)n1->name, (char *)n2->name); -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0 - (JNIEnv * env, jobject obj, jstring name_filter) -{ - vppjni_main_t * jm = &vppjni_main; - jstring rv; - hash_pair_t * p; - name_sort_t * nses = 0, * ns; - const char *this_name; - u8 * s = 0; - const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL); - if (!nf) - return NULL; - - vppjni_lock (jm, 4); - - hash_foreach_pair (p, jm->sw_if_index_by_interface_name, - ({ - this_name = (const char *)(p->key); - if (strlen (nf) == 0 || strcasestr (this_name, nf)) { - vec_add2 (nses, ns, 1); - ns->name = (u8 *)(p->key); - ns->value = (u32) p->value[0]; - } - })); - - vec_sort_with_function (nses, name_sort_cmp); - - vec_foreach (ns, nses) - s = format (s, "%s: %d, ", ns->name, ns->value); - - _vec_len (s) = vec_len (s) - 2; - vec_terminate_c_string (s); - vppjni_unlock (jm); - - vec_free (nses); - - (*env)->ReleaseStringUTFChars (env, name_filter, nf); - - rv = (*env)->NewStringUTF (env, (char *) s); - vec_free (s); - - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0 - (JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - if (if_name) { - uword * p; - - vppjni_lock (jm, 5); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - - if (p != 0) - rv = (jint) p[0]; - - vppjni_unlock (jm); - - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - } - - return rv; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_stats_t *s; - u32 sw_if_index = swIfIndex; - jobject result = NULL; - - vppjni_lock (jm, 16); - - if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) { - goto out; - } - s = &jm->sw_if_stats_by_sw_if_index[sw_if_index]; - if (!s->valid) { - goto out; - } - - result = vppInterfaceCountersObject(env, - s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast, - s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard, - s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto, - s->rx.pkts.miss, - s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast, - s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard, - s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto, - s->tx.pkts.miss); - -out: - vppjni_unlock (jm); - return result; -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_details_t *sw_if_details; - u32 sw_if_index; - jstring ifname = NULL; - - vppjni_lock (jm, 8); - - sw_if_index = swIfIndex; - - if (sw_if_index >= vec_len(jm->sw_if_table)) { - goto out; - } - sw_if_details = &jm->sw_if_table[sw_if_index]; - if (!sw_if_details->valid) { - goto out; - } - - u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); - ifname = (*env)->NewStringUTF(env, (char *)s); - -out: - vppjni_unlock (jm); - - return ifname; -} - -JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0 -(JNIEnv * env, jobject obj) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 21); - - vec_reset_length(jm->sw_if_table); - - vppjni_unlock (jm); -} - -static jobjectArray sw_if_dump_get_interfaces (); - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0 -(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter) -{ - vppjni_main_t *jm = &vppjni_main; - f64 timeout; - vl_api_sw_interface_dump_t * mp; - u32 my_context_id; - int rv; - rv = vppjni_sanity_check (jm); - if (rv) { - clib_warning("swInterfaceDump sanity_check rv = %d", rv); - return NULL; - } - - vppjni_lock (jm, 7); - my_context_id = vppjni_get_context_id (jm); - jsize cnt = (*env)->GetArrayLength (env, name_filter); - - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->name_filter_valid = name_filter_valid; - - if (cnt > sizeof(mp->name_filter)) - cnt = sizeof(mp->name_filter); - - (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter); - - DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt); - - jm->collect_indices = 1; - - S; - { - // now send control ping so we know when it ends - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - mp->context = clib_host_to_net_u32 (my_context_id); - - S; - } - vppjni_unlock (jm); - WNR; - - vppjni_lock (jm, 7); - jobjectArray result = sw_if_dump_get_interfaces(env); - vppjni_unlock (jm); - return result; -} - -static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_details_t *sw_if_details; - u32 i; - - int len = vec_len(jm->sw_if_dump_if_indices); - - jobjectArray ifArray = vppInterfaceDetailsArray(env, len); - - for (i = 0; i < len; i++) { - u32 sw_if_index = jm->sw_if_dump_if_indices[i]; - ASSERT(sw_if_index < vec_len(jm->sw_if_table)); - sw_if_details = &jm->sw_if_table[sw_if_index]; - ASSERT(sw_if_details->valid); - - u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); - - jstring ifname = (*env)->NewStringUTF(env, (char *)s); - jint ifIndex = sw_if_details->sw_if_index; - jint supIfIndex = sw_if_details->sup_sw_if_index; - jbyteArray physAddr = (*env)->NewByteArray(env, - sw_if_details->l2_address_length); - (*env)->SetByteArrayRegion(env, physAddr, 0, - sw_if_details->l2_address_length, - (signed char*)sw_if_details->l2_address); - jint subId = sw_if_details->sub_id; - jint subOuterVlanId = sw_if_details->sub_outer_vlan_id; - jint subInnerVlanId = sw_if_details->sub_inner_vlan_id; - jint vtrOp = sw_if_details->vtr_op; - jint vtrPushDot1q = sw_if_details->vtr_push_dot1q; - jint vtrTag1 = sw_if_details->vtr_tag1; - jint vtrTag2 = sw_if_details->vtr_tag2; - jint linkMtu = sw_if_details->link_mtu; - - jbyte adminUpDown = sw_if_details->admin_up_down; - jbyte linkUpDown = sw_if_details->link_up_down; - jbyte linkDuplex = sw_if_details->link_duplex; - jbyte linkSpeed = sw_if_details->link_speed; - jbyte subDot1ad = sw_if_details->sub_dot1ad; - jbyte subNumberOfTags = sw_if_details->sub_number_of_tags; - jbyte subExactMatch = sw_if_details->sub_exact_match; - jbyte subDefault = sw_if_details->sub_default; - jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any; - jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any; - - jobject ifObj = vppInterfaceDetailsObject(env, - ifIndex, ifname, - supIfIndex, physAddr, adminUpDown, linkUpDown, - linkDuplex, linkSpeed, subId, subDot1ad, - subNumberOfTags, subOuterVlanId, subInnerVlanId, - subExactMatch, subDefault, subOuterVlanIdAny, - subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu); - (*env)->SetObjectArrayElement(env, ifArray, i, ifObj); - } - - jm->collect_indices = 0; - vec_reset_length(jm->sw_if_dump_if_indices); - return ifArray; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0 - (JNIEnv * env, jobject obj, jstring bridgeDomain) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); - if (bdName) { - static u8 * bd_name = 0; - - vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); - (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); - - vppjni_lock (jm, 6); - rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name); - vppjni_unlock (jm); - - _vec_len(bd_name) = 0; - } - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0 - (JNIEnv * env, jobject obj, jstring bridgeDomain) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); - if (bdName) { - static u8 * bd_name = 0; - - vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); - (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); - - vppjni_lock (jm, 20); - rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name); - vppjni_unlock (jm); - - _vec_len(bd_name) = 0; - } - - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0 - (JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t * jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 sw_if_index; - jint rv = -1; - const char * if_name; - uword * p; - - if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - - vppjni_lock (jm, 14); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - - if (p != 0) { - sw_if_index = (jint) p[0]; - p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index); - if (p != 0) { - rv = (jint) p[0]; - } - } - - vppjni_unlock (jm); - - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - - return rv; -} - -/* - * Special-case: build the interface table, maintain - * the next loopback sw_if_index vbl. - */ -static void vl_api_sw_interface_details_t_handler -(vl_api_sw_interface_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - static sw_interface_details_t empty_sw_if_details = {0,}; - sw_interface_details_t *sw_if_details; - u32 sw_if_index; - - vppjni_lock (jm, 1); - - sw_if_index = ntohl (mp->sw_if_index); - - u8 * s = format (0, "%s%c", mp->interface_name, 0); - - if (jm->collect_indices) { - u32 pos = vec_len(jm->sw_if_dump_if_indices); - vec_validate(jm->sw_if_dump_if_indices, pos); - jm->sw_if_dump_if_indices[pos] = sw_if_index; - } - - vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details); - sw_if_details = &jm->sw_if_table[sw_if_index]; - sw_if_details->valid = 1; - - snprintf((char *)sw_if_details->interface_name, - sizeof(sw_if_details->interface_name), "%s", (char *)s); - sw_if_details->sw_if_index = sw_if_index; - sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index); - sw_if_details->l2_address_length = ntohl (mp->l2_address_length); - ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address)); - memcpy(sw_if_details->l2_address, mp->l2_address, - sw_if_details->l2_address_length); - sw_if_details->sub_id = ntohl (mp->sub_id); - sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id); - sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id); - sw_if_details->vtr_op = ntohl (mp->vtr_op); - sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q); - sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1); - sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2); - - sw_if_details->admin_up_down = mp->admin_up_down; - sw_if_details->link_up_down = mp->link_up_down; - sw_if_details->link_duplex = mp->link_duplex; - sw_if_details->link_speed = mp->link_speed; - sw_if_details->sub_dot1ad = mp->sub_dot1ad; - sw_if_details->sub_number_of_tags = mp->sub_number_of_tags; - sw_if_details->sub_exact_match = mp->sub_exact_match; - sw_if_details->sub_default = mp->sub_default; - sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; - sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; - - hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index); - DEBUG_LOG ("Got interface %s", (char *)s); - - /* In sub interface case, fill the sub interface table entry */ - if (mp->sw_if_index != mp->sup_sw_if_index) { - sw_interface_subif_t * sub = NULL; - - vec_add2(jm->sw_if_subif_table, sub, 1); - - vec_validate(sub->interface_name, strlen((char *)s) + 1); - strncpy((char *)sub->interface_name, (char *)s, - vec_len(sub->interface_name)); - sub->sw_if_index = ntohl(mp->sw_if_index); - sub->sub_id = ntohl(mp->sub_id); - - sub->sub_dot1ad = mp->sub_dot1ad; - sub->sub_number_of_tags = mp->sub_number_of_tags; - sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id); - sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id); - sub->sub_exact_match = mp->sub_exact_match; - sub->sub_default = mp->sub_default; - sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; - sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; - - /* vlan tag rewrite */ - sub->vtr_op = ntohl(mp->vtr_op); - sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q); - sub->vtr_tag1 = ntohl(mp->vtr_tag1); - sub->vtr_tag2 = ntohl(mp->vtr_tag2); - } - vppjni_unlock (jm); -} - -static void vl_api_sw_interface_set_flags_t_handler -(vl_api_sw_interface_set_flags_t * mp) -{ - /* $$$ nothing for the moment */ -} - -static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 *buf = NULL; - u32 i; - - if (bd_id != ~0) { - vec_add1(buf, bd_id); - } else { - for (i = 0; i < vec_len(bdm->bd_oper); i++) { - u32 bd_id = bdm->bd_oper[i].bd_id; - vec_add1(buf, bd_id); - } - } - - jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf)); - if (!bdidArray) { - goto out; - } - - (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf); - -out: - vec_free(buf); - return bdidArray; -} - -static void bridge_domain_oper_free(void) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t *bdm = &jm->vjbd_main; - u32 i; - - for (i = 0; i < vec_len(bdm->bd_oper); i++) { - vec_free(bdm->bd_oper->l2fib_oper); - } - vec_reset_length(bdm->bd_oper); - hash_free(bdm->bd_id_by_sw_if_index); - hash_free(bdm->oper_bd_index_by_bd_id); -} - -JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0 -(JNIEnv * env, jobject obj, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_bridge_domain_dump_t * mp; - u32 my_context_id; - f64 timeout; - int rv; - rv = vppjni_sanity_check (jm); - if (rv) return NULL; - - vppjni_lock (jm, 15); - - if (~0 == bd_id) { - bridge_domain_oper_free(); - } - - my_context_id = vppjni_get_context_id (jm); - M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->bd_id = clib_host_to_net_u32(bd_id); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - return NULL; - } - - jintArray ret = create_array_of_bd_ids(env, bd_id); - - vppjni_unlock (jm); - - return ret; -} - -static void -vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vjbd_oper_t * bd_oper; - u32 bd_id, bd_index; - - bd_id = ntohl (mp->bd_id); - - bd_index = vec_len(bdm->bd_oper); - vec_validate (bdm->bd_oper, bd_index); - bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index); - - hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index); - - bd_oper->bd_id = bd_id; - bd_oper->flood = mp->flood != 0; - bd_oper->forward = mp->forward != 0; - bd_oper->learn = mp->learn != 0; - bd_oper->uu_flood = mp->uu_flood != 0; - bd_oper->arp_term = mp->arp_term != 0; - bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index); - bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs); - - bd_oper->bd_sw_if_oper = 0; -} - -static void -vl_api_bridge_domain_sw_if_details_t_handler -(vl_api_bridge_domain_sw_if_details_t * mp) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - bd_sw_if_oper_t * bd_sw_if_oper; - u32 bd_id, sw_if_index; - - bd_id = ntohl (mp->bd_id); - sw_if_index = ntohl (mp->sw_if_index); - - uword *p; - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id); - return; - } - u32 oper_bd_index = (jint) p[0]; - vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - - u32 len = vec_len(bd_oper->bd_sw_if_oper); - vec_validate(bd_oper->bd_sw_if_oper, len); - bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len]; - bd_sw_if_oper->bd_id = bd_id; - bd_sw_if_oper->sw_if_index = sw_if_index; - bd_sw_if_oper->shg = mp->shg; - - hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id); -} - -static const char* interface_name_from_sw_if_index(u32 sw_if_index) -{ - vppjni_main_t *jm = &vppjni_main; - - if (sw_if_index >= vec_len(jm->sw_if_table)) { - return NULL; - } - if (!jm->sw_if_table[sw_if_index].valid) { - return NULL; - } - return (const char*)jm->sw_if_table[sw_if_index].interface_name; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0 -(JNIEnv * env, jobject obj, jint bdId) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 oper_bd_index; - u32 bd_id = bdId; - jobject rv = NULL; - uword *p; - - vppjni_lock (jm, 16); - - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - rv = NULL; - goto out; - } - oper_bd_index = (jint) p[0]; - - vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - - - /* setting BridgeDomainDetails */ - - jobject bddObj = vppBridgeDomainDetailsObject(env); - - u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id); - if (NULL == vec_bd_name) { - rv = NULL; - goto out; - } - char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0); - vec_free(vec_bd_name); - jstring bdName = (*env)->NewStringUTF(env, str_bd_name); - vec_free(str_bd_name); - if (NULL == bdName) { - rv = NULL; - goto out; - } - - set_vppBridgeDomainDetails_name(env, bddObj, bdName); - set_vppBridgeDomainDetails_bdId(env, bddObj, bdId); - set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood); - set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood); - set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward); - set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn); - set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term); - - jstring bviInterfaceName = NULL; - if (~0 != bd_oper->bvi_sw_if_index) { - const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index); - if (NULL == str_if_name) { - clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index); - rv = NULL; - goto out; - } - bviInterfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == bviInterfaceName) { - rv = NULL; - goto out; - } - } - - set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName); - - /* setting BridgeDomainInterfaceDetails */ - - u32 len = vec_len(bd_oper->bd_sw_if_oper); - ASSERT(len == bd_oper->n_sw_ifs); - - jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len); - - u32 i; - for (i = 0; i < len; i++) { - bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i]; - - jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env); - (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj); - - u32 sw_if_index = sw_if_oper->sw_if_index; - const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); - if (NULL == str_if_name) { - rv = NULL; - goto out; - } - jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == interfaceName) { - rv = NULL; - goto out; - } - - set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName); - set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg); - } - - set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray); - - rv = bddObj; - -out: - - vppjni_unlock (jm); - - return rv; -} - -static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib) -{ - u32 sw_if_index = l2_fib->sw_if_index; - const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); - if (NULL == str_if_name) { - return NULL; - } - jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == interfaceName) { - return NULL; - } - - jbyteArray physAddr = (*env)->NewByteArray(env, 6); - (*env)->SetByteArrayRegion(env, physAddr, 0, 6, - (signed char*)l2_fib->mac_addr.fields.mac); - jboolean staticConfig = !l2_fib->learned; - jstring outgoingInterface = interfaceName; - jboolean filter = l2_fib->filter; - jboolean bridgedVirtualInterface = l2_fib->bvi; - - return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface); -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0 -(JNIEnv * env, jobject obj, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vl_api_l2_fib_table_dump_t *mp; - jobjectArray l2FibArray = NULL; - vjbd_oper_t *bd_oper; - u32 oper_bd_index; - uword *p; - f64 timeout; - int rv; - u32 i; - - vppjni_lock (jm, 17); - - //vjbd_l2fib_oper_reset (bdm); - - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - goto done; - } - oper_bd_index = p[0]; - bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - vec_reset_length (bd_oper->l2fib_oper); - - /* Get list of l2 fib table entries */ - M(L2_FIB_TABLE_DUMP, l2_fib_table_dump); - mp->bd_id = ntohl(bd_id); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - goto done; - } - - u32 count = vec_len(bd_oper->l2fib_oper); - bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper; - - l2FibArray = vppL2FibArray(env, count); - for (i = 0; i < count; i++) { - bd_l2fib_oper_t *l2_fib = &l2fib_oper[i]; - jobject l2FibObj = l2_fib_create_object(env, l2_fib); - (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj); - } - -done: - vppjni_unlock (jm); - - return l2FibArray; -} - -static void -vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp) -{ - //static u8 * mac_addr; - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vjbd_oper_t * bd_oper; - u32 bd_id, oper_bd_index; - //uword mhash_val_l2fi; - bd_l2fib_oper_t * l2fib_oper; - l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac; - - bd_id = ntohl (mp->bd_id); - - uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - return; - } - oper_bd_index = (jint) p[0]; - bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - -#if 0 - vec_validate (mac_addr, MAC_ADDRESS_SIZE); - memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE); - mhash_val_l2fi = vec_len (bd_oper->l2fib_oper); - if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0) - mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); - mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0); -#endif - - vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1); - - l2fib_oper->bd_id = bd_id; - l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac); - l2fib_oper->sw_if_index = ntohl (mp->sw_if_index); - l2fib_oper->learned = !mp->static_mac; - l2fib_oper->filter = mp->filter_mac; - l2fib_oper->bvi = mp->bvi_mac; -} - -static int ipAddressDump -(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_ip_address_dump_t * mp; - const char *if_name; - u32 my_context_id; - u32 sw_if_index; - f64 timeout; - uword *p; - int rv = 0; - - if (NULL == interfaceName) { - return -1; - } - - if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - if (!if_name) { - return -1; - } - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - if (p == 0) { - return -1; - } - sw_if_index = (u32) p[0]; - - rv = vppjni_sanity_check (jm); - if (0 != rv) { - return rv; - } - - my_context_id = vppjni_get_context_id (jm); - M(IP_ADDRESS_DUMP, ip_address_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->sw_if_index = clib_host_to_net_u32(sw_if_index); - mp->is_ipv6 = isIPv6; - jm->is_ipv6 = isIPv6; - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - - return rv; -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0 -(JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t *jm = &vppjni_main; - jobject returnArray = NULL; - int i; - - vppjni_lock (jm, 18); - - vec_reset_length(jm->ipv4_addresses); - - if (0 != ipAddressDump(env, obj, interfaceName, 0)) { - goto done; - } - - u32 count = vec_len(jm->ipv4_addresses); - ipv4_address_t *ipv4_address = jm->ipv4_addresses; - - jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count); - - for (i = 0; i < count; i++) { - ipv4_address_t *address = &ipv4_address[i]; - - jint ip = address->ip; - jbyte prefixLength = address->prefix_length; - - jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength); - - (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj); - } - - returnArray = ipv4AddressArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0 -(JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t *jm = &vppjni_main; - jobject returnArray = NULL; - int i; - - vppjni_lock (jm, 19); - - vec_reset_length(jm->ipv6_addresses); - - if (0 != ipAddressDump(env, obj, interfaceName, 1)) { - goto done; - } - - u32 count = vec_len(jm->ipv6_addresses); - ipv6_address_t *ipv6_address = jm->ipv6_addresses; - - jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count); - - for (i = 0; i < count; i++) { - ipv6_address_t *address = &ipv6_address[i]; - - jbyteArray ip = (*env)->NewByteArray(env, 16); - (*env)->SetByteArrayRegion(env, ip, 0, 16, - (signed char*)address->ip); - - jbyte prefixLength = address->prefix_length; - - jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength); - - (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj); - } - - returnArray = ipv6AddressArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - - if (!jm->is_ipv6) { - ipv4_address_t *address = 0; - vec_add2(jm->ipv4_addresses, address, 1); - memcpy(&address->ip, mp->ip, 4); - address->prefix_length = mp->prefix_length; - } else { - ipv6_address_t *address = 0; - vec_add2(jm->ipv6_addresses, address, 1); - memcpy(address->ip, mp->ip, 16); - address->prefix_length = mp->prefix_length; - } -} - -#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel" - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_vxlan_tunnel_dump_t * mp; - jobjectArray returnArray = NULL; - u32 my_context_id; - f64 timeout; - int rv = 0; - int i; - - vppjni_lock (jm, 22); - - vec_reset_length(jm->vxlan_tunnel_details); - - my_context_id = vppjni_get_context_id (jm); - M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->sw_if_index = clib_host_to_net_u32 (swIfIndex); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - goto done; - } - - u32 count = vec_len(jm->vxlan_tunnel_details); - - jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count); - - for (i = 0; i < count; i++) { - vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i]; - - jint src_address = details->src_address; - jint dst_address = details->dst_address; - jint encap_vrf_id = details->encap_vrf_id; - jint vni = details->vni; - jint decap_next_index = details->decap_next_index; - - jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env, - src_address, dst_address, encap_vrf_id, vni, decap_next_index); - - (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i, - vxlanTunnelDetailsObj); - } - - returnArray = vxlanTunnelDetailsArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -static void vl_api_vxlan_tunnel_details_t_handler -(vl_api_vxlan_tunnel_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - vxlan_tunnel_details_t *tunnel_details; - - vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1); - tunnel_details->src_address = ntohl(mp->src_address); - tunnel_details->dst_address = ntohl(mp->dst_address); - tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id); - tunnel_details->vni = ntohl(mp->vni); - tunnel_details->decap_next_index = ntohl(mp->decap_next_index); -} - -/* cleanup handler for RX thread */ -static void cleanup_rx_thread(void *arg) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 99); - - int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); - if (getEnvStat == JNI_EVERSION) { - clib_warning ("Unsupported JNI version\n"); - jm->retval = -999; - goto out; - } else if (getEnvStat != JNI_EDETACHED) { - (*jm->jvm)->DetachCurrentThread(jm->jvm); - } -out: - vppjni_unlock (jm); -} - -static void -vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - i32 retval = ntohl(mp->retval); - - if (retval >= 0) { - DEBUG_LOG ("show version request succeeded(%d)"); - strncpy((char*)jm->program_name, (const char*)mp->program, - sizeof(jm->program_name)-1); - jm->program_name[sizeof(jm->program_name)-1] = 0; - - strncpy((char*)jm->build_directory, (const char*)mp->build_directory, - sizeof(jm->build_directory)-1); - jm->build_directory[sizeof(jm->build_directory)-1] = 0; - - strncpy((char*)jm->version, (const char*)mp->version, - sizeof(jm->version)-1); - jm->version[sizeof(jm->version)-1] = 0; - - strncpy((char*)jm->build_date, (const char*)mp->build_date, - sizeof(jm->build_date)-1); - jm->build_date[sizeof(jm->build_date)-1] = 0; - } else { - clib_error ("show version request failed(%d)", retval); - } - jm->retval = retval; - jm->result_ready = 1; -} - -static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval - jm->result_ready = 1; -} - -// control ping needs to be very first thing called -// to attach rx thread to java thread -static void vl_api_control_ping_reply_t_handler -(vl_api_control_ping_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - i32 retval = ntohl(mp->retval); - jm->retval = retval; - - // attach to java thread if not attached - int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) { - clib_warning("Failed to attach thread\n"); - jm->retval = -999; - goto out; - } - - // workaround as we can't use pthread_cleanup_push - pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread); - // destructor is only called if the value of key is non null - pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1); - } else if (getEnvStat == JNI_EVERSION) { - clib_warning ("Unsupported JNI version\n"); - jm->retval = -999; - goto out; - } - // jm->jenv is now stable global reference that can be reused (only within RX thread) - -#if 0 - // ! callback system removed for now - // - // get issuer msg-id - p = hash_get (jm->ping_hash, context); - if (p != 0) { // ping marks end of some dump call - JNIEnv *env = jm->jenv; - u16 msg_id = (u16)p[0]; - - // we will no longer need this - hash_unset (jm->ping_hash, context); - - // get original caller obj - p = hash_get (jm->callback_hash, context); - - if (p == 0) // don't have callback stored - goto out; - - jobject obj = (jobject)p[0]; // object that called original call - - switch (msg_id) { - case VL_API_SW_INTERFACE_DUMP: - if (0 != sw_if_dump_call_all_callbacks(obj)) { - goto out2; - } - break; - default: - clib_warning("Unhandled control ping issuer msg-id: %d", msg_id); - goto out2; - break; - } -out2: - // free the saved obj - hash_unset (jm->callback_hash, context); - // delete global reference - (*env)->DeleteGlobalRef(env, obj); - } -#endif - -out: - jm->result_ready = 1; -} - -#define VPPJNI_DEBUG_COUNTERS 0 - -static void vl_api_vnet_interface_counters_t_handler -(vl_api_vnet_interface_counters_t *mp) -{ - vppjni_main_t *jm = &vppjni_main; - CLIB_UNUSED(char *counter_name); - u32 count, sw_if_index; - int i; - static sw_interface_stats_t empty_stats = {0, }; - - vppjni_lock (jm, 12); - count = ntohl (mp->count); - sw_if_index = ntohl (mp->first_sw_if_index); - if (mp->is_combined == 0) { - u64 * vp, v; - vp = (u64 *) mp->data; - - for (i = 0; i < count; i++) { - sw_interface_details_t *sw_if = NULL; - - v = clib_mem_unaligned (vp, u64); - v = clib_net_to_host_u64 (v); - vp++; - - if (sw_if_index < vec_len(jm->sw_if_table)) - sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); - - if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) { - vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); - sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); - - s->sw_if_index = sw_if_index; - s->valid = 1; - - switch (mp->vnet_counter_type) { - case VNET_INTERFACE_COUNTER_DROP: - counter_name = "drop"; - s->rx.pkts.discard = v; - break; - case VNET_INTERFACE_COUNTER_PUNT: - counter_name = "punt"; - s->rx.pkts.unknown_proto = v; - break; - case VNET_INTERFACE_COUNTER_IP4: - counter_name = "ip4"; - s->rx.pkts.ip4 = v; - break; - case VNET_INTERFACE_COUNTER_IP6: - counter_name = "ip6"; - s->rx.pkts.ip6 = v; - break; - case VNET_INTERFACE_COUNTER_RX_NO_BUF: - counter_name = "rx-no-buf"; - s->rx.pkts.fifo_full = v; - break; - case VNET_INTERFACE_COUNTER_RX_MISS: - counter_name = "rx-miss"; - s->rx.pkts.miss = v; - break; - case VNET_INTERFACE_COUNTER_RX_ERROR: - counter_name = "rx-error"; - s->rx.pkts.error = v; - break; - case VNET_INTERFACE_COUNTER_TX_ERROR: - counter_name = "tx-error (fifo-full)"; - s->tx.pkts.fifo_full = v; - break; - default: - counter_name = "bogus"; - break; - } - -#if VPPJNI_DEBUG_COUNTERS == 1 - clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index, - counter_name, v); -#endif - } - sw_if_index++; - } - } else { - vlib_counter_t *vp; - u64 packets, bytes; - vp = (vlib_counter_t *) mp->data; - - for (i = 0; i < count; i++) { - sw_interface_details_t *sw_if = NULL; - - packets = clib_mem_unaligned (&vp->packets, u64); - packets = clib_net_to_host_u64 (packets); - bytes = clib_mem_unaligned (&vp->bytes, u64); - bytes = clib_net_to_host_u64 (bytes); - vp++; - - if (sw_if_index < vec_len(jm->sw_if_table)) - sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); - - if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) { - vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); - sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); - - s->valid = 1; - s->sw_if_index = sw_if_index; - - switch (mp->vnet_counter_type) { - case VNET_INTERFACE_COUNTER_RX: - s->rx.pkts.unicast = packets; - s->rx.octets = bytes; - counter_name = "rx"; - break; - - case VNET_INTERFACE_COUNTER_TX: - s->tx.pkts.unicast = packets; - s->tx.octets = bytes; - counter_name = "tx"; - break; - - default: - counter_name = "bogus"; - break; - } - -#if VPPJNI_DEBUG_COUNTERS == 1 - clib_warning ("%s (%d): %s.packets %lld\n", - sw_if->interface_name, - sw_if_index, counter_name, packets); - clib_warning ("%s (%d): %s.bytes %lld\n", - sw_if->interface_name, - sw_if_index, counter_name, bytes); -#endif - } - sw_if_index++; - } - } - vppjni_unlock (jm); -} - -jint JNI_OnLoad(JavaVM *vm, void *reserved) { - vppjni_main_t * jm = &vppjni_main; - JNIEnv* env; - if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { - return JNI_ERR; - } - - if (vppjni_init(env) != 0) { - return JNI_ERR; - } - - jm->jvm = vm; - return JNI_VERSION_1_6; -} - -void JNI_OnUnload(JavaVM *vm, void *reserved) { - vppjni_main_t * jm = &vppjni_main; - JNIEnv* env; - if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { - return; - } - - vppjni_uninit(env); - - jm->jenv = NULL; - jm->jvm = NULL; -} - -#define foreach_vpe_api_msg \ -_(CONTROL_PING_REPLY, control_ping_reply) \ -_(SW_INTERFACE_DETAILS, sw_interface_details) \ -_(SHOW_VERSION_REPLY, show_version_reply) \ -_(WANT_STATS_REPLY, want_stats_reply) \ -_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \ -_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ -_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \ -_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \ -_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ -_(IP_ADDRESS_DETAILS, ip_address_details) \ -_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) - -static int connect_to_vpe(char *name) -{ - vppjni_main_t * jm = &vppjni_main; - api_main_t * am = &api_main; - - if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0) - return -1; - - jm->my_client_index = am->my_client_index; - jm->vl_input_queue = am->shmem_hdr->vl_input_queue; - -#define _(N,n) \ - vl_msg_api_set_handlers(VL_API_##N, #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_msg; -#undef _ - - return 0; -} - -/* Format an IP6 address. */ -u8 * format_ip6_address (u8 * s, va_list * args) -{ - ip6_address_t * a = va_arg (*args, ip6_address_t *); - u32 max_zero_run = 0, this_zero_run = 0; - int max_zero_run_index = -1, this_zero_run_index=0; - int in_zero_run = 0, i; - int last_double_colon = 0; - - /* Ugh, this is a pain. Scan forward looking for runs of 0's */ - for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { - if (a->as_u16[i] == 0) { - if (in_zero_run) { - this_zero_run++; - } else { - in_zero_run = 1; - this_zero_run =1; - this_zero_run_index = i; - } - } else { - if (in_zero_run) { - /* offer to compress the biggest run of > 1 zero */ - if (this_zero_run > max_zero_run && this_zero_run > 1) { - max_zero_run_index = this_zero_run_index; - max_zero_run = this_zero_run; - } - } - in_zero_run = 0; - this_zero_run = 0; - } - } - - if (in_zero_run) { - if (this_zero_run > max_zero_run && this_zero_run > 1) { - max_zero_run_index = this_zero_run_index; - max_zero_run = this_zero_run; - } - } - - for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { - if (i == max_zero_run_index) { - s = format (s, "::"); - i += max_zero_run - 1; - last_double_colon = 1; - } else { - s = format (s, "%s%x", - (last_double_colon || i == 0) ? "" : ":", - clib_net_to_host_u16 (a->as_u16[i])); - last_double_colon = 0; - } - } - - return s; -} - -/* Format an IP4 address. */ -u8 * format_ip4_address (u8 * s, va_list * args) -{ - u8 * a = va_arg (*args, u8 *); - return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); -} - - diff --git a/vpp-japi/japi/vppjni.h b/vpp-japi/japi/vppjni.h deleted file mode 100644 index bd0683ae..00000000 --- a/vpp-japi/japi/vppjni.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __included_vppjni_h__ -#define __included_vppjni_h__ - -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - u8 * name; - u32 value; -} name_sort_t; - -typedef struct { - u8 valid; // used in a vector of sw_interface_details_t - - u8 interface_name[64]; - u32 sw_if_index; - u32 sup_sw_if_index; - u32 l2_address_length; - u8 l2_address[8]; - u8 admin_up_down; - u8 link_up_down; - u8 link_duplex; - u8 link_speed; - u16 link_mtu; - u32 sub_id; - u8 sub_dot1ad; - u8 sub_number_of_tags; - u16 sub_outer_vlan_id; - u16 sub_inner_vlan_id; - u8 sub_exact_match; - u8 sub_default; - u8 sub_outer_vlan_id_any; - u8 sub_inner_vlan_id_any; - u32 vtr_op; - u32 vtr_push_dot1q; - u32 vtr_tag1; - u32 vtr_tag2; -} sw_interface_details_t; - -typedef struct { - u8 * interface_name; - u32 sw_if_index; - /* - * Subinterface ID. A number 0-N to uniquely identify - * this subinterface under the super interface - */ - u32 sub_id; - - /* 0 = dot1q, 1=dot1ad */ - u8 sub_dot1ad; - - /* Number of tags 0-2 */ - u8 sub_number_of_tags; - u16 sub_outer_vlan_id; - u16 sub_inner_vlan_id; - u8 sub_exact_match; - u8 sub_default; - u8 sub_outer_vlan_id_any; - u8 sub_inner_vlan_id_any; - - /* vlan tag rewrite */ - u32 vtr_op; - u32 vtr_push_dot1q; - u32 vtr_tag1; - u32 vtr_tag2; -} sw_interface_subif_t; - -typedef struct { - u8 *desc; -} sw_if_config_t; - -typedef struct { - u32 ip; - u8 prefix_length; -} ipv4_address_t; - -typedef struct { - u8 ip[16]; - u8 prefix_length; -} ipv6_address_t; - -typedef struct { - u64 ip4; - u64 ip6; - u64 unicast; - u64 multicast; - u64 broadcast; - u64 discard; - u64 fifo_full; - u64 error; - u64 unknown_proto; - u64 miss; -} packet_counters_t; - -typedef struct { - u64 octets; - packet_counters_t pkts; -} if_counters_t; - -typedef struct { - u8 valid; - u32 sw_if_index; - if_counters_t rx; - if_counters_t tx; -} sw_interface_stats_t; - -typedef struct { - u32 src_address; - u32 dst_address; - u32 encap_vrf_id; - u32 vni; - u32 decap_next_index; -} vxlan_tunnel_details_t; - - -typedef struct { - /* Context IDs */ - volatile u32 context_id_sent; - volatile u32 context_id_received; - - /* Spinlock */ - volatile u32 lock; - u32 tag; - - /* To recycle pseudo-synchronous message code from vpp_api_test... */ - volatile u32 result_ready; - volatile i32 retval; - volatile u8 *shmem_result; - - /* thread cleanup */ - pthread_key_t cleanup_rx_thread_key; - /* attachment of rx thread to java thread */ - JNIEnv *jenv; - JavaVM *jvm; - uword *callback_hash; // map context_id => jobject - uword *ping_hash; // map ping context_id => msg type called - - /* Timestamp */ - clib_time_t clib_time; - - /* connected indication */ - u8 is_connected; - - /* context -> non-trivial reply hash */ - uword * reply_hash; - u32 saved_reply_count; - - /* interface name map */ - uword * sw_if_index_by_interface_name; - - /* interface counters */ - sw_interface_stats_t * sw_if_stats_by_sw_if_index; - - /* interface table */ - sw_interface_details_t * sw_if_table; - - uword * sw_if_config_by_sw_if_index; - - /* interface indices of responses to one sw_if_dump request */ - u8 collect_indices; - u32 * sw_if_dump_if_indices; - - /* program name, build_dir, version */ - u8 program_name[32]; - u8 build_directory[256]; - u8 version[32]; - u8 build_date[32]; - - /* subinterface table */ - sw_interface_subif_t * sw_if_subif_table; - - /* used in ip_address_dump request and response handling */ - ipv4_address_t *ipv4_addresses; - ipv6_address_t *ipv6_addresses; - u8 is_ipv6; - - /* used in vxlan_tunnel_dump request and response handling */ - vxlan_tunnel_details_t *vxlan_tunnel_details; - - /* main heap */ - u8 * heap; - - /* convenience */ - unix_shared_memory_queue_t * vl_input_queue; - api_main_t * api_main; - u32 my_client_index; - - vjbd_main_t vjbd_main; -} vppjni_main_t; - -vppjni_main_t vppjni_main __attribute__((aligned (64))); - - -static inline u32 vppjni_get_context_id (vppjni_main_t * jm) -{ - u32 my_context_id; - my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1); - return my_context_id; -} - -static inline void vppjni_lock (vppjni_main_t * jm, u32 tag) -{ - while (__sync_lock_test_and_set (&jm->lock, 1)) - ; - jm->tag = tag; -} - -static inline void vppjni_unlock (vppjni_main_t * jm) -{ - jm->tag = 0; - CLIB_MEMORY_BARRIER(); - jm->lock = 0; -} - -static inline f64 vppjni_time_now (vppjni_main_t *jm) -{ - return clib_time_now (&jm->clib_time); -} - -static inline int vppjni_sanity_check (vppjni_main_t * jm) -{ - if (!jm->is_connected) - return VNET_API_ERROR_NOT_CONNECTED; - return 0; -} - -#define __PACKED(x) x __attribute__((packed)) - -typedef __PACKED(struct _vl_api_generic_reply { - u16 _vl_msg_id; - u32 context; - i32 retval; - u8 data[0]; -}) vl_api_generic_reply_t; - -void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp); - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - jm->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = jm->my_client_index; \ - } while(0); - -#define M2(T,t,n) \ -do { \ - jm->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = jm->my_client_index; \ - } while(0); - - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ - do { \ - timeout = vppjni_time_now (jm) + 1.0; \ - \ - while (vppjni_time_now (jm) < timeout) { \ - if (jm->result_ready == 1) { \ - return (jm->retval); \ - } \ - } \ - return -99; \ -} while(0); - -/* WNR: wait for results, with timeout (without returning) */ -#define WNR \ - do { \ - timeout = vppjni_time_now (jm) + 1.0; \ - \ - rv = -99; \ - while (vppjni_time_now (jm) < timeout) { \ - if (jm->result_ready == 1) { \ - rv = (jm->retval); \ - break; \ - } \ - } \ -} while(0); - -#endif /* __included_vppjni_h__ */ diff --git a/vpp-japi/japi/vppjni_bridge_domain.h b/vpp-japi/japi/vppjni_bridge_domain.h deleted file mode 100644 index b614a5be..00000000 --- a/vpp-japi/japi/vppjni_bridge_domain.h +++ /dev/null @@ -1,510 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2009-2014 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------- - */ - -#ifndef __included_vppjni_bridge_domain_h__ -#define __included_vppjni_bridge_domain_h__ - -#include -#include -#include - -/* - * The L2fib key is the mac address and bridge domain ID - */ -#define MAC_ADDRESS_SIZE 6 - -typedef struct { - union { - struct { - u16 unused1; - u8 mac[MAC_ADDRESS_SIZE]; - } fields; - u64 raw; - }; -} l2fib_u64_mac_t; - -/* - * The l2fib entry results - */ -typedef struct { - u32 bd_id; - l2fib_u64_mac_t mac_addr; - u32 sw_if_index; - u8 learned:1; - u8 bvi:1; - u8 filter:1; // drop packets to/from this mac - u8 unused1:5; -} bd_l2fib_oper_t; - -typedef struct { - u32 bd_id; - u8 * bd_name; -} bd_local_cfg_t; - -typedef struct { - u32 bd_id; - u32 sw_if_index; - u32 shg; -} bd_sw_if_oper_t; - -typedef struct { - u32 bd_id; - u8 flood:1; - u8 forward:1; - u8 learn:1; - u8 uu_flood:1; - u8 arp_term:1; - u8 unused1:3; - u32 bvi_sw_if_index; - u32 n_sw_ifs; - bd_sw_if_oper_t * bd_sw_if_oper; - f64 last_sync_time; - mhash_t l2fib_index_by_mac; - bd_l2fib_oper_t * l2fib_oper; // vector indexed by l2fib_index -} vjbd_oper_t; - -#define BD_OPER_REFRESH_INTERVAL 2.0 -#define BD_OPER_L2FIB_REFRESH_INTERVAL 5.0 - -typedef struct { - u32 next_bd_id; - uword * bd_index_bitmap; - uword * bd_index_by_id; - mhash_t bd_id_by_name; - bd_local_cfg_t * local_cfg; // vector indexed by bd_index - vjbd_oper_t * bd_oper; // vector indexed by oper_bd_index - f64 bd_oper_last_sync_all_time; - bd_sw_if_oper_t * sw_if_oper; // vector indexed by sw_if_index - f64 l2fib_oper_last_sync_time; - uword * bd_id_by_sw_if_index; - uword * oper_bd_index_by_bd_id; -} vjbd_main_t; - -extern vjbd_main_t vjbd_main; - -always_inline -u64 l2fib_mac_to_u64 (u8 * mac_address) { - u64 temp; - - // The mac address in memory is A:B:C:D:E:F - // The bd id in register is H:L -#if CLIB_ARCH_IS_LITTLE_ENDIAN - // Create the in-register key as F:E:D:C:B:A:H:L - // In memory the key is L:H:A:B:C:D:E:F - temp = *((u64 *)(mac_address - 2)); - temp = (temp & ~0xffff); -#else - // Create the in-register key as H:L:A:B:C:D:E:F - // In memory the key is H:L:A:B:C:D:E:F - temp = *((u64 *)(mac_address)) >> 16; -#endif - - return temp; -} - -static_always_inline void vjbd_main_init (vjbd_main_t *bdm) -{ - bdm->bd_index_by_id = hash_create (0, sizeof(uword)); - mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32)); - bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32)); - bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32)); -} - -static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id) -{ - return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id)); -} - -static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index) -{ - u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; - - return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) && - (bd_index < vec_len (bdm->local_cfg)) && - ((bd_id == 0) || (bd_id == ~0))); -} - -static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index) -{ - return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) && - (bd_index < vec_len (bdm->local_cfg))); -} - -static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm, - const u8 * bd_name) -{ - u32 bd_id; - uword * p; - - ASSERT (vec_c_string_is_terminated (bd_name)); - - if (bdm->next_bd_id == 0) - return ~0; - - p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name); - if (p) - { - bd_id = p[0]; - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - } - else - bd_id = ~0; - - return bd_id; -} - -static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - uword * p; - u16 bd_index; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - p = hash_get (bdm->bd_index_by_id, bd_id); - - ASSERT (p); // there is always an index associated with a valid bd_id - bd_index = p[0]; - - ASSERT (vjbd_index_is_valid (bdm, bd_index)); - - return bd_index; -} - -static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index) -{ - u32 bd_id; - - ASSERT (vjbd_index_is_valid (bdm, bd_index)); - - bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - return bd_id; -} - -static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - - return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name; -} - -static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - if (vjbd_id_is_valid (bdm, bd_id)) { - return format(0, "%s", vjbd_name_from_id(bdm, bd_id)); - } else { - return format(0, "BridgeDomainOper%d", bd_id); - } -} - -static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm, - u32 bd_id) -{ - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - return vec_elt_at_index (bdm->bd_oper, bd_index); -} - -static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm, - u32 bd_id) -{ -#ifdef VPPJNI_OPER - vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); - - if (bd_id == ~0) - { - if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) > - BD_OPER_REFRESH_INTERVAL) - { - ovam_bridge_domain_dump (bd_id); - bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam); - } - } - - else - { - vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id); - - if ((ovam_time_now (ovam) - bd_oper->last_sync_time) > - BD_OPER_REFRESH_INTERVAL) - { - ovam_bridge_domain_dump (bd_id); - - bd_oper->last_sync_time = ovam_time_now (ovam); - } - } -#endif -} - -static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm, - u32 sw_if_index) -{ - bd_sw_if_oper_t * bd_sw_if_oper; - u32 bd_id = ~0; - - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); - if (sw_if_index < vec_len (bdm->sw_if_oper)) - { - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); - bd_id = bd_sw_if_oper->bd_id; - } - - return bd_id; -} - -static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm, - u32 sw_if_index) -{ - u32 bd_id, bd_index; - u8 * bd_name = 0; - - /* DAW-FIXME: - ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index)); - */ - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); - bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index); - if (vjbd_id_is_valid (bdm, bd_id)) - { - bd_index = vjbd_index_from_id (bdm, bd_id); - bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name; - } - - return bd_name; -} - -static_always_inline u32 -vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac) -{ - u32 l2fib_index; - uword * p; - - p = mhash_get (&bd_oper->l2fib_index_by_mac, mac); - if (p) - { - l2fib_index = p[0]; - ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper)); - } - else - l2fib_index = ~0; - - return l2fib_index; -} - -static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm, - u32 bd_id) -{ - u32 i, end = vec_len (bdm->local_cfg); - u32 next_bd_id = 0; - - if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id)) - for (i = 0; i < end; i++) - { - u32 curr_bd_id = bdm->local_cfg[i].bd_id; - if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) && - ((next_bd_id == 0) || (curr_bd_id < next_bd_id))) - next_bd_id = curr_bd_id; - } - - return next_bd_id; -} - -static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm, - u32 start, u32 bd_id) -{ - u32 i, end = vec_len (bdm->sw_if_oper); - - if (vjbd_id_is_valid (bdm, bd_id)) - for (i = start; i < end; i++) - if (bdm->sw_if_oper[i].bd_id == bd_id) - return i; - - return ~0; -} - -static_always_inline void -vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm) -{ -#ifdef VPPJNI_OPER - vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); - if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) > - BD_OPER_L2FIB_REFRESH_INTERVAL) - { - ovam_l2fib_table_dump (); - bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam); - } -#endif -} - -static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm) -{ - vjbd_oper_t * bd_oper; - - vec_foreach (bd_oper, bdm->bd_oper) - { - mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); - vec_reset_length (bd_oper->l2fib_oper); - } -} - -static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index; - u32 si, len; - vjbd_oper_t * bd_oper; - u32 end; - - if (!bdm->bd_oper) - { - ASSERT (vec_len (bdm->sw_if_oper) == 0); - return; - } - - if (bd_id == ~0) - { - bdm->bd_oper_last_sync_all_time = 0.0; - bd_index = 0; - end = vec_len (bdm->bd_oper); - } - else - { - bd_index = vjbd_index_from_id (bdm, bd_id); - end = bd_index + 1; - } - - for (; bd_index < end; bd_index++) - { - bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); - bd_oper->last_sync_time = 0.0; - - len = vec_len (bdm->sw_if_oper); - for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id); - (si != ~0) && (si < len); - si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id)) - { - bd_sw_if_oper_t * bd_sw_if_oper; - - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si); - bd_sw_if_oper->bd_id = ~0; - } - } -} - -static_always_inline void -vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add) -{ - vjbd_main_t * bdm = &vjbd_main; - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); - bd_sw_if_oper_t * bd_sw_if_oper; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - /* DAW-FIXME - ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index)); - */ - - vec_validate (bdm->sw_if_oper, sw_if_index); - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); - if (is_add) - { - bd_sw_if_oper->bd_id = bd_id; - bd_sw_if_oper->shg = shg; - bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0; - } - else - { - bd_sw_if_oper->bd_id = 0; - bd_sw_if_oper->shg = 0; - if (bd_oper->bvi_sw_if_index == sw_if_index) - bd_oper->bvi_sw_if_index = ~0; - } -} - -static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id) -{ - u32 count = 0, i, end = vec_len (bdm->sw_if_oper); - - if (vjbd_id_is_valid (bdm, bd_id)) - for (count = i = 0; i < end; i++) - if (bdm->sw_if_oper[i].bd_id == bd_id) - count++; - - return count; -} - -static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name) -{ - u16 bd_index; - u32 bd_id; - bd_local_cfg_t * bd_local_cfg; - uword mhash_val_bd_id; - - bd_id = vjbd_id_from_name (bdm, bd_name); - if (bd_id != ~0) - return bd_id; - - mhash_val_bd_id = bd_id = ++bdm->next_bd_id; - mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0); - - bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap); - vec_validate (bdm->local_cfg, bd_index); - vec_validate (bdm->bd_oper, bd_index); - - ASSERT (vjbd_index_is_free (bdm, bd_index)); - - bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); - bd_local_cfg->bd_id = bd_id; - vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name, - vec_len (bd_name) - 1); - hash_set (bdm->bd_index_by_id, bd_id, bd_index); - bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, - bd_index, 1); - return bd_id; -} - -static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index; - bd_local_cfg_t * bd_local_cfg; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - // bd must not have any members before deleting - ASSERT (!vjbd_id_sw_if_count (bdm, bd_id)); - - bd_index = vjbd_index_from_id (bdm, bd_id); - bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); - vjbd_oper_reset (bdm, bd_id); - - mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0); - bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, - bd_index, 0); - hash_unset (bdm->bd_index_by_id, bd_id); - bd_local_cfg->bd_id = ~0; - vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0); - - if (clib_bitmap_is_zero (bdm->bd_index_bitmap)) - { - vec_reset_length (bdm->local_cfg); - vec_reset_length (bdm->bd_oper); - } - - /* Force a resync of all bd_oper data. */ - bdm->bd_oper_last_sync_all_time = 0.0; - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); -} - -#endif /* __included_vppjni_vpp_bridge_domain_h__ */ diff --git a/vpp-japi/japi/vppjni_env.c b/vpp-japi/japi/vppjni_env.c deleted file mode 100644 index 1c4ea6eb..00000000 --- a/vpp-japi/japi/vppjni_env.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include "vppjni_env.h" - -// Head of the class registration list. -static vppjni_class_t *class_head; -// Head of the class registration list. -static vppjni_field_t *field_head; - -void vppjni_register_class(vppjni_class_t *ptr) -{ - vppjni_class_t **where = &class_head; - while (*where != NULL) { - where = &((*where)->next); - } - *where = ptr; -} - -void vppjni_register_field(vppjni_field_t *ptr) { - vppjni_field_t **where = &field_head; - while (*where != NULL) { - where = &((*where)->next); - } - *where = ptr; -} - -jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) { - jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - return NULL; - } - - return obj; -} - -int vppjni_init(JNIEnv *env) -{ - vppjni_class_t *cwlk; - vppjni_field_t *fwlk; - - for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { - jclass cls; - jmethodID method; - - cls = (*env)->FindClass(env, cwlk->fqcn); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - - method = (*env)->GetMethodID(env, cls, "", cwlk->init_sig); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - - cwlk->jclass = (*env)->NewGlobalRef(env, cls); - if (cwlk->jclass == NULL) { - vppjni_uninit(env); - return JNI_ERR; - } - cwlk->jinit = method; - } - - for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { - fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - } - - return 0; -} - -void vppjni_uninit(JNIEnv *env) { - vppjni_class_t *cwlk; - vppjni_field_t *fwlk; - - for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { - fwlk->jfield = NULL; - } - - for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { - if (cwlk->jclass != NULL ) { - (*env)->DeleteGlobalRef(env, cwlk->jclass); - } - - cwlk->jclass = NULL; - cwlk->jinit = NULL; - } -} - diff --git a/vpp-japi/japi/vppjni_env.h b/vpp-japi/japi/vppjni_env.h deleted file mode 100644 index 44029c2c..00000000 --- a/vpp-japi/japi/vppjni_env.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Utilities for accessing Java classes/method/fields in an efficient - * manner. - */ - -/* - * A potentially-uninitialized reference to a Java class - */ -typedef struct vppjni_class { - // Fully-Qualified Class Name - const char *fqcn; - // Constructor signature - const char *init_sig; - // Global reference to class handle - jclass jclass; - // Constructor method handle - jmethodID jinit; - // Next item in linked list - struct vppjni_class *next; -} vppjni_class_t; - -typedef struct jenv_field { - // Field name - const char *name; - // Field type - const char *type; - // Defining class reference - const vppjni_class_t *clsref; - // Field handle - jfieldID jfield; - // Next item in linked list - struct jenv_field *next; -} vppjni_field_t; - -#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name -#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init -#define BIND_JAPI_CLASS(name, sig) \ - static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \ - static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \ - static void VPPJNI_CLASS_INIT(name)() \ - { \ - VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \ - VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \ - vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \ - } \ - static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \ - { \ - return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \ - } \ - static jobject name##Object(JNIEnv *env, ...) \ - { \ - va_list ap; \ - va_start(ap, env); \ - jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \ - va_end(ap); \ - return obj; \ - } - -#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name -#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init -#define BIND_JAPI_FIELD(cls, field, sig) \ - static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \ - static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \ - static void VPPJNI_FIELD_INIT(cls, field)() \ - { \ - VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \ - VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \ - VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \ - vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \ - } -#define BIND_JAPI_BOOL_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "Z"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \ - { \ - (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_BYTE_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "B"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \ - { \ - (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_INT_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "I"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \ - { \ - (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \ - BIND_JAPI_FIELD(cls, field, sig); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \ - { \ - (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_STRING_FIELD(cls, field) \ - BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;") - -jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden"))); -void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden"))); -void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden"))); -int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden"))); -void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden"))); - diff --git a/vpp-japi/libtool b/vpp-japi/libtool deleted file mode 100755 index 5f65406b..00000000 --- a/vpp-japi/libtool +++ /dev/null @@ -1,10083 +0,0 @@ -#! /bin/sh - -# libtool - Provide generalized library-building support services. -# Generated automatically by config.status (vpp-japi) 0.1 -# Libtool was configured on host tf-ucs-3: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="" - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=2.4.2 -macro_revision=1.3337 - -# Whether or not to build shared libraries. -build_libtool_libs=yes - -# Whether or not to build static libraries. -build_old_libs=yes - -# What type of objects to build. -pic_mode=default - -# Whether or not to optimize for fast installation. -fast_install=yes - -# Shell to use when invoking shell scripts. -SHELL="/bin/sh" - -# An echo program that protects backslashes. -ECHO="printf %s\\n" - -# The PATH separator for the build system. -PATH_SEPARATOR=":" - -# The host system. -host_alias= -host=x86_64-unknown-linux-gnu -host_os=linux-gnu - -# The build system. -build_alias= -build=x86_64-unknown-linux-gnu -build_os=linux-gnu - -# A sed program that does not truncate output. -SED="/bin/sed" - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP="/bin/grep" - -# An ERE matcher. -EGREP="/bin/grep -E" - -# A literal string matcher. -FGREP="/bin/grep -F" - -# A BSD- or MS-compatible name lister. -NM="/usr/bin/nm -B" - -# Whether we need soft or hard links. -LN_S="ln -s" - -# What is the maximum length of a command? -max_cmd_len=1572864 - -# Object file suffix (normally "o"). -objext=o - -# Executable file suffix (normally ""). -exeext= - -# whether the shell understands "unset". -lt_unset=unset - -# turn spaces into newlines. -SP2NL="tr \\040 \\012" - -# turn newlines into spaces. -NL2SP="tr \\015\\012 \\040\\040" - -# convert $build file names to $host format. -to_host_file_cmd=func_convert_file_noop - -# convert $build files to toolchain format. -to_tool_file_cmd=func_convert_file_noop - -# An object symbol dumper. -OBJDUMP="objdump" - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method="pass_all" - -# Command to use when deplibs_check_method = "file_magic". -file_magic_cmd="\$MAGIC_CMD" - -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob="" - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob="no" - -# DLL creation program. -DLLTOOL="false" - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd="printf %s\\n" - -# The archiver. -AR="ar" - -# Flags to create an archive. -AR_FLAGS="cru" - -# How to feed a file listing to the archiver. -archiver_list_spec="@" - -# A symbol stripping program. -STRIP="strip" - -# Commands used to install an old-style archive. -RANLIB="ranlib" -old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$tool_oldlib" -old_postuninstall_cmds="" - -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=no - -# A C compiler. -LTCC="gcc" - -# LTCC compiler flags. -LTCFLAGS="-g -O2" - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'" - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'" - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p'" - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\(lib[^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"lib\\2\", (void *) \\&\\2},/p'" - -# Specify filename containing input files for $NM. -nm_file_list_spec="@" - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot= - -# The name of the directory that contains temporary libtool files. -objdir=.libs - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=file - -# Must we lock files when doing compilation? -need_locks="no" - -# Manifest tool. -MANIFEST_TOOL=":" - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL="" - -# Tool to change global to local symbols on Mac OS X. -NMEDIT="" - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO="" - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL="" - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64="" - -# Old archive suffix (normally "a"). -libext=a - -# Shared library suffix (normally ".so"). -shrext_cmds=".so" - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds="" - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" - -# Do we need the "lib" prefix for modules? -need_lib_prefix=no - -# Do we need a version for libraries? -need_version=no - -# Library versioning type. -version_type=linux - -# Shared library runtime path variable. -runpath_var=LD_RUN_PATH - -# Shared library path variable. -shlibpath_var=LD_LIBRARY_PATH - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=no - -# Format of library name prefix. -libname_spec="lib\$name" - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" - -# The coded name of the library, if different from the real name. -soname_spec="\${libname}\${release}\${shared_ext}\$major" - -# Permission mode override for installation of shared libraries. -install_override_mode="" - -# Command to use after installation of a shared archive. -postinstall_cmds="" - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds="" - -# Commands used to finish a libtool library installation in a directory. -finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval="" - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=yes - -# Compile-time system search path for libraries. -sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/4.8 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib " - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/mesa-egl /usr/lib/nvidia-346 /usr/lib32/nvidia-346 /usr/lib/x86_64-linux-gnu/mir/clientplatform/mesa /lib32 /usr/lib32 " - -# Whether dlopen is supported. -dlopen_support=unknown - -# Whether dlopen of programs is supported. -dlopen_self=unknown - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=unknown - -# Commands to strip libraries. -old_striplib="strip --strip-debug" -striplib="strip --strip-unneeded" - - -# The linker used to build libraries. -LD="/usr/bin/ld -m elf_x86_64" - -# How to create reloadable object files. -reload_flag=" -r" -reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" - -# Commands used to build an old-style archive. -old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib" - -# A language specific compiler. -CC="gcc" - -# Is the compiler the GNU compiler? -with_gcc=yes - -# Compiler flag to turn off builtin functions. -no_builtin_flag=" -fno-builtin" - -# Additional compiler flags for building library objects. -pic_flag=" -fPIC -DPIC" - -# How to pass a linker flag through the compiler. -wl="-Wl," - -# Compiler flag to prevent dynamic linking. -link_static_flag="-static" - -# Does compiler simultaneously support -c and -o options? -compiler_c_o="yes" - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=no - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=no - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec="\${wl}--export-dynamic" - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object="no" - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds="" - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds="" - -# Commands used to build a shared archive. -archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" -archive_expsym_cmds="echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~ - cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~ - echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~ - \$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib" - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds="" -module_expsym_cmds="" - -# Whether we are building with GNU ld or not. -with_gnu_ld="yes" - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag="" - -# Flag that enforces no undefined symbols. -no_undefined_flag="" - -# Flag to hardcode $libdir into a binary during linking. -# This must work even if $libdir does not exist -hardcode_libdir_flag_spec="\${wl}-rpath \${wl}\$libdir" - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator="" - -# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=no - -# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting ${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=no - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=no - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=unsupported - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=no - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=no - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=no - -# Set to "yes" if exported symbols are required. -always_export_symbols=no - -# The commands to list exported symbols. -export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*" - -# Symbols that must always be exported. -include_expsyms="" - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds="" - -# Commands necessary for finishing linking programs. -postlink_cmds="" - -# Specify filename containing input files. -file_list_spec="" - -# How to hardcode a shared library path into an executable. -hardcode_action=immediate - -# ### END LIBTOOL CONFIG - - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" -TIMESTAMP="" -package_revision=1.3337 - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES -do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" - fi" -done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. - -exit_status=$EXIT_SUCCESS - -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" - -dirname="s,/[^/]*$,," -basename="s,^.*/,," - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} # Extended-shell func_dirname implementation - - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} # Extended-shell func_basename implementation - - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} # Extended-shell func_dirname_and_basename implementation - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} # Extended-shell func_stripname implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" -} - -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} - - # A bug in bash halts the script if the last line of a function - # fails when set -e is in force, so we need another command to - # work around that: - : -} - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 - - # bash bug again: - : -} - -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} - -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "$my_tmpdir" -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. -func_quote_for_eval () -{ - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac - - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac -} - - -# func_quote_for_expand arg -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - case $1 in - *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; - *) - my_arg="$1" ;; - esac - - case $my_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" - ;; - esac - - func_quote_for_expand_result="$my_arg" -} - - -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. -func_show_eval () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. Use the saved locale for evaluation. -func_show_eval_locale () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - -# func_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? -} - -# func_usage -# Echo short help message to standard output and exit. -func_usage () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"} -} # Extended-shell func_split_short_opt implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=} -} # Extended-shell func_split_long_opt implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}+=\${2}" -} # Extended-shell func_append implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}+=\\ \$func_quote_for_eval_result" -} # Extended-shell func_append_quoted implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} # Extended-shell func_arith implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} # Extended-shell func_len implementation - - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} # Extended-shell func_lo2o implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} # Extended-shell func_xform implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then - taglist="$taglist $tagname" - - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac -} - -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF - fi - - exit $EXIT_MISMATCH - fi -} - - -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -preserve_args+=" $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -preserve_args+=" $opt" - ;; - --no-verbose) - opt_verbose=false -preserve_args+=" $opt" - ;; - --silent|--quiet) - opt_silent=: -preserve_args+=" $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -preserve_args+=" $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -preserve_args+=" $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || preserve_args+=" --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps - ;; - esac - - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_lalib_p () -{ - test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 -} - -# func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function implements the same check as func_lalib_p without -# resorting to external programs. To this end, it redirects stdin and -# closes it afterwards, without saving the original file descriptor. -# As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. -func_lalib_unsafe_p () -{ - lalib_p=no - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then - for lalib_p_l in 1 2 3 4 - do - read lalib_p_line - case "$lalib_p_line" in - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; - esac - done - exec 0<&5 5<&- - fi - test "$lalib_p" = yes -} - -# func_ltwrapper_script_p file -# True iff FILE is a libtool wrapper script -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_script_p () -{ - func_lalib_p "$1" -} - -# func_ltwrapper_executable_p file -# True iff FILE is a libtool wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_executable_p () -{ - func_ltwrapper_exec_suffix= - case $1 in - *.exe) ;; - *) func_ltwrapper_exec_suffix=.exe ;; - esac - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 -} - -# func_ltwrapper_scriptname file -# Assumes file is an ltwrapper_executable -# uses $file to determine the appropriate filename for a -# temporary ltwrapper_script. -func_ltwrapper_scriptname () -{ - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# func_ltwrapper_p file -# True iff FILE is a libtool wrapper script or wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_p () -{ - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" -} - - -# func_execute_cmds commands fail_cmd -# Execute tilde-delimited COMMANDS. -# If FAIL_CMD is given, eval that upon failure. -# FAIL_CMD may read-access the current command in variable CMD! -func_execute_cmds () -{ - $opt_debug - save_ifs=$IFS; IFS='~' - for cmd in $1; do - IFS=$save_ifs - eval cmd=\"$cmd\" - func_show_eval "$cmd" "${2-:}" - done - IFS=$save_ifs -} - - -# func_source file -# Source FILE, adding directory component if necessary. -# Note that it is not necessary on cygwin/mingw to append a dot to -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe -# behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. -func_source () -{ - $opt_debug - case $1 in - */* | *\\*) . "$1" ;; - *) . "./$1" ;; - esac -} - - -# func_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$1 - ;; - esac -} - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - $opt_debug - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" -# else -# func_verbose "using $tagname tagged configuration" - fi - ;; - esac - fi -} - - - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () -{ - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi - - $opt_dry_run || { - cat >${write_libobj}T </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_to_host_path_result+="$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# Path separators are also converted from $build format to $host format. If -# ARG begins or ends with a path separator character, it is preserved (but -# converted to $host format) on output. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from ARG. MSYS - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; - # and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - pie_flag+=" $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - later+=" $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - base_compile+=" $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." - func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname - - test -z "$base_compile" && \ - func_fatal_help "you must specify a compilation command" - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $ECHO "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - removelist+=" $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - removelist+=" $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - command="$base_compile $qsrcfile $pic_flag" - else - # Don't build PIC code - command="$base_compile $qsrcfile" - fi - - func_mkdir_p "$xdir$objdir" - - if test -z "$output_obj"; then - # Place PIC objects in $objdir - command+=" -o $lobj" - fi - - func_show_eval_locale "$command" \ - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - func_show_eval '$MV "$output_obj" "$lobj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - - # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then - suppress_output=' >/dev/null 2>&1' - fi - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $qsrcfile$pie_flag" - else - command="$base_compile $qsrcfile $pic_flag" - fi - if test "$compiler_c_o" = yes; then - command+=" -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - command+="$suppress_output" - func_show_eval_locale "$command" \ - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - func_show_eval '$MV "$output_obj" "$obj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - fi - - $opt_dry_run || { - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - removelist=$lockfile - $RM "$lockfile" - fi - } - - exit $EXIT_SUCCESS -} - -$opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_mode in - "") - # Generic help is extracted from the usage comments - # at the start of this file. - func_help - ;; - - clean) - $ECHO \ -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - - compile) - $ECHO \ -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to build PIC objects only - -prefer-non-pic try to build non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - - execute) - $ECHO \ -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - - finish) - $ECHO \ -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - - install) - $ECHO \ -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The following components of INSTALL-COMMAND are treated specially: - - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - - link) - $ECHO \ -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -shared only do dynamic linking of libtool libraries - -shrext SUFFIX override the standard shared library file extension - -static do not do any dynamic linking of uninstalled libtool libraries - -static-libtool-libs - do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -weak LIBNAME declare that the target provides the LIBNAME interface - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - - uninstall) - $ECHO \ -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - - *) - func_fatal_help "invalid operation mode \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# func_mode_execute arg... -func_mode_execute () -{ - $opt_debug - # The first argument is the command name. - cmd="$nonopt" - test -z "$cmd" && \ - func_fatal_help "you must specify a COMMAND" - - # Handle -dlopen flags immediately. - for file in $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" - - # Read the libtool library. - dlname= - library_names= - func_source "$file" - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" - continue - fi - - func_dirname "$file" "" "." - dir="$func_dirname_result" - - if test -f "$dir/$objdir/$dlname"; then - dir+="/$objdir" - else - if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" - fi - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - func_dirname "$file" "" "." - dir="$func_dirname_result" - ;; - - *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -* | *.la | *.lo ) ;; - *) - # Do a test to see if this is really a libtool program. - if func_ltwrapper_script_p "$file"; then - func_source "$file" - # Transform arg to wrapped name. - file="$progdir/$program" - elif func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - func_source "$func_ltwrapper_scriptname_result" - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - func_append_quoted args "$file" - done - - if test "X$opt_dry_run" = Xfalse; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES - do - eval "if test \"\${save_$lt_var+set}\" = set; then - $lt_var=\$save_$lt_var; export $lt_var - else - $lt_unset $lt_var - fi" - done - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - libdirs+=" $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - libs+=" $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds -'"$cmd"'"' - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || admincmds+=" - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} - - -# func_mode_install arg... -func_mode_install () -{ - $opt_debug - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then - # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " - arg=$1 - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - func_quote_for_eval "$arg" - install_prog+="$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - files+=" $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - install_prog+=" $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - install_shared_prog+=" $func_quote_for_eval_result" - done - - test -z "$install_prog" && \ - func_fatal_help "you must specify an install program" - - test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" - - if test -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - install_shared_prog+=" -m $func_quote_for_eval_result" - fi - fi - - if test -z "$files"; then - if test -z "$dest"; then - func_fatal_help "no file or destination specified" - else - func_fatal_help "you must specify a destination" - fi - fi - - # Strip any trailing slash from the destination. - func_stripname '' '/' "$dest" - dest=$func_stripname_result - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" - - # Not a directory, so check to see that there is only one file specified. - set dummy $files; shift - test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - func_fatal_help "\`$destdir' must be an absolute directory name" - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs+=" $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" - - library_names= - old_library= - relink_command= - func_source "$file" - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs+=" $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs+=" $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - dir+="$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - func_warning "relinking \`$file'" - func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' - fi - - # See the names of the shared library. - set dummy $library_names; shift - if test -n "$1"; then - realname="$1" - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ - 'exit $?' - tstripme="$stripme" - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - case $realname in - *.dll.a) - tstripme="" - ;; - esac - ;; - esac - if test -n "$tstripme" && test -n "$striplib"; then - func_show_eval "$striplib $destdir/$realname" 'exit $?' - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - test "$linkname" != "$realname" \ - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - func_execute_cmds "$postinstall_cmds" 'exit $?' - fi - - # Install the pseudo-library for information purposes. - func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs+=" $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - func_lo2o "$destfile" - staticdest=$func_lo2o_result - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" - ;; - esac - - # Install the libtool object if requested. - test -n "$destfile" && \ - func_show_eval "$install_prog $file $destfile" 'exit $?' - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - func_lo2o "$file" - staticobj=$func_lo2o_result - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - func_stripname '' '.exe' "$file" - file=$func_stripname_result - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin* | *mingw*) - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - wrapper=$func_ltwrapper_scriptname_result - else - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result - fi - ;; - *) - wrapper=$file - ;; - esac - if func_ltwrapper_script_p "$wrapper"; then - notinst_deplibs= - relink_command= - - func_source "$wrapper" - - # Check the variables that should have been set. - test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - func_source "$lib" - fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no - fi - done - - relink_command= - func_source "$wrapper" - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - $opt_dry_run || { - if test "$finalize" = yes; then - tmpdir=`func_mktempdir` - func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` - - $opt_silent || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" - } - if eval "$relink_command"; then : - else - func_error "error: relink \`$file' with the above command before installing it" - $opt_dry_run || ${RM}r "$tmpdir" - continue - fi - file="$outputname" - else - func_warning "cannot relink \`$file'" - fi - } - else - # Install the binary that we compiled earlier. - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - func_stripname '' '.exe' "$destfile" - destfile=$func_stripname_result - ;; - esac - ;; - esac - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' - $opt_dry_run || if test -n "$outputname"; then - ${RM}r "$tmpdir" - fi - ;; - esac - done - - for file in $staticlibs; do - func_basename "$file" - name="$func_basename_result" - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' - fi - - # Do each command in the postinstall commands. - func_execute_cmds "$old_postinstall_cmds" 'exit $?' - done - - test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = install && func_mode_install ${1+"$@"} - - -# func_generate_dlsyms outputname originator pic_p -# Extract symbols from dlprefiles and create ${outputname}S.o with -# a dlpreopen symbol table. -func_generate_dlsyms () -{ - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` - my_dlsyms= - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" - else - func_error "not configured to extract global symbols from dlpreopened files" - fi - fi - - if test -n "$my_dlsyms"; then - case $my_dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" - - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" - - # Parse the name list into a source file. - func_verbose "creating $output_objdir/$my_dlsyms" - - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" - - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $opt_dry_run || { - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - if test -n "$export_symbols_regex"; then - $opt_dry_run || { - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $opt_dry_run || { - $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' - ;; - esac - } - else - $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' - ;; - esac - } - fi - fi - - for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" - func_basename "$dlprefile" - name="$func_basename_result" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - done - - $opt_dry_run || { - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $MV "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if $GREP -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - $GREP -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" - fi - - echo >> "$output_objdir/$my_dlsyms" "\ - -/* The mapping between symbol names and symbols. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; -extern LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; -LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," - - case $need_lib_prefix in - no) - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - *) - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - esac - echo >> "$output_objdir/$my_dlsyms" "\ - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_${my_prefix}_LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - } # !$opt_dry_run - - pic_flag_for_symtable= - case "$compile_command " in - *" -static "*) ;; - *) - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; - *-*-hpux*) - pic_flag_for_symtable=" $pic_flag" ;; - *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi - ;; - esac - ;; - esac - symtab_cflags= - for arg in $LTCFLAGS; do - case $arg in - -pie | -fpie | -fPIE) ;; - *) symtab_cflags+=" $arg" ;; - esac - done - - # Now compile the dynamic symbol file. - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' - - # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' - - # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" - case $host in - *cygwin* | *mingw* | *cegcc* ) - if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - ;; - esac - ;; - *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` - fi -} - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -# Despite the name, also deal with 64 bit binaries. -func_win32_libid () -{ - $opt_debug - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' - 1,100{ - / I /{ - s,.*,import, - p - q - } - }'` - case $win32_nmres in - import*) win32_libid_type="x86 archive import";; - *) win32_libid_type="x86 archive static";; - esac - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $ECHO "$win32_libid_type" -} - -# func_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" - fi -} - - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - $opt_debug - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - func_basename "$my_xlib" - my_xlib="$func_basename_result" - my_xlib_u=$my_xlib - while :; do - case " $extracted_archives " in - *" $my_xlib_u "*) - func_arith $extracted_serial + 1 - extracted_serial=$func_arith_result - my_xlib_u=lt$extracted_serial-$my_xlib ;; - *) break ;; - esac - done - extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" - - func_mkdir_p "$my_xdir" - - case $host in - *-darwin*) - func_verbose "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - $opt_dry_run || { - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` - if test -n "$darwin_arches"; then - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` - $LIPO -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - $RM -rf unfat-$$ - cd "$darwin_orig_dir" - else - cd $darwin_orig_dir - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - } # !$opt_dry_run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - func_emit_wrapper_arg1=${1-no} - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${1+\"\$@\"} - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" -} - - -# func_emit_cwrapperexe_src -# emit the source code for a wrapper executable on stdout -# Must ONLY be called from within func_mode_link because -# it depends on a number of variable set therein. -func_emit_cwrapperexe_src () -{ - cat < -#include -#ifdef _MSC_VER -# include -# include -# include -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef S_IXOTH -# define S_IXOTH 0 -#endif -#ifndef S_IXGRP -# define S_IXGRP 0 -#endif - -/* path handling portability macros */ -#ifndef DIR_SEPARATOR -# define DIR_SEPARATOR '/' -# define PATH_SEPARATOR ':' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -# define HAVE_DOS_BASED_FILE_SYSTEM -# define FOPEN_WB "wb" -# ifndef DIR_SEPARATOR_2 -# define DIR_SEPARATOR_2 '\\' -# endif -# ifndef PATH_SEPARATOR_2 -# define PATH_SEPARATOR_2 ';' -# endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#ifndef PATH_SEPARATOR_2 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) -#else /* PATH_SEPARATOR_2 */ -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) -#endif /* PATH_SEPARATOR_2 */ - -#ifndef FOPEN_WB -# define FOPEN_WB "w" -#endif -#ifndef _O_BINARY -# define _O_BINARY 0 -#endif - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -void *xmalloc (size_t num); -char *xstrdup (const char *string); -const char *base_name (const char *name); -char *find_executable (const char *wrapper); -char *chase_symlinks (const char *pathspec); -int make_executable (const char *path); -int check_executable (const char *path); -char *strendzap (char *str, const char *pat); -void lt_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -void lt_setenv (const char *name, const char *value); -char *lt_extend_str (const char *orig_value, const char *add, int to_end); -void lt_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 0) - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - return 1; - else - return 0; -} - -int -make_executable (const char *path) -{ - int rval = 0; - struct stat st; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - if ((!path) || (!*path)) - return 0; - - if (stat (path, &st) >= 0) - { - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); - } - return rval; -} - -/* Searches for the full path of the wrapper. Returns - newly allocated full path name if found, NULL otherwise - Does not chase symlinks, even on platforms that support them. -*/ -char * -find_executable (const char *wrapper) -{ - int has_slash = 0; - const char *p; - const char *p_next; - /* static buffer for getcwd */ - char tmp[LT_PATHMAX + 1]; - int tmp_len; - char *concat_name; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - if ((wrapper == NULL) || (*wrapper == '\0')) - return NULL; - - /* Absolute path? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } -#endif - - for (p = wrapper; *p; p++) - if (*p == '/') - { - has_slash = 1; - break; - } - if (!has_slash) - { - /* no slashes; search PATH */ - const char *path = getenv ("PATH"); - if (path != NULL) - { - for (p = path; *p; p = p_next) - { - const char *q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR (*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else - { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); - } - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - } - /* not found in PATH; assume curdir */ - } - /* Relative path | not found in path: prepend cwd */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - return NULL; -} - -char * -chase_symlinks (const char *pathspec) -{ -#ifndef S_ISLNK - return xstrdup (pathspec); -#else - char buf[LT_PATHMAX]; - struct stat s; - char *tmp_pathspec = xstrdup (pathspec); - char *p; - int has_symlinks = 0; - while (strlen (tmp_pathspec) && !has_symlinks) - { - lt_debugprintf (__FILE__, __LINE__, - "checking path component for symlinks: %s\n", - tmp_pathspec); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK (s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen (tmp_pathspec) - 1; - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - p--; - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "could not follow symlinks for %s", pathspec); - } - return xstrdup (tmp_pathspec); -#endif -} - -char * -strendzap (char *str, const char *pat) -{ - size_t len, patlen; - - assert (str != NULL); - assert (pat != NULL); - - len = strlen (str); - patlen = strlen (pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp (str, pat) == 0) - *str = '\0'; - } - return str; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (value)); - { -#ifdef HAVE_SETENV - /* always make a copy, for consistency with !HAVE_SETENV */ - char *str = xstrdup (value); - setenv (name, str, 1); -#else - int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); - sprintf (str, "%s=%s", name, value); - if (putenv (str) != EXIT_SUCCESS) - { - XFREE (str); - } -#endif - } -} - -char * -lt_extend_str (const char *orig_value, const char *add, int to_end) -{ - char *new_value; - if (orig_value && *orig_value) - { - int orig_value_len = strlen (orig_value); - int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); - if (to_end) - { - strcpy (new_value, orig_value); - strcpy (new_value + orig_value_len, add); - } - else - { - strcpy (new_value, add); - strcpy (new_value + add_len, orig_value); - } - } - else - { - new_value = xstrdup (add); - } - return new_value; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - /* some systems can't cope with a ':'-terminated path #' */ - int len = strlen (new_value); - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) - { - new_value[len-1] = '\0'; - } - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -void -lt_update_lib_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -EOF - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# func_mode_link arg... -func_mode_link () -{ - $opt_debug - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invocation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args=$nonopt - base_compile="$nonopt $@" - compile_command=$nonopt - finalize_command=$nonopt - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - new_inherited_linker_flags= - - avoid_version=no - bindir= - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - non_pic_objects= - precious_files_regex= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - vinfo_number=no - weak_libs= - single_module="${wl}-single_module" - func_infer_tag $base_compile - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - break - ;; - -all-static | -static | -static-libtool-libs) - case $arg in - -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - func_warning "complete static linking is impossible in this configuration" - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - -static) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=built - ;; - -static-libtool-libs) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - esac - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - libtool_args+=" $func_quote_for_eval_result" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command+=" @OUTPUT@" - finalize_command+=" @OUTPUT@" - ;; - esac - - case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command+=" @SYMFILE@" - finalize_command+=" @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles+=" $arg" - else - dlprefiles+=" $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - framework) - case $host in - *-*-darwin*) - case "$deplibs " in - *" $qarg.ltframework "*) ;; - *) deplibs+=" $qarg.ltframework" # this is fixed later - ;; - esac - ;; - esac - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat "$save_arg"` - do -# moreargs+=" $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles+=" $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles+=" $pic_object" - prev= - fi - - # A PIC object. - libobjs+=" $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects+=" $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - non_pic_objects+=" $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - libobjs+=" $pic_object" - non_pic_objects+=" $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - done - else - func_fatal_error "link input file \`$arg' does not exist" - fi - arg=$save_arg - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath+=" $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath+=" $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - weak_libs+=" $arg" - prev= - continue - ;; - xcclinker) - linker_flags+=" $qarg" - compiler_flags+=" $qarg" - prev= - compile_command+=" $qarg" - finalize_command+=" $qarg" - continue - ;; - xcompiler) - compiler_flags+=" $qarg" - prev= - compile_command+=" $qarg" - finalize_command+=" $qarg" - continue - ;; - xlinker) - linker_flags+=" $qarg" - compiler_flags+=" $wl$qarg" - prev= - compile_command+=" $wl$qarg" - finalize_command+=" $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - # See comment for -static flag below, for more details. - compile_command+=" $link_static_flag" - finalize_command+=" $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -bindir) - prev=bindir - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - func_fatal_error "more than one -exported-symbols argument is not allowed" - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework) - prev=framework - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - compile_command+=" $arg" - finalize_command+=" $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; then - if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" - else - func_fatal_error "need path for \`-L' option" - fi - fi - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) deplibs+=" $arg" ;; - *) deplibs+=" -L$dir" ;; - esac - lib_search_path+=" $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) dllsearchpath+=":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) dllsearchpath+=":$testbindir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - deplibs+=" System.ltframework" - continue - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - test "X$arg" = "X-lc" && continue - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs+=" $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) - compiler_flags+=" $arg" - compile_command+=" $arg" - finalize_command+=" $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - compiler_flags+=" $arg" - compile_command+=" $arg" - finalize_command+=" $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) new_inherited_linker_flags+=" $arg" ;; - esac - continue - ;; - - -multi_module) - single_module="${wl}-multi_module" - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) - # The PATH hackery in wrapper scripts is required on Windows - # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - func_stripname '-R' '' "$arg" - dir=$func_stripname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - =*) - func_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath+=" $dir" ;; - esac - continue - ;; - - -shared) - # The effects of -shared are defined in a previous loop. - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -static | -static-libtool-libs) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -weak) - prev=weak - continue - ;; - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - arg+=" $func_quote_for_eval_result" - compiler_flags+=" $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Wl,*) - func_stripname '-Wl,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - arg+=" $wl$func_quote_for_eval_result" - compiler_flags+=" $wl$func_quote_for_eval_result" - linker_flags+=" $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # -msg_* for osf cc - -msg_*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - compile_command+=" $arg" - finalize_command+=" $arg" - compiler_flags+=" $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - objs+=" $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles+=" $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles+=" $pic_object" - prev= - fi - - # A PIC object. - libobjs+=" $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects+=" $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - non_pic_objects+=" $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - libobjs+=" $pic_object" - non_pic_objects+=" $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs+=" $arg" - old_deplibs+=" $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles+=" $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles+=" $func_resolve_sysroot_result" - prev= - else - deplibs+=" $func_resolve_sysroot_result" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command+=" $arg" - finalize_command+=" $arg" - fi - done # argument parsing loop - - test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command+=" $arg" - finalize_command+=" $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # Create the object directory. - func_mkdir_p "$output_objdir" - - # Determine the type of output - case $output in - "") - func_fatal_help "you must specify an output file" - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - libs+=" $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if $opt_duplicate_compiler_generated_deps; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs+=" $pre_post_deps" ;; - esac - pre_post_deps+=" $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - - case $linkmode in - lib) - passes="conv dlpreopen link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - - for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) - libs="$deplibs %DEPLIBS%" - test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" - ;; - esac - fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then - # Collect and forward deplibs of preopened libtool libs - for lib in $dlprefiles; do - # Ignore non-libtool-libs - dependency_libs= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) deplibs+=" $deplib" ;; - esac - done - done - libs="$dlprefiles" - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - compiler_flags+=" $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) new_inherited_linker_flags+=" $deplib" ;; - esac - fi - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" - continue - fi - func_stripname '-l' '' "$deplib" - name=$func_stripname_result - if test "$linkmode" = lib; then - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" - else - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" - fi - for searchdir in $searchdirs; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if func_lalib_p "$lib"; then - library_names= - old_library= - func_source "$lib" - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) new_inherited_linker_flags+=" $deplib" ;; - esac - fi - fi - continue - ;; - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_result" - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath+=" $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - # Linking convenience modules into shared libraries is allowed, - # but linking other static libraries is non-portable. - case " $dlpreconveniencelibs " in - *" $deplib "*) ;; - *) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - echo - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." - else - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - ;; - esac - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles+=" $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles+=" $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" - - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - inherited_linker_flags= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - func_source "$lib" - - # Convert "-framework foo" to "foo.ltframework" - if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do - case " $new_inherited_linker_flags " in - *" $tmp_inherited_linker_flag "*) ;; - *) new_inherited_linker_flags+=" $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles+=" $dlopen" - test -n "$dlpreopen" && dlprefiles+=" $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - # It is a libtool convenience library, so add in its objects. - convenience+=" $ladir/$objdir/$old_library" - old_convenience+=" $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - tmp_libs+=" $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles+=" $lib $dependency_libs" - else - newdlfiles+=" $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" - func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" - fi - ;; - esac - func_basename "$lib" - laname="$func_basename_result" - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - notinst_path+=" $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path+=" $abs_ladir" - fi - fi # $installed = yes - func_stripname 'lib' '.la' "$laname" - name=$func_stripname_result - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" - fi - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - newdlprefiles+=" $dir/$linklib" - else - newdlprefiles+=" $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - dlpreconveniencelibs+=" $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles+=" $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - dlpreconveniencelibs+=" $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles+=" $dir/$dlname" - else - newdlprefiles+=" $dir/$linklib" - fi - ;; - esac - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path+=" $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_result" - ;; - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - tmp_libs+=" $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || - test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in - *"$absdir:"*) ;; - *) temp_rpath+="$absdir:" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath+=" $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath+=" $libdir" ;; - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then - use_static_libs=no - fi - if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc*) - # No point in relinking DLLs because paths are not encoded - notinst_deplibs+=" $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - notinst_deplibs+=" $lib" - need_relink=yes - fi - ;; - esac - # This is a shared library - - # Warn about portability, can't link against -module's on some - # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" - for dlpremoduletest in $dlprefiles; do - if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" - break - fi - done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - echo - if test "$linkmode" = prog; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" - else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" - fi - $ECHO "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath+=" $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath+=" $libdir" ;; - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - shift - realname="$1" - shift - libname=`eval "\\$ECHO \"$libname_spec\""` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw* | *cegcc*) - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - func_basename "$soroot" - soname="$func_basename_result" - func_stripname 'lib' '.dll' "$soname" - newlib=libimp-$func_stripname_result.a - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - func_verbose "extracting exported symbol list from \`$soname'" - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$opt_mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not - # link against it, someone is ignoring the earlier warnings - if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then - if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - elif test -n "$old_library"; then - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir+=" -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - func_fatal_configuration "unsupported hardcode properties" - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath+="$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath+="$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath+="$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir+=" -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - $ECHO "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) func_stripname '-R' '' "$libdir" - temp_xrpath=$func_stripname_result - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath+=" $temp_xrpath";; - esac;; - *) temp_deplibs+=" $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path+=" $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - specialdeplibs+=" $func_resolve_sysroot_result" ;; - esac - fi - tmp_libs+=" $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - func_dirname "$deplib" "" "." - dir=$func_dirname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" - fi - ;; - esac - if $GREP "^installed=no" $deplib > /dev/null; then - case $host in - *-*-darwin*) - depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - fi - compiler_flags+=" ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - linker_flags+=" -dylib_file ${darwin_install_name}:${depdepl}" - path= - fi - fi - ;; - *) - path="-L$absdir/$objdir" - ;; - esac - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - test "$absdir" != "$libdir" && \ - func_warning "\`$deplib' seems to be moved" - - path="-L$absdir" - fi - ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - fi - fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path+=" $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs+=" $deplib" ;; - esac - ;; - *) tmp_libs+=" $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - tmp_libs+=" $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" - - test -n "$release" && \ - func_warning "\`-release' is ignored for archives" - - test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs+="$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - func_stripname 'lib' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" - - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - func_stripname '' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - func_stripname '' '.la' "$outputname" - libname=$func_stripname_result - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" - else - echo - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" - libobjs+=" $objs" - fi - fi - - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" - - set dummy $rpath - shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" - - test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - shift - IFS="$save_ifs" - - test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$1" - number_minor="$2" - number_revision="$3" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - # correct linux to gnu/linux during the next big refactor - darwin|linux|osf|windows|none) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|qnx|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_minor" - lt_irix_increment=no - ;; - *) - func_fatal_configuration "$modename: unknown library version type \`$version_type'" - ;; - esac - ;; - no) - current="$1" - revision="$2" - age="$3" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - func_arith $current + 1 - minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current" - ;; - - irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then - func_arith $current - $age - else - func_arith $current - $age + 1 - fi - major=$func_arith_result - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - func_arith $revision - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) # correct to gnu/linux during the next big refactor - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - ;; - - osf) - func_arith $current - $age - major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - func_arith $current - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring+=":${current}.0" - ;; - - qnx) - major=".$current" - versuffix=".$current" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - - *) - func_fatal_configuration "unknown library version type \`$version_type'" - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - fi - - func_generate_dlsyms "$libname" "$libname" "yes" - libobjs+=" $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$ECHO "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext | *.gcno) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - removelist+=" $p" - ;; - *) ;; - esac - done - test -n "$removelist" && \ - func_show_eval "${RM}r \$removelist" - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs+=" $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` - #done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - func_replace_sysroot "$libdir" - temp_xrpath+=" -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath+=" $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles+=" $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles+=" $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs+=" System.ltframework" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs+=" -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c </dev/null` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null | - $GREP " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs+=" $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a file magic. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - newdeplibs+=" $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - for a_deplib in $deplibs; do - case $a_deplib in - -l*) - func_stripname -l '' "$a_deplib" - name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - newdeplibs+=" $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval "\\$ECHO \"$libname_spec\""` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs+=" $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a regex pattern. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - newdeplibs+=" $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - ;; - esac - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - case $host in - *-*-darwin*) - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $deplibs " in - *" -L$path/$objdir "*) - new_libs+=" -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs+=" $deplib" ;; - esac - ;; - *) new_libs+=" $deplib" ;; - esac - done - deplibs="$new_libs" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs+="$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath+=" $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath+="$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - shift - realname="$1" - shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - linknames= - for link - do - linknames+=" $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` - test "X$libobjs" = "X " && libobjs= - - delfiles= - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" - delfiles+=" $export_symbols" - fi - - orig_export_symbols= - case $host_os in - cygwin* | mingw* | cegcc*) - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then - # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then - # and it's NOT already a .def file. Must figure out - # which of the given symbols are data symbols and tag - # them as such. So, trigger use of export_symbols_cmds. - # export_symbols gets reassigned inside the "prepare - # the list of exported symbols" if statement, so the - # include_expsyms logic still works. - orig_export_symbols="$export_symbols" - export_symbols= - always_export_symbols=yes - fi - fi - ;; - esac - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - delfiles+=" $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - skipped_export=false - else - # The command line is too long to execute in one step. - func_verbose "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles+=" $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - tmp_deplibs+=" $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && - test -z "$libobjs"; then - # extract the archives, so we have objects to list. - # TODO: could optimize this to just extract one archive. - whole_archive_flag_spec= - fi - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - else - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - - func_extract_archives $gentop $convenience - libobjs+=" $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags+=" $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - func_len " $test_cmds" && - len=$func_len_result && - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise - # or, if using GNU ld and skipped_export is not :, use a linker - # script. - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - func_basename "$output" - output_la=$func_basename_result - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - last_robj= - k=1 - - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript - func_verbose "creating GNU ld script: $output" - echo 'INPUT (' > $output - for obj in $save_libobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - delfiles+=" $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk - func_verbose "creating linker input file list: $output" - : > $output - set x $save_libobjs - shift - firstobj= - if test "$compiler_needs_object" = yes; then - firstobj="$1 " - shift - fi - for obj - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - delfiles+=" $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - else - if test -n "$save_libobjs"; then - func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext - eval test_cmds=\"$reload_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - if test "X$objlist" = X || - test "$len" -lt "$max_cmd_len"; then - objlist+=" $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - func_arith $k + 1 - k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext - objlist=" $obj" - func_len " $last_robj" - func_arith $len0 + $func_len_result - len=$func_arith_result - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - delfiles+=" $output" - - else - output= - fi - - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - libobjs=$output - # Append the command to create the export file. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" - fi - fi - - test -n "$save_libobjs" && - func_verbose "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - if test -n "$export_symbols_regex" && ${skipped_export-false}; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - - if ${skipped_export-false}; then - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles+=" $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - fi - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - fi - - if test -n "$delfiles"; then - # Append the command to remove temporary files to $cmds. - eval cmds=\"\$cmds~\$RM $delfiles\" - fi - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - - func_extract_archives $gentop $dlprefiles - libobjs+=" $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - func_show_eval '${RM}r "$gentop"' - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" - - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" - - test -n "$release" && \ - func_warning "\`-release' is ignored for objects" - - case $output in - *.lo) - test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" - - libobj=$output - func_lo2o "$libobj" - obj=$func_lo2o_result - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $opt_dry_run || $RM $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - generated+=" $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - func_execute_cmds "$reload_cmds" 'exit $?' - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - func_execute_cmds "$reload_cmds" 'exit $?' - fi - - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) func_stripname '' '.exe' "$output" - output=$func_stripname_result.exe;; - esac - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" - - test -n "$release" && \ - func_warning "\`-release' is ignored for programs" - - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - case $host in - *-*-darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in - 10.[0123]) - compile_command+=" ${wl}-bind_at_load" - finalize_command+=" ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $compile_deplibs " in - *" -L$path/$objdir "*) - new_libs+=" -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs+=" $deplib" ;; - esac - ;; - *) new_libs+=" $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - compile_command+=" $compile_deplibs" - finalize_command+=" $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath+=" $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs+="$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath+=" $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$libdir:"*) ;; - ::) dllsearchpath=$libdir;; - *) dllsearchpath+=":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) dllsearchpath+=":$testbindir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs+="$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath+=" $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - fi - - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" - - # template prelinking step - if test -n "$prelink_cmds"; then - func_execute_cmds "$prelink_cmds" 'exit $?' - fi - - wrappers_required=yes - case $host in - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - esac - if test "$wrappers_required" = no; then - # Replace the output file specification. - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - exit_status=0 - func_show_eval "$link_command" 'exit_status=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' - fi - - exit $exit_status - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath+="$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath+="$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $opt_dry_run || $RM $output - # Link the executable and exit - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname - - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Now create the wrapper script. - func_verbose "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - fi - - # Only actually do things if not in dry run mode. - $opt_dry_run || { - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) func_stripname '' '.exe' "$output" - output=$func_stripname_result ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - func_stripname '' '.exe' "$outputname" - outputname=$func_stripname_result ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - func_dirname_and_basename "$output" "" "." - output_name=$func_basename_result - output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" - $RM $cwrappersource $cwrapper - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - func_emit_cwrapperexe_src > $cwrappersource - - # The wrapper executable is built using the $host compiler, - # because it contains $host paths and files. If cross- - # compiling, it, like the target executable, must be - # executed on the $host or under an emulation environment. - $opt_dry_run || { - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource - $STRIP $cwrapper - } - - # Now, create the wrapper script for func_source use: - func_ltwrapper_scriptname $cwrapper - $RM $func_ltwrapper_scriptname_result - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 - $opt_dry_run || { - # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result - else - func_emit_wrapper no > $func_ltwrapper_scriptname_result - fi - } - ;; - * ) - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - - func_emit_wrapper no > $output - chmod +x $output - ;; - esac - } - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - oldobjs+=" $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - - func_extract_archives $gentop $addlibs - oldobjs+=" $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - - func_extract_archives $gentop $dlprefiles - oldobjs+=" $func_extract_archives_result" - fi - - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else - echo "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - func_arith $counter + 1 - counter=$func_arith_result - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - oldobjs+=" $gentop/$newobj" - ;; - *) oldobjs+=" $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - eval cmds=\"$old_archive_cmds\" - - func_len " $cmds" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - func_verbose "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - oldobjs= - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - eval test_cmds=\"$old_archive_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - for obj in $save_oldobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - objlist+=" $obj" - if test "$len" -lt "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - len=$len0 - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - func_execute_cmds "$cmds" 'exit $?' - done - - test -n "$generated" && \ - func_show_eval "${RM}r$generated" - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - func_verbose "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - # Only create the output if not a dry run. - $opt_dry_run || { - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - func_basename "$deplib" - name="$func_basename_result" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - newdependency_libs+=" ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - newdependency_libs+=" -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - newdependency_libs+=" -R$func_replace_sysroot_result" - ;; - *) newdependency_libs+=" $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - - for lib in $dlfiles; do - case $lib in - *.la) - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - newdlfiles+=" ${lt_sysroot:+=}$libdir/$name" - ;; - *) newdlfiles+=" $lib" ;; - esac - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - *.la) - # Only pass preopened files to the pseudo-archive (for - # eventual linking with the app. that links it) if we - # didn't already link the preopened objects directly into - # the library: - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - newdlprefiles+=" ${lt_sysroot:+=}$libdir/$name" - ;; - esac - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlfiles+=" $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles+=" $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - esac - $ECHO > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags='$new_inherited_linker_flags' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Names of additional weak libraries provided by this library -weak_library_names='$weak_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $ECHO >> $output "\ -relink_command=\"$relink_command\"" - fi - done - } - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' - ;; - esac - exit $EXIT_SUCCESS -} - -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && - func_mode_link ${1+"$@"} - - -# func_mode_uninstall arg... -func_mode_uninstall () -{ - $opt_debug - RM="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) RM+=" $arg"; rmforce=yes ;; - -*) RM+=" $arg" ;; - *) files+=" $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) rmdirs+=" $odir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if { test -L "$file"; } >/dev/null 2>&1 || - { test -h "$file"; } >/dev/null 2>&1 || - test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if func_lalib_p "$file"; then - func_source $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles+=" $odir/$n" - done - test -n "$old_library" && rmfiles+=" $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && rmfiles+=" $odir/$dlname" ;; - esac - test -n "$libdir" && rmfiles+=" $odir/$name $odir/${name}i" - ;; - uninstall) - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - # FIXME: should reinstall the best remaining shared library. - ;; - esac - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if func_lalib_p "$file"; then - - # Read the .lo file - func_source $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then - rmfiles+=" $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then - rmfiles+=" $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_mode" = clean ; then - noexename=$name - case $file in - *.exe) - func_stripname '' '.exe' "$file" - file=$func_stripname_result - func_stripname '' '.exe' "$name" - noexename=$func_stripname_result - # $file with .exe has already been added to rmfiles, - # add $file without .exe - rmfiles+=" $file" - ;; - esac - # Do a test to see if this is a libtool program. - if func_ltwrapper_p "$file"; then - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - relink_command= - func_source $func_ltwrapper_scriptname_result - rmfiles+=" $func_ltwrapper_scriptname_result" - else - relink_command= - func_source $dir/$noexename - fi - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - rmfiles+=" $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles+=" $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles+=" $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - func_show_eval "rmdir $dir >/dev/null 2>&1" - fi - done - - exit $exit_status -} - -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" - -if test -n "$exec_cmd"; then - eval exec "$exec_cmd" - exit $EXIT_FAILURE -fi - -exit $exit_status - - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: -# vi:sw=2 - diff --git a/vpp-japi/m4/ax_check_java_home.m4 b/vpp-japi/m4/ax_check_java_home.m4 deleted file mode 100644 index cfe8f589..00000000 --- a/vpp-japi/m4/ax_check_java_home.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_JAVA_HOME -# -# DESCRIPTION -# -# Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in. -# If found, set environment variable JAVA_HOME = Java installation home, -# else left JAVA_HOME untouch, which in most case means JAVA_HOME is -# empty. -# -# LICENSE -# -# Copyright (c) 2008 Gleen Salmon -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) - -AC_DEFUN([AX_CHECK_JAVA_HOME], -[AC_MSG_CHECKING([for JAVA_HOME]) -# We used a fake loop so that we can use "break" to exit when the result -# is found. -while true -do - # If the user defined JAVA_HOME, don't touch it. - test "${JAVA_HOME+set}" = set && break - - # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get - # the value of JAVA_HOME to use. - # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html). - JAVA_HOME=`/usr/libexec/java_home 2>/dev/null` - test x"$JAVA_HOME" != x && break - - # See if we can find the java executable, and compute from there. - TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1` - if test x$TRY_JAVA_HOME != x; then - PATH=$PATH:$TRY_JAVA_HOME/bin - fi - AC_PATH_PROG([JAVA_PATH_NAME], [java]) - if test "x$JAVA_PATH_NAME" != x; then - JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"` - break - fi - - AC_MSG_NOTICE([Could not compute JAVA_HOME]) - break -done -AC_MSG_RESULT([$JAVA_HOME]) -]) diff --git a/vpp-japi/m4/ax_check_java_plugin.m4 b/vpp-japi/m4/ax_check_java_plugin.m4 deleted file mode 100644 index 920753e5..00000000 --- a/vpp-japi/m4/ax_check_java_plugin.m4 +++ /dev/null @@ -1,101 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_JAVA_PLUGIN() -# -# DESCRIPTION -# -# This macro sets to empty on failure and to a compatible -# version of plugin.jar otherwise. Directories searched are /usr/java/* -# and /usr/local/java/*, which are assumed to be j{dk,re} installations. -# Apply the shell variable as you see fit. If sun changes things so -# /lib/plugin.jar is not the magic file it will stop working. -# -# This macro assumes that unzip, zipinfo or pkzipc is available (and can -# list the contents of the jar archive). The first two are assumed to work -# similarly enough to the infozip versisonms. The pkzipc version is -# assumed to work if I undertstand the documentation on pkware's site but -# YMMV. I do not have access to pwkware's version to test it. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN]) -AC_DEFUN([AX_CHECK_JAVA_PLUGIN], -[AC_REQUIRE([AC_PROG_AWK]) -AC_REQUIRE([AC_PROG_FGREP]) -AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc]) -AC_MSG_CHECKING([for the java plugin]) -case "x$ZIPINFO" in -[*/zipinfo)] - zipinf="zipinfo -1" ;; -[*/unzip)] - zipinf="unzip -l";; -[*/pkzipc)] - ziping="unzipc -view";; -[x*)] - AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found]) - AC_SUBST($1,[]) - zipinf="";; -esac -if test "x$zipinf" != "x"; then -jplugin="" -for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do -for jfile in lib/plugin.jar jre/lib/plugin.jar; do -if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then -eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null -if test $? -eq 0; then -dnl Some version of gcj (and javac) refuse to work with some files -dnl that pass this test. To stop this problem make sure that the compiler -dnl still works with this jar file in the classpath -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then -jplugin="$jhome/$jfile" -fi -rm -f Test.java Test.class -fi; fi; done; done -if test "x$jplugin" != "x"; then -AC_SUBST($1,$jplugin) -AC_MSG_RESULT($jplugin) -else -AC_MSG_RESULT([java plugin not found]) -AC_SUBST($1,[]) -fi -fi -]) diff --git a/vpp-japi/m4/ax_java_check_class.m4 b/vpp-japi/m4/ax_java_check_class.m4 deleted file mode 100644 index 917638ae..00000000 --- a/vpp-japi/m4/ax_java_check_class.m4 +++ /dev/null @@ -1,85 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_JAVA_CHECK_CLASS(,,) -# -# DESCRIPTION -# -# Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This -# version uses a cache variable which is both compiler, options and -# classpath dependent (so if you switch from javac to gcj it correctly -# notices and redoes the test). -# -# The macro tries to compile a minimal program importing . Some -# newer compilers moan about the failure to use this but fail or produce a -# class file anyway. All moaing is sunk to /dev/null since I only wanted -# to know if the class could be imported. This is a recommended followup -# to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) -AC_DEFUN([AX_JAVA_CHECK_CLASS],[ -m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")]) -if test "x$CLASSPATH" != "x"; then -xtra=" with classpath ${CLASSPATH}" -xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'` -xopts="-classpath $xopts" -else xtra=""; xopts=""; fi -cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}]) -AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -cat << \EOF > $JAVA_TEST -/* [#]xline __oline__ "configure" */ -import $1; -public class Test { -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then - eval "${cache_var}=yes" -else - eval "${cache_var}=no" - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD -fi -rm -f $JAVA_TEST $CLASS_TEST -]) -if eval 'test "x$'${cache_var}'" = "xyes"'; then -$2 -true; else -$3 -false; fi]) diff --git a/vpp-japi/m4/ax_java_options.m4 b/vpp-japi/m4/ax_java_options.m4 deleted file mode 100644 index 36c10d92..00000000 --- a/vpp-japi/m4/ax_java_options.m4 +++ /dev/null @@ -1,48 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_options.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_JAVA_OPTIONS -# -# DESCRIPTION -# -# AX_JAVA_OPTIONS adds configure command line options used for Java m4 -# macros. This Macro is optional. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) -AC_DEFUN([AX_JAVA_OPTIONS],[ -AC_ARG_WITH(java-prefix, - [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) -AC_ARG_WITH(javac-flags, - [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) -AC_ARG_WITH(java-flags, - [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) -JAVAPREFIX=$with_java_prefix -JAVACFLAGS=$with_javac_flags -JAVAFLAGS=$with_java_flags -AC_SUBST(JAVAPREFIX)dnl -AC_SUBST(JAVACFLAGS)dnl -AC_SUBST(JAVAFLAGS)dnl -AC_SUBST(JAVA)dnl -AC_SUBST(JAVAC)dnl -]) diff --git a/vpp-japi/m4/ax_libgcj_jar.m4 b/vpp-japi/m4/ax_libgcj_jar.m4 deleted file mode 100644 index 5e942857..00000000 --- a/vpp-japi/m4/ax_libgcj_jar.m4 +++ /dev/null @@ -1,83 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_libgcj_jar.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIBGCJ_JAR -# -# DESCRIPTION -# -# Locate libgcj.jar so you can place it before everything else when using -# gcj. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([DPS_LIBGCJ_JAR], [AX_LIBGCJ_JAR]) -AC_DEFUN([AX_LIBGCJ_JAR], -[ -AC_REQUIRE([AC_EXEEXT]) -AC_REQUIRE([AX_PROG_JAVAC]) -AC_REQUIRE([AC_PROG_FGREP]) -AC_PROG_SED -if test "x$SED" = "x"; then -AC_MSG_WARN([sed not avaiable, so libgcj.jar test skipped]) -else -AC_MSG_CHECKING([if $JAVAC is gcj]); -jc=`eval "[echo x$JAVAC | $SED 's/^x.*\\/\\([^/]*\\)\$/x\\1/;s/^ *\\([^ ]*\\) .*$/\\1/;s/"$EXEEXT"$//']"` -if test "x$jc" != "xxgcj"; then -AC_MSG_RESULT(no) -else -AC_MSG_RESULT(yes) -AC_MSG_CHECKING([libgcj.jar location]) -save_cp="$CLASSPATH"; -unset CLASSPATH; -AC_MSG_CHECKING([gcj default classpath]) -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -lgcj=`eval "[$JAVAC -v -C Test.java 2>&1 | $FGREP \\(system\\) | $SED 's/^ *\\([^ ]*\\) .*$/\\1/;s/\\.jar\\//.jar/']"`; -if test -f Test.class && test "x$lgcj" != "x"; then -AC_MSG_RESULT($lgcj) -$1="$lgcj:" -else -AC_MSG_RESULT(failed) -$1="" -fi -if test "x$save_cp" != "x"; then CLASSPATH="$save_cp"; fi -rm -f Test.java Test.class -fi -fi -]) diff --git a/vpp-japi/m4/ax_prog_jar.m4 b/vpp-japi/m4/ax_prog_jar.m4 deleted file mode 100644 index 3c60fcaf..00000000 --- a/vpp-japi/m4/ax_prog_jar.m4 +++ /dev/null @@ -1,49 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAR -# -# DESCRIPTION -# -# AX_PROG_JAR tests for an existing jar program. It uses the environment -# variable JAR then tests in sequence various common jar programs. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAR=yourcompiler before calling -# AX_PROG_JAR -# -# - at the configure level, setenv JAR -# -# You can use the JAR variable in your Makefile.in, with @JAR@. -# -# Note: This macro depends on the autoconf M4 macros for Java programs. It -# is VERY IMPORTANT that you download that whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# The general documentation of those macros, as well as the sample -# configure.in, is included in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Egon Willighagen -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 7 - -AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) -AC_DEFUN([AX_PROG_JAR],[ -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], - [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) -test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_java.m4 b/vpp-japi/m4/ax_prog_java.m4 deleted file mode 100644 index 03961db5..00000000 --- a/vpp-japi/m4/ax_prog_java.m4 +++ /dev/null @@ -1,115 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA -# -# DESCRIPTION -# -# Here is a summary of the main macros: -# -# AX_PROG_JAVAC: finds a Java compiler. -# -# AX_PROG_JAVA: finds a Java virtual machine. -# -# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). -# -# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops -# otherwise. -# -# AX_TRY_COMPILE_JAVA: attempt to compile user given source. -# -# AX_TRY_RUN_JAVA: attempt to compile and run user given source. -# -# AX_JAVA_OPTIONS: adds Java configure options. -# -# AX_PROG_JAVA tests an existing Java virtual machine. It uses the -# environment variable JAVA then tests in sequence various common Java -# virtual machines. For political reasons, it starts with the free ones. -# You *must* call [AX_PROG_JAVAC] before. -# -# If you want to force a specific VM: -# -# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA -# -# (but after AC_INIT) -# -# - at the configure level, setenv JAVA -# -# You can use the JAVA variable in your Makefile.in, with @JAVA@. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# TODO: allow to exclude virtual machines (rationale: most Java programs -# cannot run with some VM like kaffe). -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# A Web page, with a link to the latest CVS snapshot is at -# . -# -# This is a sample configure.in Process this file with autoconf to produce -# a configure script. -# -# AC_INIT(UnTag.java) -# -# dnl Checks for programs. -# AC_CHECK_CLASSPATH -# AX_PROG_JAVAC -# AX_PROG_JAVA -# -# dnl Checks for classes -# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) -# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) -# -# AC_OUTPUT(Makefile) -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) -AC_DEFUN([AX_PROG_JAVA],[ -m4_define([m4_ax_prog_java_list], [kaffe java])dnl -AS_IF([test "x$JAVAPREFIX" = x], - [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], - [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) -test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) -m4_undefine([m4_ax_prog_java_list])dnl -AX_PROG_JAVA_WORKS -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_java_cc.m4 b/vpp-japi/m4/ax_prog_java_cc.m4 deleted file mode 100644 index 3df064ff..00000000 --- a/vpp-japi/m4/ax_prog_java_cc.m4 +++ /dev/null @@ -1,104 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA_CC -# -# DESCRIPTION -# -# Finds the appropriate java compiler on your path. By preference the java -# compiler is gcj, then jikes then javac. -# -# The macro can take one argument specifying a space separated list of -# java compiler names. -# -# For example: -# -# AX_PROG_JAVA_CC(javac, gcj) -# -# The macro also sets the compiler options variable: JAVA_CC_OPTS to -# something sensible: -# -# - for GCJ it sets it to: @GCJ_OPTS@ -# (if GCJ_OPTS is not yet defined then it is set to "-C") -# -# - no other compiler has applicable options yet -# -# Here's an example configure.in: -# -# AC_INIT(Makefile.in) -# AX_PROG_JAVA_CC() -# AC_OUTPUT(Makefile) -# dnl End. -# -# And here's the start of the Makefile.in: -# -# PROJECT_ROOT := @srcdir@ -# # Tool definitions. -# JAVAC := @JAVA_CC@ -# JAVAC_OPTS := @JAVA_CC_OPTS@ -# JAR_TOOL := @jar_tool@ -# -# LICENSE -# -# Copyright (c) 2008 Nic Ferrier -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 4 - -# AX_PROG_JAVA_CC([COMPILER ...]) -# -------------------------- -# COMPILER ... is a space separated list of java compilers to search for. -# This just gives the user an opportunity to specify an alternative -# search list for the java compiler. -AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC]) -AC_DEFUN([AX_PROG_JAVA_CC], -[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl -AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl -m4_ifval([$1], - [AC_CHECK_TOOLS(JAVA_CC, [$1])], -[AC_CHECK_TOOL(JAVA_CC, gcj) -if test -z "$JAVA_CC"; then - AC_CHECK_TOOL(JAVA_CC, javac) -fi -if test -z "$JAVA_CC"; then - AC_CHECK_TOOL(JAVA_CC, jikes) -fi -]) - -if test "$JAVA_CC" = "gcj"; then - if test "$GCJ_OPTS" = ""; then - AC_SUBST(GCJ_OPTS,-C) - fi - AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@, - [Define the compilation options for GCJ]) -fi -test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH]) -])# AX_PROG_JAVA_CC diff --git a/vpp-japi/m4/ax_prog_java_works.m4 b/vpp-japi/m4/ax_prog_java_works.m4 deleted file mode 100644 index 54e132af..00000000 --- a/vpp-japi/m4/ax_prog_java_works.m4 +++ /dev/null @@ -1,134 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA_WORKS -# -# DESCRIPTION -# -# Internal use ONLY. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) -AC_DEFUN([AX_PROG_JAVA_WORKS], [ -AC_PATH_PROG(UUDECODE, uudecode, [no]) -if test x$UUDECODE != xno; then -AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ -dnl /** -dnl * Test.java: used to test if java compiler works. -dnl */ -dnl public class Test -dnl { -dnl -dnl public static void -dnl main( String[] argv ) -dnl { -dnl System.exit (0); -dnl } -dnl -dnl } -cat << \EOF > Test.uue -begin-base64 644 Test.class -yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE -bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 -bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s -YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG -aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB -AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB -AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= -==== -EOF -if $UUDECODE Test.uue; then - ac_cv_prog_uudecode_base64=yes -else - echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD - echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD - cat Test.uue >&AS_MESSAGE_LOG_FD - ac_cv_prog_uudecode_base64=no -fi -rm -f Test.uue]) -fi -if test x$ac_cv_prog_uudecode_base64 != xyes; then - rm -f Test.class - AC_MSG_WARN([I have to compile Test.class from scratch]) - if test x$ac_cv_prog_javac_works = xno; then - AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) - fi - if test x$ac_cv_prog_javac_works = x; then - AX_PROG_JAVAC - fi -fi -AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -TEST=Test -changequote(, )dnl -cat << \EOF > $JAVA_TEST -/* [#]line __oline__ "configure" */ -public class Test { -public static void main (String args[]) { - System.exit (0); -} } -EOF -changequote([, ])dnl -if test x$ac_cv_prog_uudecode_base64 != xyes; then - if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then - : - else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD - AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) - fi -fi -if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then - ac_cv_prog_java_works=yes -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD - AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) -fi -rm -fr $JAVA_TEST $CLASS_TEST Test.uue -]) -AC_PROVIDE([$0])dnl -] -) diff --git a/vpp-japi/m4/ax_prog_javac.m4 b/vpp-japi/m4/ax_prog_javac.m4 deleted file mode 100644 index d061243c..00000000 --- a/vpp-japi/m4/ax_prog_javac.m4 +++ /dev/null @@ -1,79 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAC -# -# DESCRIPTION -# -# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment -# variable JAVAC then tests in sequence various common Java compilers. For -# political reasons, it starts with the free ones. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAVAC=yourcompiler before calling -# AX_PROG_JAVAC -# -# - at the configure level, setenv JAVAC -# -# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# TODO: allow to exclude compilers (rationale: most Java programs cannot -# compile with some compilers like guavac). -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) -AC_DEFUN([AX_PROG_JAVAC],[ -m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], - [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) -m4_undefine([m4_ax_prog_javac_list])dnl -test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) -AX_PROG_JAVAC_WORKS -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javac_works.m4 b/vpp-japi/m4/ax_prog_javac_works.m4 deleted file mode 100644 index 7dfa1e37..00000000 --- a/vpp-japi/m4/ax_prog_javac_works.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAC_WORKS -# -# DESCRIPTION -# -# Internal use ONLY. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) -AC_DEFUN([AX_PROG_JAVAC_WORKS],[ -AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -cat << \EOF > $JAVA_TEST -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then - ac_cv_prog_javac_works=yes -else - AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD -fi -rm -f $JAVA_TEST $CLASS_TEST -]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javadoc.m4 b/vpp-japi/m4/ax_prog_javadoc.m4 deleted file mode 100644 index bcb6045a..00000000 --- a/vpp-japi/m4/ax_prog_javadoc.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVADOC -# -# DESCRIPTION -# -# AX_PROG_JAVADOC tests for an existing javadoc generator. It uses the -# environment variable JAVADOC then tests in sequence various common -# javadoc generator. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAVADOC=yourgenerator before calling -# AX_PROG_JAVADOC -# -# - at the configure level, setenv JAVADOC -# -# You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@. -# -# Note: This macro depends on the autoconf M4 macros for Java programs. It -# is VERY IMPORTANT that you download that whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# The general documentation of those macros, as well as the sample -# configure.in, is included in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Egon Willighagen -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) -AC_DEFUN([AX_PROG_JAVADOC],[ -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc])], - [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc], [], [$JAVAPREFIX/bin])]) -test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javah.m4 b/vpp-japi/m4/ax_prog_javah.m4 deleted file mode 100644 index cefc616d..00000000 --- a/vpp-japi/m4/ax_prog_javah.m4 +++ /dev/null @@ -1,64 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAH -# -# DESCRIPTION -# -# AX_PROG_JAVAH tests the availability of the javah header generator and -# looks for the jni.h header file. If available, JAVAH is set to the full -# path of javah and CPPFLAGS is updated accordingly. -# -# LICENSE -# -# Copyright (c) 2008 Luc Maisonobe -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) -AC_DEFUN([AX_PROG_JAVAH],[ -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CPP])dnl -AC_PATH_PROG(JAVAH,javah) -AS_IF([test -n "$ac_cv_path_JAVAH"], - [ - AC_TRY_CPP([#include ],,[ - ac_save_CPPFLAGS="$CPPFLAGS" - _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") - ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])` - ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include" - AS_CASE([$build_os], - [cygwin*], - [ac_machdep=win32], - [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) - CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" - AC_TRY_CPP([#include ], - ac_save_CPPFLAGS="$CPPFLAGS", - AC_MSG_WARN([unable to include ])) - CPPFLAGS="$ac_save_CPPFLAGS"]) - ]) -]) - -AC_DEFUN([_ACJAVAH_FOLLOW_SYMLINKS],[ -# find the include directory relative to the javac executable -_cur="$1" -while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do - AC_MSG_CHECKING([symlink for $_cur]) - _slink=`ls -ld "$_cur" | sed 's/.* -> //'` - case "$_slink" in - /*) _cur="$_slink";; - # 'X' avoids triggering unwanted echo options. - *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; - esac - AC_MSG_RESULT([$_cur]) -done -_ACJAVAH_FOLLOWED="$_cur" -]) diff --git a/vpp-japi/m4/ax_try_compile_java.m4 b/vpp-japi/m4/ax_try_compile_java.m4 deleted file mode 100644 index a8ed6b2a..00000000 --- a/vpp-japi/m4/ax_try_compile_java.m4 +++ /dev/null @@ -1,55 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_TRY_COMPILE_JAVA -# -# DESCRIPTION -# -# AX_TRY_COMPILE_JAVA attempt to compile user given source. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) -AC_DEFUN([AX_TRY_COMPILE_JAVA],[ -AC_REQUIRE([AX_PROG_JAVAC])dnl -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -ifelse([$1], , , [import $1;]) -public class Test { -[$2] -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class -then -dnl Don't remove the temporary files here, so they can be examined. - ifelse([$3], , :, [$3]) -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat Test.java >&AS_MESSAGE_LOG_FD -ifelse([$4], , , [ rm -fr Test.java Test.class - $4 -])dnl -fi -rm -fr Test.java Test.class]) diff --git a/vpp-japi/m4/ax_try_run_java.m4 b/vpp-japi/m4/ax_try_run_java.m4 deleted file mode 100644 index c680f03f..00000000 --- a/vpp-japi/m4/ax_try_run_java.m4 +++ /dev/null @@ -1,56 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_TRY_RUN_JAVA -# -# DESCRIPTION -# -# AX_TRY_RUN_JAVA attempt to compile and run user given source. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 2 - -AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) -AC_DEFUN([AX_TRY_RUN_JAVA],[ -AC_REQUIRE([AX_PROG_JAVAC])dnl -AC_REQUIRE([AX_PROG_JAVA])dnl -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -ifelse([$1], , , [include $1;]) -public class Test { -[$2] -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null -then -dnl Don't remove the temporary files here, so they can be examined. - ifelse([$3], , :, [$3]) -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat Test.java >&AS_MESSAGE_LOG_FD -ifelse([$4], , , [ rm -fr Test.java Test.class - $4 -])dnl -fi -rm -fr Test.java Test.class]) diff --git a/vpp/api/api.c b/vpp/api/api.c index b47214f0..cf2b8f44 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -5365,8 +5365,8 @@ vl_api_map_domain_dump_t_handler } pool_foreach(d, mm->domains, ({ + /* Make sure every field is initiated (or don't skip the memset()) */ rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs(VL_API_MAP_DOMAIN_DETAILS); rmp->domain_index = htonl(d - mm->domains); rmp->ea_bits_len = d->ea_bits_len; @@ -5462,15 +5462,15 @@ vl_api_map_summary_stats_t_handler ( map_domain_counter_unlock (mm); - /* Note: in HOST byte order! */ - rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] = total_pkts[MAP_DOMAIN_COUNTER_RX]; - rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] = total_bytes[MAP_DOMAIN_COUNTER_RX]; - rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] = total_pkts[MAP_DOMAIN_COUNTER_TX]; - rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] = total_bytes[MAP_DOMAIN_COUNTER_TX]; - rmp->total_bindings = pool_elts(mm->domains); + /* Note: in network byte order! */ + rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_RX]); + rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_RX]); + rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_TX]); + rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_TX]); + rmp->total_bindings = clib_host_to_net_u64(pool_elts(mm->domains)); rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter. - rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] = map_error_counter_get(ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK); - rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] = map_error_counter_get(ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK); + rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK)); + rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK)); vl_msg_api_send_shmem(q, (u8 *)&rmp); } diff --git a/vppapigen/lex.c b/vppapigen/lex.c index b41eb5ec..f1d49a87 100644 --- a/vppapigen/lex.c +++ b/vppapigen/lex.c @@ -28,7 +28,7 @@ #include "node.h" #include "gram.h" -FILE *ifp, *ofp, *javafp, *jnifp; +FILE *ifp, *ofp, *javafp, *jnifp, *pythonfp; char *java_class = "vppApi"; char *vlib_app_name = "vpp"; int dump_tree; @@ -260,6 +260,7 @@ int main (int argc, char **argv) char *ofile=0; char *jofile=0; char *jnifile=0; + char *pythonfile=0; char *show_name=0; while (curarg < argc) { @@ -364,6 +365,23 @@ int main (int argc, char **argv) } continue; } + if (!strncmp (argv [curarg], "--python", 8)) { + curarg++; + if (curarg < argc) { + pythonfp = fopen (argv[curarg], "w"); + if (pythonfp == NULL) { + fprintf (stderr, "Couldn't open python output file %s\n", + argv[curarg]); + exit (1); + } + pythonfile = argv[curarg]; + curarg++; + } else { + fprintf(stderr, "Missing filename after --python\n"); + exit(1); + } + continue; + } if (!strncmp (argv [curarg], "--app", 4)) { curarg++; if (curarg < argc) { @@ -399,6 +417,9 @@ int main (int argc, char **argv) if (jnifp == NULL) { jnifile = 0; } + if (pythonfp == NULL) { + pythonfile = 0; + } if (ifp == NULL) { fprintf(stderr, "No input file specified...\n"); exit(1); @@ -424,6 +445,10 @@ int main (int argc, char **argv) printf ("Java native bindings written to %s\n", jnifile); fclose (jnifp); } + if (pythonfile) { + printf ("Python bindings written to %s\n", pythonfile); + fclose (pythonfp); + } } else { fclose (ifp); @@ -441,6 +466,10 @@ int main (int argc, char **argv) printf ("Removing %s\n", jnifile); unlink (jnifile); } + if (pythonfile) { + printf ("Removing %s\n", pythonfile); + unlink (pythonfile); + } exit (1); } exit (0); @@ -452,7 +481,7 @@ int main (int argc, char **argv) static void usage (char *progname) { fprintf (stderr, - "usage: %s --input [--output ]\n%s", + "usage: %s --input [--output ] [--python ]\n%s", progname, " [--yydebug] [--dump-tree]\n"); exit (1); diff --git a/vppapigen/node.c b/vppapigen/node.c index 3a32abec..ffe5d77e 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -34,6 +34,7 @@ FILE *ofp; FILE *javafp; FILE *jnifp; +FILE *pythonfp; char *java_class; time_t starttime; char *vlib_app_name; @@ -161,6 +162,12 @@ void primtype_recursive_generate(node_t *this, enum passid which, FILE *ofp, current_java_methodfun = vftp->java_method_function; break; + case PYTHON_PASS: + fputs("('", pythonfp); + fputs((char *)type_name, pythonfp); + fputs("', ", pythonfp); + break; + default: fprintf(stderr, "primtype_recursive_generate: unimp pass %d\n", which); break; @@ -876,6 +883,20 @@ void node_define_generate (node_t *this, enum passid which, FILE *fp) fprintf (fp, "}\n\n"); break; + case PYTHON_PASS: + fprintf(fp, "('%s',\n", CDATA0); + child = this->deeper; + indent += 4; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + } + indent -= 4; + fprintf(fp, "),\n\n"); + break; + default: fprintf(stderr, "node_define_generate: unimp pass %d\n", which); break; @@ -1032,6 +1053,9 @@ void node_scalar_generate (node_t *this, enum passid which, FILE *fp) } } break; + case PYTHON_PASS: + fprintf(fp, "'%s'),\n", CDATA0); + break; default: fprintf(stderr, "node_scalar_generate: unimp pass %d\n", which); @@ -1136,6 +1160,9 @@ void node_vector_generate (node_t *this, enum passid which, FILE *fp) indent_me(fp); fprintf(fp, "}\n"); break; + case PYTHON_PASS: + fprintf(fp, "'%s', '%d'),\n", CDATA0, IDATA1); + break; default: fprintf(stderr, "node_vector_generate: unimp pass %d\n", which); @@ -1216,6 +1243,14 @@ void node_complex_generate (node_t *this, enum passid which, FILE *fp) fprintf(fp, "%s_endian(&a->%s%s);\n", CDATA0, union_prefix, member_name); break; + case PYTHON_PASS: + fprintf(fp, "('%s',", CDATA0); + deeper = this->deeper; + if (deeper) { + vftp = the_vft[deeper->type]; + vftp->generate(deeper, which, fp); + } + break; default: fprintf(stderr, "node_complex_generate unimp pass %d...\n", which); @@ -1767,14 +1802,14 @@ void add_msg_ids(YYSTYPE a1) while (np) { if (np->type == NODE_DEFINE) { if (!(np->flags & NODE_FLAG_TYPEONLY)) { - /* add the parse tree for "u16 _vl_msg_id" */ + /* add the parse tree for "u16 _vl_msg_id" */ new_u16 = make_node(NODE_U16); new_u16->peer = np->deeper; np->deeper = new_u16; new_vbl = make_node(NODE_SCALAR); new_vbl->data[0] = sxerox("_vl_msg_id"); new_u16->deeper = new_vbl; - } + } } np = np->peer; } @@ -1988,6 +2023,23 @@ void generate_jni_bottom_boilerplate(FILE *fp) fputs (hookup_boilerplate, fp); } +void generate_python (YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "vppapidef = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + void generate(YYSTYPE a1) { if (dump_tree) { @@ -2020,4 +2072,7 @@ void generate(YYSTYPE a1) generate_jni_code(a1, jnifp); generate_jni_bottom_boilerplate(jnifp); } + if (pythonfp) { + generate_python(a1, pythonfp); + } } diff --git a/vppapigen/node.h b/vppapigen/node.h index 670b5aff..1f5a153c 100644 --- a/vppapigen/node.h +++ b/vppapigen/node.h @@ -63,6 +63,7 @@ enum passid { PRINTFUN_PASS, JAVA_METHOD_PASS, JAVA_JNI_PASS, + PYTHON_PASS, }; extern void *make_node (enum node_subclass type); -- cgit 1.2.3-korg From 0777915b2a98ea6353e6c0951c3aa195d4751d35 Mon Sep 17 00:00:00 2001 From: Srivatsa Sangli Date: Fri, 15 Apr 2016 13:59:00 -0700 Subject: ubuntu 16.04 build support. Supporting systemd with vpp.service files. Incorporating review comments : modified debian/control dependencies Change-Id: Ib2fe85d81eb7f1803ef8f54294c7c18cd07c61ba Signed-off-by: Srivatsa Sangli --- Makefile | 2 +- build-root/deb/debian/control | 2 +- build-root/deb/debian/rules | 2 +- build-root/deb/debian/vpp.service | 14 +++++++++++ build-root/vagrant/bootstrap.ubuntu1604.sh | 39 ++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 build-root/deb/debian/vpp.service create mode 100644 build-root/vagrant/bootstrap.ubuntu1604.sh (limited to 'Makefile') diff --git a/Makefile b/Makefile index 68652836..fd1d0ff9 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ MINIMAL_STARTUP_CONF="unix { interactive }" GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache -DEB_DEPENDS += debhelper dkms default-jdk git libtool libganglia1-dev libapr1-dev +DEB_DEPENDS += debhelper dkms default-jdk git libtool libganglia1-dev libapr1-dev dh-systemd DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope RPM_DEPENDS_GROUPS = 'Development Tools' diff --git a/build-root/deb/debian/control b/build-root/deb/debian/control index cf22fd02..97464e42 100644 --- a/build-root/deb/debian/control +++ b/build-root/deb/debian/control @@ -2,7 +2,7 @@ Source: vpp Section: net Priority: extra Maintainer: Cisco OpenVPP Packaging Team -Build-Depends: debhelper (>= 9), dkms +Build-Depends: debhelper (>= 9), dkms, dh-systemd Standards-Version: 3.9.4 Package: vpp diff --git a/build-root/deb/debian/rules b/build-root/deb/debian/rules index bcee0121..b5afbdb6 100755 --- a/build-root/deb/debian/rules +++ b/build-root/deb/debian/rules @@ -18,7 +18,7 @@ include /usr/share/dpkg/default.mk # main packaging script based on dh7 syntax %: - dh $@ --with dkms + dh $@ --with dkms --with systemd override_dh_install: dh_install --exclude .git diff --git a/build-root/deb/debian/vpp.service b/build-root/deb/debian/vpp.service new file mode 100644 index 00000000..a2849296 --- /dev/null +++ b/build-root/deb/debian/vpp.service @@ -0,0 +1,14 @@ +[Unit] +Description=vector packet processing engine +After=network.target + +[Service] +Type=simple +ExecStartPre=-/bin/rm -f /dev/shm/* +ExecStartPre=-/sbin/modprobe igb_uio +ExecStart=/usr/bin/vpp -c /etc/vpp/startup.conf +ExecStopPost=/bin/rm -f /dev/shm/* +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/build-root/vagrant/bootstrap.ubuntu1604.sh b/build-root/vagrant/bootstrap.ubuntu1604.sh new file mode 100644 index 00000000..2e607f1e --- /dev/null +++ b/build-root/vagrant/bootstrap.ubuntu1604.sh @@ -0,0 +1,39 @@ +# Fix grub-pc on Virtualbox with Ubuntu +export DEBIAN_FRONTEND=noninteractive + +# Standard update + upgrade dance +apt-get update +apt-get upgrade -y + +# Fix the silly notion that /bin/sh should point to dash by pointing it to bash + +sudo update-alternatives --install /bin/sh sh /bin/bash 100 + +cd /vpp +sudo -H -u vagrant make install-dep + +# Install useful but non-mandatory tools +apt-get install -y emacs git-review gdb gdbserver + +sudo -H -u vagrant make bootstrap +sudo -H -u vagrant make pkg-deb +(cd build-root/;dpkg -i *.deb) + +# Capture all the interface IPs, in case we need them later +ifconfig -a > ~vagrant/ifconfiga +chown vagrant:vagrant ~vagrant/ifconfiga + +# Disable all ethernet interfaces other than the default route +# interface so VPP will use those interfaces. The VPP auto-blacklist +# algorithm prevents the use of any physical interface contained in the +# routing table (i.e. "route --inet --inet6") preventing the theft of +# the management ethernet interface by VPP from the kernel. +for intf in $(ls /sys/class/net) ; do + if [ -d /sys/class/net/$intf/device ] && + [ "$(route --inet --inet6 | grep default | grep $intf)" == "" ] ; then + ifconfig $intf down + fi +done + +systemctl start vpp +cat /vagrant/README -- cgit 1.2.3-korg From 6b1d7c55d694fc6c0a262d6e1279fe207164e1b5 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 26 Apr 2016 18:19:47 +0200 Subject: Make automake silent rules default Change-Id: Ia504ccdac1deac20f20cf7fb76f78b2d8c505474 Signed-off-by: Damjan Marion --- Makefile | 3 +-- build-root/scripts/make-plugin-toolkit | 2 +- svm/configure.ac | 2 +- vlib-api/configure.ac | 2 +- vlib/configure.ac | 2 +- vnet/configure.ac | 2 +- vpp-api/configure.ac | 2 +- vpp-api/java/configure.ac | 2 +- vpp/configure.ac | 2 +- vppinfra/configure.ac | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fd1d0ff9..a222567e 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,6 @@ WS_ROOT=$(CURDIR) BR=$(WS_ROOT)/build-root CCACHE_DIR?=$(BR)/.ccache -V?=0 GDB?=gdb PLATFORM?=vpp @@ -119,7 +118,7 @@ else endif define make - @make -C $(BR) V=$(V) PLATFORM=$(PLATFORM) TAG=$(1) $(2) + @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2) endef build: $(BR)/.bootstrap.ok diff --git a/build-root/scripts/make-plugin-toolkit b/build-root/scripts/make-plugin-toolkit index 14e9eda2..e1d6fcfb 100755 --- a/build-root/scripts/make-plugin-toolkit +++ b/build-root/scripts/make-plugin-toolkit @@ -26,7 +26,7 @@ make PLATFORM=vpp sample-plugin-find-source make PLATFORM=vpp TAG=vpp wipe-all echo Build vpp forwarder production package -make PLATFORM=vpp TAG=vpp V=0 strip_sumbols=yes install-packages +make PLATFORM=vpp TAG=vpp strip_sumbols=yes install-packages tmp_dir="`mktemp -d /tmp/plugin-XXXXXX`" trap "rm -rf $tmp_dir" err diff --git a/svm/configure.ac b/svm/configure.ac index 8db58214..b3948176 100644 --- a/svm/configure.ac +++ b/svm/configure.ac @@ -2,7 +2,7 @@ AC_INIT(svm, 1.0) LT_INIT AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AM_PROG_AS AC_PROG_CC_C_O diff --git a/vlib-api/configure.ac b/vlib-api/configure.ac index b5f3157a..ab21f894 100644 --- a/vlib-api/configure.ac +++ b/vlib-api/configure.ac @@ -2,7 +2,7 @@ AC_INIT(vlibapi, 1.0) LT_INIT AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AC_PROG_CC AM_PROG_CC_C_O diff --git a/vlib/configure.ac b/vlib/configure.ac index 1a45d33e..4f32a21c 100644 --- a/vlib/configure.ac +++ b/vlib/configure.ac @@ -1,7 +1,7 @@ AC_INIT(vlib, 1.1) LT_INIT AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AC_PROG_CC AM_PROG_CC_C_O diff --git a/vnet/configure.ac b/vnet/configure.ac index bc1922b9..8f8b91f7 100644 --- a/vnet/configure.ac +++ b/vnet/configure.ac @@ -3,7 +3,7 @@ AC_CONFIG_AUX_DIR(config) AC_CONFIG_HEADERS(config/config.h) LT_INIT AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AC_PROG_CC AM_PROG_CC_C_O diff --git a/vpp-api/configure.ac b/vpp-api/configure.ac index 31ee6656..9f8c3ed3 100644 --- a/vpp-api/configure.ac +++ b/vpp-api/configure.ac @@ -3,7 +3,7 @@ LT_INIT AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SUBDIRS([java]) AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AM_PROG_AS AC_PROG_CC diff --git a/vpp-api/java/configure.ac b/vpp-api/java/configure.ac index 1607061d..02f25702 100644 --- a/vpp-api/java/configure.ac +++ b/vpp-api/java/configure.ac @@ -2,7 +2,7 @@ AC_INIT(vpp-japi, 1.0.0) LT_INIT AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AM_PROG_AS AC_PROG_CC diff --git a/vpp/configure.ac b/vpp/configure.ac index 5b72eea6..3eb7bb7c 100644 --- a/vpp/configure.ac +++ b/vpp/configure.ac @@ -1,6 +1,6 @@ AC_INIT(vpp, 1.1) AM_INIT_AUTOMAKE -AM_SILENT_RULES +AM_SILENT_RULES([yes]) AM_PROG_AS AC_PROG_CC diff --git a/vppinfra/configure.ac b/vppinfra/configure.ac index 712186af..88720f71 100644 --- a/vppinfra/configure.ac +++ b/vppinfra/configure.ac @@ -5,7 +5,7 @@ AC_CONFIG_HEADERS(config/config.h) AC_CANONICAL_BUILD AC_CANONICAL_HOST AM_INIT_AUTOMAKE([gnu no-dist-gzip dist-bzip2]) -AM_SILENT_RULES +AM_SILENT_RULES([yes]) # Checks for programs. AC_PROG_CC -- cgit 1.2.3-korg From 473bf23be85e861f95d69992b09b0b7d7a6efa2e Mon Sep 17 00:00:00 2001 From: Thomas F Herbert Date: Wed, 27 Apr 2016 16:19:03 -0400 Subject: Update Makefile to add debuginfo RPMs for gdb Change-Id: I29d8cc839565999e2fabe09d29c40e09aa1ea784 Signed-off-by: Thomas F Herbert --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a222567e..caf93dda 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ DEB_DEPENDS += debhelper dkms default-jdk git libtool libganglia1-dev libapr1-de DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope RPM_DEPENDS_GROUPS = 'Development Tools' -RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel +RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel EPEL_DEPENDS = libconfuse-devel ganglia-devel @@ -113,6 +113,7 @@ else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) @sudo yum install -y $(RPM_DEPENDS) @sudo yum install -y --enablerepo=epel $(EPEL_DEPENDS) + @sudo debuginfo-install glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 else $(error "This option currently works only on Ubuntu or Centos systems") endif -- cgit 1.2.3-korg From 60c63c7b537260c88225848bd42f0c34a618671d Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 26 Apr 2016 08:01:31 +0200 Subject: VPP-8: Set java-8 for JNI Change-Id: Ia81713a72e3c48b1d97bbf3f20a908bbc4ebd3b1 Signed-off-by: Maros Marsalek Signed-off-by: Marek Gradzki --- Makefile | 15 ++++++++++++++- build-data/packages/vpp-api.mk | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index caf93dda..3aeea8fe 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ MINIMAL_STARTUP_CONF="unix { interactive }" GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache -DEB_DEPENDS += debhelper dkms default-jdk git libtool libganglia1-dev libapr1-dev dh-systemd +DEB_DEPENDS += debhelper dkms openjdk-8-jdk git libtool libganglia1-dev libapr1-dev dh-systemd DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope RPM_DEPENDS_GROUPS = 'Development Tools' @@ -77,8 +77,19 @@ help: @echo " PLATFORM = $(PLATFORM)" @echo " DPDK_VERSION = $(DPDK_VERSION)" +# openjdk-8-jdk is not available in 14.04 repos by default +define use_ppa_for_jdk8 +if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ + sudo apt install software-properties-common; \ + sudo add-apt-repository -y ppa:openjdk-r/ppa; \ + sudo apt update; \ +fi; +endef + $(BR)/.bootstrap.ok: ifeq ("$(shell lsb_release -si)", "Ubuntu") + $(use_ppa_for_jdk8) + @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \ if [ -n "$$MISSING" ] ; then \ echo "\nPlease install missing packages: \n$$MISSING\n" ; \ @@ -108,6 +119,7 @@ bootstrap: $(BR)/.bootstrap.ok install-dep: ifeq ("$(shell lsb_release -si)", "Ubuntu") + $(use_ppa_for_jdk8) @sudo apt-get -y install $(DEB_DEPENDS) else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) @@ -188,3 +200,4 @@ ctags: ctags.files cscope: cscope.files @cscope -b -q -v + diff --git a/build-data/packages/vpp-api.mk b/build-data/packages/vpp-api.mk index f1841648..4937023a 100644 --- a/build-data/packages/vpp-api.mk +++ b/build-data/packages/vpp-api.mk @@ -20,4 +20,4 @@ vpp-api_LDFLAGS = $(call installed_libs_fn, \ vlib \ vlib-api) -vpp-api_CPPFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include +vpp-api_CPPFLAGS += -I/usr/lib/jvm/java-8-openjdk-amd64/include -- cgit 1.2.3-korg From 7226b84d7418fcbb9b8dd42045aa7a5f18da9679 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Thu, 28 Apr 2016 18:23:43 -0400 Subject: Fix for java8 releated breakage in make install-dep Change-Id: I17ae3c7031a820746a3785a35b440e17430d0ac5 Signed-off-by: Ed Warnicke --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3aeea8fe..53930928 100644 --- a/Makefile +++ b/Makefile @@ -80,9 +80,9 @@ help: # openjdk-8-jdk is not available in 14.04 repos by default define use_ppa_for_jdk8 if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ - sudo apt install software-properties-common; \ + sudo apt-get -y install software-properties-common; \ sudo add-apt-repository -y ppa:openjdk-r/ppa; \ - sudo apt update; \ + sudo apt-get update; \ fi; endef -- cgit 1.2.3-korg From 45a42b5d7f6940fbd93d6b3413c2d943e497a0b1 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Thu, 28 Apr 2016 12:29:33 +0200 Subject: HONEYCOMB-10: jVpp - the new java API. Java code generation The old japi has two main drawbacks: * it is not fully generated (requres manual coding for every new api call that returns data other thanstatus code) * it is not asynchronous from Java perspective (requires active wait loops - big overhead due to JNI boundary being crossed lots of times). The new api is lightweight (fully generated except for connect, disconenct and ping) and truly asynchronous (uses callbacks, utilities that offer java.util.concurrent.Future interface are also provided). Change-Id: I531080ef651e8a74f19210490c71d161221ab600 Signed-off-by: Marek Gradzki Signed-off-by: Maros Marsalek Signed-off-by: Ed Warnicke --- Makefile | 6 + vpp-api/java/jvpp/gen/callback_gen.py | 89 ++++++++ vpp-api/java/jvpp/gen/dto_gen.py | 143 +++++++++++++ vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py | 236 +++++++++++++++++++++ vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py | 184 ++++++++++++++++ vpp-api/java/jvpp/gen/jvpp_impl_gen.py | 140 ++++++++++++ vpp-api/java/jvpp/gen/util.py | 173 +++++++++++++++ .../java/jvpp/org/openvpp/jvpp/VppConnection.java | 37 ++++ .../jvpp/org/openvpp/jvpp/VppJNIConnection.java | 144 +++++++++++++ .../org/openvpp/jvpp/callback/JVppCallback.java | 23 ++ .../java/jvpp/org/openvpp/jvpp/dto/JVppDump.java | 24 +++ .../java/jvpp/org/openvpp/jvpp/dto/JVppReply.java | 24 +++ .../jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java | 25 +++ .../jvpp/org/openvpp/jvpp/dto/JVppRequest.java | 33 +++ .../jvpp/org/openvpp/jvpp/future/FutureJVpp.java | 36 ++++ .../org/openvpp/jvpp/future/FutureJVppFacade.java | 110 ++++++++++ .../org/openvpp/jvpp/test/CallbackApiTest.java | 87 ++++++++ .../openvpp/jvpp/test/CallbackJVppFacadeTest.java | 67 ++++++ .../org/openvpp/jvpp/test/ControlPingTest.java | 53 +++++ .../jvpp/org/openvpp/jvpp/test/FutureApiTest.java | 124 +++++++++++ 20 files changed, 1758 insertions(+) create mode 100644 vpp-api/java/jvpp/gen/callback_gen.py create mode 100644 vpp-api/java/jvpp/gen/dto_gen.py create mode 100644 vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py create mode 100644 vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py create mode 100644 vpp-api/java/jvpp/gen/jvpp_impl_gen.py create mode 100644 vpp-api/java/jvpp/gen/util.py create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVpp.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppFacade.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java create mode 100644 vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java (limited to 'Makefile') diff --git a/Makefile b/Makefile index 53930928..f4b46f8e 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,9 @@ ifeq ("$(shell lsb_release -si)", "Ubuntu") echo "by executing \"make install-dep\"\n" ; \ exit 1 ; \ fi ; \ + if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ + sudo update-alternatives --set javah /usr/lib/jvm/java-8-openjdk-amd64/bin/javah ; \ + fi ; \ exit 0 endif @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk @@ -121,6 +124,9 @@ install-dep: ifeq ("$(shell lsb_release -si)", "Ubuntu") $(use_ppa_for_jdk8) @sudo apt-get -y install $(DEB_DEPENDS) + if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ + update-alternatives --set javah /usr/lib/jvm/java-8-openjdk-amd64/bin/javah ; \ + fi ; \ else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) @sudo yum install -y $(RPM_DEPENDS) diff --git a/vpp-api/java/jvpp/gen/callback_gen.py b/vpp-api/java/jvpp/gen/callback_gen.py new file mode 100644 index 00000000..218ac622 --- /dev/null +++ b/vpp-api/java/jvpp/gen/callback_gen.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import util +from string import Template + +from util import remove_suffix + +callback_suffix = "Callback" + +callback_template = Template(""" +package $base_package.$callback_package; + +/** + * $docs + */ +public interface $cls_name extends $base_package.$callback_package.JVppCallback { + + $callback_method + +} +""") + +global_callback_template = Template(""" +package $base_package.$callback_package; + +/** + * + * + * Global aggregated callback interface + */ +public interface JVppGlobalCallback extends $callbacks { +} +""") + + +def generate_callbacks(func_list, base_package, callback_package, dto_package): + """ Generates callback interfaces """ + print "Generating Callback interfaces" + + if not os.path.exists(callback_package): + raise Exception("%s folder is missing" % callback_package) + + callbacks = [] + for func in func_list: + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # FIXME handle notifications + continue + + camel_case_name_with_suffix = util.underscore_to_camelcase_upper(func['name']) + if not util.is_reply(camel_case_name_with_suffix): + continue + + camel_case_name = util.remove_reply_suffix(camel_case_name_with_suffix) + callbacks.append("{0}.{1}.{2}".format(base_package, callback_package, camel_case_name + callback_suffix)) + callback_path = os.path.join(callback_package, camel_case_name + callback_suffix + ".java") + callback_file = open(callback_path, 'w') + + reply_type = "%s.%s.%s" % (base_package, dto_package, camel_case_name_with_suffix) + method = "void on{0}({1} reply);".format(camel_case_name_with_suffix, reply_type) + callback_file.write( + callback_template.substitute(docs='Generated from ' + str(func), + cls_name=camel_case_name + callback_suffix, + callback_method=method, + base_package=base_package, + callback_package=callback_package)) + callback_file.flush() + callback_file.close() + + callback_file = open(os.path.join(callback_package, "JVppGlobalCallback.java"), 'w') + callback_file.write(global_callback_template.substitute(callbacks=", ".join(callbacks), + base_package=base_package, + callback_package=callback_package)) + callback_file.flush() + callback_file.close() diff --git a/vpp-api/java/jvpp/gen/dto_gen.py b/vpp-api/java/jvpp/gen/dto_gen.py new file mode 100644 index 00000000..17fde68a --- /dev/null +++ b/vpp-api/java/jvpp/gen/dto_gen.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, util +from string import Template + +dto_template = Template(""" +package $base_package.$dto_package; + +/** + * $docs + */ +public final class $cls_name implements $base_package.$dto_package.$base_type { + +$fields +$methods +} +""") + +field_template = Template(""" public $type $name;\n""") + +send_template = Template(""" @Override + public int send(final $base_package.JVpp jvpp) { + return jvpp.$method_name($args); + }\n""") + + +def generate_dtos(func_list, base_package, dto_package): + """ Generates dto objects in a dedicated package """ + print "Generating DTOs" + + if not os.path.exists(dto_package): + raise Exception("%s folder is missing" % dto_package) + + for func in func_list: + camel_case_dto_name = util.underscore_to_camelcase_upper(func['name']) + camel_case_method_name = util.underscore_to_camelcase(func['name']) + dto_path = os.path.join(dto_package, camel_case_dto_name + ".java") + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # TODO handle notifications + continue + + fields = "" + for t in zip(func['types'], func['args']): + fields += field_template.substitute(type=util.jni_2_java_type_mapping[t[0]], + name=util.underscore_to_camelcase(t[1])) + methods = "" + base_type = "" + if util.is_reply(camel_case_dto_name): + request_dto_name = get_request_name(camel_case_dto_name, func['name']) + if util.is_details(camel_case_dto_name): + # FIXME assumption that dump calls end with "Dump" suffix. Not enforced in vpe.api + base_type += "JVppReply<%s.%s.%s>" % (base_package, dto_package, request_dto_name + "Dump") + generate_dump_reply_dto(request_dto_name, base_package, dto_package, camel_case_dto_name, + camel_case_method_name, func) + else: + base_type += "JVppReply<%s.%s.%s>" % (base_package, dto_package, request_dto_name) + else: + args = "" if fields is "" else "this" + methods = send_template.substitute(method_name=camel_case_method_name, + base_package=base_package, + args=args) + if util.is_dump(camel_case_dto_name): + base_type += "JVppDump" + else: + base_type += "JVppRequest" + + dto_file = open(dto_path, 'w') + dto_file.write(dto_template.substitute(docs='Generated from ' + str(func), + cls_name=camel_case_dto_name, + fields=fields, + methods=methods, + base_package=base_package, + base_type=base_type, + dto_package=dto_package)) + dto_file.flush() + dto_file.close() + + flush_dump_reply_dtos() + + +dump_dto_suffix = "ReplyDump" +dump_reply_artificial_dtos = {} + + +# Returns request name or special one from unconventional_naming_rep_req map +def get_request_name(camel_case_dto_name, func_name): + return util.underscore_to_camelcase_upper( + util.unconventional_naming_rep_req[func_name]) if func_name in util.unconventional_naming_rep_req \ + else util.remove_reply_suffix(camel_case_dto_name) + + +def flush_dump_reply_dtos(): + for dump_reply_artificial_dto in dump_reply_artificial_dtos.values(): + dto_path = os.path.join(dump_reply_artificial_dto['dto_package'], + dump_reply_artificial_dto['cls_name'] + ".java") + dto_file = open(dto_path, 'w') + dto_file.write(dto_template.substitute(docs=dump_reply_artificial_dto['docs'], + cls_name=dump_reply_artificial_dto['cls_name'], + fields=dump_reply_artificial_dto['fields'], + methods=dump_reply_artificial_dto['methods'], + base_package=dump_reply_artificial_dto['base_package'], + base_type=dump_reply_artificial_dto['base_type'], + dto_package=dump_reply_artificial_dto['dto_package'])) + dto_file.flush() + dto_file.close() + + +def generate_dump_reply_dto(request_dto_name, base_package, dto_package, camel_case_dto_name, camel_case_method_name, + func): + base_type = "JVppReplyDump<%s.%s.%s, %s.%s.%s>" % ( + base_package, dto_package, util.remove_reply_suffix(camel_case_dto_name) + "Dump", + base_package, dto_package, camel_case_dto_name) + fields = " public java.util.List<%s> %s = new java.util.ArrayList<>();" % (camel_case_dto_name, camel_case_method_name) + cls_name = camel_case_dto_name + dump_dto_suffix + + # In case of already existing artificial reply dump DTO, just update it + # Used for sub-dump dtos + if request_dto_name in dump_reply_artificial_dtos.keys(): + dump_reply_artificial_dtos[request_dto_name]['fields'] = \ + dump_reply_artificial_dtos[request_dto_name]['fields'] + '\n' + fields + else: + dump_reply_artificial_dtos[request_dto_name] = ({'docs': 'Dump reply wrapper generated from ' + str(func), + 'cls_name': cls_name, + 'fields': fields, + 'methods': "", + 'base_package': base_package, + 'base_type': base_type, + 'dto_package': dto_package, + }) diff --git a/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py b/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py new file mode 100644 index 00000000..731bd894 --- /dev/null +++ b/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py @@ -0,0 +1,236 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, util +from string import Template + +import callback_gen +import dto_gen + +jvpp_ifc_template = Template(""" +package $base_package.$callback_facade_package; + +public interface CallbackJVpp extends java.lang.AutoCloseable { + + @Override + void close(); + + // TODO add send + +$methods +} +""") + +jvpp_impl_template = Template(""" +package $base_package.$callback_facade_package; + +public final class CallbackJVppFacade implements $base_package.$callback_facade_package.CallbackJVpp { + + private final $base_package.JVpp jvpp; + private final java.util.Map callbacks; + + public CallbackJVppFacade(final $base_package.JVpp jvpp, + java.util.Map callbacks) { + if(jvpp == null) { + throw new java.lang.NullPointerException("jvpp is null"); + } + this.jvpp = jvpp; + this.callbacks = callbacks; + } + + @Override + public void close() { + } + + // TODO add send() + +$methods +} +""") + +method_template = Template( + """ void $name($base_package.$dto_package.$request request, $base_package.$callback_package.$callback callback);""") +method_impl_template = Template(""" public final void $name($base_package.$dto_package.$request request, $base_package.$callback_package.$callback callback) { + synchronized (callbacks) { + callbacks.put(jvpp.$name(request), callback); + } + } +""") + +no_arg_method_template = Template(""" void $name($base_package.$callback_package.$callback callback);""") +no_arg_method_impl_template = Template(""" public final void $name($base_package.$callback_package.$callback callback) { + synchronized (callbacks) { + callbacks.put(jvpp.$name(), callback); + } + } +""") + + +def generate_jvpp(func_list, base_package, dto_package, callback_package, callback_facade_package): + """ Generates callback facade """ + print "Generating JVpp callback facade" + + if os.path.exists(callback_facade_package): + util.remove_folder(callback_facade_package) + + os.mkdir(callback_facade_package) + + methods = [] + methods_impl = [] + for func in func_list: + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # TODO handle notifications + continue + + camel_case_name = util.underscore_to_camelcase(func['name']) + camel_case_name_upper = util.underscore_to_camelcase_upper(func['name']) + if util.is_reply(camel_case_name): + continue + + # Strip suffix for dump calls + callback_type = get_request_name(camel_case_name_upper, func['name']) + callback_gen.callback_suffix + + if len(func['args']) == 0: + methods.append(no_arg_method_template.substitute(name=camel_case_name, + base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback=callback_type)) + methods_impl.append(no_arg_method_impl_template.substitute(name=camel_case_name, + base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback=callback_type)) + else: + methods.append(method_template.substitute(name=camel_case_name, + request=camel_case_name_upper, + base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback=callback_type)) + methods_impl.append(method_impl_template.substitute(name=camel_case_name, + request=camel_case_name_upper, + base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback=callback_type)) + + join = os.path.join(callback_facade_package, "CallbackJVpp.java") + jvpp_file = open(join, 'w') + jvpp_file.write( + jvpp_ifc_template.substitute(methods="\n".join(methods), + base_package=base_package, + dto_package=dto_package, + callback_facade_package=callback_facade_package)) + jvpp_file.flush() + jvpp_file.close() + + jvpp_file = open(os.path.join(callback_facade_package, "CallbackJVppFacade.java"), 'w') + jvpp_file.write(jvpp_impl_template.substitute(methods="\n".join(methods_impl), + base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback_facade_package=callback_facade_package)) + jvpp_file.flush() + jvpp_file.close() + + generate_callback(func_list, base_package, dto_package, callback_package, callback_facade_package) + + +jvpp_facade_callback_template = Template(""" +package $base_package.$callback_facade_package; + +/** + * Async facade callback setting values to future objects + */ +public final class CallbackJVppFacadeCallback implements $base_package.$callback_package.JVppGlobalCallback { + + private final java.util.Map requests; + + public CallbackJVppFacadeCallback(final java.util.Map requestMap) { + this.requests = requestMap; + } + +$methods +} +""") + +jvpp_facade_callback_method_template = Template(""" + @Override + @SuppressWarnings("unchecked") + public void on$callback_dto($base_package.$dto_package.$callback_dto reply) { + + $base_package.$callback_package.$callback callback; + synchronized(requests) { + callback = ($base_package.$callback_package.$callback) requests.remove(reply.context); + } + + if(callback != null) { + callback.on$callback_dto(reply); + } + } +""") + + +def generate_callback(func_list, base_package, dto_package, callback_package, callback_facade_package): + callbacks = [] + for func in func_list: + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # TODO handle notifications + continue + + camel_case_name_with_suffix = util.underscore_to_camelcase_upper(func['name']) + if not util.is_reply(camel_case_name_with_suffix): + continue + + callbacks.append(jvpp_facade_callback_method_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + callback=util.remove_reply_suffix(camel_case_name_with_suffix) + callback_gen.callback_suffix, + callback_dto=camel_case_name_with_suffix)) + + jvpp_file = open(os.path.join(callback_facade_package, "CallbackJVppFacadeCallback.java"), 'w') + jvpp_file.write(jvpp_facade_callback_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + methods="".join(callbacks), + callback_facade_package=callback_facade_package)) + jvpp_file.flush() + jvpp_file.close() + + +# Returns request name or special one from unconventional_naming_rep_req map +def get_request_name(camel_case_dto_name, func_name): + if func_name in reverse_dict(util.unconventional_naming_rep_req): + request_name = util.underscore_to_camelcase_upper(reverse_dict(util.unconventional_naming_rep_req)[func_name]) + else: + request_name = camel_case_dto_name + return remove_suffix(request_name) + + +def reverse_dict(map): + return dict((v, k) for k, v in map.iteritems()) + + +def remove_suffix(name): + if util.is_reply(name): + return util.remove_reply_suffix(name) + else: + if util.is_dump(name): + return util.remove_suffix(name, util.dump_suffix) + else: + return name diff --git a/vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py b/vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py new file mode 100644 index 00000000..2aae5b80 --- /dev/null +++ b/vpp-api/java/jvpp/gen/jvpp_future_facade_gen.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, util +from string import Template + +import dto_gen + +jvpp_facade_callback_template = Template(""" +package $base_package.$future_package; + +/** + * Async facade callback setting values to future objects + */ +public final class FutureJVppFacadeCallback implements $base_package.$callback_package.JVppGlobalCallback { + + private final java.util.Map>> requests; + + public FutureJVppFacadeCallback(final java.util.Map>> requestMap) { + this.requests = requestMap; + } + +$methods +} +""") + +jvpp_facade_callback_method_template = Template(""" + @Override + @SuppressWarnings("unchecked") + public void on$callback_dto($base_package.$dto_package.$callback_dto reply) { + final java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply> completableFuture; + + synchronized(requests) { + completableFuture = (java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply>) requests.get(reply.context); + } + + if(completableFuture != null) { + if(reply.retval < 0) { + completableFuture.completeExceptionally(new Exception("Invocation of " + $base_package.$dto_package.$callback_dto.class + + " failed with value " + reply.retval)); + } else { + completableFuture.complete(reply); + } + + synchronized(requests) { + requests.remove(reply.context); + } + } + } +""") + +# TODO reuse common parts with generic method callback +jvpp_facade_control_ping_method_template = Template(""" + @Override + @SuppressWarnings("unchecked") + public void on$callback_dto($base_package.$dto_package.$callback_dto reply) { + final java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply> completableFuture; + + synchronized(requests) { + completableFuture = (java.util.concurrent.CompletableFuture<$base_package.$dto_package.JVppReply>) requests.get(reply.context); + } + + if(completableFuture != null) { + // Finish dump call + if (completableFuture instanceof $base_package.$future_package.FutureJVppFacade.CompletableDumpFuture) { + completableFuture.complete((($base_package.$future_package.FutureJVppFacade.CompletableDumpFuture) completableFuture).getReplyDump()); + // Remove future mapped to dump call context id + synchronized(requests) { + requests.remove((($base_package.$future_package.FutureJVppFacade.CompletableDumpFuture) completableFuture).getContextId()); + } + } else { + if(reply.retval < 0) { + completableFuture.completeExceptionally(new Exception("Invocation of " + $base_package.$dto_package.$callback_dto.class + + " failed with value " + reply.retval)); + } else { + completableFuture.complete(reply); + } + } + + synchronized(requests) { + requests.remove(reply.context); + } + } + } +""") + +jvpp_facade_details_callback_method_template = Template(""" + @Override + @SuppressWarnings("unchecked") + public void on$callback_dto($base_package.$dto_package.$callback_dto reply) { + final FutureJVppFacade.CompletableDumpFuture<$base_package.$dto_package.$callback_dto_reply_dump> completableFuture; + + synchronized(requests) { + completableFuture = ($base_package.$future_package.FutureJVppFacade.CompletableDumpFuture<$base_package.$dto_package.$callback_dto_reply_dump>) requests.get(reply.context); + } + + if(completableFuture != null) { + $base_package.$dto_package.$callback_dto_reply_dump replyDump = completableFuture.getReplyDump(); + if(replyDump == null) { + replyDump = new $base_package.$dto_package.$callback_dto_reply_dump(); + completableFuture.setReplyDump(replyDump); + } + + replyDump.$callback_dto_field.add(reply); + } + } +""") + + +def generate_jvpp(func_list, base_package, dto_package, callback_package, future_facade_package): + """ Generates JVpp interface and JNI implementation """ + print "Generating JVpp future facade" + + if not os.path.exists(future_facade_package): + raise Exception("%s folder is missing" % future_facade_package) + + callbacks = [] + for func in func_list: + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # TODO handle notifications + continue + + camel_case_name_with_suffix = util.underscore_to_camelcase_upper(func['name']) + if not util.is_reply(camel_case_name_with_suffix): + continue + + if util.is_details(camel_case_name_with_suffix): + camel_case_method_name = util.underscore_to_camelcase(func['name']) + camel_case_request_name = get_standard_dump_reply_name(util.underscore_to_camelcase_upper(func['name']), + func['name']) + callbacks.append(jvpp_facade_details_callback_method_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_dto=camel_case_name_with_suffix, + callback_dto_field=camel_case_method_name, + callback_dto_reply_dump=camel_case_request_name + dto_gen.dump_dto_suffix, + future_package=future_facade_package)) + else: + if util.is_control_ping(camel_case_name_with_suffix): + callbacks.append(jvpp_facade_control_ping_method_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_dto=camel_case_name_with_suffix, + future_package=future_facade_package)) + else: + callbacks.append(jvpp_facade_callback_method_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_dto=camel_case_name_with_suffix)) + + jvpp_file = open(os.path.join(future_facade_package, "FutureJVppFacadeCallback.java"), 'w') + jvpp_file.write(jvpp_facade_callback_template.substitute(base_package=base_package, + dto_package=dto_package, + callback_package=callback_package, + methods="".join(callbacks), + future_package=future_facade_package)) + jvpp_file.flush() + jvpp_file.close() + + +# Returns request name or special one from unconventional_naming_rep_req map +def get_standard_dump_reply_name(camel_case_dto_name, func_name): + # FIXME this is a hotfix for sub-details callbacks + # FIXME also for L2FibTableEntry + # It's all because unclear mapping between + # request -> reply, + # dump -> reply, details, + # notification_start -> reply, notifications + + # vpe.api needs to be "standardized" so we can parse the information and create maps before generating java code + suffix = func_name.split("_")[-1] + return util.underscore_to_camelcase_upper( + util.unconventional_naming_rep_req[func_name]) + util.underscore_to_camelcase_upper(suffix) if func_name in util.unconventional_naming_rep_req \ + else camel_case_dto_name diff --git a/vpp-api/java/jvpp/gen/jvpp_impl_gen.py b/vpp-api/java/jvpp/gen/jvpp_impl_gen.py new file mode 100644 index 00000000..5446a694 --- /dev/null +++ b/vpp-api/java/jvpp/gen/jvpp_impl_gen.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, util +from string import Template + +jvpp_ifc_template = Template(""" +package $base_package; + +public interface JVpp extends java.lang.AutoCloseable { + + /** + * Generic dispatch method for sending requests to VPP + */ + int send($base_package.$dto_package.JVppRequest request); + + @Override + void close(); + +$methods +} +""") + +jvpp_impl_template = Template(""" +package $base_package; + +public final class JVppImpl implements $base_package.JVpp { + + private final $base_package.VppConnection connection; + + public JVppImpl(final $base_package.VppConnection connection) { + if(connection == null) { + throw new java.lang.NullPointerException("Connection is null"); + } + this.connection = connection; + } + + @Override + public void close() { + connection.close(); + } + + @Override + public int send($base_package.$dto_package.JVppRequest request) { + return request.send(this); + } + +$methods +} +""") + +method_template = Template(""" int $name($base_package.$dto_package.$request request);""") +method_native_template = Template( + """ private static native int ${name}0($base_package.$dto_package.$request request);""") +method_impl_template = Template(""" public final int $name($base_package.$dto_package.$request request) { + if(request == null) { + throw new java.lang.NullPointerException("Null request object"); + } + connection.checkActive(); + return ${name}0(request); + } +""") + +no_arg_method_template = Template(""" int $name();""") +no_arg_method_native_template = Template(""" private static native int ${name}0();""") +no_arg_method_impl_template = Template(""" public final int $name() { + connection.checkActive(); + return ${name}0(); + } +""") + + +def generate_jvpp(func_list, base_package, dto_package): + """ Generates JVpp interface and JNI implementation """ + print "Generating JVpp" + + methods = [] + methods_impl = [] + for func in func_list: + + if util.is_notification(func['name']) or util.is_ignored(func['name']): + # TODO handle notifications + continue + + camel_case_name = util.underscore_to_camelcase(func['name']) + camel_case_name_upper = util.underscore_to_camelcase_upper(func['name']) + if util.is_reply(camel_case_name): + continue + + if len(func['args']) == 0: + methods.append(no_arg_method_template.substitute(name=camel_case_name, + base_package=base_package, + dto_package=dto_package)) + methods_impl.append( + no_arg_method_native_template.substitute(name=camel_case_name, + base_package=base_package, + dto_package=dto_package)) + methods_impl.append(no_arg_method_impl_template.substitute(name=camel_case_name, + base_package=base_package, + dto_package=dto_package)) + else: + methods.append(method_template.substitute(name=camel_case_name, + request=camel_case_name_upper, + base_package=base_package, + dto_package=dto_package)) + methods_impl.append(method_native_template.substitute(name=camel_case_name, + request=camel_case_name_upper, + base_package=base_package, + dto_package=dto_package)) + methods_impl.append(method_impl_template.substitute(name=camel_case_name, + request=camel_case_name_upper, + base_package=base_package, + dto_package=dto_package)) + + jvpp_file = open("JVpp.java", 'w') + jvpp_file.write( + jvpp_ifc_template.substitute(methods="\n".join(methods), + base_package=base_package, + dto_package=dto_package)) + jvpp_file.flush() + jvpp_file.close() + + jvpp_file = open("JVppImpl.java", 'w') + jvpp_file.write(jvpp_impl_template.substitute(methods="\n".join(methods_impl), + base_package=base_package, + dto_package=dto_package)) + jvpp_file.flush() + jvpp_file.close() diff --git a/vpp-api/java/jvpp/gen/util.py b/vpp-api/java/jvpp/gen/util.py new file mode 100644 index 00000000..17dc2ed9 --- /dev/null +++ b/vpp-api/java/jvpp/gen/util.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from os import removedirs + + +def underscore_to_camelcase(name): + name = name.title().replace("_", "") + return name[0].lower() + name[1:] + + +def underscore_to_camelcase_upper(name): + name = name.title().replace("_", "") + return name[0].upper() + name[1:] + + +def remove_folder(folder): + """ Remove folder with all its files """ + for root, dirs, files in os.walk(folder, topdown=False): + for name in files: + os.remove(os.path.join(root, name)) + removedirs(folder) + + +reply_suffixes = ("reply", "details", "l2fibtableentry") + + +def is_reply(name): + return name.lower().endswith(reply_suffixes) + + +def is_details(name): + return name.lower().endswith(reply_suffixes[1]) or name.lower().endswith(reply_suffixes[2]) + +dump_suffix = "dump" + + +def is_dump(name): + return name.lower().endswith(dump_suffix) + + +def get_reply_suffix(name): + for reply_suffix in reply_suffixes: + if name.lower().endswith(reply_suffix): + if reply_suffix == reply_suffixes[2]: + # FIXME workaround for l2_fib_table_entry + return 'entry' + else: + return reply_suffix + +# http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html +jni_2_java_type_mapping = {'jbyte': 'byte', + 'jbyteArray': 'byte[]', + 'jchar': 'char', + 'jcharArray': 'char[]', + 'jshort': 'short', + 'jshortArray': 'short[]', + 'jint': 'int', + 'jintArray': 'int[]', + 'jlong': 'long', + 'jlongArray': 'long[]', + 'jdouble': 'double', + 'jdoubleArray': 'double[]', + 'jfloat': 'float', + 'jfloatArray': 'float[]', + 'void': 'void', + 'jstring': 'java.lang.String', + 'jobject': 'java.lang.Object', + 'jobjectArray': 'java.lang.Object[]' + } + +# https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#type_signatures +jni_2_signature_mapping = {'jbyte': 'B', + 'jbyteArray': '[B', + 'jchar': 'C', + 'jcharArray': '[C', + 'jshort': 'S', + 'jshortArray': '[S', + 'jint': 'I', + 'jintArray': '[I', + 'jlong': 'J', + 'jlongArray': '[J', + 'jdouble': 'D', + 'jdoubleArray': '[D', + 'jfloat': 'F', + 'jfloatArray': '[F' + } + +# https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#Get_type_Field_routines +jni_field_accessors = { + 'jbyte': 'ByteField', + 'jbyteArray': 'ObjectField', + 'jchar': 'CharField', + 'jcharArray': 'ObjectField', + 'jshort': 'ShortField', + 'jshortArray': 'ObjectField', + 'jint': 'IntField', + 'jintArray': 'ObjectField', + 'jlong': 'LongField', + 'jlongArray': 'ObjectField', + 'jdouble': 'DoubleField', + 'jdoubleArray': 'ObjectField', + 'jfloat': 'FloatField', + 'jfloatArray': 'ObjectField' +} + +# TODO watch out for unsigned types +# http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html +vpp_2_jni_type_mapping = {'u8': 'jbyte', # fixme + 'i8': 'jbyte', + 'u16': 'jchar', + 'i16': 'jshort', + 'u32': 'jint', # fixme + 'i32': 'jint', + 'u64': 'jlong', # fixme + 'i64': 'jlong', + 'f64': 'jdouble' + } + +# vpe.api calls that do not follow naming conventions and have to be handled exceptionally when finding reply -> request mapping +# FIXME in vpe.api +unconventional_naming_rep_req = { + 'cli_reply': 'cli_request', + 'vnet_summary_stats_reply': 'vnet_get_summary_stats', + # This below is actually a sub-details callback. We cannot derive the mapping of dump request + # belonging to this sub-details from naming conventions. We need special mapping + 'bridge_domain_sw_if_details': 'bridge_domain', + # This is standard dump call + details reply. However it's not called details but entry + 'l2_fib_table_entry': 'l2_fib_table' + } + +# +# FIXME no convention in the naming of events (notifications) in vpe.api +notifications_message_suffixes = ("event", "counters") +notification_messages = ["from_netconf_client", "from_netconf_server", "to_netconf_client", "to_netconf_server"] + +# messages that must be ignored. These messages are INSUFFICIENTLY marked as disabled in vpe.api +# FIXME +ignored_messages = ["is_address_reachable"] + + +def is_notification(param): + return param.lower().endswith(notifications_message_suffixes) or param.lower() in notification_messages + + +def is_ignored(param): + return param.lower() in ignored_messages + + +def remove_reply_suffix(camel_case_name_with_suffix): + return remove_suffix(camel_case_name_with_suffix, get_reply_suffix(camel_case_name_with_suffix)) + + +def remove_suffix(camel_case_name_with_suffix, suffix): + suffix_length = len(suffix) + return camel_case_name_with_suffix[:-suffix_length] if suffix_length != 0 else camel_case_name_with_suffix + + +def is_control_ping(camel_case_name_with_suffix): + return "controlping" in camel_case_name_with_suffix.lower() diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java new file mode 100644 index 00000000..72ff62c9 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp; + +/** + * Representation of a management connection to VPP. + * Connection is initiated when instance is created, closed with close(). + */ +public interface VppConnection extends AutoCloseable { + + /** + * Check if this instance connection is active. + * + * @throws IllegalStateException if this instance was disconnected. + */ + void checkActive(); + + /** + * Closes Vpp connection. + */ + @Override + void close(); +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java new file mode 100644 index 00000000..9e07cc76 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; +import org.openvpp.jvpp.callback.JVppCallback; + +/** + * JNI based representation of a management connection to VPP + */ +public final class VppJNIConnection implements VppConnection { + private final static Logger LOG = Logger.getLogger(VppJNIConnection.class.getName()); + private static final String LIBNAME = "libjvpp.so.0.0.0"; + + static { + try { + loadLibrary(); + } catch (Exception e) { + LOG.severe("Can't find vpp jni library: " + LIBNAME); + throw new ExceptionInInitializerError(e); + } + } + + private static void loadStream(final InputStream is) throws IOException { + final Set perms = PosixFilePermissions.fromString("rwxr-x---"); + final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); + try { + Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); + + try { + Runtime.getRuntime().load(p.toString()); + } catch (UnsatisfiedLinkError e) { + throw new IOException("Failed to load library " + p, e); + } + } finally { + try { + Files.deleteIfExists(p); + } catch (IOException e) { + } + } + } + + private static void loadLibrary() throws IOException { + try (final InputStream is = VppJNIConnection.class.getResourceAsStream('/' + LIBNAME)) { + if (is == null) { + throw new IOException("Failed to open library resource " + LIBNAME); + } + loadStream(is); + } + } + + private final String clientName; + private volatile boolean disconnected = false; + + private VppJNIConnection(final String clientName) { + if (clientName == null) { + throw new NullPointerException("Null clientName"); + } + this.clientName = clientName; + } + + /** + * Guarded by VppJNIConnection.class + */ + private static final Map connections = new HashMap<>(); + + /** + * Create a new Vpp connection identified by clientName parameter. + * + * Multiple instances are allowed since this class is not a singleton + * (VPP allows multiple management connections). + * + * However only a single connection per clientName is allowed. + * + * @param clientName identifier of vpp connection + * @param callback global callback to receive response calls from vpp + * + * @return new Vpp connection + * @throws IOException in case the connection could not be established, or there already is a connection with the same name + */ + public static VppJNIConnection create(final String clientName, final JVppCallback callback) throws IOException { + synchronized (VppJNIConnection.class) { + if(connections.containsKey(clientName)) { + throw new IOException("Client " + clientName + " already connected"); + } + + final VppJNIConnection vppJNIConnection = new VppJNIConnection(clientName); + final int ret = clientConnect(clientName, callback); + if (ret != 0) { + throw new IOException("Connection returned error " + ret); + } + connections.put(clientName, vppJNIConnection); + return vppJNIConnection; + } + } + + @Override + public final void checkActive() { + if (disconnected) { + throw new IllegalStateException("Disconnected client " + clientName); + } + } + + @Override + public synchronized final void close() { + if (!disconnected) { + disconnected = true; + try { + clientDisconnect(); + } finally { + synchronized (VppJNIConnection.class) { + connections.remove(clientName); + } + } + } + } + + private static native int clientConnect(String clientName, JVppCallback callback); + private static native void clientDisconnect(); +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java b/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java new file mode 100644 index 00000000..c17f2e0a --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.callback; + +/** +* Base JVppCallback interface +*/ +public interface JVppCallback { +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java new file mode 100644 index 00000000..295bbba8 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.dto; + +/** +* Base interface for all dump requests +*/ +public interface JVppDump extends JVppRequest { + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java new file mode 100644 index 00000000..2f4964c4 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.dto; + +/** +* Base interface for all reply DTOs +*/ +public interface JVppReply { + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java new file mode 100644 index 00000000..4aecedc1 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.dto; + +/** +* Base interface for all dump replies +*/ +public interface JVppReplyDump> + extends JVppReply { + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java new file mode 100644 index 00000000..8cd1534a --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.dto; + +import org.openvpp.jvpp.JVpp; + +/** +* Base interface for all request DTOs +*/ +public interface JVppRequest { + + /** + * Invoke current operation asynchronously on VPP + * + * @return context id of this request. Can be used to track incomming response + */ + int send(JVpp jvpp); + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVpp.java b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVpp.java new file mode 100644 index 00000000..d860bc2d --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVpp.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.future; + + +import java.util.concurrent.CompletionStage; +import org.openvpp.jvpp.dto.JVppReply; +import org.openvpp.jvpp.dto.JVppRequest; + +/** +* Future facade on top of JVpp +*/ +public interface FutureJVpp { + + /** + * Invoke asynchronous operation on VPP + * + * @return CompletionStage with future result of an async VPP call + */ + > CompletionStage send(REQ req); + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppFacade.java b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppFacade.java new file mode 100644 index 00000000..5b8222c4 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppFacade.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.future; + + +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import org.openvpp.jvpp.JVpp; +import org.openvpp.jvpp.dto.ControlPing; +import org.openvpp.jvpp.dto.JVppDump; +import org.openvpp.jvpp.dto.JVppReply; +import org.openvpp.jvpp.dto.JVppReplyDump; +import org.openvpp.jvpp.dto.JVppRequest; + +/** +* Future facade on top of JVpp +*/ +public final class FutureJVppFacade implements FutureJVpp { + + private final JVpp jvpp; + + /** + * Guarded by self + */ + private final Map>> requests; + + public FutureJVppFacade(final JVpp jvpp, + final Map>> requestMap) { + // TODO use guava's preconditions for nonNull and state checks + // However adding guava as a dependency requires better build system for Java in VPP project + // Currently it's just invocation of javac + if(jvpp == null) { + throw new NullPointerException("Null jvpp"); + } + this.jvpp = jvpp; + if(requestMap == null) { + throw new NullPointerException("Null requestMap"); + } + // Request map represents the shared state between this facade and it's callback + // where facade puts futures in and callback completes + removes them + // TODO what if the call never completes ? + this.requests = requestMap; + } + + // TODO use Optional in Future, java8 + + @Override + @SuppressWarnings("unchecked") + public > CompletionStage send(REQ req) { + synchronized(requests) { + final int contextId = jvpp.send(req); + + final CompletableFuture replyCompletableFuture; + if(req instanceof JVppDump) { + replyCompletableFuture = (CompletableFuture) new CompletableDumpFuture<>(contextId); + } else { + replyCompletableFuture = new CompletableFuture<>(); + } + + requests.put(contextId, replyCompletableFuture); + if(req instanceof JVppDump) { + requests.put(jvpp.send(new ControlPing()), replyCompletableFuture); + } + return replyCompletableFuture; + } + } + + static final class CompletableDumpFuture> extends CompletableFuture { + // TODO make this final + // The reason why this is not final is the instantiation of ReplyDump DTOs + // Their instantiation must be generated, so currently the DTOs are created in callback and set when first dump reponses + // is returned. Because in callback we have method per response, but here where requests are invoked there is only + // a single generic send method that does not have enough information to create the DTO + // This can be final as soon as we provide specific send methods here + private T replyDump; + private final long contextId; + + CompletableDumpFuture(final long contextId) { + this.contextId = contextId; + } + + long getContextId() { + return contextId; + } + + T getReplyDump() { + return replyDump; + } + + void setReplyDump(final T replyDump) { + this.replyDump = replyDump; + } + } + +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java new file mode 100644 index 00000000..5ac4b69a --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.test; + +import org.openvpp.jvpp.JVpp; +import org.openvpp.jvpp.JVppImpl; +import org.openvpp.jvpp.VppJNIConnection; +import org.openvpp.jvpp.callback.GetNodeIndexCallback; +import org.openvpp.jvpp.callback.ShowVersionCallback; +import org.openvpp.jvpp.callback.SwInterfaceCallback; +import org.openvpp.jvpp.dto.GetNodeIndex; +import org.openvpp.jvpp.dto.GetNodeIndexReply; +import org.openvpp.jvpp.dto.ShowVersion; +import org.openvpp.jvpp.dto.ShowVersionReply; +import org.openvpp.jvpp.dto.SwInterfaceDetails; +import org.openvpp.jvpp.dto.SwInterfaceDump; + +public class CallbackApiTest { + + private static class TestCallback implements GetNodeIndexCallback, ShowVersionCallback, SwInterfaceCallback { + + @Override + public void onGetNodeIndexReply(final GetNodeIndexReply msg) { + System.out.printf("Received GetNodeIndexReply: context=%d, retval=%d, nodeIndex=%d\n", + msg.context, msg.retval, msg.nodeIndex); + } + @Override + public void onShowVersionReply(final ShowVersionReply msg) { + System.out.printf("Received ShowVersionReply: context=%d, retval=%d, program=%s, version=%s, " + + "buildDate=%s, buildDirectory=%s\n", + msg.context, msg.retval, new String(msg.program), new String(msg.version), + new String(msg.buildDate), new String(msg.buildDirectory)); + } + + @Override + public void onSwInterfaceDetails(final SwInterfaceDetails msg) { + System.out.printf("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, " + + "linkUpDown=%d, linkSpeed=%d, linkMtu=%d\n", + new String(msg.interfaceName), msg.l2AddressLength, msg.adminUpDown, + msg.linkUpDown, msg.linkSpeed, (int)msg.linkMtu); + } + } + + private static void testCallbackApi() throws Exception { + System.out.println("Testing Java callback API"); + JVpp jvpp = new JVppImpl(VppJNIConnection.create("CallbackApiTest", new TestCallback())); + System.out.println("Successfully connected to VPP"); + + System.out.println("Sending ShowVersion request..."); + jvpp.send(new ShowVersion()); + + System.out.println("Sending GetNodeIndex request..."); + GetNodeIndex getNodeIndexRequest = new GetNodeIndex(); + getNodeIndexRequest.nodeName = "node0".getBytes(); + jvpp.send(getNodeIndexRequest); + + System.out.println("Sending SwInterfaceDump request..."); + SwInterfaceDump swInterfaceDumpRequest = new SwInterfaceDump(); + swInterfaceDumpRequest.nameFilterValid = 0; + swInterfaceDumpRequest.nameFilter = "".getBytes(); + jvpp.send(swInterfaceDumpRequest); + + Thread.sleep(5000); + + System.out.println("Disconnecting..."); + jvpp.close(); + Thread.sleep(1000); + } + + public static void main(String[] args) throws Exception { + testCallbackApi(); + } +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java new file mode 100644 index 00000000..df3b0e70 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.test; + +import java.util.HashMap; +import java.util.Map; +import org.openvpp.jvpp.JVpp; +import org.openvpp.jvpp.JVppImpl; +import org.openvpp.jvpp.VppJNIConnection; +import org.openvpp.jvpp.callback.JVppCallback; +import org.openvpp.jvpp.callback.ShowVersionCallback; +import org.openvpp.jvpp.callfacade.CallbackJVppFacade; +import org.openvpp.jvpp.callfacade.CallbackJVppFacadeCallback; + +/** + * CallbackJVppFacade together with CallbackJVppFacadeCallback allow for setting different callback for each request. + * This is more convenient than the approach shown in CallbackApiTest. + */ +public class CallbackJVppFacadeTest { + + private static ShowVersionCallback showVersionCallback1 = msg -> + System.out.printf("ShowVersionCallback1 received ShowVersionReply: context=%d, retval=%d, program=%s," + + "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, msg.retval, new String(msg.program), + new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory)); + + private static ShowVersionCallback showVersionCallback2 = msg -> + System.out.printf("ShowVersionCallback2 received ShowVersionReply: context=%d, retval=%d, program=%s," + + "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, msg.retval, new String(msg.program), + new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory)); + + private static void testCallbackFacade() throws Exception { + System.out.println("Testing CallbackJVppFacade"); + + final Map callbackMap = new HashMap<>(); + JVpp impl = new JVppImpl(VppJNIConnection.create("CallbackApiTest", new CallbackJVppFacadeCallback(callbackMap))); + CallbackJVppFacade jvpp = new CallbackJVppFacade(impl, callbackMap); + System.out.println("Successfully connected to VPP"); + + jvpp.showVersion(showVersionCallback1); + jvpp.showVersion(showVersionCallback2); + + + Thread.sleep(2000); + + System.out.println("Disconnecting..."); + impl.close(); + Thread.sleep(1000); + } + + public static void main(String[] args) throws Exception { + testCallbackFacade(); + } +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java new file mode 100644 index 00000000..f1bd41de --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.test; + +import org.openvpp.jvpp.JVpp; +import org.openvpp.jvpp.JVppImpl; +import org.openvpp.jvpp.VppJNIConnection; +import org.openvpp.jvpp.callback.ControlPingCallback; +import org.openvpp.jvpp.dto.ControlPing; +import org.openvpp.jvpp.dto.ControlPingReply; + +public class ControlPingTest { + + private static void testControlPing() throws Exception { + System.out.println("Testing ControlPing using Java callback API"); + + JVpp jvpp = new JVppImpl(VppJNIConnection.create("ControlPingTest", new ControlPingCallback() { + @Override + public void onControlPingReply(final ControlPingReply reply) { + System.out.printf("Received ControlPingReply: context=%d, retval=%d, clientIndex=%d vpePid=%d\n", + reply.context, reply.retval, reply.clientIndex, reply.vpePid); + } + })); + System.out.println("Successfully connected to VPP"); + Thread.sleep(1000); + + jvpp.send(new ControlPing()); + + Thread.sleep(2000); + + System.out.println("Disconnecting..."); + jvpp.close(); + Thread.sleep(1000); + } + + public static void main(String[] args) throws Exception { + testControlPing(); + } +} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java new file mode 100644 index 00000000..b5b36d58 --- /dev/null +++ b/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.jvpp.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; +import org.openvpp.jvpp.VppJNIConnection; +import org.openvpp.jvpp.dto.GetNodeIndex; +import org.openvpp.jvpp.dto.GetNodeIndexReply; +import org.openvpp.jvpp.dto.JVppReply; +import org.openvpp.jvpp.dto.ShowVersion; +import org.openvpp.jvpp.dto.ShowVersionReply; +import org.openvpp.jvpp.dto.SwInterfaceDetails; +import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump; +import org.openvpp.jvpp.dto.SwInterfaceDump; +import org.openvpp.jvpp.future.FutureJVppFacade; +import org.openvpp.jvpp.future.FutureJVppFacadeCallback; + +public class FutureApiTest { + + private static void testShowVersion(final FutureJVppFacade jvpp) { + System.out.println("Sending ShowVersion request..."); + try { + final Future> replyFuture = jvpp.send(new ShowVersion()).toCompletableFuture(); + final ShowVersionReply reply = (ShowVersionReply) replyFuture.get(); // TODO can we get rid of that cast? + System.out.printf("Received ShowVersionReply: context=%d, retval=%d, program=%s, " + + "version=%s, buildDate=%s, buildDirectory=%s\n", + reply.context, reply.retval, new String(reply.program), new String(reply.version), + new String(reply.buildDate), new String(reply.buildDirectory)); + } catch (Exception e) { + System.err.printf("ShowVersion request failed:\n"); + e.printStackTrace(); + } + } + + /** + * This test will fail with some error code if node 'node0' is not defined. + * TODO: consider adding error messages specific for given api calls + */ + private static void testGetNodeIndex(final FutureJVppFacade jvpp) { + System.out.println("Sending GetNodeIndex request..."); + try { + final GetNodeIndex request = new GetNodeIndex(); + request.nodeName = "node0".getBytes(); + final Future> replyFuture = jvpp.send(request).toCompletableFuture(); + final GetNodeIndexReply reply = (GetNodeIndexReply) replyFuture.get(); + System.out.printf("Received GetNodeIndexReply: context=%d, retval=%d, nodeIndex=%d\n", + reply.context, reply.retval, reply.nodeIndex); + } catch (Exception e) { + System.err.printf("GetNodeIndex request failed:\n"); + e.printStackTrace(); + } + } + + private static void testSwInterfaceDump(final FutureJVppFacade jvpp) { + System.out.println("Sending SwInterfaceDump request..."); + try { + final SwInterfaceDump request = new SwInterfaceDump(); + request.nameFilterValid = 0; + request.nameFilter = "".getBytes(); + final Future> replyFuture = jvpp.send(request).toCompletableFuture(); + final SwInterfaceDetailsReplyDump reply = (SwInterfaceDetailsReplyDump) replyFuture.get(); + + if (reply == null) { + throw new IllegalStateException("SwInterfaceDetailsReplyDump is null!"); + } + if (reply.swInterfaceDetails == null) { + throw new IllegalStateException("SwInterfaceDetailsReplyDump.swInterfaceDetails is null!"); + } + + for (SwInterfaceDetails details : reply.swInterfaceDetails) { + if (details == null) { + throw new IllegalStateException("reply.swInterfaceDetails contains null element!"); + } + + System.out.printf("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, " + + "linkUpDown=%d, linkSpeed=%d, linkMtu=%d\n", + new String(details.interfaceName), details.l2AddressLength, details.adminUpDown, + details.linkUpDown, details.linkSpeed, (int) details.linkMtu); + } + } catch (Exception e) { + System.err.printf("SwInterfaceDump request failed:\n"); + e.printStackTrace(); + } + } + + private static void testFutureApi() throws Exception { + System.out.println("Testing Java future API"); + + final Map>> map = new HashMap<>(); + final org.openvpp.jvpp.JVppImpl impl = + new org.openvpp.jvpp.JVppImpl(VppJNIConnection.create("FutureApiTest", new FutureJVppFacadeCallback(map))); + final FutureJVppFacade jvpp = new FutureJVppFacade(impl, map); + System.out.println("Successfully connected to VPP"); + + testShowVersion(jvpp); + testGetNodeIndex(jvpp); + testSwInterfaceDump(jvpp); + + System.out.println("Disconnecting..."); + // TODO we should consider adding jvpp.close(); to the facade + impl.close(); + } + + public static void main(String[] args) throws Exception { + testFutureApi(); + } +} -- cgit 1.2.3-korg From f86abbb936908a724be6d4e61e3720fd44b7d956 Mon Sep 17 00:00:00 2001 From: "Keith Burns (alagalah)" Date: Mon, 2 May 2016 10:20:53 -0700 Subject: VPP-33 Removing javah from Makefile. Merged as fix for Gerrit 884 Change-Id: I2d9d6a607ffa1a8788c1ce79770db8b2b9bae6fb Signed-off-by: Keith Burns (alagalah) --- Makefile | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f4b46f8e..53930928 100644 --- a/Makefile +++ b/Makefile @@ -96,9 +96,6 @@ ifeq ("$(shell lsb_release -si)", "Ubuntu") echo "by executing \"make install-dep\"\n" ; \ exit 1 ; \ fi ; \ - if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ - sudo update-alternatives --set javah /usr/lib/jvm/java-8-openjdk-amd64/bin/javah ; \ - fi ; \ exit 0 endif @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk @@ -124,9 +121,6 @@ install-dep: ifeq ("$(shell lsb_release -si)", "Ubuntu") $(use_ppa_for_jdk8) @sudo apt-get -y install $(DEB_DEPENDS) - if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ - update-alternatives --set javah /usr/lib/jvm/java-8-openjdk-amd64/bin/javah ; \ - fi ; \ else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) @sudo yum install -y $(RPM_DEPENDS) -- cgit 1.2.3-korg From c5e8681b320884f780508458ebff873761d5e04a Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 2 May 2016 19:40:27 +0200 Subject: Re-do java-8 handling, add unattended switch to toplevel Makefile Change-Id: Ifaea353be5b42bb6edbcfa0506d02b721c00e392 Signed-off-by: Damjan Marion --- Makefile | 39 +++++++++++++++++++++------------------ build-root/vagrant/build.sh | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 53930928..f9a95437 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,12 @@ MINIMAL_STARTUP_CONF="unix { interactive }" GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" +# +# OS Detection +# +OS_ID = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache DEB_DEPENDS += debhelper dkms openjdk-8-jdk git libtool libganglia1-dev libapr1-dev dh-systemd DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope @@ -34,6 +40,10 @@ ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),) STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf endif +ifeq ($(findstring y,$(UNATTENDED)),y) +CONFIRM=-y +endif + .PHONY: help bootstrap wipe wipe-release build build-release rebuild rebuild-release .PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm .PHONY: ctags cscope @@ -77,19 +87,8 @@ help: @echo " PLATFORM = $(PLATFORM)" @echo " DPDK_VERSION = $(DPDK_VERSION)" -# openjdk-8-jdk is not available in 14.04 repos by default -define use_ppa_for_jdk8 -if [ "$(shell lsb_release -r | awk '{print $$2}')"=="14.04" ]; then \ - sudo apt-get -y install software-properties-common; \ - sudo add-apt-repository -y ppa:openjdk-r/ppa; \ - sudo apt-get update; \ -fi; -endef - $(BR)/.bootstrap.ok: -ifeq ("$(shell lsb_release -si)", "Ubuntu") - $(use_ppa_for_jdk8) - +ifeq ($(OS_ID),ubuntu) @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \ if [ -n "$$MISSING" ] ; then \ echo "\nPlease install missing packages: \n$$MISSING\n" ; \ @@ -118,13 +117,17 @@ endif bootstrap: $(BR)/.bootstrap.ok install-dep: -ifeq ("$(shell lsb_release -si)", "Ubuntu") - $(use_ppa_for_jdk8) - @sudo apt-get -y install $(DEB_DEPENDS) +ifeq ($(OS_ID),ubuntu) +ifeq ($(OS_VERSION_ID),14.04) + @sudo apt-get $(CONFIRM) install software-properties-common + @sudo add-apt-repository $(CONFIRM) ppa:openjdk-r/ppa + @sudo apt-get update +endif + @sudo apt-get $(CONFIRM) install $(DEB_DEPENDS) else ifneq ("$(wildcard /etc/redhat-release)","") - @sudo yum groupinstall -y $(RPM_DEPENDS_GROUPS) - @sudo yum install -y $(RPM_DEPENDS) - @sudo yum install -y --enablerepo=epel $(EPEL_DEPENDS) + @sudo yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS) + @sudo yum install $(CONFIRM) $(RPM_DEPENDS) + @sudo yum install $(CONFIRM) --enablerepo=epel $(EPEL_DEPENDS) @sudo debuginfo-install glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 else $(error "This option currently works only on Ubuntu or Centos systems") diff --git a/build-root/vagrant/build.sh b/build-root/vagrant/build.sh index 45a7eb4d..aaaa62f6 100755 --- a/build-root/vagrant/build.sh +++ b/build-root/vagrant/build.sh @@ -34,7 +34,7 @@ echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION # Install dependencies cd $VPP_DIR -make install-dep +make UNATTENDED=yes install-dep # Really really clean things up so we can be sure # that the build works even when switching distros -- cgit 1.2.3-korg From d6a779c41160f5ff50a6bfa2114bedcca12605e0 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Tue, 3 May 2016 16:47:50 -0500 Subject: Fix for unattended in Makefile Also works around verify Change-Id: I79ac470ec3fa9943c3a0913ebfaaf91176eb9a81 Signed-off-by: Ed Warnicke --- Makefile | 2 +- build-root/vagrant/build.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f9a95437..226c7951 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS) @sudo yum install $(CONFIRM) $(RPM_DEPENDS) @sudo yum install $(CONFIRM) --enablerepo=epel $(EPEL_DEPENDS) - @sudo debuginfo-install glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 + @sudo debuginfo-install $(CONFIRM) glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 else $(error "This option currently works only on Ubuntu or Centos systems") endif diff --git a/build-root/vagrant/build.sh b/build-root/vagrant/build.sh index aaaa62f6..7fd7e3a6 100755 --- a/build-root/vagrant/build.sh +++ b/build-root/vagrant/build.sh @@ -42,6 +42,18 @@ make wipe (cd build-root/;make distclean) rm -f build-root/.bootstrap.ok +if [ $DISTRIB_ID == "CentOS" ]; then + echo rpm -V apr-devel + rpm -V apr-devel + if [ $? != 0 ]; then sudo yum reinstall -y apr-devel;fi + echo rpm -V ganglia-devel + rpm -V ganglia-devel + if [ $? != 0 ]; then sudo yum reinstall -y ganglia-devel;fi + echo rpm -V libconfuse-devel + rpm -V libconfuse-devel + if [ $? != 0 ]; then sudo yum reinstall -y libconfuse-devel;fi +fi + # Build and install packaging $SUDOCMD make bootstrap if [ $DISTRIB_ID == "Ubuntu" ]; then -- cgit 1.2.3-korg From 027103e561a1a04c348a2507129e943297748e2a Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Thu, 5 May 2016 18:03:27 -0500 Subject: Switch to using -headless JDK By default, jdks bring a bunch of UI related things we don't need, so switch to headeless. Also, use default-jdk-headless for Ubuntu after 14.04. Use openjdk-8-jdk-headless for Ubuntu 14.04. Change-Id: I3cf14c39c9f59dc2f1beba8dfb19971f4b67f5a6 Signed-off-by: Ed Warnicke --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 226c7951..8050f876 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,13 @@ OS_ID = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\" OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache -DEB_DEPENDS += debhelper dkms openjdk-8-jdk git libtool libganglia1-dev libapr1-dev dh-systemd +DEB_DEPENDS += debhelper dkms git libtool libganglia1-dev libapr1-dev dh-systemd DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope +ifeq ($(OS_VERSION_ID),14.04) + DEB_DEPENDS += openjdk-8-jdk-headless +else + DEB_DEPENDS += default-jdk-headless +endif RPM_DEPENDS_GROUPS = 'Development Tools' RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils -- cgit 1.2.3-korg From b585097048884e063ac25aecc26a6802ee3faa4d Mon Sep 17 00:00:00 2001 From: Chris Luke Date: Tue, 3 May 2016 16:34:59 -0400 Subject: VPP-57 Add Doxygen to VPP - Configures Doxygen. - Adds a source filter to do magic on our use of the preprocessor to do constructor stuff to make Doxygen grok it better. - Adds a convenience helper to the root Makefile. - Adds a README.md to the root directory (and which Doxygem uses as its "mainpage". - Add several other documentative files. - Currently using SVG for call graphs, though this may have a load-time performance impact in browsers. Change-Id: I25fc6fb5bf634319dcb36a7f0e32031921c125ac Signed-off-by: Chris Luke --- .gitignore | 3 + Makefile | 25 + README.md | 94 ++ doxygen/assets/doxy-vpp.css | 47 + doxygen/assets/logo_fdio.png | Bin 0 -> 3092 bytes doxygen/dir.dox.sample | 6 + doxygen/doxygen.cfg | 2433 ++++++++++++++++++++++++++++++++++++++++++ doxygen/filter_c.py | 37 + doxygen/layout.xml | 194 ++++ svm/dir.dox | 5 + vlib/dir.dox | 5 + vlib/example/dir.dox | 6 + vlib/vlib/dir.dox | 5 + vlib/vlib/unix/cli.c | 176 ++- vpp/vnet/main.c | 8 - vppinfra/dir.dox | 3 + vppinfra/tools/dir.dox | 3 + vppinfra/vppinfra/dir.dox | 3 + vppinfra/vppinfra/vec.h | 4 +- 19 files changed, 2996 insertions(+), 61 deletions(-) create mode 100644 README.md create mode 100644 doxygen/assets/doxy-vpp.css create mode 100644 doxygen/assets/logo_fdio.png create mode 100644 doxygen/dir.dox.sample create mode 100644 doxygen/doxygen.cfg create mode 100755 doxygen/filter_c.py create mode 100644 doxygen/layout.xml create mode 100644 svm/dir.dox create mode 100644 vlib/dir.dox create mode 100644 vlib/example/dir.dox create mode 100644 vlib/vlib/dir.dox create mode 100644 vppinfra/dir.dox create mode 100644 vppinfra/tools/dir.dox create mode 100644 vppinfra/vppinfra/dir.dox (limited to 'Makefile') diff --git a/.gitignore b/.gitignore index a104623c..e3182fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ test-driver # cscope and ctags /cscope.* /tags + +# Generated documentation +/build-root/docs diff --git a/Makefile b/Makefile index 8050f876..dee25667 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,9 @@ endif RPM_DEPENDS_GROUPS = 'Development Tools' RPM_DEPENDS = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel +#RPM_DEPENDS += doxygen # TODO EPEL_DEPENDS = libconfuse-devel ganglia-devel +#EPEL_DEPENDS += graphviz # TODO ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),) STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf @@ -209,3 +211,26 @@ ctags: ctags.files cscope: cscope.files @cscope -b -q -v + +DOXY_INPUT = \ + README.md \ + vppinfra \ + svm \ + vlib \ + vlib-api \ + vnet \ + vpp \ + vpp-api + +.PHONY: doxygen +doxygen: + @mkdir -p "$(BR)/docs" + ROOT="$(WS_ROOT)" \ + BUILD_ROOT="$(BR)" \ + INPUT="$(addprefix $(WS_ROOT)/,$(DOXY_INPUT))" \ + HTML=YES \ + VERSION="`git describe --tags --dirty`" \ + doxygen doxygen/doxygen.cfg + +wipe-doxygen: + rm -rf "$(BR)/docs" diff --git a/README.md b/README.md new file mode 100644 index 00000000..2a71d27e --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +Vector Packet Processing +======================== + +## Introduction. + +The VPP platform is an extensible framework that provides out-of-the-box +production quality switch/router functionality. It is the open source version +of Cisco's Vector Packet Processing (VPP) technology: a high performance, +packet-processing stack that can run on commodity CPUs. + +The benefits of this implementation of VPP are its high performance, proven +technology, its modularity and flexibility, and rich feature set. + +For more information on VPP and its features please visit the +[FD.io website](http://fd.io/) and +[What is VPP?](https://wiki.fd.io/view/VPP/What_is_VPP%3F) pages. + + +## Directory layout. + +Directory name | Description +---------------------- | ------------------------------------------- + build-data | Build metadata + build-root | Build output directory + doxygen | Documentation generator configuration + dpdk | DPDK patches and build infrastructure + g2 | Event log visualization tool + gmod | perf related? + perftool | Performance tool + sample-plugin | A sample plugin +@ref svm | Shared virtual memory allocation library + test | Unit tests +@ref vlib | VPP application library source +@ref vlib-api | VPP API library source +@ref vnet | VPP networking source +@ref vpp | VPP application source +@ref vpp-api | VPP application API source + vppapigen | VPP API generator source + vpp-api-test | VPP API test program source +@ref vppinfra | VPP core library source + +(If the page you are viewing is not generated by Doxygen then +ignore any @@ref labels in the above table.) + + +## Getting started. + +In general anyone interested in building, developing or running VPP should +consult the [VPP wiki](https://wiki.fd.io/view/VPP) for more complete +documentation. + +In particular, readers are recommended to take a look at [Pulling, Building, +Running, Hacking, Pushing](https://wiki.fd.io/view/VPP/Pulling,_Building,_Run +ning,_Hacking_and_Pushing_VPP_Code) which provides extensive step-by-step +coverage of the topic. + +For the impatient, some salient information is distilled below. + + +### Quick-start: On an existing Linux host. + +To install system dependencies, build VPP and then install it, simply run the +build script. This should be performed a non-privileged user with `sudo` +access from the project base directory: + + ./build-root/vagrant/build.sh + +If you want a more fine-grained approach because you intend to do some +development work, the `Makefile` in the root directory of the source tree +provides several convenience shortcuts as `make` targets that may be of +interest. To see the available targets run: + + make + + +### Quick-start: Vagrant. + +The directory `build-root/vagrant` contains a `VagrantFile` and supporting +scripts to bootstrap a working VPP inside a Vagrant-managed Virtual Machine. +This VM can then be used to test concepts with VPP or as a development +platform to extend VPP. Some obvious caveats apply when using a VM for VPP +since its performance will never match that of bare metal; if your work is +timing or performance sensitive, consider using bare metal in addition or +instead of the VM. + +For this to work you will need a working installation of Vagrant. Instructions +for this can be found [on the Setting up Vagrant wiki page] +(https://wiki.fd.io/view/DEV/Setting_Up_Vagrant). + + +## More information. + +Visit the [VPP wiki](https://wiki.fd.io/view/VPP) for details on more +advanced building strategies and development notes. diff --git a/doxygen/assets/doxy-vpp.css b/doxygen/assets/doxy-vpp.css new file mode 100644 index 00000000..3b74eb6f --- /dev/null +++ b/doxygen/assets/doxy-vpp.css @@ -0,0 +1,47 @@ +/* VPP CSS overrides */ + +body, table, div, p, dl { + font: initial; + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: small; +} + +code, tt { + font: initial; + font-family: Consolas, Courier, monospace; + font-size: small; +} + +pre { + font-size: 105%; +} + + +.title { + font: initial; + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 150%; + font-weight: bold; +} + + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + font-family: Consolas, Courier, monospace; +} + +.memname { + font-family: Consolas, Courier, monospace; + font-weight: bold; + font-size: 105%; +} + +.paramname { + font-family: Consolas, Courier, monospace; + font-weight: bold; +} + +a.el { + font-family: Consolas, Courier, monospace; +} diff --git a/doxygen/assets/logo_fdio.png b/doxygen/assets/logo_fdio.png new file mode 100644 index 00000000..ddfef2c7 Binary files /dev/null and b/doxygen/assets/logo_fdio.png differ diff --git a/doxygen/dir.dox.sample b/doxygen/dir.dox.sample new file mode 100644 index 00000000..8dc0fee7 --- /dev/null +++ b/doxygen/dir.dox.sample @@ -0,0 +1,6 @@ +/* Doxygen directory documentation */ +/** +@dir +@brief Someone please fix this description +@todo This directory needs a description. +*/ diff --git a/doxygen/doxygen.cfg b/doxygen/doxygen.cfg new file mode 100644 index 00000000..6d6bb6cc --- /dev/null +++ b/doxygen/doxygen.cfg @@ -0,0 +1,2433 @@ +# Doxyfile 1.8.11 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "FD.io VPP" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = $(VERSION) + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Vector Packet Processing" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = $(ROOT)/doxygen/assets/logo_fdio.png + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = $(BUILD_ROOT)/docs + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = YES + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = $(ROOT) + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = $(ROOT) + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = def=C + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = NO + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 50 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = $(ROOT)/doxygen/layout.xml + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = $(INPUT) + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, +# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. + +FILE_PATTERNS = *.md *.c *.h *.def *.inc *.S *.dox + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = YES + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = */test/* *_test.c test_*.c + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = _ _* + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = *.c *.h + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = $(ROOT)/doxygen/assets + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = *.c=$(ROOT)/doxygen/filter_c.py + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = $(ROOT)/README.md + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = $(ROOT)/doxygen/assets/doxy-vpp.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 230 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 255 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = YES + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "FD.io VPP" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = io.fd.vpp + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = io.fd.vpp + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = YES + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = io.fd.vpp + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /