summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/configure.ac16
-rw-r--r--src/plugins/Makefile.am1
-rw-r--r--src/suffix-rules.mk12
-rw-r--r--src/vppapigen.am9
5 files changed, 28 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0fc437a46aa..bba90eaebf8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/configure.ac b/src/configure.ac
index 4ed5570516a..eb380d8bf20 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -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
###############################################################################
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 987310b7b40..3e9ab91cd24 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -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))
diff --git a/src/suffix-rules.mk b/src/suffix-rules.mk
index f97b22764cc..9115c55b567 100644
--- a/src/suffix-rules.mk
+++ b/src/suffix-rules.mk
@@ -14,14 +14,14 @@
# 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
diff --git a/src/vppapigen.am b/src/vppapigen.am
index edde339d451..3207c83a325 100644
--- a/src/vppapigen.am
+++ b/src/vppapigen.am
@@ -13,14 +13,17 @@
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