Makefile.PL 10.5 KB
Newer Older
Marc Lehmann's avatar
Marc Lehmann committed
1
require 5.004_04;
Marc Lehmann's avatar
Marc Lehmann committed
2

Marc Lehmann's avatar
Marc Lehmann committed
3
4
use Config;

Marc Lehmann's avatar
Marc Lehmann committed
5
$|=1;
Marc Lehmann's avatar
Marc Lehmann committed
6
7
8
9
10
11
12

if ($ARGV[0] ne "--writemakefile") {
   for(@ARGV) {
      s/^prefix=/--prefix=/i;
   }
   
   do './config.pl';
Marc Lehmann's avatar
Marc Lehmann committed
13
   $EXTENSIVE_TESTS = 1;
Marc Lehmann's avatar
Marc Lehmann committed
14
15
16
17
18
19
20
21
   
   $ENV{'EXTENSIVE_TESTS'} = $EXTENSIVE_TESTS;
   $ENV{CC}=$Config{cc};
   $ENV{LD}=$Config{ld};
   $ENV{prefix}=$Config{prefix};
   $ENV{PERL}=$Config{perlpath};
   $ENV{MAKEFILE_PL}=$0;
   $ENV{IN_GIMP}=0;
Marc Lehmann's avatar
Marc Lehmann committed
22
   exit system("./configure",@ARGV)>>8;
Marc Lehmann's avatar
Marc Lehmann committed
23
} else {
Marc Lehmann's avatar
Marc Lehmann committed
24
   shift;
Marc Lehmann's avatar
Marc Lehmann committed
25
   local $do_config_msg = 1;
Marc Lehmann's avatar
Marc Lehmann committed
26
   do './config.pl'; die $@ if $@;
Marc Lehmann's avatar
Marc Lehmann committed
27
28
}

Marc Lehmann's avatar
Marc Lehmann committed
29
30
31
32
33
34
35
@otherdeps = qw(
      povray imagemagick
);
@gtk_pins =
   qw(
     dataurl colorhtml avi PDB parasite-editor
   ); # miff should be in @pins(!) but detection of non-default arguments is broken
Marc Lehmann's avatar
Marc Lehmann committed
36
@pins =
Marc Lehmann's avatar
Marc Lehmann committed
37
38
   qw(
      windify prep4gif webify tex-to-float ditherize
Marc Lehmann's avatar
Marc Lehmann committed
39
      xachlego xachshadow roundsel blended2 warp-sharp
Marc Lehmann's avatar
Marc Lehmann committed
40
      scratches blowinout terral_text xachvision perlcc translogo
Marc Lehmann's avatar
Marc Lehmann committed
41
      animate_cells image_tile yinyang stamps font_table sethspin
Marc Lehmann's avatar
Marc Lehmann committed
42
      perlotine randomblends innerbevel fit-text guidegrid
Marc Lehmann's avatar
Marc Lehmann committed
43
      repdup centerguide stampify goldenmean mirrorsplit
Marc Lehmann's avatar
Marc Lehmann committed
44
      layerfuncs randomart1 glowing_steel frame_reshuffle frame_filter
Marc Lehmann's avatar
Marc Lehmann committed
45
      logulator guide_remove guides_to_selection burst
Marc Lehmann's avatar
Marc Lehmann committed
46
      layerfuncs bricks miff dust
Marc Lehmann's avatar
Marc Lehmann committed
47
48
49
   );
@pdl_pins =
   qw(
Marc Lehmann's avatar
Marc Lehmann committed
50
      border gouge pixelmap view3d clear_alpha
Marc Lehmann's avatar
Marc Lehmann committed
51

Marc Lehmann's avatar
Marc Lehmann committed
52
53
      fire map_to_gradient
   ); # fire should use normal gradient map!
Marc Lehmann's avatar
Marc Lehmann committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

eval "use Gtk;"; $GTK = $@ eq "";
eval "use Parse::RecDescent;"; $PRD = $@ eq "";

