From e11d297f08e5beee494fa3b58d430a8ecfda00e6 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 6 Jan 2005 09:43:43 +0000 Subject: [PATCH] - Makefile.PL now builds imconfig.h with #defines for libraries present (and for the GIF library version) rather than putting them into CFLAGS --- .cvsignore | 1 + Changes | 3 +++ Makefile.PL | 47 +++++++++++++++++++++++++++++++++++++++++------ image.h | 1 + log.c | 1 + 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.cvsignore b/.cvsignore index 4be0832c..ea87bc7f 100644 --- a/.cvsignore +++ b/.cvsignore @@ -6,3 +6,4 @@ Imager.c pm_to_blib Imager.bs t1lib.log +imconfig.h diff --git a/Changes b/Changes index 54ffffee..f1bf40ac 100644 --- a/Changes +++ b/Changes @@ -990,6 +990,9 @@ Revision history for Perl extension Imager. and pkg-config to configure libpng. - avoid complaining about include/lib directories we pull from perl's config or we have built-in +- Makefile.PL now builds imconfig.h with #defines for libraries + present (and for the GIF library version) rather than putting them + into CFLAGS ================================================================= diff --git a/Makefile.PL b/Makefile.PL index 5cb36ccd..a3e08042 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -26,6 +26,8 @@ getenv(); # get environment variables init(); # initialize global data pathcheck(); # Check if directories exist +my @defines; + # Pick what libraries are used if ($MANUAL) { manual(); @@ -43,8 +45,9 @@ if ($MANUAL) { gifcheck(); my $lib_cflags = ''; -for $frm(values %formats) { - $F_DEFINE .= ' -D'.$frm->{def}; +for my $frmkey (keys %formats) { + my $frm = $formats{$frmkey}; + push @defines, [ $frm->{def}, 1, "$frmkey available" ]; $F_LIBS .= ' ' .$frm->{libfiles}; $F_OBJECT .= ' ' .$frm->{objfiles}; $lib_cflags .= ' ' .$frm->{cflags} if $frm->{cflags}; @@ -71,7 +74,7 @@ if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; } 'NAME' => 'Imager', 'VERSION_FROM' => 'Imager.pm', 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS", - 'DEFINE' => "$F_DEFINE $EXTDEF $OSDEF $CFLAGS", + 'DEFINE' => "$OSDEF $CFLAGS", 'INC' => "$lib_cflags $DFLAGS $F_INC", 'OBJECT' => join(' ', @objs, $F_OBJECT), clean => { FILES=>'testout' }, @@ -85,6 +88,8 @@ if ($ExtUtils::MakeMaker::VERSION > 6.10) { $opts{NO_META} = 1; } +make_imconfig(\@defines); + if ($VERBOSE) { print Dumper(\%opts); } mkdir('testout',0777); # since we cannot include it in the archive. WriteMakefile(%opts); @@ -99,6 +104,11 @@ dyntest.$(MYEXTLIB) : dynfilt/Makefile lib/Imager/Regops.pm : regmach.h regops.perl $(PERL) regops.perl regmach.h lib/Imager/Regops.pm + +imconfig.h: Makefile.PL + $(ECHO) "imconfig.h out-of-date with respect to $?" + $(PERLRUN) Makefile.PL + $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <==" '; } @@ -198,7 +208,8 @@ EOFF # we need the version in a #ifdefable form - $F_DEFINE .= "-DIM_GIFMAJOR=$major -DIM_GIFMINOR=$minor"; + push @defines, [ IM_GIFMAJOR, $major, "Parsed giflib version" ]; + push @defines, [ IM_GIFMINOR, $minor ]; } @@ -469,15 +480,39 @@ sub getenv { if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);} if ($NOLOG) { print "Logging not compiled into module\n"; } - else { $EXTDEF.=' -DIMAGER_LOG'; } + else { + push @defines, [ IMAGER_LOG => 1, "Logging system" ]; + } if ($DEBUG_MALLOC) { - $EXTDEF.=' -DIMAGER_DEBUG_MALLOC'; + push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ]; print "Malloc debugging enabled\n"; } } +sub make_imconfig { + my ($defines) = @_; + + open CONFIG, "> imconfig.h" + or die "Cannot create imconfig.h: $!\n"; + print CONFIG <[2]) { + print CONFIG "\n/*\n $define->[2]\n*/\n\n"; + } + print CONFIG "#define $define->[0] $define->[1]\n"; + } + print CONFIG "\n#endif\n"; + close CONFIG; +} + # probes for freetype2 by trying to run freetype-config sub freetype2_probe { my ($frm, $frmkey) = @_; diff --git a/image.h b/image.h index 5278c09a..52f50717 100644 --- a/image.h +++ b/image.h @@ -1,6 +1,7 @@ #ifndef _IMAGE_H_ #define _IMAGE_H_ +#include "imconfig.h" #include "imio.h" #include "iolayer.h" #include "log.h" diff --git a/log.c b/log.c index 04e225a7..c2b23e62 100644 --- a/log.c +++ b/log.c @@ -1,3 +1,4 @@ +#include "imconfig.h" #include "log.h" #define DTBUFF 50 -- 2.39.5