From c2588300e3b61df51b846dd79d90b3da9628d0cb Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 10 Mar 2005 17:03:34 +0000 Subject: [PATCH] * Updated perl compile system. It now uses Makefile.PL for everything, but gets it to install the perl module in @prefix@/lib/perl such that you can use the same use lib line for whatever platform and perlversion you install into this directory. They all live neatly next to each other. * fixed examples to work with new perl install system. Added a few exec_prefix lines where appropriate * fixed piped demo * fixed VeraMono.ttf file. This somehow got damaged by cvs ... * added thread defines to normal compile run, so that _r functions to not through errors. * tested compilation and installation git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@307 a5681a0c-68f1-0310-ab6d-d61299d08faa --- README | 9 +++--- acinclude.m4 | 24 +++++++------- bindings/Makefile.am | 19 +++++------ configure.ac | 78 ++++++++++++++++++++++++++++++---------------- examples/4charts.pl.in | 4 +-- examples/bigtops.pl.in | 5 +-- examples/cgi-demo.cgi.in | 2 +- examples/minmax.pl.in | 5 +-- examples/piped-demo.pl.in | 13 ++++---- examples/shared-demo.pl.in | 5 +-- examples/stripes.pl.in | 7 +---- src/rrd.h | 2 +- src/rrd_last.c | 2 +- src/rrd_tool.h | 2 +- 14 files changed, 91 insertions(+), 86 deletions(-) diff --git a/README b/README index 2eb96a6..b3631ba 100644 --- a/README +++ b/README @@ -37,7 +37,7 @@ To compile: -I/scratch/oetiker/lib/include/freetype2" \ LDFLAGS="-L/scratch/oetiker/lib/lib -R/scratch/oetiker/lib/lib \ -L/scratch/oetiker/cgilib-0.5" \ - ./configure --prefix=/scratch/oetiker/lib + ./configure --prefix=/scratch/oetiker/rrdtool make <------ GNU make @@ -58,10 +58,11 @@ directory. This will require you to use a 'use lib' statement in your RRDtool perl programs. If you do not care what happens to your site-perl directory, you can also use - make site-perl-install + --enable-perl-site-install -this will install the perl modules whereever you keep your local perl -modules. Doing this reliefs you from using 'use lib' in your scripts. +when running configure to have the RRD perl modules installed whereever you +keep your local perl modules. Doing this reliefs you from using 'use lib' in +your scripts. Configure will also look for an TCL installation on your system. If it finds one it will build a TCL interface for RRDtool. If you keep tcl in a non diff --git a/acinclude.m4 b/acinclude.m4 index 329501d..062216a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -240,11 +240,9 @@ for flag in $acx_pthread_flags; do # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" @@ -270,8 +268,7 @@ if test "x$acx_pthread_ok" = xyes; then AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_TRY_LINK([#include ], [int attr=$attr;], - [attr_name=$attr; break]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int attr=$attr;]])],[attr_name=$attr; break],[]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then @@ -281,14 +278,14 @@ if test "x$acx_pthread_ok" = xyes; then fi AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no + x_rflag=no case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + *-aix* | *-freebsd* | *-darwin*) x_rflag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) x_rflag="-D_REENTRANT";; esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + AC_MSG_RESULT(${x_rflag}) + if test "x$x_rflag" != xno; then + PTHREAD_CFLAGS="$x_rflag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" @@ -322,6 +319,9 @@ dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES, dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]) dnl +dnl substitute them in all the files listed in AC_OUTPUT +AC_SUBST(PERLFLAGS) + AC_DEFUN([AC_IEEE], [ AC_MSG_CHECKING([if IEEE math works $1]) AC_CACHE_VAL([rd_cv_ieee_$2], diff --git a/bindings/Makefile.am b/bindings/Makefile.am index f551196..48a7508 100644 --- a/bindings/Makefile.am +++ b/bindings/Makefile.am @@ -1,18 +1,13 @@ -SUBDIRS = tcl +SUBDIRS = tcl # the following files are not mentioned in any other Makefile EXTRA_DIST = $(shell for A in perl-*; do cat $$A/MANIFEST | sed -e s,^,$$A/, ; done) -# lets schedule the perl stuff for installation -# the special call to install-sh is because the -d switch is not portable -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(prefix)/lib/perl/auto/RRDs - $(INSTALL) -m 644 perl-piped/RRDp.pm $(DESTDIR)$(prefix)/lib/perl - $(INSTALL) -m 644 perl-shared/RRDs.pm $(DESTDIR)$(prefix)/lib/perl - $(INSTALL) -m 644 perl-shared/blib/arch/auto/RRDs/RRDs.bs $(DESTDIR)$(prefix)/lib/perl/auto/RRDs - $(INSTALL) -m 755 perl-shared/blib/arch/auto/RRDs/RRDs.@SO_EXT@ $(DESTDIR)$(prefix)/lib/perl/auto/RRDs - # add the following to the all target -all-local: @COMP_PERL@ +all-local: @COMP_PERL@ + +install-data-local: + cd perl-piped && test -f Makefile && $(MAKE) install || true + cd perl-shared && test -f Makefile && $(MAKE) install || true # rules for building the perl module perl_piped: perl-piped/Makefile @@ -22,7 +17,7 @@ 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) RPATH=$(prefix)/lib + cd perl-shared && $(MAKE) RPATH=$(exec_prefix)/lib perl-shared/Makefile: perl-shared/Makefile.PL cd perl-shared && $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) diff --git a/configure.ac b/configure.ac index 0c7790b..f385ebc 100644 --- a/configure.ac +++ b/configure.ac @@ -151,9 +151,6 @@ AC_C_CONST AC_HEADER_TIME AC_STRUCT_TM -dnl substitute them in all the files listed in AC_OUTPUT -AC_SUBST(PERLFLAGS) - dnl Checks for libraries. AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos)) @@ -214,7 +211,7 @@ if test "$EX_CHECK_ALL_ERR" = "YES"; then fi AC_LANG_PUSH(C) -dnl solaris has some odd define it need in order to propperly compile ctime_r +dnl solaris has some odd defines it needs in order to propperly compile ctime_r AC_MSG_CHECKING([if ctime_r need special care to act posixly correct]) AC_LINK_IFELSE( AC_LANG_PROGRAM( @@ -252,7 +249,14 @@ AC_SUBST(MULTITHREAD_LDFLAGS) AC_ARG_ENABLE(pthread,[ --disable-pthread disable multithread support], [],[enable_pthread=yes]) - + +dnl since we use lots of *_r functions all over the code we better +dnl make sure they are known + +if test "x$x_rflag" != "xno"; then + CPPFLAGS="$CPPFLAGS $x_rflag" +fi + if test $enable_pthread != no; then ACX_PTHREAD([ MULTITHREAD_CFLAGS=$PTHREAD_CFLAGS @@ -271,24 +275,53 @@ if test "x$PERL" = "xno"; then COMP_PERL= else COMP_PERL="perl_piped perl_shared" - AC_MSG_CHECKING(for shared library extension) - SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'` - AC_MSG_RESULT($SO_EXT) + AC_MSG_CHECKING(for the perl version you are running) + PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}'` + AC_MSG_RESULT($PERL_VERSION) AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules) - PROBLEMCC=`$PERL -e 'use Config; ($cc = $Config{cc}) =~ s/\s.*//; exit 0 if -x $cc; map {if (-x "$_/$cc"){exit 0}} split /:/, $ENV{PATH};print $Config{cc}'` - if test x$PROBLEMCC != x; then - AC_MSG_RESULT(no) - echo Could not find the Compiler: '"'$PROBLEMCC'"' - echo which has been used to build perl. You may have to compile - echo your own copy of perl to make this work. Binary perls often - echo exhibit this problem - exit 1 - else - AC_MSG_RESULT(found) + perlcc=`$PERL -MConfig -e 'print $Config{cc}'` + AC_MSG_RESULT($perlcc) + if test ! -x $perlcc; then + AC_PATH_PROG(PERLCC, ${perlcc}, no) + if test -x $"x$PERLCC" = "xno"; then + AC_MSG_WARN([ +I would not find the Compiler ($perlcc) that was originally used to compile your +perl binary. You should either make sure that this compiler is available on your +system, or use a different perl setup that was compiled with $CC. + +I will disable the compilation of the RRDs perl module. +]) + COMP_PERL="perl_piped" + fi fi fi +AC_MSG_CHECKING(Perl Modules to build) +AC_MSG_RESULT(${COMP_PERL:-No Perl Modules will be built}) + +# Options to pass when configuring perl module +PERL_MAKE_OPTIONS="PREFIX=$prefix LIB=$prefix/lib/perl/$PERL_VERSION" + +dnl pass additional perl options when generating Makefile from Makefile.PL +AC_ARG_ENABLE(perl-site-install, +[ --enable-perl-site-install by default the rrdtool perl modules are installed + together with rrdtool in $prefix/lib/perl. You have to + put a 'use lib qw($prefix/lib/perl)' into your scripts + when you want to use them. When you set this option + the perl modules will get installed wherever + your perl setup thinks it is best.], +[PERL_MAKE_OPTIONS=],[]) + +AC_ARG_WITH(perl-options, +[ --with-perl-options=[OPTIONS] options to pass on command-line when + generating Makefile from Makefile.PL. If you set this + option, interesting things may happen unless you know + what you are doing!], +[PERL_MAKE_OPTIONS=$withval]) + +AC_SUBST(PERL_MAKE_OPTIONS) +AC_SUBST(PERL) AC_SUBST(COMP_PERL) -AC_SUBST(SO_EXT) +AC_SUBST(PERL_VERSION) dnl Check for Tcl. withval="" @@ -310,13 +343,6 @@ else . $tcl_config fi -dnl Pass additional perl options when generating Makefile from Makefile.PL -# Options to pass when configuring perl module -AC_ARG_WITH(perl-options, -[ --with-perl-options=[OPTIONS] options to pass on command-line when - generating Makefile from Makefile.PL], -[PERL_MAKE_OPTIONS=$withval]) -AC_SUBST(PERL_MAKE_OPTIONS) AM_CONDITIONAL(COMP_TCL, test x$found = x1 ) diff --git a/examples/4charts.pl.in b/examples/4charts.pl.in index 7249b07..beeb6f4 100755 --- a/examples/4charts.pl.in +++ b/examples/4charts.pl.in @@ -1,9 +1,7 @@ #! @PERL@ #makes things work when run without install -use lib qw( ../bindings/perl-shared/blib/lib ../bindings/perl-shared/blib/arch ); -# this is for after install -use lib qw( @prefix@/lib/perl ../lib/perl ); +use lib qw( @prefix@/lib/perl ); use RRDs; diff --git a/examples/bigtops.pl.in b/examples/bigtops.pl.in index 9bc39db..b3fa6e4 100755 --- a/examples/bigtops.pl.in +++ b/examples/bigtops.pl.in @@ -1,9 +1,6 @@ #! @PERL@ - -#makes things work when run without install -use lib qw( ../bindings/perl-shared/blib/lib ../bindings/perl-shared/blib/arch ); # this is for after install -use lib qw( @prefix@/lib/perl ../lib/perl ); +use lib qw( @prefix@/lib/perl ); use RRDs; my $start=time; diff --git a/examples/cgi-demo.cgi.in b/examples/cgi-demo.cgi.in index 9ec1587..c5c5a11 100755 --- a/examples/cgi-demo.cgi.in +++ b/examples/cgi-demo.cgi.in @@ -1,4 +1,4 @@ -#! @prefix@/bin/rrdcgi +#! @exec_prefix@/bin/rrdcgi diff --git a/examples/minmax.pl.in b/examples/minmax.pl.in index 14faecb..29c0169 100755 --- a/examples/minmax.pl.in +++ b/examples/minmax.pl.in @@ -1,9 +1,6 @@ #! @PERL@ -#makes things work when run without install -use lib qw( ../bindings/perl-shared/blib/lib ../bindings/perl-shared/blib/arch ); -# this is for after install -use lib qw( @prefix@/lib/perl ../lib/perl ); +use lib qw( @prefix@/lib/perl ); use RRDs; my $start=time; diff --git a/examples/piped-demo.pl.in b/examples/piped-demo.pl.in index 82232fb..71d69e7 100755 --- a/examples/piped-demo.pl.in +++ b/examples/piped-demo.pl.in @@ -1,9 +1,5 @@ #! @PERL@ -#makes things work when run without install -use lib qw( ../bindings/perl-piped/blib/lib ../lib/perl ); - -#makes programm work AFTER install use lib qw( @prefix@/lib/perl ); use RRDp; @@ -20,8 +16,8 @@ $SVG = "piped-demo.svg"; $PNG = "piped-demo.png"; # some magic to find the correct rrdtol executable -if ( -x "@prefix@/bin/rrdtool") { - RRDp::start "@prefix@/bin/rrdtool"; +if ( -x "@exec_prefix@/bin/rrdtool") { + RRDp::start "@exec_prefix@/bin/rrdtool"; } elsif ( -x "../bin/rrdtool") { RRDp::start "../bin/rrdtool"; } else { @@ -109,6 +105,9 @@ print "\n\n* Creating $GRUNS PNG graphs: $PNG\n\n"; $now = time; ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real); +my $local = "".localtime(time()); +$local =~ s/:/\\:/g; + for ($i=0;$i<$GRUNS;$i++) { RRDp::cmd "graph $PNG ", "--title 'Test GRAPH' ", "--imgformat PNG --height 150 --vertical-label 'Dummy Units' ". @@ -128,7 +127,7 @@ RRDp::cmd "graph $PNG ", "--title 'Test GRAPH' ", "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'", "VRULE:".($now-3600)."#008877:'60 Minutes ago'", "COMMENT:'\\s'", - "COMMENT:'Graph created on\\: ".localtime(time())."\\c'"; + "COMMENT:'Graph created on\\: $local\\c'"; $answer = RRDp::read; } diff --git a/examples/shared-demo.pl.in b/examples/shared-demo.pl.in index 9442196..6d9374f 100755 --- a/examples/shared-demo.pl.in +++ b/examples/shared-demo.pl.in @@ -14,11 +14,8 @@ sub ok print "ok $ok_count $what\n"; } -#makes things work when run without install -use lib qw( ../bindings/perl-shared/blib/lib ../bindings/perl-shared/blib/arch ); - #makes programm work AFTER install -use lib qw( @prefix@/lib/perl ../lib/perl ); +use lib qw( @prefix@/lib/perl ); use strict; use vars qw(@ISA $loaded); diff --git a/examples/stripes.pl.in b/examples/stripes.pl.in index 5c4c6df..5187a56 100755 --- a/examples/stripes.pl.in +++ b/examples/stripes.pl.in @@ -1,10 +1,5 @@ #! @PERL@ - -#makes things work when run without install -use lib qw( ../bindings/perl-shared/blib/lib ../bindings/perl-shared/blib/arch ); - -#makes programm work AFTER install -use lib qw( @prefix@/lib/perl ../lib/perl ); +use lib qw( @prefix@/lib/perl ); use strict; use vars qw(@ISA $loaded); diff --git a/src/rrd.h b/src/rrd.h index f63d117..2868ebb 100644 --- a/src/rrd.h +++ b/src/rrd.h @@ -69,7 +69,7 @@ int rrd_fetch(int, char **, time_t *, time_t *, unsigned long *, int rrd_restore(int, char **); int rrd_dump(int, char **); int rrd_tune(int, char **); -time_t rrd_last(int, const char **); +time_t rrd_last(int, char **); int rrd_resize(int, char **); int rrd_xport(int, char **, int *, time_t *, time_t *, unsigned long *, unsigned long *, diff --git a/src/rrd_last.c b/src/rrd_last.c index ad8075e..d50e760 100644 --- a/src/rrd_last.c +++ b/src/rrd_last.c @@ -9,7 +9,7 @@ #include "rrd_tool.h" time_t -rrd_last(int argc, const char **argv) +rrd_last(int argc, char **argv) { if(argc < 2){ rrd_set_error("please specify an rrd"); diff --git a/src/rrd_tool.h b/src/rrd_tool.h index dbfb26b..56b4568 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -140,7 +140,7 @@ typedef union infoval { unsigned long u_cnt; rrd_value_t u_val; char *u_str; - int u_int; + int u_int; } infoval; typedef struct info_t { -- 2.11.0