$] >= 5.005 or print <<EOF;

NOTICE:  You are using a version of perl older than 5.005. This will slightly
         reduce the features available to the Gimp-Perl extension.

EOF

$GTK or print <<EOF;

NOTICE:  unable to use the Perl-Gtk interface. Many features (like
         Gimp::Fu) rely on this extension. You can build without it (and
         many scripts will be disabled or run with reduced functionality
         only), but it's better to install it (version 0.6123 or higher is
         required, you can get it from ftp://ftp.gimp.org/pub/gtk/perl/ or
         any CPAN mirror.

EOF

$PRD or print <<EOF;

NOTICE: Parse::RecDescent not found, scm2perl, the Scheme->Perl
        translator, will not work. This is normally not a problem, since
        it is quite unimportant for most people.

EOF

($major,$minor,$patch)=split /[._]/,$Gtk::VERSION;
Marc Lehmann's avatar
Marc Lehmann committed
85

Marc Lehmann's avatar
Marc Lehmann committed
86
87
88
require ExtUtils::MakeMaker;
import ExtUtils::MakeMaker;

Marc Lehmann's avatar
Marc Lehmann committed
89
90
91
92
93
94
95
96
97
98
99
100
$MICRO = int ($] * 100000 % 100);

if ($MICRO > 49) {
   print <<EOF;

WARNING: You are using perl version $]. This is an *ALPHA* version that is
         very likely to have serious bugs that keep gimp-perl from working
         properly. Please upgrade/downgrade to a stable release.

EOF
}

Marc Lehmann's avatar
Marc Lehmann committed
101
102
103
104
105
106
107
108
109
110
111
112
if ($Config{usethreads} or $Config{use5005threads}) {
   print <<EOF;

WARNING: Your perl has been built with multithreading enabled. The 5.005
         threading model is utterly broken (and about to be removed),
         while the 5.6 threading model is about to change very soon.
         Since I suppose you know how to fix perl since you enabled
         threading, I'll proceed with building gimp-perl.

EOF
}

Marc Lehmann's avatar
Marc Lehmann committed
113
114
115
116
117
118
119
120
121
122
if ($] < 5.006 && $Config{usethreads}) {
   print <<EOF;

WARNING: You are using the experimental (and very broken) multithread support.
         While gimp-perl might seem to work, it is very likely to not work
         properly (or at all). Please use a *stable* version of perl.
            
EOF
}

Marc Lehmann's avatar
Marc Lehmann committed
123
124
125
push @pins, @pdl_pins if $PDL;
push @pins, @gtk_pins if $GTK;

Marc Lehmann's avatar
Marc Lehmann committed
126
127
@INC = grep /^\//,@INC; # comment out as well?
if (0) {		# comment out because it breaks
Marc Lehmann's avatar
Marc Lehmann committed
128
129
eval { $Gimp::no_SIG=1; require Gimp };
unless($@) {
Marc Lehmann's avatar
Marc Lehmann committed
130
131
132
   eval { require Gimp::Config };
   $old_prefix = eval { $Gimp::Config{GIMP_PREFIX} };
   $old_prefix = eval { Gimp::_gimp_prefix() } unless $old_prefix;
Marc Lehmann's avatar
Marc Lehmann committed
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
   if ($@) {
      print <<EOF;

WARNING: I've detected an old version of Gimp-Perl installed
	 already. Since I cannot detect the prefix used to install
	 it I will just overwrite it.  If you happen to use two
	 different and incompatible versions of the Gimp with differing
	 prefixes you should call configure with the --disable-perl
	 switch to disable the perl extension, or consider installing
	 the perl module elsewhere, using the environment variables
	 PERL5LIB=/my/module/dir and PERL_MM_OPTS="PREFIX=\$PERL5LIB" to
	 overwrite the installation directory (PERL_MM_OPTS) and run the
	 Gimp (PERL5LIB). See "perldoc ExtUtils::MakeMaker" for a full
	 discussion of your options.

EOF
   } else {
      if ($GIMP_PREFIX ne $old_prefix) {
	 print <<EOF;

WARNING: I've detected another installation of the Gimp-Perl extension.
	    
	 This version uses the prefix '$GIMP_PREFIX'.
	 The already installed version uses the prefix '$old_prefix'.

	 They don't match, which indicates that installing Gimp-Perl might
Marc Lehmann's avatar
Marc Lehmann committed
159
160
	 overwrite an old but still used installation. The Gimp-Perl
         installation _might_ therefore be broken.
Marc Lehmann's avatar
Marc Lehmann committed
161
162
163
164
165

EOF
      }
   }
}
Marc Lehmann's avatar
Marc Lehmann committed
166
}
Marc Lehmann's avatar
Marc Lehmann committed
167

