From: Peter A. Bigot Date: Sat, 17 May 2014 19:25:18 +0000 (-0500) Subject: automake: rework for separated builds X-Git-Tag: v1.5.0-rc1~95^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12bf1a88218d415dbda10f0d7f9f9f46ed317b9c;p=thirdparty%2Frrdtool-1.x.git automake: rework for separated builds Standard practice (including the assumptions of make distcheck) is that the system can be built in an out-of-tree directory referencing sources in a read-only filesystem. The language-specific bindings build infrastructure, particularly for perl, makes that difficult but achievable. Signed-off-by: Peter A. Bigot --- diff --git a/bindings/Makefile.am b/bindings/Makefile.am index 7f1b1211..29a3a7d3 100644 --- a/bindings/Makefile.am +++ b/bindings/Makefile.am @@ -1,4 +1,4 @@ -.PHONY: python ruby +.PHONY: lua perl-piped perl-shared python ruby if BUILD_TCL SUB_tcl = tcl @@ -20,40 +20,96 @@ EXTRA_DIST = perl-piped/MANIFEST perl-piped/README perl-piped/Makefile.PL perl-p all-local: @COMP_PERL@ @COMP_RUBY@ @COMP_PYTHON@ install-data-local: - $(AM_V_GEN)test -f perl-piped/Makefile && cd perl-piped && $(MAKE) install || true - $(AM_V_GEN)test -f perl-shared/Makefile && cd perl-shared && $(MAKE) install || true - $(AM_V_GEN)test -f ruby/Makefile && cd ruby && $(MAKE) EPREFIX=$(DESTDIR)$(exec_prefix) $(RUBY_MAKE_OPTIONS) install || true - $(AM_V_GEN)test -d python/build && cd python && env BUILDLIBDIR=../../src/.libs $(PYTHON) setup.py install --skip-build --prefix=$(DESTDIR)$(prefix) --exec-prefix=$(DESTDIR)$(exec_prefix) || true + $(AM_V_GEN)test -f ${builddir}/perl-piped/Makefile \ + && ( cd ${builddir}/perl-piped \ + && $(MAKE) install ) \ + || true + $(AM_V_GEN)test -f ${builddir}/perl-shared/Makefile \ + && ( cd ${builddir}/perl-shared \ + && $(MAKE) install ) \ + || true + $(AM_V_GEN)test -f ${builddir}/ruby/Makefile \ + && ( cd ${builddir}/ruby \ + && $(MAKE) EPREFIX=$(DESTDIR)$(exec_prefix) $(RUBY_MAKE_OPTIONS) install ) \ + || true + $(AM_V_GEN)test -d ${builddir}/python/build \ + && ( cd ${builddir}/python \ + && env BUILDLIBDIR=${abs_top_builddir}/src/.libs \ + $(PYTHON) ${abs_srcdir}/python/setup.py install \ + --skip-build --prefix=$(DESTDIR)$(prefix) \ + --exec-prefix=$(DESTDIR)$(exec_prefix) ) \ + || true # rules for building the ruby module # RUBYARCHDIR= is to work around in a makefile quirk not sure # it is is the right thing todo, but it makes rrdtool build on freebsd as well -ruby: Makefile - cd ruby && $(RUBY) extconf.rb && $(MAKE) EPREFIX=$(exec_prefix) $(RUBY_MAKE_OPTIONS) RUBYARCHDIR= +ruby: + -mkdir -p ${builddir}/ruby + ( cd ${builddir}/ruby \ + && $(RUBY) ${abs_srcdir}/ruby/extconf.rb \ + && $(MAKE) \ + EPREFIX=$(exec_prefix) \ + ABS_TOP_SRCDIR=${abs_top_srcdir} \ + ABS_TOP_BUILDDIR=${abs_top_builddir} \ + $(RUBY_MAKE_OPTIONS) RUBYARCHDIR= ) # rules for building the pyton module -python: Makefile - cd python && env BUILDLIBDIR=../../src/.libs LD_RUN_PATH=$(libdir) $(PYTHON) setup.py build_ext --rpath=$(libdir) && env LIBDIR=../../src/.libs $(PYTHON) setup.py build +python: + -mkdir -p ${builddir}/$@ + cd ${builddir}/$@ \ + && ( test -e rrdtoolmodule.c || ln -s ${abs_srcdir}/$@/rrdtoolmodule.c ) \ + && env \ + ABS_TOP_SRCDIR=${abs_top_srcdir} \ + ABS_TOP_BUILDDIR=${abs_top_builddir} \ + LD_RUN_PATH=$(libdir) \ + $(PYTHON) ${abs_srcdir}/$@/setup.py build_ext --rpath=$(libdir) \ + && env \ + ABS_TOP_SRCDIR=${abs_top_srcdir} \ + ABS_TOP_BUILDDIR=${abs_top_builddir} \ + $(PYTHON) ${abs_srcdir}/$@/setup.py build # rules for building the perl module -perl_piped: perl-piped/Makefile - cd perl-piped && $(MAKE) +perl-piped: + -mkdir -p ${builddir}/$@ + ( cd ${builddir}/$@ \ + && ( test -e Makefile.PL || ln -s ${abs_srcdir}/$@/Makefile.PL ) \ + && ( test -e RRDp.pm || ln -s ${abs_srcdir}/$@/RRDp.pm ) \ + && ( test -e t || ln -s ${abs_srcdir}/$@/t ) \ + && env \ + ABS_TOP_SRCDIR=${abs_top_srcdir} \ + ABS_TOP_BUILDDIR=${abs_top_builddir} \ + ABS_SRCDIR=${abs_srcdir}/$@ \ + $(PERL) Makefile.PL $(PERL_MAKE_OPTIONS) \ + && $(MAKE) ) -perl-piped/Makefile: perl-piped/Makefile.PL - cd perl-piped && $(PERL) Makefile.PL $(PERL_MAKE_OPTIONS) - -perl_shared: perl-shared/Makefile - cd perl-shared && $(MAKE) - -perl-shared/Makefile: perl-shared/Makefile.PL Makefile - cd perl-shared && $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) RPATH=$(libdir) -# LIBS="$(LDFLAGS) $(LIBS)" $(PERLFLAGS) $(PERL_MAKE_OPTIONS) +perl-shared: + -mkdir -p ${builddir}/$@ + ( cd ${builddir}/$@ \ + && ( test -e Makefile.PL || ln -s ${abs_srcdir}/$@/Makefile.PL ) \ + && ( test -e RRDs.pm || ln -s ${abs_srcdir}/$@/RRDs.pm ) \ + && ( test -e RRDs.ppd || ln -s ${abs_srcdir}/$@/RRDs.ppd ) \ + && ( test -e RRDs.xs || ln -s ${abs_srcdir}/$@/RRDs.xs ) \ + && ( test -e t || ln -s ${abs_srcdir}/$@/t ) \ + && env \ + ABS_TOP_SRCDIR=${abs_top_srcdir} \ + ABS_TOP_BUILDDIR=${abs_top_builddir} \ + ABS_SRCDIR=${abs_srcdir}/$@ \ + $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) RPATH=$(libdir) \ + && $(MAKE) ) + -mkdir -p ${builddir}/perl-shared clean-local: - test -f perl-piped/Makefile && cd perl-piped && $(MAKE) clean || true - test -f perl-piped/Makefile && rm perl-piped/Makefile || true - test -f perl-shared/Makefile && cd perl-shared && $(MAKE) clean || true - test -f perl-shared/Makefile && rm -f perl-shared/Makefile || true - test -f ruby/Makefile && cd ruby && $(MAKE) clean && rm Makefile || true - test -d python/build && cd python && rm -rf build || true + -( test -f ${builddir}/perl-piped/Makefile \ + && cd ${builddir}/perl-piped \ + && ( $(MAKE) clean || true ) \ + && rm -f Makefile ) + -( test -f ${builddir}/perl-shared/Makefile \ + && cd ${builddir}/perl-shared \ + && ( $(MAKE) clean || true ) \ + && rm -f Makefile ) + -( test -f ${builddir}/ruby/Makefile \ + && cd ${builddir}/ruby \ + && ( $(MAKE) clean || true ) \ + && rm -f Makefile ) + -rm -rf ${builddir}/python/build ##END## diff --git a/bindings/perl-shared/Makefile.PL b/bindings/perl-shared/Makefile.PL index 42becf46..31ab25f9 100644 --- a/bindings/perl-shared/Makefile.PL +++ b/bindings/perl-shared/Makefile.PL @@ -27,6 +27,9 @@ if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} eq '')) { ) : () ); }else{ + my $TOP_SRCDIR = $ENV{'ABS_TOP_SRCDIR'} || '../../..'; + my $TOP_BUILDDIR = $ENV{'ABS_TOP_BUILDDIR'} || '../../..'; + my $SRCDIR = $ENV{'ABS_SRCDIR'} || '.'; # if the last argument when calling Makefile.PL is RPATH=/... and ... is the # path to librrd.so then the Makefile will be written such that RRDs.so knows # where to find librrd.so later on ... @@ -51,20 +54,20 @@ if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} eq '')) { if ($^O eq 'darwin'){ $librrd = '-lrrd'; } else { - $librrd = "-L../../src/.libs/ $R -lrrd"; + $librrd = "-L${TOP_BUILDDIR}/src/.libs/ $R -lrrd"; } WriteMakefile( 'NAME' => 'RRDs', 'VERSION_FROM' => 'RRDs.pm', # finds $VERSION 'DEFINE' => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}", - 'INC' => '-I../../src', + 'INC' => "-I${TOP_BUILDDIR}/src -I${TOP_SRCDIR}/src", # Perl will figure out which one is valid #'dynamic_lib' => {'OTHERLDFLAGS' => "$librrd -lm"}, - 'depend' => {'RRDs.c' => "../../src/librrd.la"}, + 'depend' => {'RRDs.c' => "${TOP_BUILDDIR}/src/librrd.la"}, 'LDFROM' => '$(OBJECT) '.$librrd, 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' }, - ($^O eq 'darwin') ? ( 'LDDLFLAGS' => "-L../../src/.libs/ $Config{lddlflags}" ) : () + ($^O eq 'darwin') ? ( 'LDDLFLAGS' => "-L${TOP_BUILDDIR}/src/.libs/ $Config{lddlflags}" ) : () ); } diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 1b024144..e44da314 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -31,9 +31,8 @@ from distutils.core import setup, Extension import sys, os -RRDBASE = os.environ.get('LOCALBASE', '../../src') -library_dir = os.environ.get('BUILDLIBDIR', os.path.join(RRDBASE, '.libs')) -include_dir = os.environ.get('INCDIR', RRDBASE) +TOP_SRCDIR = os.environ.get('ABS_TOP_SRCDIR', '../../src') +TOP_BUILDDIR = os.environ.get('ABS_TOP_BUILDDIR', '../../src') setup(name = "py-rrdtool", version = "0.2.2", @@ -48,8 +47,9 @@ setup(name = "py-rrdtool", "rrdtoolmodule", ["rrdtoolmodule.c"], libraries=['rrd'], - library_dirs=[library_dir], - include_dirs=[include_dir], + library_dirs=[ os.path.join(TOP_BUILDDIR, 'src', '.libs') ], + include_dirs=[ os.path.join(TOP_BUILDDIR, 'src'), + os.path.join(TOP_SRCDIR, 'src') ], ) ] ) diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index 164a525a..882b0b07 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -13,6 +13,6 @@ elsif /aix/ =~ RUBY_PLATFORM $LDFLAGS += ' -blibpath:$(EPREFIX)/lib' end -dir_config("rrd","../../src","../../src/.libs") +dir_config("rrd",['$(ABS_TOP_BUILDDIR)/src', '$(ABS_TOP_SRCDIR)/src'],'$(ABS_TOP_BUILDDIR)/src/.libs') have_library("rrd", "rrd_create") create_makefile("RRD") diff --git a/bindings/tcl/Makefile.am b/bindings/tcl/Makefile.am index f13afe69..d88238aa 100644 --- a/bindings/tcl/Makefile.am +++ b/bindings/tcl/Makefile.am @@ -18,7 +18,7 @@ TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@ CLEANFILES = tclrrd.o tclrrd.so SRC_DIR = $(top_srcdir)/src -AM_CPPFLAGS = $(TCL_INCLUDE_SPEC) -I$(SRC_DIR) -DUSE_TCL_STUBS +AM_CPPFLAGS = $(TCL_INCLUDE_SPEC) -I$(top_builddir)/src -I$(SRC_DIR) -DUSE_TCL_STUBS LIBDIRS = -L$(top_builddir)/src/.libs -L$(top_builddir)/src -L$(libdir) LIB_RUNTIME_DIR = $(libdir) diff --git a/configure.ac b/configure.ac index 8d765f42..fd740e98 100644 --- a/configure.ac +++ b/configure.ac @@ -576,7 +576,7 @@ AC_ARG_VAR(PERLLDFLAGS, [LD flags for Perl modules]) if test "x$PERL" = "xno" -o x$enable_perl = xno; then COMP_PERL= else - COMP_PERL="perl_piped perl_shared" + COMP_PERL="perl-piped perl-shared" AC_MSG_CHECKING(for the perl version you are running) PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}'` AC_MSG_RESULT($PERL_VERSION) @@ -595,7 +595,7 @@ appropriately, or use a different perl setup that was compiled locally. I will disable the compilation of the RRDs perl module for now. ]) - COMP_PERL="perl_piped" + COMP_PERL="perl-piped" fi fi fi