File: configure

package info (click to toggle)
netpbm-free 2%3A10.0-8sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,780 kB
  • ctags: 8,098
  • sloc: ansic: 101,856; perl: 1,321; sh: 772; makefile: 748; lex: 206; csh: 13
file content (798 lines) | stat: -rwxr-xr-x 26,414 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
#!/usr/bin/perl -w

die "You don't want to use this\nRead the comment at the start of the file";
# Sorry, but this script is probably broken
# 
# It is not changed for the new makefile methods, and we don't use it at
# debian, so we also don't test it. We're happy if someone fixes it, and
# would welcome patches on this.

use strict;
use English;

my ($TRUE, $FALSE) = (1,0);

# This program generates Makefile.config, which is included by all of the
# Netpbm makefiles.  You run this program as the first step in building 
# Netpbm.  (The second step is 'make').

# This program is only a convenience.  It is supported to create 
# Makefile.config any way you want.  In fact, an easy way is to copy
# Makefile.config.in and follow the instructions in the comments therein
# to uncomment certain lines and make other changes.

# Note that if you invoke 'make' without having first run 'configure',
# the make will call 'configure' itself when it finds
# 'Makefile.config' missing.  That might look a little messy to the
# user, but it isn't the normal build process.

# The argument to this program is the filepath of the Makefile.config.in
# file.  If unspecified, the default is 'Makefile.config.in' in the 
# current directory.

# For explanations of the stuff we put in the make files, see the comments
# in Makefile.config.in.

sub symlink_command();
sub getsvga($);

my $config_in_path;
if (@ARGV > 0) {
    $config_in_path = $ARGV[0];
} else {
    $config_in_path = "Makefile.config.in";
}

if (stat("Makefile.config")) {
    print("Discard existing Makefile.config?\n");
    print("Y or N (N) ==> ");

    my $answer = <STDIN>;
    chomp($answer);
    if (uc($answer) ne "Y") {
        exit(1);
    }
}

print("\n");

my $platform;
{
    print("Which of the following best describes your platform?\n");
 
    print("gnu      GNU/Linux\n");
    print("sun      Solaris or SunOS\n");
    print("hp       HP-UX\n");
    print("aix      AIX\n");
    print("win      Windows/DOS (Cygwin, DJGPP, Mingw32)\n");
    print("tru64    Tru64\n");
    print("irix     Irix\n");
    print("bsd      NetBSD, BSD/OS\n");
    print("openbsd  OpenBSD\n");
    print("osx      Darwin or Mac OS X\n");
    print("unixware Unixware\n");
    print("beos     BeOS\n");
    print("none     none of these are even close\n");
    print("\n");
    
    my $default;
    if ($OSNAME eq "linux") {
        $default = "gnu";
    } elsif ($OSNAME eq "aix") {
        $default = "aix";
    } elsif ($OSNAME eq "cygwin") {
        $default = "win";
    }
    # OK - if you know what $OSNAME is on any other platform, send me a patch!

    print("Your choice ");

    if (defined($default)) {
        print("($default)");
    }
    print("==> ");

    my $response = <STDIN>;

    print("\n");

    if (!defined($response)) {
        print("Aborting.\n");
        exit;
    }

    chomp($response);

    if ($response eq "") {
        if (defined($default)) {
            $response = $default;
        } else {
            print("Aborting.\n");
            exit;
        }
    }
        
    my %platform = ("gnu"      => "GNU",
                    "sun"      => "SOLARIS",
                    "hp"       => "HP-UX",
                    "aix"      => "AIX",
                    "tru64"    => "TRU64",
                    "irix"     => "IRIX",
                    "win"      => "WINDOWS",
                    "beos"     => "BEOS",
                    "bsd"      => "NETBSD",
                    "openbsd"  => "OPENBSD",
                    "unixware" => "UNIXWARE",
                    "osx"      => "DARWIN",
                    "none"     => "NONE"
                    );

    $platform = $platform{$response};
    if (!defined($platform)) {
        print("'$response' isn't one of the choices.\n");
        exit 8;
    }
}