Marc Lehmann's avatar
Marc Lehmann committed
168
sub MY::install {
Marc Lehmann's avatar
Marc Lehmann committed
169
   my $self=shift;
Marc Lehmann's avatar
Marc Lehmann committed
170
   package MY;
Marc Lehmann's avatar
Marc Lehmann committed
171
   my $install = $self->SUPER::install(@_);
Marc Lehmann's avatar
Marc Lehmann committed
172
   ($install =~ s/\b(un)?install\b/really-$1install/g) or return $install;
Marc Lehmann's avatar
Marc Lehmann committed
173
   '
Marc Lehmann's avatar
Marc Lehmann committed
174
install :: install-po
Marc Lehmann's avatar
Marc Lehmann committed
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
	@for dir in \
	   $(INSTALLPRIVLIB) \
	   $(INSTALLARCHLIB) \
	   $(INSTALLBIN) \
	   $(INSTALLSCRIPT) \
	   $(INSTALLMAN1DIR) \
	   $(INSTALLMAN3DIR) ; \
	do \
	   $(MKPATH) "$$dir"; \
	   if test -d "$$dir" && test -w "$$dir" ; then : ; else \
	      echo ; \
	      echo "ERROR: installation directory \"$$dir\"" ; \
	      echo "       is not writable, not installing gimp-perl" ; \
	      echo ; \
	      exit ; \
190
	   fi ; \
Marc Lehmann's avatar
Marc Lehmann committed
191
	done ; \
Marc Lehmann's avatar
Marc Lehmann committed
192
	$(MAKE) really-install install-plugins'."
Marc Lehmann's avatar
Marc Lehmann committed
193
	$main::dont_embed || (cd embed && \$(MAKE) install)
Marc Lehmann's avatar
Marc Lehmann committed
194

Marc Lehmann's avatar
Marc Lehmann committed
195
install-po:
Sven Neumann's avatar
Sven Neumann committed
196
	cd po && \$(MAKE) install
Marc Lehmann's avatar
Marc Lehmann committed
197
        
Marc Lehmann's avatar
Marc Lehmann committed
198
".$install;
Marc Lehmann's avatar
Marc Lehmann committed
199
200
}

Marc Lehmann's avatar
Marc Lehmann committed
201
sub MY::postamble {
Marc Lehmann's avatar
Marc Lehmann committed
202
   my $self=shift;
Marc Lehmann's avatar
Marc Lehmann committed
203
   my $install_program = $cfg{INSTALL};
Marc Lehmann's avatar
Marc Lehmann committed
204
205
   $install_program =~ s{^\.\./}{../../};
   my $GT = $IN_GIMP ? $install_program : "$GIMPTOOL --install-admin-bin";
Marc Lehmann's avatar
Marc Lehmann committed
206
   my $UT = $IN_GIMP ? '$(RM_F)' : "$GIMPTOOL --uninstall-admin-bin";
Marc Lehmann's avatar
Marc Lehmann committed
207
   my $GT2 = $IN_GIMP ? '$(gimpplugindir)/plug-ins/' : '';
Marc Lehmann's avatar
Marc Lehmann committed
208
   my $postamble="
Marc Lehmann's avatar
Marc Lehmann committed
209

Marc Lehmann's avatar
Marc Lehmann committed
210
objclean :: clean
Marc Lehmann's avatar
Marc Lehmann committed
211
212
maintainer-clean :: realclean
distclean :: realclean
213
check :: test
Marc Lehmann's avatar
Marc Lehmann committed
214

Marc Lehmann's avatar
Marc Lehmann committed
215
216
MY_FIXIN = \$(PERL) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) -MExtUtils::MakeMaker -e 'MY->fixin(\@ARGV)'

