~ubuntu-branches/debian/squeeze/putty/squeeze

« back to all changes in this revision

Viewing changes to mkfiles.pl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-05-28 09:28:32 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080528092832-88epkb3d4s1zsw61
Tags: 0.60-3
* Move putty to Applications/Network/Communication menu sub-section.
* Use dh_desktop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#    are hardwired, and also the libraries are fixed. This is
13
13
#    mainly because I was too scared to go anywhere near it.
14
14
#  - sbcsgen.pl is still run at startup.
 
15
#
 
16
# FIXME: no attempt made to handle !forceobj in the project files.
15
17
 
16
18
use FileHandle;
17
19
use Cwd;
52
54
  if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
53
55
  if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
54
56
  if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
 
57
  if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
55
58
  if ($_[0] eq "!begin") {
56
59
      if (&mfval($_[1])) {
57
60
          $sect = $_[2] ? $_[2] : "end";
212
215
    # Returns true if the argument is a known makefile type. Otherwise,
213
216
    # prints a warning and returns false;
214
217
    if (grep { $type eq $_ }
215
 
        ("vc","vcproj","cygwin","borland","lcc","gtk","mpw","osx")) {
 
218
        ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","ac","mpw",
 
219
         "osx",)) {
216
220
            return 1;
217
221
        }
218
222
    warn "$.:unknown makefile type '$type'\n";
296
300
  $splitchar = (defined $splitchar ? $splitchar : '\\');
297
301
  while (length $line > $len) {
298
302
    $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
299
 
    $result .= $1 . " ${splitchar}\n\t\t";
 
303
    $result .= $1;
 
304
    $result .= " ${splitchar}\n\t\t" if $2 ne '';
300
305
    $line = $2;
301
306
    $len = 60;
302
307
  }
324
329
      s/\//$dirsep/g;
325
330
      $_ = $prefix . $_;
326
331
    } @deps;
327
 
    push @ret, {obj => $x, deps => [@deps]};
 
332
    push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
328
333
  }
329
334
  return @ret;
330
335
}
375
380
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
376
381
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
377
382
    # gcc command line option is -D not /D
378
 
    ($_ = $help) =~ s/=\/D/=-D/gs;
 
383
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
379
384
    print $_;
380
385
    print
381
386
    "\n".
391
396
    "# RCINC = --include-dir c:\\cygwin\\include\\\n".
392
397
    "\n".
393
398
    &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
394
 
      " -D_NO_OLDNAMES -DNO_MULTIMON " .
 
399
      " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
395
400
               (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
396
401
               "\n".
397
402
    "LDFLAGS = -mno-cygwin -s\n".
415
420
                       $objstr . " $libstr", 69), "\n\n";
416
421
    }
417
422
    foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
418
 
      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
419
 
        "\n";
 
423
      if ($forceobj{$d->{obj_orig}}) {
 
424
        printf ("%s: FORCE\n", $d->{obj});
 
425
      } else {
 
426
        print &splitline(sprintf("%s: %s", $d->{obj},
 
427
                         join " ", @{$d->{deps}})), "\n";
 
428
      }
420
429
      if ($d->{obj} =~ /\.res\.o$/) {
421
430
          print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";
422
431
      } else {
423
 
          print "\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c ".$d->{deps}->[0]."\n\n";
 
432
          print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
424
433
      }
425
434
    }
426
435
    print "\n";
427
436
    print $makefile_extra{'cygwin'}->{'end'};
428
437
    print "\nclean:\n".
429
438
    "\trm -f *.o *.exe *.res.o *.map\n".
430
 
    "\n";
 
439
    "\n".
 
440
    "FORCE:\n";
431
441
    select STDOUT; close OUT;
432
442
 
433
443
}
454
464
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
455
465
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
456
466
    # bcc32 command line option is -D not /D
457
 
    ($_ = $help) =~ s/=\/D/=-D/gs;
 
467
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
458
468
    print $_;
459
469
    print
460
470
    "\n".
463
473
    "MAKEFILE = Makefile.bor\n".
464
474
    "\n".
465
475
    "# C compilation flags\n".
466
 
    "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
 
476
    "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
 
477
    "# Resource compilation flags\n".
 
478
    "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
467
479
    "\n".
468
480
    "# Get include directory for resource compiler\n".
469
481
    "!if !\$d(BCB)\n".
