Skip to content

Commit

Permalink
Only compile example snippets for make check (#59)
Browse files Browse the repository at this point in the history
* Only compile example snippets for make check

This snippets were compiled unconditionally which was a problem for
cross-compilation scenarios (see #58).

* Remove deprecated comment in Makefile
  • Loading branch information
antoninbas authored Nov 11, 2016
1 parent 3b03a04 commit d9ea41a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 34 deletions.
8 changes: 5 additions & 3 deletions examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(top_builddir)/src/libpifegeneric.la \
$(top_builddir)/src/libpip4info.la \
$(top_builddir)/targets/dummy/libpi_dummy.la

noinst_PROGRAMS = example_1 example_2
check_PROGRAMS = example_1 example_2

example_1_SOURCES = example_1.c

Expand All @@ -26,9 +26,11 @@ gen_fe_defines = $(top_builddir)/generators/pi_gen_fe_defines
$(fe_defines) : $(srcdir)/testdata/simple_router.json $(gen_fe_defines)
$(gen_fe_defines) -c $< -d $(abs_builddir) -n $(p4_name)

BUILT_SOURCES = $(fe_defines)

example_2_SOURCES = example_2.c
nodist_example_2_SOURCES = $(fe_defines)
# This is a bit risky. See "Recording Dependencies manually" at
# https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Built-Sources-Example
example_2.$(OBJEXT) : $(fe_defines)

EXTRA_DIST = \
testdata/simple_router.json
Expand Down
32 changes: 2 additions & 30 deletions frontends_extra/cpp/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

SUBDIRS = . example

AM_CPPFLAGS = \
-I$(top_srcdir)/../../include

Expand All @@ -9,34 +11,4 @@ src/tables.cpp
nobase_include_HEADERS = \
PI/frontends/cpp/tables.h

noinst_PROGRAMS = example
example_SOURCES = example.cpp
testdata_dirpath = $(top_srcdir)/../../examples/testdata
p4_name = p4
example_CPPFLAGS = \
-I$(top_srcdir)/../../include \
-DTESTDATADIR=\"$(testdata_dirpath)\"
fe_defines = pi_fe_defines_$(p4_name).h
gen_fe_defines = $(top_builddir)/../../generators/pi_gen_fe_defines
$(fe_defines) : $(testdata_dirpath)/simple_router.json $(gen_fe_defines)
$(gen_fe_defines) -c $< -d $(abs_builddir) -n $(p4_name)
BUILT_SOURCES = $(fe_defines)

if WITH_BMV2
example_LDADD = \
$(top_builddir)/../../src/libpi.la \
libpifecpp.la \
$(top_builddir)/../../targets/bmv2/libpi_bmv2.la \
$(top_builddir)/../../src/libpip4info.la \
-lthrift -lruntimestubs -lsimpleswitch_thrift
else
example_LDADD = \
$(top_builddir)/../../src/libpi.la \
libpifecpp.la \
$(top_builddir)/../../src/libpip4info.la \
$(top_builddir)/../../targets/dummy/libpi_dummy.la
endif

lib_LTLIBRARIES = libpifecpp.la

CLEANFILES = $(fe_defines)
3 changes: 2 additions & 1 deletion frontends_extra/cpp/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AC_TYPE_SIZE_T
AC_SUBST([AM_CXXFLAGS], ["-Wall -Werror -Wextra"])

# Generate makefiles
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile
example/Makefile])

AC_OUTPUT
File renamed without changes.
34 changes: 34 additions & 0 deletions frontends_extra/cpp/example/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

check_PROGRAMS = example
testdata_dirpath = $(top_srcdir)/../../examples/testdata
p4_name = p4
AM_CPPFLAGS = \
-I$(top_srcdir)/../../include \
-DTESTDATADIR=\"$(testdata_dirpath)\"
fe_defines = pi_fe_defines_$(p4_name).h
gen_fe_defines = $(top_builddir)/../../generators/pi_gen_fe_defines
$(fe_defines) : $(testdata_dirpath)/simple_router.json $(gen_fe_defines)
$(gen_fe_defines) -c $< -d $(abs_builddir) -n $(p4_name)
example_SOURCES = example.cpp
nodist_example_SOURCES = $(fe_defines)
# This is a bit risky. See "Recording Dependencies manually" at
# https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Built-Sources-Example
example.$(OBJEXT) : $(fe_defines)

if WITH_BMV2
LDADD = \
$(top_builddir)/../../src/libpi.la \
$(top_builddir)/libpifecpp.la \
$(top_builddir)/../../targets/bmv2/libpi_bmv2.la \
$(top_builddir)/../../src/libpip4info.la \
-lthrift -lruntimestubs -lsimpleswitch_thrift
else
LDADD = \
$(top_builddir)/../../src/libpi.la \
$(top_builddir)/libpifecpp.la \
$(top_builddir)/../../src/libpip4info.la \
$(top_builddir)/../../targets/dummy/libpi_dummy.la
endif

CLEANFILES = $(fe_defines)
File renamed without changes.

0 comments on commit d9ea41a

Please sign in to comment.