if ($platform eq "NONE") {
    print("You will have to construct Makefile.config manually.  To do \n");
    print("this, copy Makefile.config.in as Makefile.config, and then \n");
    print("edit it.  Follow the instructions and examples in the file. \n");
    print("Please report your results to the Netpbm maintainer so he \n");
    print("can improve the configure program. \n");
    exit;
}

my $subplatform;

if ($platform eq "WINDOWS") {
    print("Are you building in/for the Cygwin environment?\n");
    print("\n");

    my $default;
    if ($OSNAME eq "cygwin") {
        $default = "y";
    } else {
        $default = "n";
    }

    print("(y)es or (n)o ($default)=> ");

    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    }

    if (uc($response) =~ /^(Y|YES)$/)  {
        $subplatform = "cygwin";
    } elsif (uc($response) =~ /^(N|NO)$/)  {
        $subplatform = "other";
    } else {
        print("'$response' isn't one of the choices.  \n" .
              "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
        exit 12;
    }
}
my $compiler;

if ($platform eq "SOLARIS") {
    print("GNU compiler or Sun compiler?\n");
    print("\n");

    my $default = "gcc";
    print("gcc or sun ($default)=> ");

    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    }
    if ($response eq "gcc") {
        $compiler = "gcc";
    } elsif ($response eq "sun") {
        $compiler = "sun";
    } else {
        print("'$response' isn't one of the choices.  \n" .
              "You must choose 'gcc' or 'sun'.\n");
        exit 12;
    }
}

my $default_target;

print("Do you want a regular build or a merge build (see README)?\n");
print("\n");

{
    my $default = "regular";
    print("regular or merge ($default)=> ");
    
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    }
    if ($response eq "regular") {
        $default_target = "nonmerge";
    } elsif ($response eq "merge") {
        $default_target = "merge";
    } else {
        print("'$response' isn't one of the choices.  \n" .
              "You must choose 'regular' or 'merge'.\n");
        exit 12;
    }
}

print("\n");

my ($netpbmlibtype, $netpbmlibsuffix, $shlibprefixlist);
my $willBuildShared;

print("Do you want static-linked Netpbm libraries or shared?\n");
print("\n");

{
    my $default = ($default_target eq "merge") ? "static" : "shared";

    print("static or shared ($default)=> ");

    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    }
    if ($response eq "shared") {
        $willBuildShared = $TRUE;
        if ($platform eq "WINDOWS") {
            $netpbmlibtype = "dll";
            $netpbmlibsuffix = "dll";
            if ($subplatform eq 'cygwin') {
                $shlibprefixlist = "cyg lib";
            } else {
                $shlibprefixlist = "lib";
            }
        } elsif ($platform eq "DARWIN") {
            $netpbmlibtype = "dylib";
            $netpbmlibsuffix = "dylib";
            $shlibprefixlist = "lib";
        } else {
            $netpbmlibtype = "unixshared";
            if ($platform eq "AIX") {
                $netpbmlibsuffix = "a";
            } elsif ($platform eq "HP-UX") {
                $netpbmlibsuffix = "sl";
            } else {
                $netpbmlibsuffix = "so";
            }
            $shlibprefixlist = "lib";
        }
    } elsif ($response eq "static") {
        $willBuildShared = $FALSE;
        $netpbmlibtype = "unixstatic";
        $netpbmlibsuffix = "a";
        $shlibprefixlist = "lib"; # not used in Makefile static
        # targets, but needed for building
        # libopt 
    } else {
        print("'$response' isn't one of the choices.  \n" .
              "You must choose 'static' or 'shared'.\n");
        exit 12;
    }
}
print("\n");

my $staticlib_too;