474
486
    "\n".
475
487
    ".c.obj:\n".
476
488
    &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
477
 
               " \$(XFLAGS) \$(CFLAGS) ".
 
489
               " \$(CFLAGS) \$(XFLAGS) ".
478
490
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
479
491
               " /c \$*.c",69)."\n".
480
492
    ".rc.res:\n".
481
493
    &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
482
 
      " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
 
494
      " \$(RCFLAGS) \$*.rc",69)."\n".
483
495
    "\n";
484
496
    print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
485
497
    print "\n\n";
519
531
      print "\n";
520
532
    }
521
533
    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
522
 
      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
523
 
        "\n";
 
534
      if ($forceobj{$d->{obj_orig}}) {
 
535
        printf("%s: FORCE\n", $d->{obj});
 
536
      } else {
 
537
        print &splitline(sprintf("%s: %s", $d->{obj},
 
538
                                 join " ", @{$d->{deps}})), "\n";
 
539
      }
524
540
    }
525
541
    print "\n";
526
542
    print $makefile_extra{'borland'}->{'end'};
534
550
    "\t-del *.pdb\n".
535
551
    "\t-del *.rsp\n".
536
552
    "\t-del *.tds\n".
537
 
    "\t-del *.\$\$\$\$\$\$\n";
 
553
    "\t-del *.\$\$\$\$\$\$\n".
 
554
    "\n".
 
555
    "FORCE:\n".
 
556
    "\t-rem dummy command\n";
538
557
    select STDOUT; close OUT;
539
558
}
540
559
 
557
576
      "# C compilation flags\n".
558
577
      "CFLAGS = /nologo /W3 /O1 " .
559
578
      (join " ", map {"-I$dirpfx$_"} @srcdirs) .
560
 
      " /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
 
579
      " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
561
580
      "LFLAGS = /incremental:no /fixed\n".
 
581
      "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
562
582
      "\n".
563
583
      $makefile_extra{'vc'}->{'vars'} .
564
584
      "\n".
591
611
        print "\n";
592
612
    }
593
613
    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
594
 
        print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
595
 
          "\n";
 
614
        $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
 
615
        print &splitline(sprintf("%s: %s", $d->{obj},
 
616
                                 join " ", @$extradeps, @{$d->{deps}})), "\n";
596
617
        if ($d->{obj} =~ /.obj$/) {
597
 
            print "\tcl \$(COMPAT) \$(XFLAGS) \$(CFLAGS) /c ".$d->{deps}->[0],"\n\n";
 
618
            print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
598
619
        } else {
599
 
            print "\trc \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 ".$d->{deps}->[0],"\n\n";
 
620
            print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
600
621
        }
601
622
    }
602
623
    print "\n";
646
667
    # Get names of all Windows projects (GUI and console)
647
668
    my @prognames = &prognames("G:C");
648
669
    foreach $progname (@prognames) {
649
 
        create_project(\%all_object_deps, $progname);
 
670
      create_vc_project(\%all_object_deps, $progname);
650
671
    }
651
672
    # Create the workspace file
652
673
    open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
688
709
    select STDOUT; close OUT;
689
710
    chdir $orig_dir;
690
711
 
691
 
    sub create_project {
 
712
    sub create_vc_project {
692
713
        my ($all_object_deps, $progname) = @_;
693
714
        # Construct program's dependency info
694
715
        %seen_objects = ();
896
917
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
897
918
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
898
919
    # gcc command line option is -D not /D
899
 
    ($_ = $help) =~ s/=\/D/=-D/gs;
 
920
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
900
921
    print $_;
901
922
    print
902
923
    "\n".
906
927
    "\n".
907
928
    &splitline("CFLAGS = -O2 -Wall -Werror -g " .
908
929
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
909
 
               " `gtk-config --cflags`")."\n".
910
 
    "XLDFLAGS = `gtk-config --libs`\n".
911
 
    "ULDFLAGS =#\n".
 
930
               " `gtk-config --cflags`").
 
931
                 " -D _FILE_OFFSET_BITS=64\n".
 
932
    "XLDFLAGS = \$(LDFLAGS) `gtk-config --libs`\n".
 
933
    "ULDFLAGS = \$(LDFLAGS)\n".
912
934
    "INSTALL=install\n",
913
935
    "INSTALL_PROGRAM=\$(INSTALL)\n",
914
936
    "INSTALL_DATA=\$(INSTALL)\n",
930
952
      $objstr = &objects($p, "X.o", undef, undef);
931
953
      print &splitline($prog . ": " . $objstr), "\n";
932
954
      $libstr = &objects($p, undef, undef, "-lX");
933
 
      print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
934
 
                       $objstr . " $libstr", 69), "\n\n";
