From 4dc72467425dbc063c30a871350a896b225ff224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 25 May 2014 11:49:19 +0200 Subject: [PATCH 1/2] Explicitly create output directories for flex/yacc output. When out-of-source build with '--disable-dependency-tracking' is performed, the 'lib/route' and 'lib/route/cls' directories required for flex/yacc output do not exist. As a result, the flex/yacc calls fail with ENOENT. Create the necessary directories explicitly via $(MKDIR_P) in the flex/yacc rules to guarantee proper out-of-source and in-source build. --- configure.ac | 1 + lib/Makefile.am | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index bbe4e29..879aea5 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AM_PROG_LIBTOOL +AC_PROG_MKDIR_P AC_CHECK_PROGS(FLEX, 'flex') AC_CHECK_PROGS(YACC, 'bison -y') diff --git a/lib/Makefile.am b/lib/Makefile.am index b2d142c..1aae6fe 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -47,16 +47,16 @@ CLEANFILES = \ # Hack to avoid using ylwrap. It does not function correctly in combination # with --header-file= route/pktloc_grammar.c: route/pktloc_grammar.l - $(AM_V_GEN) $(FLEX) --header-file=route/pktloc_grammar.h $(LFLAGS) -o $@ $^ + $(AM_V_GEN) $(MKDIR_P) route; $(FLEX) --header-file=route/pktloc_grammar.h $(LFLAGS) -o $@ $^ route/pktloc_syntax.c: route/pktloc_syntax.y - $(AM_V_GEN) $(YACC) -d $(YFLAGS) -o $@ $^ + $(AM_V_GEN) $(MKDIR_P) route; $(YACC) -d $(YFLAGS) -o $@ $^ route/cls/ematch_grammar.c: route/cls/ematch_grammar.l - $(AM_V_GEN) $(FLEX) --header-file=route/cls/ematch_grammar.h $(LFLAGS) -o $@ $^ + $(AM_V_GEN) $(MKDIR_P) route/cls; $(FLEX) --header-file=route/cls/ematch_grammar.h $(LFLAGS) -o $@ $^ route/cls/ematch_syntax.c: route/cls/ematch_syntax.y - $(AM_V_GEN) $(YACC) -d $(YFLAGS) -o $@ $^ + $(AM_V_GEN) $(MKDIR_P) route/cls; $(YACC) -d $(YFLAGS) -o $@ $^ libnl_route_3_la_LIBADD = libnl-3.la libnl_route_3_la_SOURCES = \ From 425d3d6661b7b25bc6058dbfb01d984f21b73f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 25 May 2014 12:51:32 +0200 Subject: [PATCH 2/2] Use paths relative to srcdir in setup.py. Currently, setup.py is created by configure in builddir while source files (.py and .i) reside in srcdir. Adjust paths in setup.py appropriately to make it possible to perform an out-of-source build. This is far from perfect but it mostly works. Python files are copied from srcdir, and swig *.i files are read from there. However, swig output files are created in srcdir rather than builddir, and distutils copies '..' literally when constructing '.o' paths. As a result, '../python/foo.i' would end up being compiled to 'build/temp*/../python/foo.i'. The alternative would be to copy '*.i' files to builddir before proceeding with the build, either in Makefile or through creating additional distutils command. --- python/setup.py.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/setup.py.in b/python/setup.py.in index 798cfe5..346c770 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -3,11 +3,11 @@ from distutils.core import setup, Extension opts = ['-O', '-nodefaultctor'] -include = ['@top_builddir@/include'] +include = ['@top_builddir@/include', '@top_srcdir@/include'] library_dirs = ['@top_builddir@/lib/.libs'] netlink_capi = Extension('netlink/_capi', - sources = ['netlink/capi.i'], + sources = ['@srcdir@/netlink/capi.i'], include_dirs = include, swig_opts = opts, library_dirs = library_dirs, @@ -15,7 +15,7 @@ netlink_capi = Extension('netlink/_capi', ) route_capi = Extension('netlink/route/_capi', - sources = ['netlink/route/capi.i'], + sources = ['@srcdir@/netlink/route/capi.i'], include_dirs = include, swig_opts = opts, library_dirs = library_dirs, @@ -23,7 +23,7 @@ route_capi = Extension('netlink/route/_capi', ) genl_capi = Extension('netlink/genl/_capi', - sources = ['netlink/genl/capi.i'], + sources = ['@srcdir@/netlink/genl/capi.i'], include_dirs = include, swig_opts = opts, library_dirs = library_dirs, @@ -36,6 +36,7 @@ setup(name = 'netlink', author = 'Thomas Graf', author_email = 'tgraf@suug.ch', ext_modules = [netlink_capi, route_capi, genl_capi], + package_dir = {'': '@srcdir@'}, packages = ['netlink', 'netlink.genl', 'netlink.route', 'netlink.route.links', 'netlink.route.qdisc'], )