+++ /dev/null
-#!/usr/bin/env perl\r
-#\r
-# Cross-platform Makefile generator.\r
-#\r
-# Reads the file `Recipe' to determine the list of generated\r
-# executables and their component objects. Then reads the source\r
-# files to compute #include dependencies. Finally, writes out the\r
-# various target Makefiles.\r
-\r
-# PuTTY specifics which could still do with removing:\r
-# - Mac makefile is not portabilised at all. Include directories\r
-# are hardwired, and also the libraries are fixed. This is\r
-# mainly because I was too scared to go anywhere near it.\r
-# - sbcsgen.pl is still run at startup.\r
-#\r
-# FIXME: no attempt made to handle !forceobj in the project files.\r
-\r
-use warnings;\r
-use FileHandle;\r
-use Cwd;\r
-\r
-open IN, "Recipe" or do {\r
- # We want to deal correctly with being run from one of the\r
- # subdirs in the source tree. So if we can't find Recipe here,\r
- # try one level up.\r
- chdir "..";\r
- open IN, "Recipe" or die "unable to open Recipe file\n";\r
-};\r
-\r
-# HACK: One of the source files in `charset' is auto-generated by\r
-# sbcsgen.pl. We need to generate that _now_, before attempting\r
-# dependency analysis.\r
-eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';\r
-\r
-@srcdirs = ("./");\r
-\r
-$divert = undef; # ref to scalar in which text is currently being put\r
-$help = ""; # list of newline-free lines of help text\r
-$project_name = "project"; # this is a good enough default\r
-%makefiles = (); # maps makefile types to output makefile pathnames\r
-%makefile_extra = (); # maps makefile types to extra Makefile text\r
-%programs = (); # maps prog name + type letter to listref of objects/resources\r
-%groups = (); # maps group name to listref of objects/resources\r
-\r
-while (<IN>) {\r
- chomp;\r
- @_ = split;\r
-\r
- # If we're gathering help text, keep doing so.\r
- if (defined $divert) {\r
- if ((defined $_[0]) && $_[0] eq "!end") {\r
- $divert = undef;\r
- } else {\r
- ${$divert} .= "$_\n";\r
- }\r
- next;\r
- }\r
- # Skip comments and blank lines.\r
- next if /^\s*#/ or scalar @_ == 0;\r
-\r
- if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }\r
- if ($_[0] eq "!end") { $divert = undef; next; }\r
- if ($_[0] eq "!name") { $project_name = $_[1]; next; }\r
- if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }\r
- if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}\r
- if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}\r
- if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }\r
- if ($_[0] eq "!begin") {\r
- if (&mfval($_[1])) {\r
- $sect = $_[2] ? $_[2] : "end";\r
- $divert = \($makefile_extra{$_[1]}->{$sect});\r
- } else {\r
- $dummy = '';\r
- $divert = \$dummy;\r
- }\r
- next;\r
- }\r
- # If we're gathering help/verbatim text, keep doing so.\r
- if (defined $divert) { ${$divert} .= "$_\n"; next; }\r
- # Ignore blank lines.\r
- next if scalar @_ == 0;\r
-\r
- # Now we have an ordinary line. See if it's an = line, a : line\r
- # or a + line.\r
- @objs = @_;\r
-\r
- if ($_[0] eq "+") {\r
- $listref = $lastlistref;\r
- $prog = undef;\r
- die "$.: unexpected + line\n" if !defined $lastlistref;\r
- } elsif ($_[1] eq "=") {\r
- $groups{$_[0]} = [] if !defined $groups{$_[0]};\r
- $listref = $groups{$_[0]};\r
- $prog = undef;\r
- shift @objs; # eat the group name\r
- } elsif ($_[1] eq ":") {\r
- $listref = [];\r
- $prog = $_[0];\r
- shift @objs; # eat the program name\r
- } else {\r
- die "$.: unrecognised line type\n";\r
- }\r
- shift @objs; # eat the +, the = or the :\r
-\r
- while (scalar @objs > 0) {\r
- $i = shift @objs;\r
- if ($groups{$i}) {\r
- foreach $j (@{$groups{$i}}) { unshift @objs, $j; }\r
- } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or\r
- $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {\r
- $type = substr($i,1,(length $i)-2);\r
- } else {\r
- push @$listref, $i;\r
- }\r
- }\r
- if ($prog and $type) {\r
- die "multiple program entries for $prog [$type]\n"\r
- if defined $programs{$prog . "," . $type};\r
- $programs{$prog . "," . $type} = $listref;\r
- }\r
- $lastlistref = $listref;\r
-}\r
-\r
-close IN;\r
-\r
-# Now retrieve the complete list of objects and resource files, and\r
-# construct dependency data for them. While we're here, expand the\r
-# object list for each program, and complain if its type isn't set.\r
-@prognames = sort keys %programs;\r
-%depends = ();\r
-@scanlist = ();\r
-foreach $i (@prognames) {\r
- ($prog, $type) = split ",", $i;\r
- # Strip duplicate object names.\r
- $prev = '';\r
- @list = grep { $status = ($prev ne $_); $prev=$_; $status }\r
- sort @{$programs{$i}};\r
- $programs{$i} = [@list];\r
- foreach $j (@list) {\r
- # Dependencies for "x" start with "x.c" or "x.m" (depending on\r
- # which one exists).\r
- # Dependencies for "x.res" start with "x.rc".\r
- # Dependencies for "x.rsrc" start with "x.r".\r
- # Both types of file are pushed on the list of files to scan.\r
- # Libraries (.lib) don't have dependencies at all.\r
- if ($j =~ /^(.*)\.res$/) {\r
- $file = "$1.rc";\r
- $depends{$j} = [$file];\r
- push @scanlist, $file;\r
- } elsif ($j =~ /^(.*)\.rsrc$/) {\r
- $file = "$1.r";\r
- $depends{$j} = [$file];\r
- push @scanlist, $file;\r
- } elsif ($j !~ /\./) {\r
- $file = "$j.c";\r
- $file = "$j.m" unless &findfile($file);\r
- $depends{$j} = [$file];\r
- push @scanlist, $file;\r
- }\r
- }\r
-}\r
-\r
-# Scan each file on @scanlist and find further inclusions.\r
-# Inclusions are given by lines of the form `#include "otherfile"'\r
-# (system headers are automatically ignored by this because they'll\r
-# be given in angle brackets). Files included by this method are\r
-# added back on to @scanlist to be scanned in turn (if not already\r
-# done).\r
-#\r
-# Resource scripts (.rc) can also include a file by means of:\r
-# - a line # ending `ICON "filename"';\r
-# - a line ending `RT_MANIFEST "filename"'.\r
-# Files included by this method are not added to @scanlist because\r
-# they can never include further files.\r
-#\r
-# In this pass we write out a hash %further which maps a source\r
-# file name into a listref containing further source file names.\r
-\r
-%further = ();\r
-while (scalar @scanlist > 0) {\r
- $file = shift @scanlist;\r
- next if defined $further{$file}; # skip if we've already done it\r
- $further{$file} = [];\r
- $dirfile = &findfile($file);\r
- open IN, "$dirfile" or die "unable to open source file $file\n";\r
- while (<IN>) {\r
- chomp;\r
- /^\s*#include\s+\"([^\"]+)\"/ and do {\r
- push @{$further{$file}}, $1;\r
- push @scanlist, $1;\r
- next;\r
- };\r
- /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {\r
- push @{$further{$file}}, $2;\r
- next;\r
- }\r
- }\r
- close IN;\r
-}\r
-\r
-# Now we're ready to generate the final dependencies section. For\r
-# each key in %depends, we must expand the dependencies list by\r
-# iteratively adding entries from %further.\r
-foreach $i (keys %depends) {\r
- %dep = ();\r
- @scanlist = @{$depends{$i}};\r
- foreach $i (@scanlist) { $dep{$i} = 1; }\r
- while (scalar @scanlist > 0) {\r
- $file = shift @scanlist;\r
- foreach $j (@{$further{$file}}) {\r
- if (!$dep{$j}) {\r
- $dep{$j} = 1;\r
- push @{$depends{$i}}, $j;\r
- push @scanlist, $j;\r
- }\r
- }\r
- }\r
-# printf "%s: %s\n", $i, join ' ',@{$depends{$i}};\r
-}\r
-\r
-# Validation of input.\r
-\r
-sub mfval($) {\r
- my ($type) = @_;\r
- # Returns true if the argument is a known makefile type. Otherwise,\r
- # prints a warning and returns false;\r
- if (grep { $type eq $_ }\r
- ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",\r
- "ac","osx",)) {\r
- return 1;\r
- }\r
- warn "$.:unknown makefile type '$type'\n";\r
- return 0;\r
-}\r
-\r
-# Utility routines while writing out the Makefiles.\r
-\r
-sub def {\r
- my ($x) = shift @_;\r
- return (defined $x) ? $x : "";\r
-}\r
-\r
-sub dirpfx {\r
- my ($path) = shift @_;\r
- my ($sep) = shift @_;\r
- my $ret = "";\r
- my $i;\r
-\r
- while (($i = index $path, $sep) >= 0 ||\r
- ($j = index $path, "/") >= 0) {\r
- if ($i >= 0 and ($j < 0 or $i < $j)) {\r
- $path = substr $path, ($i + length $sep);\r
- } else {\r
- $path = substr $path, ($j + 1);\r
- }\r
- $ret .= "..$sep";\r
- }\r
- return $ret;\r
-}\r
-\r
-sub findfile {\r
- my ($name) = @_;\r
- my $dir = '';\r
- my $i;\r
- my $outdir = undef;\r
- unless (defined $findfilecache{$name}) {\r
- $i = 0;\r
- foreach $dir (@srcdirs) {\r
- if (-f "$dir$name") {\r
- $outdir = $dir;\r
- $i++;\r
- $outdir =~ s/^\.\///;\r
- }\r
- }\r
- die "multiple instances of source file $name\n" if $i > 1;\r
- $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);\r
- }\r
- return $findfilecache{$name};\r
-}\r
-\r
-sub objects {\r
- my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;\r
- my @ret;\r
- my ($i, $x, $y);\r
- ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);\r
- @ret = ();\r
- foreach $i (@{$programs{$prog}}) {\r
- $x = "";\r
- if ($i =~ /^(.*)\.(res|rsrc)/) {\r
- $y = $1;\r
- ($x = $rtmpl) =~ s/X/$y/;\r
- } elsif ($i =~ /^(.*)\.lib/) {\r
- $y = $1;\r
- ($x = $ltmpl) =~ s/X/$y/;\r
- } elsif ($i !~ /\./) {\r
- ($x = $otmpl) =~ s/X/$i/;\r
- }\r
- push @ret, $x if $x ne "";\r
- }\r
- return join " ", @ret;\r
-}\r
-\r
-sub special {\r
- my ($prog, $suffix) = @_;\r
- my @ret;\r
- my ($i, $x, $y);\r
- ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);\r
- @ret = ();\r
- foreach $i (@{$programs{$prog}}) {\r
- if (substr($i, (length $i) - (length $suffix)) eq $suffix) {\r
- push @ret, $i;\r
- }\r
- }\r
- return (scalar @ret) ? (join " ", @ret) : undef;\r
-}\r
-\r
-sub splitline {\r
- my ($line, $width, $splitchar) = @_;\r
- my $result = "";\r
- my $len;\r
- $len = (defined $width ? $width : 76);\r
- $splitchar = (defined $splitchar ? $splitchar : '\\');\r
- while (length $line > $len) {\r
- $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;\r
- $result .= $1;\r
- $result .= " ${splitchar}\n\t\t" if $2 ne '';\r
- $line = $2;\r
- $len = 60;\r
- }\r
- return $result . $line;\r
-}\r
-\r
-sub deps {\r
- my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;\r
- my ($i, $x, $y);\r
- my @deps;\r
- my @ret;\r
- @ret = ();\r
- $depchar ||= ':';\r
- foreach $i (sort keys %depends) {\r
- next if $specialobj{$mftyp}->{$i};\r
- if ($i =~ /^(.*)\.(res|rsrc)/) {\r
- next if !defined $rtmpl;\r
- $y = $1;\r
- ($x = $rtmpl) =~ s/X/$y/;\r
- } else {\r
- ($x = $otmpl) =~ s/X/$i/;\r
- }\r
- @deps = @{$depends{$i}};\r
- @deps = map {\r
- $_ = &findfile($_);\r
- s/\//$dirsep/g;\r
- $_ = $prefix . $_;\r
- } @deps;\r
- push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};\r
- }\r
- return @ret;\r
-}\r
-\r
-sub prognames {\r
- my ($types) = @_;\r
- my ($n, $prog, $type);\r
- my @ret;\r
- @ret = ();\r
- foreach $n (@prognames) {\r
- ($prog, $type) = split ",", $n;\r
- push @ret, $n if index(":$types:", ":$type:") >= 0;\r
- }\r
- return @ret;\r
-}\r
-\r
-sub progrealnames {\r
- my ($types) = @_;\r
- my ($n, $prog, $type);\r
- my @ret;\r
- @ret = ();\r
- foreach $n (@prognames) {\r
- ($prog, $type) = split ",", $n;\r
- push @ret, $prog if index(":$types:", ":$type:") >= 0;\r
- }\r
- return @ret;\r
-}\r
-\r
-sub manpages {\r
- my ($types,$suffix) = @_;\r
-\r
- # assume that all UNIX programs have a man page\r
- if($suffix eq "1" && $types =~ /:X:/) {\r
- return map("$_.1", &progrealnames($types));\r
- }\r
- return ();\r
-}\r
-\r
-# Now we're ready to output the actual Makefiles.\r
-\r
-if (defined $makefiles{'cygwin'}) {\r
- $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");\r
-\r
- ##-- CygWin makefile\r
- open OUT, ">$makefiles{'cygwin'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under cygwin.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # gcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "# You can define this path to point at your tools if you need to\n".\r
- "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".\r
- "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".\r
- "CC = \$(TOOLPATH)gcc\n".\r
- "RC = \$(TOOLPATH)windres\n".\r
- "# Uncomment the following two lines to compile under Winelib\n".\r
- "# CC = winegcc\n".\r
- "# RC = wrc\n".\r
- "# You may also need to tell windres where to find include files:\n".\r
- "# RCINC = --include-dir c:\\cygwin\\include\\\n".\r
- "\n".\r
- &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".\r
- " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs)) .\r
- "\n".\r
- "LDFLAGS = -mno-cygwin -s\n".\r
- &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".\r
- " --define WINVER=0x0400")."\n".\r
- "\n".\r
- $makefile_extra{'cygwin'}->{'vars'} .\r
- "\n".\r
- ".SUFFIXES:\n".\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));\r
- print "\n\n";\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", "X.res.o", undef);\r
- print &splitline($prog . ".exe: " . $objstr), "\n";\r
- my $mw = $type eq "G" ? " -mwindows" : "";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .\r
- "-Wl,-Map,$prog.map " .\r
- $objstr . " $libstr", 69), "\n\n";\r
- }\r
- foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf ("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- if ($d->{obj} =~ /\.res\.o$/) {\r
- print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";\r
- } else {\r
- print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";\r
- }\r
- }\r
- print "\n";\r
- print $makefile_extra{'cygwin'}->{'end'};\r
- print "\nclean:\n".\r
- "\trm -f *.o *.exe *.res.o *.map\n".\r
- "\n".\r
- "FORCE:\n";\r
- select STDOUT; close OUT;\r
-\r
-}\r
-\r
-##-- Borland makefile\r
-if (defined $makefiles{'borland'}) {\r
- $dirpfx = &dirpfx($makefiles{'borland'}, "\\");\r
-\r
- %stdlibs = ( # Borland provides many Win32 API libraries intrinsically\r
- "advapi32" => 1,\r
- "comctl32" => 1,\r
- "comdlg32" => 1,\r
- "gdi32" => 1,\r
- "imm32" => 1,\r
- "shell32" => 1,\r
- "user32" => 1,\r
- "winmm" => 1,\r
- "winspool" => 1,\r
- "wsock32" => 1,\r
- );\r
- open OUT, ">$makefiles{'borland'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under Borland C.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # bcc32 command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "# If you rename this file to `Makefile', you should change this line,\n".\r
- "# so that the .rsp files still depend on the correct makefile.\n".\r
- "MAKEFILE = Makefile.bor\n".\r
- "\n".\r
- "# C compilation flags\n".\r
- "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".\r
- "# Resource compilation flags\n".\r
- "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".\r
- "\n".\r
- "# Get include directory for resource compiler\n".\r
- "!if !\$d(BCB)\n".\r
- "BCB = \$(MAKEDIR)\\..\n".\r
- "!endif\n".\r
- "\n".\r
- $makefile_extra{'borland'}->{'vars'} .\r
- "\n".\r
- ".c.obj:\n".\r
- &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".\r
- " \$(CFLAGS) \$(XFLAGS) ".\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs) .\r
- " /c \$*.c",69)."\n".\r
- ".rc.res:\n".\r
- &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".\r
- " \$(RCFLAGS) \$*.rc",69)."\n".\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));\r
- print "\n\n";\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.obj", "X.res", undef);\r
- print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";\r
- my $ap = ($type eq "G") ? "-aa" : "-ap";\r
- print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";\r
- }\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- print $prog, ".rsp: \$(MAKEFILE)\n";\r
- $objstr = &objects($p, "X.obj", undef, undef);\r
- @objlist = split " ", $objstr;\r
- @objlines = ("");\r
- foreach $i (@objlist) {\r
- if (length($objlines[$#objlines] . " $i") > 50) {\r
- push @objlines, "";\r
- }\r
- $objlines[$#objlines] .= " $i";\r
- }\r
- $c0w = ($type eq "G") ? "c0w32" : "c0x32";\r
- print "\techo $c0w + > $prog.rsp\n";\r
- for ($i=0; $i<=$#objlines; $i++) {\r
- $plus = ($i < $#objlines ? " +" : "");\r
- print "\techo$objlines[$i]$plus >> $prog.rsp\n";\r
- }\r
- print "\techo $prog.exe >> $prog.rsp\n";\r
- $objstr = &objects($p, "X.obj", "X.res", undef);\r
- @libs = split " ", &objects($p, undef, undef, "X");\r
- @libs = grep { !$stdlibs{$_} } @libs;\r
- unshift @libs, "cw32", "import32";\r
- $libstr = join ' ', @libs;\r
- print "\techo nul,$libstr, >> $prog.rsp\n";\r
- print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";\r
- print "\n";\r
- }\r
- foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- }\r
- print "\n";\r
- print $makefile_extra{'borland'}->{'end'};\r
- print "\nclean:\n".\r
- "\t-del *.obj\n".\r
- "\t-del *.exe\n".\r
- "\t-del *.res\n".\r
- "\t-del *.pch\n".\r
- "\t-del *.aps\n".\r
- "\t-del *.il*\n".\r
- "\t-del *.pdb\n".\r
- "\t-del *.rsp\n".\r
- "\t-del *.tds\n".\r
- "\t-del *.\$\$\$\$\$\$\n".\r
- "\n".\r
- "FORCE:\n".\r
- "\t-rem dummy command\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'vc'}) {\r
- $dirpfx = &dirpfx($makefiles{'vc'}, "\\");\r
-\r
- ##-- Visual C++ makefile\r
- open OUT, ">$makefiles{'vc'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under Visual C.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- print $help;\r
- print\r
- "\n".\r
- "# If you rename this file to `Makefile', you should change this line,\n".\r
- "# so that the .rsp files still depend on the correct makefile.\n".\r
- "MAKEFILE = Makefile.vc\n".\r
- "\n".\r
- "# C compilation flags\n".\r
- "CFLAGS = /nologo /W3 /O1 " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs) .\r
- " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".\r
- "LFLAGS = /incremental:no /fixed\n".\r
- "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".\r
- "\n".\r
- $makefile_extra{'vc'}->{'vars'} .\r
- "\n".\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));\r
- print "\n\n";\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.obj", "X.res", undef);\r
- print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";\r
- print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";\r
- }\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- print $prog, ".rsp: \$(MAKEFILE)\n";\r
- $objstr = &objects($p, "X.obj", "X.res", "X.lib");\r
- @objlist = split " ", $objstr;\r
- @objlines = ("");\r
- foreach $i (@objlist) {\r
- if (length($objlines[$#objlines] . " $i") > 50) {\r
- push @objlines, "";\r
- }\r
- $objlines[$#objlines] .= " $i";\r
- }\r
- $subsys = ($type eq "G") ? "windows" : "console";\r
- print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";\r
- for ($i=0; $i<=$#objlines; $i++) {\r
- print "\techo$objlines[$i] >> $prog.rsp\n";\r
- }\r
- print "\n";\r
- }\r
- foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {\r
- $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @$extradeps, @{$d->{deps}})), "\n";\r
- if ($d->{obj} =~ /.obj$/) {\r
- print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";\r
- } else {\r
- print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";\r
- }\r
- }\r
- print "\n";\r
- print $makefile_extra{'vc'}->{'end'};\r
- print "\nclean: tidy\n".\r
- "\t-del *.exe\n\n".\r
- "tidy:\n".\r
- "\t-del *.obj\n".\r
- "\t-del *.res\n".\r
- "\t-del *.pch\n".\r
- "\t-del *.aps\n".\r
- "\t-del *.ilk\n".\r
- "\t-del *.pdb\n".\r
- "\t-del *.rsp\n".\r
- "\t-del *.dsp\n".\r
- "\t-del *.dsw\n".\r
- "\t-del *.ncb\n".\r
- "\t-del *.opt\n".\r
- "\t-del *.plg\n".\r
- "\t-del *.map\n".\r
- "\t-del *.idb\n".\r
- "\t-del debug.log\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'vcproj'}) {\r
- $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");\r
-\r
- $orig_dir = cwd;\r
-\r
- ##-- MSVC 6 Workspace and projects\r
- #\r
- # Note: All files created in this section are written in binary\r
- # mode, because although MSVC's command-line make can deal with\r
- # LF-only line endings, MSVC project files really _need_ to be\r
- # CRLF. Hence, in order for mkfiles.pl to generate usable project\r
- # files even when run from Unix, I make sure all files are binary\r
- # and explicitly write the CRLFs.\r
- #\r
- # Create directories if necessary\r
- mkdir $makefiles{'vcproj'}\r
- if(! -d $makefiles{'vcproj'});\r
- chdir $makefiles{'vcproj'};\r
- @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");\r
- %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;\r
- # Create the project files\r
- # Get names of all Windows projects (GUI and console)\r
- my @prognames = &prognames("G:C");\r
- foreach $progname (@prognames) {\r
- create_vc_project(\%all_object_deps, $progname);\r
- }\r
- # Create the workspace file\r
- open OUT, ">$project_name.dsw"; binmode OUT; select OUT;\r
- print\r
- "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".\r
- "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".\r
- "\r\n".\r
- "###############################################################################\r\n".\r
- "\r\n";\r
- # List projects\r
- foreach $progname (@prognames) {\r
- ($windows_project, $type) = split ",", $progname;\r
- print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";\r
- }\r
- print\r
- "\r\n".\r
- "Package=<5>\r\n".\r
- "{{{\r\n".\r
- "}}}\r\n".\r
- "\r\n".\r
- "Package=<4>\r\n".\r
- "{{{\r\n".\r
- "}}}\r\n".\r
- "\r\n".\r
- "###############################################################################\r\n".\r
- "\r\n".\r
- "Global:\r\n".\r
- "\r\n".\r
- "Package=<5>\r\n".\r
- "{{{\r\n".\r
- "}}}\r\n".\r
- "\r\n".\r
- "Package=<3>\r\n".\r
- "{{{\r\n".\r
- "}}}\r\n".\r
- "\r\n".\r
- "###############################################################################\r\n".\r
- "\r\n";\r
- select STDOUT; close OUT;\r
- chdir $orig_dir;\r
-\r
- sub create_vc_project {\r
- my ($all_object_deps, $progname) = @_;\r
- # Construct program's dependency info\r
- %seen_objects = ();\r
- %lib_files = ();\r
- %source_files = ();\r
- %header_files = ();\r
- %resource_files = ();\r
- @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");\r
- foreach $object_file (@object_files) {\r
- next if defined $seen_objects{$object_file};\r
- $seen_objects{$object_file} = 1;\r
- if($object_file =~ /\.lib$/io) {\r
- $lib_files{$object_file} = 1;\r
- next;\r
- }\r
- $object_deps = $all_object_deps{$object_file};\r
- foreach $object_dep (@$object_deps) {\r
- if($object_dep =~ /\.c$/io) {\r
- $source_files{$object_dep} = 1;\r
- next;\r
- }\r
- if($object_dep =~ /\.h$/io) {\r
- $header_files{$object_dep} = 1;\r
- next;\r
- }\r
- if($object_dep =~ /\.(rc|ico)$/io) {\r
- $resource_files{$object_dep} = 1;\r
- next;\r
- }\r
- }\r
- }\r
- $libs = join " ", sort keys %lib_files;\r
- @source_files = sort keys %source_files;\r
- @header_files = sort keys %header_files;\r
- @resources = sort keys %resource_files;\r
- ($windows_project, $type) = split ",", $progname;\r
- mkdir $windows_project\r
- if(! -d $windows_project);\r
- chdir $windows_project;\r
- $subsys = ($type eq "G") ? "windows" : "console";\r
- open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;\r
- print\r
- "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".\r
- "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".\r
- "# ** DO NOT EDIT **\r\n".\r
- "\r\n".\r
- "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".\r
- "\r\n".\r
- "CFG=$windows_project - Win32 Debug\r\n".\r
- "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".\r
- "!MESSAGE use the Export Makefile command and run\r\n".\r
- "!MESSAGE \r\n".\r
- "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".\r
- "!MESSAGE \r\n".\r
- "!MESSAGE You can specify a configuration when running NMAKE\r\n".\r
- "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".\r
- "!MESSAGE \r\n".\r
- "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".\r
- "!MESSAGE \r\n".\r
- "!MESSAGE Possible choices for configuration are:\r\n".\r
- "!MESSAGE \r\n".\r
- "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".\r
- "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".\r
- "!MESSAGE \r\n".\r
- "\r\n".\r
- "# Begin Project\r\n".\r
- "# PROP AllowPerConfigDependencies 0\r\n".\r
- "# PROP Scc_ProjName \"\"\r\n".\r
- "# PROP Scc_LocalPath \"\"\r\n".\r
- "CPP=cl.exe\r\n".\r
- "MTL=midl.exe\r\n".\r
- "RSC=rc.exe\r\n".\r
- "\r\n".\r
- "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".\r
- "\r\n".\r
- "# PROP BASE Use_MFC 0\r\n".\r
- "# PROP BASE Use_Debug_Libraries 0\r\n".\r
- "# PROP BASE Output_Dir \"Release\"\r\n".\r
- "# PROP BASE Intermediate_Dir \"Release\"\r\n".\r
- "# PROP BASE Target_Dir \"\"\r\n".\r
- "# PROP Use_MFC 0\r\n".\r
- "# PROP Use_Debug_Libraries 0\r\n".\r
- "# PROP Output_Dir \"Release\"\r\n".\r
- "# PROP Intermediate_Dir \"Release\"\r\n".\r
- "# PROP Ignore_Export_Lib 0\r\n".\r
- "# PROP Target_Dir \"\"\r\n".\r
- "# ADD BASE CPP /nologo /W3 /GX /O2 ".\r
- (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .\r
- " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".\r
- "# ADD CPP /nologo /W3 /GX /O2 ".\r
- (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .\r
- " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".\r
- "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".\r
- "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".\r
- "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".\r
- "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".\r
- "BSC32=bscmake.exe\r\n".\r
- "# ADD BASE BSC32 /nologo\r\n".\r
- "# ADD BSC32 /nologo\r\n".\r
- "LINK32=link.exe\r\n".\r
- "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /machine:I386\r\n".\r
- "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".\r
- "# SUBTRACT LINK32 /pdb:none\r\n".\r
- "\r\n".\r
- "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".\r
- "\r\n".\r
- "# PROP BASE Use_MFC 0\r\n".\r
- "# PROP BASE Use_Debug_Libraries 1\r\n".\r
- "# PROP BASE Output_Dir \"Debug\"\r\n".\r
- "# PROP BASE Intermediate_Dir \"Debug\"\r\n".\r
- "# PROP BASE Target_Dir \"\"\r\n".\r
- "# PROP Use_MFC 0\r\n".\r
- "# PROP Use_Debug_Libraries 1\r\n".\r
- "# PROP Output_Dir \"Debug\"\r\n".\r
- "# PROP Intermediate_Dir \"Debug\"\r\n".\r
- "# PROP Ignore_Export_Lib 0\r\n".\r
- "# PROP Target_Dir \"\"\r\n".\r
- "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".\r
- (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .\r
- " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".\r
- "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".\r
- (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .\r
- " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".\r
- "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".\r
- "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".\r
- "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".\r
- "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".\r
- "BSC32=bscmake.exe\r\n".\r
- "# ADD BASE BSC32 /nologo\r\n".\r
- "# ADD BSC32 /nologo\r\n".\r
- "LINK32=link.exe\r\n".\r
- "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".\r
- "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".\r
- "# SUBTRACT LINK32 /pdb:none\r\n".\r
- "\r\n".\r
- "!ENDIF \r\n".\r
- "\r\n".\r
- "# Begin Target\r\n".\r
- "\r\n".\r
- "# Name \"$windows_project - Win32 Release\"\r\n".\r
- "# Name \"$windows_project - Win32 Debug\"\r\n".\r
- "# Begin Group \"Source Files\"\r\n".\r
- "\r\n".\r
- "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";\r
- foreach $source_file (@source_files) {\r
- print\r
- "# Begin Source File\r\n".\r
- "\r\n".\r
- "SOURCE=..\\..\\$source_file\r\n";\r
- if($source_file =~ /ssh\.c/io) {\r
- # Disable 'Edit and continue' as Visual Studio can't handle the macros\r
- print\r
- "\r\n".\r
- "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".\r
- "\r\n".\r
- "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".\r
- "\r\n".\r
- "# ADD CPP /Zi\r\n".\r
- "\r\n".\r
- "!ENDIF \r\n".\r
- "\r\n";\r
- }\r
- print "# End Source File\r\n";\r
- }\r
- print\r
- "# End Group\r\n".\r
- "# Begin Group \"Header Files\"\r\n".\r
- "\r\n".\r
- "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";\r
- foreach $header_file (@header_files) {\r
- print\r
- "# Begin Source File\r\n".\r
- "\r\n".\r
- "SOURCE=..\\..\\$header_file\r\n".\r
- "# End Source File\r\n";\r
- }\r
- print\r
- "# End Group\r\n".\r
- "# Begin Group \"Resource Files\"\r\n".\r
- "\r\n".\r
- "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";\r
- foreach $resource_file (@resources) {\r
- print\r
- "# Begin Source File\r\n".\r
- "\r\n".\r
- "SOURCE=..\\..\\$resource_file\r\n".\r
- "# End Source File\r\n";\r
- }\r
- print\r
- "# End Group\r\n".\r
- "# End Target\r\n".\r
- "# End Project\r\n";\r
- select STDOUT; close OUT;\r
- chdir "..";\r
- }\r
-}\r
-\r
-if (defined $makefiles{'gtk'}) {\r
- $dirpfx = &dirpfx($makefiles{'gtk'}, "/");\r
-\r
- ##-- X/GTK/Unix makefile\r
- open OUT, ">$makefiles{'gtk'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under X/GTK and Unix.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # gcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "# You can define this path to point at your tools if you need to\n".\r
- "# TOOLPATH = /opt/gcc/bin\n".\r
- "CC = \$(TOOLPATH)cc\n".\r
- "# If necessary set the path to krb5-config here\n".\r
- "KRB5CONFIG=krb5-config\n".\r
- "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".\r
- "# (depending on what works on your system) if you want to enforce\n".\r
- "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".\r
- "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".\r
- "# to 1.2 if it isn't found.\n".\r
- "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".\r
- "\n".\r
- "-include Makefile.local\n".\r
- "\n".\r
- "unexport CFLAGS # work around a weird issue with krb5-config\n".\r
- "\n".\r
- &splitline("CFLAGS = -O2 -Wall -Werror -g " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs) .\r
- " \$(shell \$(GTK_CONFIG) --cflags)").\r
- " -D _FILE_OFFSET_BITS=64\n".\r
- "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".\r
- "ULDFLAGS = \$(LDFLAGS)\n".\r
- "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".\r
- "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".\r
- "XLDFLAGS+= -ldl\n".\r
- "ULDFLAGS+= -ldl\n".\r
- "else\n".\r
- "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".\r
- "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".\r
- "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".\r
- "endif\n".\r
- "endif\n".\r
- "INSTALL=install\n".\r
- "INSTALL_PROGRAM=\$(INSTALL)\n".\r
- "INSTALL_DATA=\$(INSTALL)\n".\r
- "prefix=/usr/local\n".\r
- "exec_prefix=\$(prefix)\n".\r
- "bindir=\$(exec_prefix)/bin\n".\r
- "mandir=\$(prefix)/man\n".\r
- "man1dir=\$(mandir)/man1\n".\r
- "\n".\r
- &def($makefile_extra{'gtk'}->{'vars'}) .\r
- "\n".\r
- ".SUFFIXES:\n".\r
- "\n".\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));\r
- print "\n\n";\r
- foreach $p (&prognames("X:U")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", undef, undef);\r
- print &splitline($prog . ": " . $objstr), "\n";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC) -o \$@ " .\r
- $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";\r
- }\r
- foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");\r
- }\r
- print "\n";\r
- print $makefile_extra{'gtk'}->{'end'};\r
- print "\nclean:\n".\r
- "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";\r
- print "\nFORCE:\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'unix'}) {\r
- $dirpfx = &dirpfx($makefiles{'unix'}, "/");\r
-\r
- ##-- GTK-free pure-Unix makefile for non-GUI apps only\r
- open OUT, ">$makefiles{'unix'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under Unix.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # gcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "# You can define this path to point at your tools if you need to\n".\r
- "# TOOLPATH = /opt/gcc/bin\n".\r
- "CC = \$(TOOLPATH)cc\n".\r
- "\n".\r
- "-include Makefile.local\n".\r
- "\n".\r
- "unexport CFLAGS # work around a weird issue with krb5-config\n".\r
- "\n".\r
- &splitline("CFLAGS = -O2 -Wall -Werror -g " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs)).\r
- " -D _FILE_OFFSET_BITS=64\n".\r
- "ULDFLAGS = \$(LDFLAGS)\n".\r
- "INSTALL=install\n".\r
- "INSTALL_PROGRAM=\$(INSTALL)\n".\r
- "INSTALL_DATA=\$(INSTALL)\n".\r
- "prefix=/usr/local\n".\r
- "exec_prefix=\$(prefix)\n".\r
- "bindir=\$(exec_prefix)/bin\n".\r
- "mandir=\$(prefix)/man\n".\r
- "man1dir=\$(mandir)/man1\n".\r
- "\n".\r
- &def($makefile_extra{'unix'}->{'vars'}) .\r
- "\n".\r
- ".SUFFIXES:\n".\r
- "\n".\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_" } &progrealnames("U"));\r
- print "\n\n";\r
- foreach $p (&prognames("U")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", undef, undef);\r
- print &splitline($prog . ": " . $objstr), "\n";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC) -o \$@ " .\r
- $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";\r
- }\r
- foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");\r
- }\r
- print "\n";\r
- print &def($makefile_extra{'unix'}->{'end'});\r
- print "\nclean:\n".\r
- "\trm -f *.o". (join "", map { " $_" } &progrealnames("U")) . "\n";\r
- print "\nFORCE:\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'ac'}) {\r
- $dirpfx = &dirpfx($makefiles{'ac'}, "/");\r
-\r
- ##-- Unix/autoconf makefile\r
- open OUT, ">$makefiles{'ac'}"; select OUT;\r
- print\r
- "# Makefile.in for $project_name under Unix with Autoconf.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # gcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "CC = \@CC\@\n".\r
- "\n".\r
- &splitline("CFLAGS = \@CFLAGS\@ \@PUTTYCFLAGS\@ \@CPPFLAGS\@ " .\r
- "\@DEFS\@ \@GTK_CFLAGS\@ " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".\r
- "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".\r
- "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".\r
- "INSTALL=\@INSTALL\@\n".\r
- "INSTALL_PROGRAM=\$(INSTALL)\n".\r
- "INSTALL_DATA=\$(INSTALL)\n".\r
- "prefix=\@prefix\@\n".\r
- "exec_prefix=\@exec_prefix\@\n".\r
- "bindir=\@bindir\@\n".\r
- "datarootdir=\@datarootdir\@\n".\r
- "mandir=\@mandir\@\n".\r
- "man1dir=\$(mandir)/man1\n".\r
- "\n".\r
- &def($makefile_extra{'gtk'}->{'vars'}) .\r
- "\n".\r
- ".SUFFIXES:\n".\r
- "\n".\r
- "\n".\r
- "all: \@all_targets\@\n".\r
- &splitline("all-cli:" . join "", map { " $_" } &progrealnames("U"))."\n".\r
- &splitline("all-gtk:" . join "", map { " $_" } &progrealnames("X"))."\n";\r
- print "\n";\r
- foreach $p (&prognames("X:U")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", undef, undef);\r
- print &splitline($prog . ": " . $objstr), "\n";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC) -o \$@ " .\r
- $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";\r
- }\r
- foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");\r
- }\r
- print "\n";\r
- print $makefile_extra{'gtk'}->{'end'};\r
- print "\nclean:\n".\r
- "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";\r
- print "\ndistclean: clean\n".\r
- "\t". &splitline("rm -f config.status config.cache config.log ".\r
- "configure.lineno config.status.lineno Makefile") . "\n";\r
- print "\nFORCE:\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'lcc'}) {\r
- $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");\r
-\r
- ##-- lcc makefile\r
- open OUT, ">$makefiles{'lcc'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under lcc.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # lcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "\n".\r
- "# If you rename this file to `Makefile', you should change this line,\n".\r
- "# so that the .rsp files still depend on the correct makefile.\n".\r
- "MAKEFILE = Makefile.lcc\n".\r
- "\n".\r
- "# C compilation flags\n".\r
- "CFLAGS = -D_WINDOWS " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs) .\r
- "\n".\r
- "# Resource compilation flags\n".\r
- "RCFLAGS = \n".\r
- "\n".\r
- "# Get include directory for resource compiler\n".\r
- "\n".\r
- $makefile_extra{'lcc'}->{'vars'} .\r
- "\n";\r
- print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));\r
- print "\n\n";\r
- foreach $p (&prognames("G:C")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.obj", "X.res", undef);\r
- print &splitline("$prog.exe: " . $objstr ), "\n";\r
- $subsystemtype = '';\r
- if ($type eq "G") { $subsystemtype = "-subsystem windows"; }\r
- my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";\r
- print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");\r
- print "\n\n";\r
- }\r
-\r
- foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- if ($d->{obj} =~ /\.obj$/) {\r
- print &splitline("\tlcc -O -p6 \$(COMPAT)".\r
- " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";\r
- } else {\r
- print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".\r
- $d->{deps}->[0],69)."\n";\r
- }\r
- }\r
- print "\n";\r
- print $makefile_extra{'lcc'}->{'end'};\r
- print "\nclean:\n".\r
- "\t-del *.obj\n".\r
- "\t-del *.exe\n".\r
- "\t-del *.res\n".\r
- "\n".\r
- "FORCE:\n";\r
-\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'osx'}) {\r
- $dirpfx = &dirpfx($makefiles{'osx'}, "/");\r
-\r
- ##-- Mac OS X makefile\r
- open OUT, ">$makefiles{'osx'}"; select OUT;\r
- print\r
- "# Makefile for $project_name under Mac OS X.\n".\r
- "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".\r
- "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";\r
- # gcc command line option is -D not /D\r
- ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;\r
- print $_;\r
- print\r
- "CC = \$(TOOLPATH)gcc\n".\r
- "\n".\r
- &splitline("CFLAGS = -O2 -Wall -Werror -g " .\r
- (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".\r
- "MLDFLAGS = -framework Cocoa\n".\r
- "ULDFLAGS =\n".\r
- "\n" .\r
- $makefile_extra{'osx'}->{'vars'} .\r
- "\n" .\r
- &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .\r
- "\n";\r
- foreach $p (&prognames("MX")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", undef, undef);\r
- $icon = &special($p, ".icns");\r
- $infoplist = &special($p, "info.plist");\r
- print "${prog}.app:\n\tmkdir -p \$\@\n";\r
- print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";\r
- print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";\r
- $targets = "${prog}.app/Contents/MacOS/$prog";\r
- if (defined $icon) {\r
- print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";\r
- print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";\r
- $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";\r
- }\r
- if (defined $infoplist) {\r
- print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";\r
- $targets .= " ${prog}.app/Contents/Info.plist";\r
- }\r
- $targets .= " \$(${prog}_extra)";\r
- print &splitline("${prog}: $targets", 69) . "\n\n";\r
- print &splitline("${prog}.app/Contents/MacOS/$prog: ".\r
- "${prog}.app/Contents/MacOS " . $objstr), "\n";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .\r
- $objstr . " $libstr", 69), "\n\n";\r
- }\r
- foreach $p (&prognames("U")) {\r
- ($prog, $type) = split ",", $p;\r
- $objstr = &objects($p, "X.o", undef, undef);\r
- print &splitline($prog . ": " . $objstr), "\n";\r
- $libstr = &objects($p, undef, undef, "-lX");\r
- print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " .\r
- $objstr . " $libstr", 69), "\n\n";\r
- }\r
- foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) {\r
- if ($forceobj{$d->{obj_orig}}) {\r
- printf("%s: FORCE\n", $d->{obj});\r
- } else {\r
- print &splitline(sprintf("%s: %s", $d->{obj},\r
- join " ", @{$d->{deps}})), "\n";\r
- }\r
- $firstdep = $d->{deps}->[0];\r
- if ($firstdep =~ /\.c$/) {\r
- print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";\r
- } elsif ($firstdep =~ /\.m$/) {\r
- print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";\r
- }\r
- }\r
- print "\n".&def($makefile_extra{'osx'}->{'end'});\r
- print "\nclean:\n".\r
- "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".\r
- "\trm -rf *.app\n".\r
- "\n".\r
- "FORCE:\n";\r
- select STDOUT; close OUT;\r
-}\r
-\r
-if (defined $makefiles{'devcppproj'}) {\r
- $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");\r
- $orig_dir = cwd;\r
-\r
- ##-- Dev-C++ 5 projects\r
- #\r
- # Note: All files created in this section are written in binary\r
- # mode to prevent any posibility of misinterpreted line endings.\r
- # I don't know if Dev-C++ is as touchy as MSVC with LF-only line\r
- # endings. But however, CRLF line endings are the common way on\r
- # Win32 machines where Dev-C++ is running.\r
- # Hence, in order for mkfiles.pl to generate CRLF project files\r
- # even when run from Unix, I make sure all files are binary and\r
- # explicitly write the CRLFs.\r
- #\r
- # Create directories if necessary\r
- mkdir $makefiles{'devcppproj'}\r
- if(! -d $makefiles{'devcppproj'});\r
- chdir $makefiles{'devcppproj'};\r
- @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");\r
- %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;\r
- # Make dir names FAT/NTFS compatible\r
- my @srcdirs = @srcdirs;\r
- for ($i=0; $i<@srcdirs; $i++) {\r
- $srcdirs[$i] =~ s/\//\\/g;\r
- $srcdirs[$i] =~ s/\\$//;\r
- }\r
- # Create the project files\r
- # Get names of all Windows projects (GUI and console)\r
- my @prognames = &prognames("G:C");\r
- foreach $progname (@prognames) {\r
- create_devcpp_project(\%all_object_deps, $progname);\r
- }\r
-\r
- sub create_devcpp_project {\r
- my ($all_object_deps, $progname) = @_;\r
- # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)\r
- %seen_objects = ();\r
- %lib_files = ();\r
- %source_files = ();\r
- %header_files = ();\r
- %resource_files = ();\r
- @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");\r
- foreach $object_file (@object_files) {\r
- next if defined $seen_objects{$object_file};\r
- $seen_objects{$object_file} = 1;\r
- if($object_file =~ /\.lib$/io) {\r
- $lib_files{$object_file} = 1;\r
- next;\r
- }\r
- $object_deps = $all_object_deps{$object_file};\r
- foreach $object_dep (@$object_deps) {\r
- if($object_dep =~ /\.c$/io) {\r
- $source_files{$object_dep} = 1;\r
- next;\r
- }\r
- if($object_dep =~ /\.h$/io) {\r
- $header_files{$object_dep} = 1;\r
- next;\r
- }\r
- if($object_dep =~ /\.(rc|ico)$/io) {\r
- $resource_files{$object_dep} = 1;\r
- next;\r
- }\r
- }\r
- }\r
- $libs = join " ", sort keys %lib_files;\r
- @source_files = sort keys %source_files;\r
- @header_files = sort keys %header_files;\r
- @resources = sort keys %resource_files;\r
- ($windows_project, $type) = split ",", $progname;\r
- mkdir $windows_project\r
- if(! -d $windows_project);\r
- chdir $windows_project;\r
-\r
- $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console\r
- open OUT, ">$windows_project.dev"; binmode OUT; select OUT;\r
- print\r
- "# DEV-C++ 5 Project File - $windows_project.dev\r\n".\r
- "# ** DO NOT EDIT **\r\n".\r
- "\r\n".\r
- # No difference between DEBUG and RELEASE here as in 'vcproj', because\r
- # Dev-C++ does not support mutiple compilation profiles in one single project.\r
- # (At least I can say this for Dev-C++ 5 Beta)\r
- "[Project]\r\n".\r
- "FileName=$windows_project.dev\r\n".\r
- "Name=$windows_project\r\n".\r
- "Ver=1\r\n".\r
- "IsCpp=1\r\n".\r
- "Type=$subsys\r\n".\r
- # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h\r
- "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".\r
- "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".\r
- "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".\r
- "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".\r
- "Libs=\r\n".\r
- "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".\r
- "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".\r
- "ObjFiles=\r\n".\r
- "PrivateResource=${windows_project}_private.rc\r\n".\r
- "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".\r
- "MakeIncludes=\r\n".\r
- "Icon=\r\n". # It's ok to leave this blank.\r
- "ExeOutput=\r\n".\r
- "ObjectOutput=\r\n".\r
- "OverrideOutput=0\r\n".\r
- "OverrideOutputName=$windows_project.exe\r\n".\r
- "HostApplication=\r\n".\r
- "CommandLine=\r\n".\r
- "UseCustomMakefile=0\r\n".\r
- "CustomMakefile=\r\n".\r
- "IncludeVersionInfo=0\r\n".\r
- "SupportXPThemes=0\r\n".\r
- "CompilerSet=0\r\n".\r
- "CompilerSettings=0000000000000000000000\r\n".\r
- "\r\n";\r
- $unit_count = 1;\r
- foreach $source_file (@source_files) {\r
- print\r
- "[Unit$unit_count]\r\n".\r
- "FileName=..\\..\\$source_file\r\n".\r
- "Folder=Source Files\r\n".\r
- "Compile=1\r\n".\r
- "CompileCpp=0\r\n".\r
- "Link=1\r\n".\r
- "Priority=1000\r\n".\r
- "OverrideBuildCmd=0\r\n".\r
- "BuildCmd=\r\n".\r
- "\r\n";\r
- $unit_count++;\r
- }\r
- foreach $header_file (@header_files) {\r
- print\r
- "[Unit$unit_count]\r\n".\r
- "FileName=..\\..\\$header_file\r\n".\r
- "Folder=Header Files\r\n".\r
- "Compile=1\r\n".\r
- "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.\r
- "Link=1\r\n".\r
- "Priority=1000\r\n".\r
- "OverrideBuildCmd=0\r\n".\r
- "BuildCmd=\r\n".\r
- "\r\n";\r
- $unit_count++;\r
- }\r
- foreach $resource_file (@resources) {\r
- if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'\r
- $Compile = "0"; # Don't compile images and other binary resource files\r
- $CompileCpp = "0";\r
- } else {\r
- $Compile = "1";\r
- $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.\r
- }\r
- print\r
- "[Unit$unit_count]\r\n".\r
- "FileName=..\\..\\$resource_file\r\n".\r
- "Folder=Resource Files\r\n".\r
- "Compile=$Compile\r\n".\r
- "CompileCpp=$CompileCpp\r\n".\r
- "Link=0\r\n".\r
- "Priority=1000\r\n".\r
- "OverrideBuildCmd=0\r\n".\r
- "BuildCmd=\r\n".\r
- "\r\n";\r
- $unit_count++;\r
- }\r
- #Note: By default, [VersionInfo] is not used.\r
- print\r
- "[VersionInfo]\r\n".\r
- "Major=0\r\n".\r
- "Minor=0\r\n".\r
- "Release=1\r\n".\r
- "Build=1\r\n".\r
- "LanguageID=1033\r\n".\r
- "CharsetID=1252\r\n".\r
- "CompanyName=\r\n".\r
- "FileVersion=0.1\r\n".\r
- "FileDescription=\r\n".\r
- "InternalName=\r\n".\r
- "LegalCopyright=\r\n".\r
- "LegalTrademarks=\r\n".\r
- "OriginalFilename=$windows_project.exe\r\n".\r
- "ProductName=$windows_project\r\n".\r
- "ProductVersion=0.1\r\n".\r
- "AutoIncBuildNr=0\r\n";\r
- select STDOUT; close OUT;\r
- chdir "..";\r
- }\r
-}\r