935
 
    }
936
 
    foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
937
 
      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
938
 
          "\n";
939
 
      print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
940
 
    }
941
 
    print "\n";
942
 
    print $makefile_extra{'gtk'}->{'end'};
943
 
    print "\nclean:\n".
944
 
    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
 
955
      print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
 
956
                       $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
 
957
    }
 
958
    foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
 
959
      if ($forceobj{$d->{obj_orig}}) {
 
960
        printf("%s: FORCE\n", $d->{obj});
 
961
      } else {
 
962
        print &splitline(sprintf("%s: %s", $d->{obj},
 
963
                                 join " ", @{$d->{deps}})), "\n";
 
964
      }
 
965
      print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
 
966
    }
 
967
    print "\n";
 
968
    print $makefile_extra{'gtk'}->{'end'};
 
969
    print "\nclean:\n".
 
970
    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
 
971
    print "\nFORCE:\n";
 
972
    select STDOUT; close OUT;
 
973
}
 
974
 
 
975
if (defined $makefiles{'ac'}) {
 
976
    $dirpfx = &dirpfx($makefiles{'ac'}, "/");
 
977
 
 
978
    ##-- Unix/autoconf makefile
 
979
    open OUT, ">$makefiles{'ac'}"; select OUT;
 
980
    print
 
981
    "# Makefile.in for $project_name under Unix with Autoconf.\n".
 
982
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
 
983
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
 
984
    # gcc command line option is -D not /D
 
985
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
 
986
    print $_;
 
987
    print
 
988
    "\n".
 
989
    "CC = \@CC\@\n".
 
990
    "\n".
 
991
    &splitline("CFLAGS = \@CFLAGS\@ \@CPPFLAGS\@ \@DEFS\@ \@GTK_CFLAGS\@ " .
 
992
               (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
 
993
    "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
 
994
    "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
 
995
    "INSTALL=\@INSTALL\@\n",
 
996
    "INSTALL_PROGRAM=\$(INSTALL)\n",
 
997
    "INSTALL_DATA=\$(INSTALL)\n",
 
998
    "prefix=\@prefix\@\n",
 
999
    "exec_prefix=\@exec_prefix\@\n",
 
1000
    "bindir=\@bindir\@\n",
 
1001
    "mandir=\@mandir\@\n",
 
1002
    "man1dir=\$(mandir)/man1\n",
 
1003
    "\n".
 
1004
    $makefile_extra{'gtk'}->{'vars'} .
 
1005
    "\n".
 
1006
    ".SUFFIXES:\n".
 
1007
    "\n".
 
1008
    "\n".
 
1009
    "all: \@all_targets\@\n".
 
1010
    &splitline("all-cli:" . join "", map { " $_" } &progrealnames("U"))."\n".
 
1011
    &splitline("all-gtk:" . join "", map { " $_" } &progrealnames("X"))."\n";
 
1012
    print "\n";
 
1013
    foreach $p (&prognames("X:U")) {
 
1014
      ($prog, $type) = split ",", $p;
 
1015
      $objstr = &objects($p, "X.o", undef, undef);
 
1016
      print &splitline($prog . ": " . $objstr), "\n";
 
1017
      $libstr = &objects($p, undef, undef, "-lX");
 
1018
      print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
 
1019
                       $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
 
1020
    }
 
1021
    foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
 
1022
      if ($forceobj{$d->{obj_orig}}) {
 
1023
        printf("%s: FORCE\n", $d->{obj});
 
1024
      } else {
 
1025
        print &splitline(sprintf("%s: %s", $d->{obj},
 
1026
                                 join " ", @{$d->{deps}})), "\n";
 
1027
      }
 
1028
      print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
 
1029
    }
 
1030
    print "\n";
 
1031
    print $makefile_extra{'gtk'}->{'end'};
 
1032
    print "\nclean:\n".
 
1033
    "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
 
1034
    print "\nFORCE:\n";
945
1035
    select STDOUT; close OUT;
946
1036
}
947
1037
 
952
1042
    "# Makefile for $project_name under MPW.\n#\n".
953
1043
    "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
954
1044
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
955
 
    # MPW command line option is -d not /D
956
 
    ($_ = $help) =~ s/=\/D/=-d /gs;
 
1045
    # MPW command line option is -d not /D (FIXME further massaging?)
 
1046
    ($_ = $help) =~ s/([=" ])\/D/\1-d /gs;
957
1047
    print $_;
958
1048
    print "\n\n".
959
1049
    "ROptions     = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1095
1185
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1096
1186
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1097
1187
    # lcc command line option is -D not /D
1098
 
    ($_ = $help) =~ s/=\/D/=-D/gs;
 
1188
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1099
1189
    print $_;
1100
1190
    print
1101
1191
    "\n".
1107
1197
    "CFLAGS = -D_WINDOWS " .
1108
1198
      (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1109
1199
      "\n".
 
1200
    "# Resource compilation flags\n".
 
1201
    "RCFLAGS = \n".
1110
1202
    "\n".
1111
1203
    "# Get include directory for resource compiler\n".
1112
1204
    "\n".
1126
1218
    }
1127
1219
 
1128
1220
    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1129
 
      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1130
 
        "\n";
 
1221
      if ($forceobj{$d->{obj_orig}}) {
 
1222
         printf("%s: FORCE\n", $d->{obj});
 
1223
      } else {
 
1224
         print &splitline(sprintf("%s: %s", $d->{obj},
 
1225
                          join " ", @{$d->{deps}})), "\n";
 
1226
      }
1131
1227
      if ($d->{obj} =~ /\.obj$/) {
1132
1228
          print &splitline("\tlcc -O -p6 \$(COMPAT)".
1133
 
                           " \$(XFLAGS) \$(CFLAGS) ".$d->{deps}->[0],69)."\n";
 
1229
                           " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
1134
1230
      } else {
1135
 
          print &splitline("\tlrc \$(RCFL) -r ".$d->{deps}->[0],69)."\n";
 
1231
          print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
 
1232
                           $d->{deps}->[0],69)."\n";
1136
1233
      }
1137
1234
    }
1138
1235
    print "\n";
1140
1237
    print "\nclean:\n".
1141
1238
    "\t-del *.obj\n".
1142
1239
    "\t-del *.exe\n".
1143
 
    "\t-del *.res\n";
 
1240
    "\t-del *.res\n".
 
1241
    "\n".
 
1242
    "FORCE:\n";
1144
1243
 
1145
1244
    select STDOUT; close OUT;
1146
1245
}
1155
1254
    "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1156
