]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
automake: rework for separated builds
authorPeter A. Bigot <pab@pabigot.com>
Sat, 17 May 2014 19:25:18 +0000 (14:25 -0500)
committerPeter A. Bigot <pab@pabigot.com>
Sat, 17 May 2014 21:01:27 +0000 (16:01 -0500)
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 <pab@pabigot.com>
bindings/Makefile.am
bindings/perl-shared/Makefile.PL
bindings/python/setup.py
bindings/ruby/extconf.rb
bindings/tcl/Makefile.am
configure.ac

index 7f1b12113120573aad43c62e0c91164b5f0262eb..29a3a7d36716b8c914c08d6dcdb453024c3b2e70 100644 (file)
@@ -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##
index 42becf4678e75ee8b2ff16ef4f5e03b477085165..31ab25f98c50494026a88d2a0c947f8596257ced 100644 (file)
@@ -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}" ) : ()
        );
 }
 
index 1b024144be99a041a74159e9f11a54acbebb42c1..e44da31456ed92ea8f5eede8ea794ad9d9bbe5e8 100644 (file)
@@ -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') ],
           )
       ]
 )
index 164a525a08ab7d346c8b835b24a5d43ecc8c87ac..882b0b0718078efc89bcc6f74ae61cfd69b59223 100644 (file)
@@ -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")
index f13afe692a0aac86a8d03026c46ba234c5986157..d88238aab99cb4f4763312572b027d42ff165b19 100644 (file)
@@ -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)
 
index 8d765f42f8126f3c887b8a7154c40ba5e5eaa65a..fd740e98491c7b6bd69bd0c04dfb3494b9d6e97e 100644 (file)
@@ -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