if ($netpbmlibtype eq "unixshared" or $netpbmlibtype eq "dll") {
    print("Do you want to build static libraries too (for linking to \n");
    print("programs not in the Netpbm package?\n");
    print("\n");

    my $default = "y";

    print("(y)es or (n)o ($default)=> ");

    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = "y";
    } 
    if (uc($response) =~ /^(Y|YES)$/)  {
        $staticlib_too = "y";
    } elsif (uc($response) =~ /^(N|NO)$/)  {
        $staticlib_too = "n";
    } else {
        print("'$response' isn't one of the choices.  \n" .
              "You must choose 'yes' or 'no' (or 'y' or 'n').\n");
        exit 12;
    }
} else {
    $staticlib_too = "n";
}
print("\n");


#******************************************************************************
#
#  INSTALLATION QUESTIONS
#
#*****************************************************************************

print("The remaining questions concern how Netpbm is installed when you do\n");
print("'make install'.  None of these answers affect what gets built by\n");
print("'make'.  In particular, none of the directory paths you specify\n");
print("are built into any Netpbm program or library -- you can move them\n");
print("around as you like.\n");
print("\n");

my $install_prefix;

print("Enter the installation directory.  Everything gets installed under\n");
print("This directory.  If you want to spread Netpbm across your system,\n");
print("specify '/'\n");
print("\n");

{
    my $default;
    if ($platform eq "TRU64") {
        $default = "/usr/local1/DEC/packages/netpbm";
    } elsif ($platform eq "WINDOWS" and stat("/djgpp")) {
        $default = "/djgpp";
    } elsif ($platform eq "WINDOWS" and $subplatform eq "cygwin") {
        $default = "/usr/local";
    } else {
        $default = "/usr/local/netpbm";
    }

    print("install prefix ($default)=> ");
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    }
    $install_prefix = $response;
}
print("\n");

my $installbinaries;

print("Enter the install location for programs, relative to " .
      "$install_prefix.\n");
print("\n");
{
    my $default;
    if ($platform eq "WINDOWS") {
        $default = "bin/netpbm";
    } else {
        $default = "bin";
    }
    print("program directory ($default)=> ");
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    } elsif (substr($response,0,1) eq "/") {
        die("Cannot start with '/'.  This is a _relative_ path.");
    }
    $installbinaries = '$(INSTALL_PREFIX)/' . $response;
}
print("\n");

my $installlibs;

if ($willBuildShared) {
    print("Enter the install location for shared (runtime) libraries,\n");
    print("relative to $install_prefix.\n");
    print("\n");
    {
        my $default = "lib";
        print("library directory ($default)=> ");
        my $response = <STDIN>;
        chomp($response);
        if ($response eq "") {
            $response = $default;
        } elsif (substr($response,0,1) eq "/") {
            die("Cannot start with '/'.  This is a _relative_ path.");
        }
        $installlibs = '$(INSTALL_PREFIX)/' . $response;
    }
}
print("\n");

my $installstaticlibs;

print("Enter the install location for linktime libraries,\n");
print("relative to $install_prefix.\n");
print("These are libraries that get used when you build a program that\n");
print("is not in the Netpbm package, but uses the Netpbm subroutine\n");
print("libraries.  This includes both static-linking libraries and\n");
print("stubs for shared libraries\n");
print("\n");
{
    my $default = "lib";
    print("link directory ($default)=> ");
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    } elsif (substr($response,0,1) eq "/") {
        die("Cannot start with '/'.  This is a _relative_ path.");
    }
    $installstaticlibs = '$(INSTALL_PREFIX)/' . $response;
}
print("\n");

my $installhdrs;

print("Enter the install location for interface headers,\n");
print("relative to $install_prefix.\n");
print("These get used when you compile a program which is not in the\n");
print("Netpbm package, but uses the Netpbm subroutine libraries.\n");
print("\n");
{
    my $default = "include";
    print("header directory ($default)=> ");
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    } elsif (substr($response,0,1) eq "/") {
        die("Cannot start with '/'.  This is a _relative_ path.");
    }
    $installhdrs = '$(INSTALL_PREFIX)/' . $response;
}
print("\n");

my $installman;

