Do not require external vppapigen when not cross-compiling 88/4488/12
authorDamjan Marion <damarion@cisco.com>
Wed, 28 Dec 2016 16:51:56 +0000 (17:51 +0100)
committerDave Barach <openvpp@barachs.net>
Tue, 3 Jan 2017 15:14:49 +0000 (15:14 +0000)
Change-Id: I80b8348ed4efd53d292c37a1ff69c13ee4741986
Signed-off-by: Damjan Marion <damarion@cisco.com>
build-data/platforms.mk
build-root/rpm/vpp.spec
src/Makefile.am
src/configure.ac
src/plugins/Makefile.am
src/suffix-rules.mk
src/vppapigen.am

index 6f21b6d..e192155 100644 (file)
@@ -76,7 +76,7 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
           >> deb/debian/vpp.install ;                                  \
                                                                        \
        : dev package needs a couple of additions ;                     \
-       echo ../build-tool-native/tools/vppapigen /usr/bin              \
+       echo ../$(INSTALL_PREFIX)$(ARCH)/vpp/bin/vppapigen /usr/bin     \
           >> deb/debian/vpp-dev.install ;                              \
        echo ../../src/vpp-api/java/jvpp/gen/jvpp_gen.py /usr/bin       \
           >> deb/debian/vpp-dev.install ;                              \
index 149ac51..c3c0d92 100644 (file)
@@ -113,7 +113,6 @@ groupadd -f -r vpp
 mkdir -p -m755 %{buildroot}%{_bindir}
 mkdir -p -m755 %{buildroot}%{_unitdir}
 install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir}
-install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/tools/vppapigen %{buildroot}%{_bindir}
 
 # api
 mkdir -p -m755 %{buildroot}/usr/share/vpp/api
index 0fc437a..bba90ea 100644 (file)
@@ -102,7 +102,6 @@ api_DATA = \
        $(patsubst %.api,%.api.json,$(API_FILES))
 
 BUILT_SOURCES += \
-       $(patsubst %.api,%.api.json,$(API_FILES)) \
        $(patsubst %.api,%.api.h,$(API_FILES))
 
 endif # if ENABLE_VLIB
index 4ed5570..eb380d8 100644 (file)
@@ -11,6 +11,8 @@ AM_PROG_AS
 AM_PROG_LIBTOOL
 AC_PROG_YACC
 
+AM_CONDITIONAL([CROSSCOMPILE], [test "$cross_compiling" == "yes"])
+
 ###############################################################################
 # Macros
 ###############################################################################
@@ -172,6 +174,20 @@ AM_COND_IF([ENABLE_G2],
   PKG_CHECK_MODULES(g2, gtk+-2.0)
 ])
 
+# If cross-compiling, we need external vppapigen and we cannot continue without it
+# For native builds, we just set dependency on vpppaigen binary in top_builddir
+AM_COND_IF([CROSSCOMPILE],
+[
+  AC_PATH_PROG([VPPAPIGEN], [vppapigen], [no])
+  if test "$VPPAPIGEN" = "no"; then
+    AC_MSG_ERROR([Externaly built vppapigen is needed when cross-compiling...])
+  fi
+],[
+  VPPAPIGEN=\$\(top_builddir\)/vppapigen
+])
+AC_SUBST([VPPAPIGEN])
+
+
 ###############################################################################
 # JAVA
 ###############################################################################
index 987310b..3e9ab91 100644 (file)
@@ -73,6 +73,5 @@ api_DATA = \
        $(patsubst %.api,%.api.json,$(API_FILES))
 
 BUILT_SOURCES += \
-       $(patsubst %.api,%.api.json,$(API_FILES)) \
        $(patsubst %.api,%.api.h,$(API_FILES))
 
index f97b227..9115c55 100644 (file)
 # Shared suffix rules
 # Please do not set "SUFFIXES = .api.h .api" here
 
-%.api.h: %.api
+%.api.h: %.api @VPPAPIGEN@
        @echo "  APIGEN  " $@ ;                                 \
        mkdir -p `dirname $@` ;                                 \
-       $(CC) $(CPPFLAGS) -E -P -C -x c $^                      \
-       | vppapigen --input - --output $@ --show-name $@ > /dev/null
+       $(CC) $(CPPFLAGS) -E -P -C -x c $<                      \
+       | @VPPAPIGEN@ --input - --output $@ --show-name $@ > /dev/null
 
-%.api.json: %.api
+%.api.json: %.api @VPPAPIGEN@
        @echo "  JSON API" $@ ;                                 \
        mkdir -p `dirname $@` ;                                 \
-       $(CC) $(CPPFLAGS) -E -P -C -x c $^                      \
-       | vppapigen --input - --json $@ > /dev/null
+       $(CC) $(CPPFLAGS) -E -P -C -x c $<                      \
+       | @VPPAPIGEN@ --input - --json $@ > /dev/null
index edde339..3207c83 100644 (file)
 
 bin_PROGRAMS += vppapigen
 
-BUILT_SOURCES += tools/vppapigen/gram.h
+# We cannot rely on BUILT_SOURCES here as other built sources are relying
+# on vppapigen, so make can start compiling lex.c before gram.h is created.
+# This way we introduce new dependency by running C preprocessor.
 
-tools/vppapigen/gram.h: tools/vppapigen/gram.y
+tools/vppapigen/lex_e.c: tools/vppapigen/lex.c tools/vppapigen/gram.y
        @$(YACC) -d @srcdir@/tools/vppapigen/gram.y
        @mv y.tab.h tools/vppapigen/gram.h
        @rm y.tab.c
+       @$(CC) -I. -E -o $@ $<
 
-vppapigen_SOURCES = tools/vppapigen/gram.y tools/vppapigen/lex.c tools/vppapigen/node.c
+vppapigen_SOURCES = tools/vppapigen/gram.y tools/vppapigen/lex_e.c tools/vppapigen/node.c
 vppapigen_LDADD = libvppinfra.la
 vppapigen_LDFLAGS = -static