Marc Lehmann's avatar
Marc Lehmann committed
217
all ::
Marc Lehmann's avatar
Marc Lehmann committed
218
	$main::dont_embed || (cd embed && \$(MAKE) all)
Marc Lehmann's avatar
Marc Lehmann committed
219

Marc Lehmann's avatar
Marc Lehmann committed
220
clean ::
Marc Lehmann's avatar
Marc Lehmann committed
221
	$main::dont_embed || (cd embed && \$(MAKE) clean)
Marc Lehmann's avatar
Marc Lehmann committed
222
	test -f Makefile || mv -f Makefile.old Makefile
Marc Lehmann's avatar
Marc Lehmann committed
223
224
225
226
227
228
229
	\$(RM_RF) inst-temp

install-plugins ::
	\$(RM_RF) inst-temp
	\$(MKPATH) inst-temp
	cd inst-temp ; \\
	\$(UMASK_NULL) ; \\
Marc Lehmann's avatar
Marc Lehmann committed
230
	\$(CP) ".join(' ',map("'../examples/$_'",sort @pins))." ../Perl-Server . ; \\
Marc Lehmann's avatar
Marc Lehmann committed
231
	\$(CHMOD) 755 * ; \\
Marc Lehmann's avatar
Marc Lehmann committed
232
	\$(MY_FIXIN) * ; \\
Marc Lehmann's avatar
Marc Lehmann committed
233
	for plugin in * ; do \\
Marc Lehmann's avatar
Marc Lehmann committed
234
	   $GT \"\$\$plugin\" $GT2 ; \\
Marc Lehmann's avatar
Marc Lehmann committed
235
236
	done
	\$(RM_RF) inst-temp
Marc Lehmann's avatar
Marc Lehmann committed
237
238

uninstall :: force_uninstall_from_\$(INSTALLDIRS)dirs
Marc Lehmann's avatar
Marc Lehmann committed
239
	for plugin in Perl-Server @pins; do \\
Marc Lehmann's avatar
Marc Lehmann committed
240
241
242
243
244
245
246
247
248
           $UT $GT2\$\$plugin; \\
        done

force_uninstall_from_perldirs ::
	\$(PERL) -MExtUtils::Install -e 'uninstall(\$\$ARGV[0],1,0)' ".$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist')."

force_uninstall_from_sitedirs ::
	\$(PERL) -MExtUtils::Install -e 'uninstall(\$\$ARGV[0],1,0)' ".$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist')."

Marc Lehmann's avatar
Marc Lehmann committed
249
# generate tags file
Marc Lehmann's avatar
Marc Lehmann committed
250
251
tags: .
	ctags --lang=c `find . -name '*.xs' -print`
Marc Lehmann's avatar
Marc Lehmann committed
252
253
254
255
256

# run autoconf (&c)
autoconf:
	aclocal; autoheader; autoconf
        