print("Enter the install location for man pages,\n");
print("relative to $install_prefix.\n");
print("\n");
{
    my $default = "man";
    print("man page directory ($default)=> ");
    my $response = <STDIN>;
    chomp($response);
    if ($response eq "") {
        $response = $default;
    } elsif (substr($response,0,1) eq "/") {
        die("Cannot start with '/'.  This is a _relative_ path.");
    }
    $installman = '$(INSTALL_PREFIX)/' . $response;
}
print("\n");

my ($linuxsvgahdr, $linuxsvgalib) = getsvga($platform);

#******************************************************************************
#
#  BUILD THE FILE
#
#*****************************************************************************

my @Makefile_config;
    # This is the complete Makefile.config contents.  We construct it here
    # and ultimately write the whole thing out as Makefile.config.

# First, we just read the 'Makefile.config.in' in

open (CONFIG_IN,"<$config_in_path") or
    die("Unable to open file '$config_in_path' for input.  That file is " .
    "supposed to be in the Netpbm source top level directory, the " .
    "same as the 'configure' program.");

@Makefile_config = <CONFIG_IN>;

unshift(@Makefile_config, 
        "####This file was automatically created by 'configure.'\n",
        "####Many variables are set twice -- a generic setting, then \n",
        "####a system-specific override at the bottom of the file.\n",
        "####\n");

close(CONFIG_IN);

# Now, add the variable settings that override the default settings that are
# done by the Makefile.config.in contents.

push(@Makefile_config, "\n\n\n\n");
push(@Makefile_config, "####Lines above were copied from Makefile.config.in " .
     "by 'configure'.\n");
push(@Makefile_config, "####Lines below were added by 'configure' based on " .
     "the $platform platform.\n");


push(@Makefile_config, "DEFAULT_TARGET = $default_target\n");

push(@Makefile_config, "NETPBMLIBTYPE=$netpbmlibtype\n");
push(@Makefile_config, "NETPBMLIBSUFFIX=$netpbmlibsuffix\n");
push(@Makefile_config, "SHLIBPREFIXLIST=$shlibprefixlist\n");

push(@Makefile_config, "STATICLIB_TOO=$staticlib_too\n");


