Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Makefile.PL now builds imconfig.h with #defines for libraries

  present (and for the GIF library version) rather than putting them
  into CFLAGS
  • Loading branch information...
commit e11d297f08e5beee494fa3b58d430a8ecfda00e6 1 parent 7b063aa
Tony Cook authored
Showing with 47 additions and 6 deletions.
  1. +1 −0  .cvsignore
  2. +3 −0  Changes
  3. +41 −6 Makefile.PL
  4. +1 −0  image.h
  5. +1 −0  log.c
View
1  .cvsignore
@@ -6,3 +6,4 @@ Imager.c
pm_to_blib
Imager.bs
t1lib.log
+imconfig.h
View
3  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
=================================================================
View
47 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 <<EOS;
+/* This file is automatically generated by Makefile.PL.
+ Don't edit this file, since any changes will be lost */
+
+#ifndef IMAGER_IMCONFIG_H
+#define IMAGER_IMCONFIG_H
+EOS
+ for my $define (@$defines) {
+ if ($define->[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) = @_;
View
1  image.h
@@ -1,6 +1,7 @@
#ifndef _IMAGE_H_
#define _IMAGE_H_
+#include "imconfig.h"
#include "imio.h"
#include "iolayer.h"
#include "log.h"
View
1  log.c
@@ -1,3 +1,4 @@
+#include "imconfig.h"
#include "log.h"
#define DTBUFF 50
Please sign in to comment.
Something went wrong with that request. Please try again.