Marc Lehmann's avatar
Marc Lehmann committed
257
258
# set \$VERSION in all modules
setver:
Marc Lehmann's avatar
Marc Lehmann committed
259
	\$(PERL) -pi -e 's/^(\\s*\\\$\$VERSION\\s*=\\s*).*\$\$/\$\${1}\$(VERSION);/' *.pm Gimp/*.pm UI/*.pm Net/*.pm
Marc Lehmann's avatar
Marc Lehmann committed
260

Marc Lehmann's avatar
Marc Lehmann committed
261
";
Marc Lehmann's avatar
Marc Lehmann committed
262
263

   $postamble;
Marc Lehmann's avatar
Marc Lehmann committed
264
265
}

Marc Lehmann's avatar
Marc Lehmann committed
266
$GIMP_INC_NOUI = "-I../../ $GIMP_INC_NOUI" if $IN_GIMP;
Marc Lehmann's avatar
Marc Lehmann committed
267
@DIRS= qw/Gimp Net UI/;
Marc Lehmann's avatar
Marc Lehmann committed
268
269

$build_module = $IN_GIMP || $ENV{GIMP_PERL_MODULE_INC};
Marc Lehmann's avatar
Marc Lehmann committed
270
271
# temporarily disabled because of politics
$build_module = $ENV{GIMP_PERL_MODULE_INC};
Marc Lehmann's avatar
Marc Lehmann committed
272
273
274
275

print "building embedded perl module... ";
if ($build_module) {
   print "yes\n";
Marc Lehmann's avatar
Marc Lehmann committed
276
   $dont_embed = "false";
Marc Lehmann's avatar
Marc Lehmann committed
277
   push(@DIRS,'Module');
Marc Lehmann's avatar
Marc Lehmann committed
278
   print "configuring in embed/Makefile...\n";
Marc Lehmann's avatar
Marc Lehmann committed
279
   system("cd embed && perl Makefile.PL");
Marc Lehmann's avatar
Marc Lehmann committed
280
} else {
Marc Lehmann's avatar
Marc Lehmann committed
281
   print "no\n";
Marc Lehmann's avatar
Marc Lehmann committed
282
283
284
   $dont_embed = "true";
}

Marc Lehmann's avatar
Marc Lehmann committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
print "writing Gimp/Config.pm... ";
{
   sub conf_eval {
      my $v = expand($cfg{$_[0]});
      $v =~ s/([\\\]])/\\$1/g;
      $v;
   }
   local $/,*FH;
   open FH,"<Gimp/Config.pm.in" or die "Gimp/Config.pm.in: $!\n";
   my $cfg = <FH>;
   $cfg =~ s/#CFG#/join "",
                        map sprintf("   %-20s => q[%s],\n",$_,conf_eval $_),
                            keys %cfg/e;
   open FH,">Gimp/Config.pm" or die "Gimp/Config.pm: $!\n";
   print(FH $cfg)>0 or die "Gimp/Config.pm: $!\n";
}
print "ok\n";

Marc Lehmann's avatar
Marc Lehmann committed
303
304
305
@EXE_FILES = qw(gimpdoc xcftopnm embedxpm);
push @EXE_FILES, qw(scm2perl scm2scm) if $PRD;

Marc Lehmann's avatar
Marc Lehmann committed
306
307
WriteMakefile(
    'dist'	=> {
Marc Lehmann's avatar
Marc Lehmann committed
308
	            PREOP	=> 'make setver && chmod -R u=rwX,go=rX . ;',
Marc Lehmann's avatar
Marc Lehmann committed
309
310
	            COMPRESS	=> 'gzip -9v',
	            SUFFIX	=> '.gz',
Marc Lehmann's avatar
Marc Lehmann committed
311
	           },
Marc Lehmann's avatar
Marc Lehmann committed
312
    'PREREQ_PM'	=> {
Marc Lehmann's avatar
Marc Lehmann committed
313
    		    Gtk			=> 0.5,
Marc Lehmann's avatar
Marc Lehmann committed
314
                    PDL			=> 1.99,
Marc Lehmann's avatar
Marc Lehmann committed
315
    		    Data::Dumper	=> 2.0,
Marc Lehmann's avatar
Marc Lehmann committed
316
                    Parse::RecDescent	=> 1.6,
Marc Lehmann's avatar
Marc Lehmann committed
317
		   },
Marc Lehmann's avatar
Marc Lehmann committed
318
    'DIR'	=> [@DIRS],
Marc Lehmann's avatar
Marc Lehmann committed
319
320
    'NAME'	=> 'Gimp',
    'VERSION_FROM' => 'Gimp.pm',
Marc Lehmann's avatar
Marc Lehmann committed
321
    'INSTALLBIN'=> $bindir,
Marc Lehmann's avatar
Marc Lehmann committed
322
323
324
325
326
327
    'PM'	=> {
    		    'Gimp.pm'		=> '$(INST_LIBDIR)/Gimp.pm',
    		    'Gimp/Data.pm'	=> '$(INST_LIBDIR)/Gimp/Data.pm',
    		    'Gimp/Fu.pm'	=> '$(INST_LIBDIR)/Gimp/Fu.pm',
    		    'Gimp/Lib.pm'	=> '$(INST_LIBDIR)/Gimp/Lib.pm',
    		    'Gimp/PDL.pm'	=> '$(INST_LIBDIR)/Gimp/PDL.pm',
Marc Lehmann's avatar
Marc Lehmann committed
328
    		    'Gimp/Util.pm'	=> '$(INST_LIBDIR)/Gimp/Util.pm',
Marc Lehmann's avatar
Marc Lehmann committed
329
    		    'Gimp/Feature.pm'	=> '$(INST_LIBDIR)/Gimp/Feature.pm',
Marc Lehmann's avatar
Marc Lehmann committed
330
331
    		    'Gimp/Module.pm'	=> '$(INST_LIBDIR)/Gimp/Module.pm',
    		    'Gimp/Config.pm'	=> '$(INST_LIBDIR)/Gimp/Config.pm',
Marc Lehmann's avatar
Marc Lehmann committed
332
    		   },
Marc Lehmann's avatar
Marc Lehmann committed
333
    'LDFROM'	=> expand("\$(OBJECT) $LIBS $INTLLIBS"),
Marc Lehmann's avatar
Marc Lehmann committed
334
335
    'INC'	=> "$INC1 $GIMP_INC_NOUI $CPPFLAGS $CFLAGS",
    'DEFINE'	=> "$DEFINE1 $DEFS",
Marc Lehmann's avatar
Marc Lehmann committed
336
    'EXE_FILES'	=> \@EXE_FILES,
Marc Lehmann's avatar
Marc Lehmann committed
337
    'macro'	=> \%cfg,
Marc Lehmann's avatar
Marc Lehmann committed
338
    'realclean'	=> { FILES => "config.status config.cache config.pl config.log config.h Gimp/Config.pm Makefile" },
Marc Lehmann's avatar
Marc Lehmann committed
339
    'clean'	=> { FILES => "Makefile.old stamp-h" },
Marc Lehmann's avatar
Marc Lehmann committed
340
341
342
343
344
);

$IN_GIMP or print <<EOF;


Marc Lehmann's avatar
Marc Lehmann committed
345
346
Hopefully, Gimp is now correctly configured. you can now enter "make",
"make test" and "make install".
Marc Lehmann's avatar
Marc Lehmann committed
347
348
349

EOF

Marc Lehmann's avatar
Marc Lehmann committed
350
__END__
Marc Lehmann's avatar
Marc Lehmann committed
351
352
353
354
355
356
357
358
359
360
# write an empty makefile (the last chance to stop)
# and warn the user.
sub not_halt {
   print STDERR "WARNING: *** perl extension will not be built ($_[0]) ***\n\n";
   open MAKEFILE,">Makefile" or die "unable to create Makefile: $!";
   print MAKEFILE <<EOF;
all install check:

clean mostlyclean objclean:

Marc Lehmann's avatar
Marc Lehmann committed
361
distclean maintainer-clean realclean clobber: clean
Marc Lehmann's avatar
Marc Lehmann committed
362
363
364
	\$(RM_F) Makefile config.cache config.pl config.log
        \$(RM_F) config.h config.status stamp-h Makefile.old Gimp/Config.pm
        \$(RM_RF) test-dir inst-temp
Marc Lehmann's avatar
Marc Lehmann committed
365
366
367
368
369
EOF
   close MAKEFILE;
   exit;
}

Marc Lehmann's avatar
Marc Lehmann committed
370
371