if ($platform eq "GNU") {
    # All the defaults are designed for a typical GNU system, so we don't
    # have to do much here.

#    # Red Hat Linux doesn't have 'ginstall', for some crazy reason, but
#    # of course 'install' is GNU install.
#    my $ginstall_result = `ginstall --version 2>/dev/null`;
#    if (!$ginstall_result) {
#        # System doesn't have 'ginstall', so use 'install' instead.
#        push(@Makefile_config, "INSTALL = install\n");
#   }
    push(@Makefile_config, "CFLAGS = -pedantic -O3 " .
         "-Wall -Wno-uninitialized -Wmissing-declarations\n");
# The merged programs have a main_XXX subroutine instead of main(),
# which would cause a warning with -Wmissing-declarations
    push(@Makefile_config, "CFLAGS_MERGE = -Wno-missing-declarations\n");
} elsif ($platform eq "SOLARIS") {
#    push(@Makefile_config, "INSTALL = /usr/ucb/install\n");
    # If the system uses gcc as a linker, the following LDFLAGS isn't right.
    push(@Makefile_config, 'LDFLAGS = -R$(INSTALLLIBS)', "\n");
    # If the system uses GNU Ld, the following LDSHLIB isn't right.
    push(@Makefile_config, 
         'LDSHLIB = -Wl,-B,dynamic,-G,-h,$(SONAME) -R$(INSTALLLIBS)', "\n");
    push(@Makefile_config, 'NEED_RUNTIME_PATH = Y', "\n");
    if ($compiler eq "sun") {
        push(@Makefile_config, "CC = cc\n");
        push(@Makefile_config, "CFLAGS = -O\n");
        push(@Makefile_config, "CFLAGS_SHLIB = -Kpic\n");
    }
    push(@Makefile_config, "NETWORKLD = -lsocket -lnsl\n");
} elsif ($platform eq "HP-UX") {
    push(@Makefile_config, 'CFLAGS = -O3 -fPIC $(CDEBUG)', "\n");
    push(@Makefile_config, 'LDFLAGS = -Wl,+b,/usr/pubsw/lib', "\n");
} elsif ($platform eq "AIX") {
    push(@Makefile_config, 'CFLAGS = -O3 -D_ALL_SOURCE $(CDEBUG)', "\n");
    push(@Makefile_config, 'LDFLAGS = -L /usr/pubsw/lib', "\n");
} elsif ($platform eq "TRU64") {
    push(@Makefile_config, "CC=cc\n");
    push(@Makefile_config, "LD=cc\n");
#    push(@Makefile_config, "INSTALL = installbsd\n");
    push(@Makefile_config, 'CFLAGS = -O2 -std1 -DLONG_32 $(CDEBUG)', "\n");
    push(@Makefile_config, "LDFLAGS = -call_shared -oldstyle_liblookup\n");
    push(@Makefile_config, "LDSHLIB = -shared -expect_unresolved \"*\"\n");
    push(@Makefile_config, "TIFFHDR_DIR = /usr/local1/DEC/include\n");
    push(@Makefile_config, "TIFFLIB_DIR = /usr/local1/DEC/lib\n");
    push(@Makefile_config, "JPEGLIB_DIR = /usr/local1/DEC/lib\n");
    push(@Makefile_config, "JPEGHDR_DIR = /usr/local1/DEC/include\n");
    push(@Makefile_config, "PNGLIB_DIR = /usr/local1/DEC/lib\n");
    push(@Makefile_config, "PNGHDR_DIR = /usr/local1/DEC/include\n");
    push(@Makefile_config, "NETWORKLD = NONE\n");
} elsif ($platform eq "IRIX") {
    push(@Makefile_config, "CC=cc\n");
#    push(@Makefile_config, "INSTALL = install\n");
    push(@Makefile_config, 'MANCP = $(SRCDIR)/buildtools/mantocat', "\n");
    push(@Makefile_config, 'RANLIB = true', "\n");
    push(@Makefile_config, 'CFLAGS = -n32 -O3', "\n");
    push(@Makefile_config, 'LDFLAGS = -n32', "\n");
    push(@Makefile_config, 'LDSHLIB = -shared -n32', "\n");
} elsif ($platform eq "WINDOWS") {
    # Until 9.15 (June 2001), we set MANCP here because it appeared that DJGPP
    # required it.  Now I'm not sure.
#    push(@Makefile_config, 'MANCP = $(SRCDIR)/buildtools/mantocat', "\n");
    push(@Makefile_config, "EXE = .exe\n");
    push(@Makefile_config, "NETWORKLD = NONE\n");
#    # Though it may not have the link as "ginstall", "install" in a Windows
#    # Unix environment is usually GNU install.
#    my $ginstall_result = `ginstall --version 2>/dev/null`;
#    if (!$ginstall_result) {
#        # System doesn't have 'ginstall', so use 'install' instead.
#        push(@Makefile_config, "INSTALL = install\n");
#    }
    push(@Makefile_config, 'SYMLINK = ', symlink_command(), "\n");
    push(@Makefile_config, "LDSHLIB = " . 
         '-shared -Wl,--enable-auto-image-base', "\n");
    push(@Makefile_config, 'TIFFHDR_DIR = /usr/include', "\n");
    push(@Makefile_config, 'TIFFLIB_DIR = /usr/lib', "\n");
    push(@Makefile_config, 'JPEGLIB_DIR = /usr/lib', "\n");
    push(@Makefile_config, 'JPEGHDR_DIR = /usr/include', "\n");
    push(@Makefile_config, 'PNGLIB_DIR = /usr/lib', "\n");
    push(@Makefile_config, 'PNGHDR_DIR = /usr/include', "\n");
    push(@Makefile_config, 'ZLIB_DIR = /usr/lib', "\n");
    push(@Makefile_config, 'ZHDR_DIR = /usr/include', "\n");
} elsif ($platform eq "BEOS") {
    push(@Makefile_config, "LDSHLIB = -nostart\n");
} elsif ($platform eq "NETBSD") {
    push(@Makefile_config, 'LDFLAGS = -Wl,--rpath,$(INSTALLLIBS)', "\n");
    push(@Makefile_config, 'CFLAGS_SHLIB = -fpic', "\n");
    push(@Makefile_config, 'TIFFHDR_DIR = $(LOCALBASE)/include', "\n");
    push(@Makefile_config, 'TIFFLIB_DIR = $(LOCALBASE)/lib', "\n");
    push(@Makefile_config, 'JPEGLIB_DIR = $(LOCALBASE)/lib', "\n");
    push(@Makefile_config, 'JPEGHDR_DIR = $(LOCALBASE)/include', "\n");
    push(@Makefile_config, 'PNGLIB_DIR = $(LOCALBASE)/lib', "\n");
    push(@Makefile_config, 'PNGHDR_DIR = $(LOCALBASE)/include', "\n");
    push(@Makefile_config, "\n");
} elsif ($platform eq "OPENBSD") {
    # vedge@vedge.com.ar says on 2001.04.29 that there are a ton of 
    # undefined symbols in the Fiasco stuff on OpenBSD.  So we'll just
    # cut it out of the build until someone feels like fixing it.
    push(@Makefile_config, 'BUILD_FIASCO = N', "\n");
} elsif ($platform eq "UNIXWARE") {
    # Nothing to do.
} elsif ($platform eq "DARWIN") {
    push(@Makefile_config, "CC = cc -no-cpp-precomp\n");
    push(@Makefile_config, 'CFLAGS_SHLIB = -fno-common', "\n");
    push(@Makefile_config, 'LDSHLIB = -dynamiclib -install_name $(INSTALLLIBS)/lib$(LIBROOT).$(MAJ).dylib', "\n");
#    push(@Makefile_config, "INSTALL = install\n");
    push(@Makefile_config, 'TIFFHDR_DIR = $(LOCALBASE)/include', "\n");
    push(@Makefile_config, 'TIFFLIB_DIR = $(LOCALBASE)/lib', "\n"); 
    push(@Makefile_config, 'JPEGLIB_DIR = $(LOCALBASE)/lib', "\n");     
    push(@Makefile_config, 'JPEGHDR_DIR = $(LOCALBASE)/include', "\n");
    push(@Makefile_config, 'PNGLIB_DIR = $(LOCALBASE)/lib', "\n");
    push(@Makefile_config, 'PNGHDR_DIR = $(LOCALBASE)/include', "\n");
} else {
    die ("Internal error: invalid value for \$platform: '$platform'\n");
}