1255
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1157
1256
    # gcc command line option is -D not /D
1158
 
    ($_ = $help) =~ s/=\/D/=-D/gs;
 
1257
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1159
1258
    print $_;
1160
1259
    print
1161
1260
    "CC = \$(TOOLPATH)gcc\n".
1204
1303
                       $objstr . " $libstr", 69), "\n\n";
1205
1304
    }
1206
1305
    foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1207
 
      print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1208
 
          "\n";
 
1306
      if ($forceobj{$d->{obj_orig}}) {
 
1307
         printf("%s: FORCE\n", $d->{obj});
 
1308
      } else {
 
1309
         print &splitline(sprintf("%s: %s", $d->{obj},
 
1310
                                  join " ", @{$d->{deps}})), "\n";
 
1311
      }
1209
1312
      $firstdep = $d->{deps}->[0];
1210
1313
      if ($firstdep =~ /\.c$/) {
1211
 
          print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
 
1314
          print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1212
1315
      } elsif ($firstdep =~ /\.m$/) {
1213
 
          print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
 
1316
          print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1214
1317
      }
1215
1318
    }
1216
1319
    print "\n".$makefile_extra{'osx'}->{'end'};
1217
1320
    print "\nclean:\n".
1218
 
    "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n";
 
1321
    "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
1219
1322
    "\trm -rf *.app\n";
 
1323
    "\n".
 
1324
    "FORCE:\n";
1220
1325
    select STDOUT; close OUT;
1221
1326
}
 