my $flex_result = `flex --version`;
if (!$flex_result) {
    # System doesn't have 'flex'.  Maybe 'lex' will work; we don't really
    # know yet.  2001.05.16.

    # lex may work; we don't really know yet.  Schwarb Manfred reports
    # that it compiles OK, but with warnings, on Solaris.  Solaris Lex
    # has a -e option that eliminates the lex warnings, but causes
    # compiler warnings.  AIX and Flex don't have a -e option.
    # -Bryan 2001.05.16.

    push(@Makefile_config, "LEX = lex\n"); 

    # We could also set LEX to null, and then the one part that requires
    # it -- thinkjettopbm -- would simply not get built.

#    print("\n");
#    print("There is no 'flex' command in your environment, so we will not\n");
#    print("Build the part that requires it: thinkjettopbm.\n");

#    print("\n");
#    print("Press ENTER to continue.\n");
    my $key = <STDIN>;
}

if (defined($linuxsvgahdr)) {
    push(@Makefile_config, "LINUXSVGAHDR_DIR = $linuxsvgahdr\n");
}
if (defined($linuxsvgalib)) {
    push(@Makefile_config, "LINUXSVGALIB_DIR = $linuxsvgalib\n");
}

push(@Makefile_config, "INSTALL_PREFIX = $install_prefix\n");
push(@Makefile_config, "# Some people specify PREFIX= on the command line, " .
     "because that's conventional\n");
push(@Makefile_config, 'ifneq ($(PREFIX)x,x)', "\n");
push(@Makefile_config, '  INSTALL_PREFIX = $(PREFIX)', "\n");
push(@Makefile_config, 'endif', "\n");

if (defined($installbinaries)) {
    push(@Makefile_config, "INSTALLBINARIES = $installbinaries\n");
}
if (defined($installlibs)) {
    push(@Makefile_config, "INSTALLLIBS = $installlibs\n");
}
if (defined($installstaticlibs)) {
    push(@Makefile_config, "INSTALLSTATICLIBS = $installstaticlibs\n");
}
if (defined($installhdrs)) {
    push(@Makefile_config, "INSTALLHDRS = $installhdrs\n");
}
if (defined($installman)) {
    push(@Makefile_config, "INSTALLMAN = $installman\n");
}



#******************************************************************************
#
#  WRITE OUT THE FILE
#
#*****************************************************************************

open(MAKEFILE_CONFIG, ">Makefile.config") or
    die("Unable to open Makefile.config for writing in the current " .
        "directory.");

print MAKEFILE_CONFIG @Makefile_config;

close(MAKEFILE_CONFIG) or
    die("Error:  Close of Makefile.config failed.\n");

print("\n");
print("We have created the file 'Makefile.config'.  You can now \n");
print("proceed to enter the 'make' command.\n");
print("\n");
print("Note, however, that we guessed a lot at your configuration,\n");
print("and you may want to look at Makefile.config and\n");
print("edit it to your requirements and taste before doing the make. \n");

exit 0;          
    


sub symlink_command() {

    my $retval;

    # Some Windows environments don't have symbolic links (or even a
    # simulation via a "ln" command, but have a "cp" command which works
    # in a pinch.
    
    # I wish I knew how to eliminate the stderr messages from these,
    # but I don't think I can count on /dev/null existing on these
    # systems.
    print("We now check to see if the 'ln' and 'cp' commands exist on \n");
    print("your system.  Ignore any error messages.\n");
    my $ln_rc = system("ln");
    my $cp_rc = system("cp");

    # I think 127 is universally the return code for "command not found"
    if ($ln_rc != 127) {
        $retval = "ln -s";
    } elsif ($cp_rc != 127) {
        $retval = "cp";
    } else {
        # Well, maybe we just made a mistake.
        $retval = "ln -s";
    }
    return $retval;
}

sub getsvga($) {
    my ($platform) = @_;

    my ($linuxsvgahdr, $linuxsvgalib);

    if ($platform eq "GNU") {
        # Look for SVGALIB 
        if (-f "/usr/include/vga.h") {
            $linuxsvgahdr = "/usr/include";
        } elsif (-d "/usr/include/svgalib") {
            $linuxsvgahdr = "/usr/include/svgalib";
        } else {
            print("Cannot find the include files for SVGALIB.  Enter the " .
                  "directory where they reside, or NONE.  " .
                  "If NONE, a default " .
                  "make will not build programs that require " .
                  "the SVGALIB library.\n");

            print("Svgalib header location (NONE)=> ");

            my $response = <STDIN>;
            chomp($response);
            if ($response eq "") {
                $response = "NONE";
            }
            $linuxsvgahdr = $response;
        }
        if ($linuxsvgahdr eq "NONE") {
            $linuxsvgalib = "NONE";
        } else {
            if (-f "/usr/lib/svgalib.so") {
                $linuxsvgalib = "/usr/lib/svgalib.so";
            } elsif (-d "/usr/link/svgalib") {
                $linuxsvgalib = "/usr/link/svgalib";
            } else {
                print("Cannot find the link libraries for SVGALIB.  " .
                      "Enter the " .
                      "directory where they reside, or NONE.  If NONE, " .
                      "a default make will not build programs that require " .
                      "the SVGALIB library.\n");

                print("Svgalib link lib location (NONE)=> ");

                my $response = <STDIN>;
                chomp($response);
                if ($response eq "") {
                    $response = "NONE";
                }
                $linuxsvgalib = $response;
            }
        }
    }
    return($linuxsvgahdr, $linuxsvgalib);
}