1327
 
 
1328
if (defined $makefiles{'devcppproj'}) {
 
1329
    $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
 
1330
    $orig_dir = cwd;
 
1331
 
 
1332
    ##-- Dev-C++ 5 projects
 
1333
    #
 
1334
    # Note: All files created in this section are written in binary
 
1335
    # mode to prevent any posibility of misinterpreted line endings.
 
1336
    # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
 
1337
    # endings. But however, CRLF line endings are the common way on
 
1338
    # Win32 machines where Dev-C++ is running.
 
1339
    # Hence, in order for mkfiles.pl to generate CRLF project files
 
1340
    # even when run from Unix, I make sure all files are binary and
 
1341
    # explicitly write the CRLFs.
 
1342
    #
 
1343
    # Create directories if necessary
 
1344
    mkdir $makefiles{'devcppproj'}
 
1345
        if(! -d $makefiles{'devcppproj'});
 
1346
    chdir $makefiles{'devcppproj'};
 
1347
    @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
 
1348
    %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
 
1349
    # Make dir names FAT/NTFS compatible
 
1350
    my @srcdirs = @srcdirs;
 
1351
    for ($i=0; $i<@srcdirs; $i++) {
 
1352
      $srcdirs[$i] =~ s/\//\\/g;
 
1353
      $srcdirs[$i] =~ s/\\$//;
 
1354
    }
 
1355
    # Create the project files
 
1356
    # Get names of all Windows projects (GUI and console)
 
1357
    my @prognames = &prognames("G:C");
 
1358
    foreach $progname (@prognames) {
 
1359
      create_devcpp_project(\%all_object_deps, $progname);
 
1360
    }
 
1361
 
 
1362
    sub create_devcpp_project {
 
1363
      my ($all_object_deps, $progname) = @_;
 
1364
      # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
 
1365
      %seen_objects = ();
 
1366
      %lib_files = ();
 
1367
      %source_files = ();
 
1368
      %header_files = ();
 
1369
      %resource_files = ();
 
1370
      @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
 
1371
      foreach $object_file (@object_files) {
 
1372
      next if defined $seen_objects{$object_file};
 
1373
      $seen_objects{$object_file} = 1;
 
1374
      if($object_file =~ /\.lib$/io) {
 
1375
    $lib_files{$object_file} = 1;
 
1376
    next;
 
1377
      }
 
1378
      $object_deps = $all_object_deps{$object_file};
 
1379
      foreach $object_dep (@$object_deps) {
 
1380
    if($object_dep =~ /\.c$/io) {
 
1381
        $source_files{$object_dep} = 1;
 
1382
        next;
 
1383
    }
 
1384
    if($object_dep =~ /\.h$/io) {
 
1385
        $header_files{$object_dep} = 1;
 
1386
        next;
 
1387
    }
 
1388
    if($object_dep =~ /\.(rc|ico)$/io) {
 
1389
        $resource_files{$object_dep} = 1;
 
1390
        next;
 
1391
    }
 
1392
      }
 
1393
      }
 
1394
      $libs = join " ", sort keys %lib_files;
 
1395
      @source_files = sort keys %source_files;
 
1396
      @header_files = sort keys %header_files;
 
1397
      @resources = sort keys %resource_files;
 
1398
  ($windows_project, $type) = split ",", $progname;
 
1399
      mkdir $windows_project
 
1400
      if(! -d $windows_project);
 
1401
      chdir $windows_project;
 
1402
 
 
1403
  $subsys = ($type eq "G") ? "0" : "1";  # 0 = Win32 GUI, 1 = Win32 Console
 
1404
      open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
 
1405
      print
 
1406
      "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
 
1407
      "# ** DO NOT EDIT **\r\n".
 
1408
      "\r\n".
 
1409
      # No difference between DEBUG and RELEASE here as in 'vcproj', because
 
1410
      # Dev-C++ does not support mutiple compilation profiles in one single project.
 
1411
      # (At least I can say this for Dev-C++ 5 Beta)
 
1412
      "[Project]\r\n".
 
1413
      "FileName=$windows_project.dev\r\n".
 
1414
      "Name=$windows_project\r\n".
 
1415
      "Ver=1\r\n".
 
1416
      "IsCpp=1\r\n".
 
1417
      "Type=$subsys\r\n".
 
1418
      # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
 
1419
      "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
 
1420
      "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
 
1421
      "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
 
1422
      "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
 
1423
      "Libs=\r\n".
 
1424
      "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
 
1425
      "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
 
1426
      "ObjFiles=\r\n".
 
1427
      "PrivateResource=${windows_project}_private.rc\r\n".
 
1428
      "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
 
1429
      "MakeIncludes=\r\n".
 
1430
      "Icon=\r\n". # It's ok to leave this blank.
 
1431
      "ExeOutput=\r\n".
 
1432
      "ObjectOutput=\r\n".
 
1433
      "OverrideOutput=0\r\n".
 
1434
      "OverrideOutputName=$windows_project.exe\r\n".
 
1435
      "HostApplication=\r\n".
 
1436
      "CommandLine=\r\n".
 
1437
      "UseCustomMakefile=0\r\n".
 
1438
      "CustomMakefile=\r\n".
 
1439
      "IncludeVersionInfo=0\r\n".
 
1440
      "SupportXPThemes=0\r\n".
 
1441
      "CompilerSet=0\r\n".
 
1442
      "CompilerSettings=0000000000000000000000\r\n".
 
1443
      "\r\n";
 
1444
      $unit_count = 1;
 
1445
      foreach $source_file (@source_files) {
 
1446
      print
 
1447
        "[Unit$unit_count]\r\n".
 
1448
        "FileName=..\\..\\$source_file\r\n".
 
1449
        "Folder=Source Files\r\n".
 
1450
        "Compile=1\r\n".
 
1451
        "CompileCpp=0\r\n".
 
1452
        "Link=1\r\n".
 
1453
        "Priority=1000\r\n".
 
1454
        "OverrideBuildCmd=0\r\n".
 
1455
        "BuildCmd=\r\n".
 
1456
        "\r\n";
 
1457
      $unit_count++;
 
1458
  }
 
1459
      foreach $header_file (@header_files) {
 
1460
      print
 
1461
        "[Unit$unit_count]\r\n".
 
1462
        "FileName=..\\..\\$header_file\r\n".
 
1463
        "Folder=Header Files\r\n".
 
1464
        "Compile=1\r\n".
 
1465
        "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
 
1466
        "Link=1\r\n".
 
1467
        "Priority=1000\r\n".
 
1468
        "OverrideBuildCmd=0\r\n".
 
1469
        "BuildCmd=\r\n".
 
1470
        "\r\n";
 
1471
      $unit_count++;
 
1472
  }
 
1473
      foreach $resource_file (@resources) {
 
1474
      if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
 
1475
        $Compile = "0";    # Don't compile images and other binary resource files
 
1476
        $CompileCpp = "0";
 
1477
      } else {
 
1478
        $Compile = "1";
 
1479
        $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
 
1480
      }
 
1481
      print
 
1482
        "[Unit$unit_count]\r\n".
 
1483
        "FileName=..\\..\\$resource_file\r\n".
 
1484
        "Folder=Resource Files\r\n".
 
1485
        "Compile=$Compile\r\n".
 
1486
        "CompileCpp=$CompileCpp\r\n".
 
1487
        "Link=0\r\n".
 
1488
        "Priority=1000\r\n".
 
1489
        "OverrideBuildCmd=0\r\n".
 
1490
        "BuildCmd=\r\n".
 
1491
        "\r\n";
 
1492
      $unit_count++;
 
1493
  }
 
1494
      #Note: By default, [VersionInfo] is not used.
 
1495
      print
 
1496
      "[VersionInfo]\r\n".
 
1497
      "Major=0\r\n".
 
1498
      "Minor=0\r\n".
 
1499
      "Release=1\r\n".
 
1500
      "Build=1\r\n".
 
1501
      "LanguageID=1033\r\n".
 
1502
      "CharsetID=1252\r\n".
 
1503
      "CompanyName=\r\n".
 
1504
      "FileVersion=0.1\r\n".
 
1505
      "FileDescription=\r\n".
 
1506
      "InternalName=\r\n".
 
1507
      "LegalCopyright=\r\n".
 
1508
      "LegalTrademarks=\r\n".
 
1509
      "OriginalFilename=$windows_project.exe\r\n".
 
1510
      "ProductName=$windows_project\r\n".
 
1511
      "ProductVersion=0.1\r\n".
 
1512
      "AutoIncBuildNr=0\r\n";
 
1513
      select STDOUT; close OUT;
 
1514
      chdir "..";
 
1515
    }
 
1516
}