X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/985b644054f5e0d777184c48bfd8a97e824705fd..f160b7b8908cac4a7ca37b49928b7855fe0a11fe:/mkfiles.pl diff --git a/mkfiles.pl b/mkfiles.pl index ff468b5f..f0a57570 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -12,6 +12,8 @@ # are hardwired, and also the libraries are fixed. This is # mainly because I was too scared to go anywhere near it. # - sbcsgen.pl is still run at startup. +# +# FIXME: no attempt made to handle !forceobj in the project files. use FileHandle; use Cwd; @@ -52,6 +54,7 @@ while () { if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; } if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;} if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;} + if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; } if ($_[0] eq "!begin") { if (&mfval($_[1])) { $sect = $_[2] ? $_[2] : "end"; @@ -297,7 +300,8 @@ sub splitline { $splitchar = (defined $splitchar ? $splitchar : '\\'); while (length $line > $len) { $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/; - $result .= $1 . " ${splitchar}\n\t\t"; + $result .= $1; + $result .= " ${splitchar}\n\t\t" if $2 ne ''; $line = $2; $len = 60; } @@ -325,7 +329,7 @@ sub deps { s/\//$dirsep/g; $_ = $prefix . $_; } @deps; - push @ret, {obj => $x, deps => [@deps]}; + push @ret, {obj => $x, obj_orig => $i, deps => [@deps]}; } return @ret; } @@ -376,7 +380,7 @@ if (defined $makefiles{'cygwin'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # gcc command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "\n". @@ -392,7 +396,7 @@ if (defined $makefiles{'cygwin'}) { "# RCINC = --include-dir c:\\cygwin\\include\\\n". "\n". &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT". - " -D_NO_OLDNAMES -DNO_MULTIMON " . + " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " . (join " ", map {"-I$dirpfx$_"} @srcdirs)) . "\n". "LDFLAGS = -mno-cygwin -s\n". @@ -416,19 +420,24 @@ if (defined $makefiles{'cygwin'}) { $objstr . " $libstr", 69), "\n\n"; } foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; + if ($forceobj{$d->{obj_orig}}) { + printf ("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } if ($d->{obj} =~ /\.res\.o$/) { print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n"; } else { - print "\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c ".$d->{deps}->[0]."\n\n"; + print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n"; } } print "\n"; print $makefile_extra{'cygwin'}->{'end'}; print "\nclean:\n". "\trm -f *.o *.exe *.res.o *.map\n". - "\n"; + "\n". + "FORCE:\n"; select STDOUT; close OUT; } @@ -455,7 +464,7 @@ if (defined $makefiles{'borland'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # bcc32 command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "\n". @@ -464,7 +473,9 @@ if (defined $makefiles{'borland'}) { "MAKEFILE = Makefile.bor\n". "\n". "# C compilation flags\n". - "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n". + "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n". + "# Resource compilation flags\n". + "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n". "\n". "# Get include directory for resource compiler\n". "!if !\$d(BCB)\n". @@ -475,12 +486,12 @@ if (defined $makefiles{'borland'}) { "\n". ".c.obj:\n". &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)". - " \$(XFLAGS) \$(CFLAGS) ". + " \$(CFLAGS) \$(XFLAGS) ". (join " ", map {"-I$dirpfx$_"} @srcdirs) . " /c \$*.c",69)."\n". ".rc.res:\n". &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r". - " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n". + " \$(RCFLAGS) \$*.rc",69)."\n". "\n"; print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); print "\n\n"; @@ -520,8 +531,12 @@ if (defined $makefiles{'borland'}) { print "\n"; } foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; + if ($forceobj{$d->{obj_orig}}) { + printf("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } } print "\n"; print $makefile_extra{'borland'}->{'end'}; @@ -535,7 +550,10 @@ if (defined $makefiles{'borland'}) { "\t-del *.pdb\n". "\t-del *.rsp\n". "\t-del *.tds\n". - "\t-del *.\$\$\$\$\$\$\n"; + "\t-del *.\$\$\$\$\$\$\n". + "\n". + "FORCE:\n". + "\t-rem dummy command\n"; select STDOUT; close OUT; } @@ -558,8 +576,9 @@ if (defined $makefiles{'vc'}) { "# C compilation flags\n". "CFLAGS = /nologo /W3 /O1 " . (join " ", map {"-I$dirpfx$_"} @srcdirs) . - " /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n". + " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n". "LFLAGS = /incremental:no /fixed\n". + "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n". "\n". $makefile_extra{'vc'}->{'vars'} . "\n". @@ -592,12 +611,13 @@ if (defined $makefiles{'vc'}) { print "\n"; } foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; + $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : []; + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @$extradeps, @{$d->{deps}})), "\n"; if ($d->{obj} =~ /.obj$/) { - print "\tcl \$(COMPAT) \$(XFLAGS) \$(CFLAGS) /c ".$d->{deps}->[0],"\n\n"; + print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n"; } else { - print "\trc \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 ".$d->{deps}->[0],"\n\n"; + print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n"; } } print "\n"; @@ -897,19 +917,26 @@ if (defined $makefiles{'gtk'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # gcc command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "\n". "# You can define this path to point at your tools if you need to\n". "# TOOLPATH = /opt/gcc/bin\n". "CC = \$(TOOLPATH)cc\n". + "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n". + "# (depending on what works on your system) if you want to enforce\n". + "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n". + "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n". + "# to 1.2 if it isn't found.\n". + "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n". "\n". &splitline("CFLAGS = -O2 -Wall -Werror -g " . (join " ", map {"-I$dirpfx$_"} @srcdirs) . - " `gtk-config --cflags`")."\n". - "XLDFLAGS = `gtk-config --libs`\n". - "ULDFLAGS =#\n". + " `\$(GTK_CONFIG) --cflags`"). + " -D _FILE_OFFSET_BITS=64\n". + "XLDFLAGS = \$(LDFLAGS) `\$(GTK_CONFIG) --libs`\n". + "ULDFLAGS = \$(LDFLAGS)\n". "INSTALL=install\n", "INSTALL_PROGRAM=\$(INSTALL)\n", "INSTALL_DATA=\$(INSTALL)\n", @@ -931,18 +958,23 @@ if (defined $makefiles{'gtk'}) { $objstr = &objects($p, "X.o", undef, undef); print &splitline($prog . ": " . $objstr), "\n"; $libstr = &objects($p, undef, undef, "-lX"); - print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " . - $objstr . " $libstr", 69), "\n\n"; + print &splitline("\t\$(CC)" . $mw . " -o \$@ " . + $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n"; } foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; - print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n"); + if ($forceobj{$d->{obj_orig}}) { + printf("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } + print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n"); } print "\n"; print $makefile_extra{'gtk'}->{'end'}; print "\nclean:\n". "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n"; + print "\nFORCE:\n"; select STDOUT; close OUT; } @@ -956,7 +988,7 @@ if (defined $makefiles{'ac'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # gcc command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "\n". @@ -989,18 +1021,23 @@ if (defined $makefiles{'ac'}) { $objstr = &objects($p, "X.o", undef, undef); print &splitline($prog . ": " . $objstr), "\n"; $libstr = &objects($p, undef, undef, "-lX"); - print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " . - $objstr . " $libstr", 69), "\n\n"; + print &splitline("\t\$(CC)" . $mw . " -o \$@ " . + $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n"; } foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; - print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n"); + if ($forceobj{$d->{obj_orig}}) { + printf("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } + print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n"); } print "\n"; print $makefile_extra{'gtk'}->{'end'}; print "\nclean:\n". "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n"; + print "\nFORCE:\n"; select STDOUT; close OUT; } @@ -1011,8 +1048,8 @@ if (defined $makefiles{'mpw'}) { "# Makefile for $project_name under MPW.\n#\n". "# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; - # MPW command line option is -d not /D - ($_ = $help) =~ s/=\/D/=-d /gs; + # MPW command line option is -d not /D (FIXME further massaging?) + ($_ = $help) =~ s/([=" ])\/D/\1-d /gs; print $_; print "\n\n". "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`". @@ -1154,7 +1191,7 @@ if (defined $makefiles{'lcc'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # lcc command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "\n". @@ -1166,6 +1203,8 @@ if (defined $makefiles{'lcc'}) { "CFLAGS = -D_WINDOWS " . (join " ", map {"-I$dirpfx$_"} @srcdirs) . "\n". + "# Resource compilation flags\n". + "RCFLAGS = \n". "\n". "# Get include directory for resource compiler\n". "\n". @@ -1185,13 +1224,18 @@ if (defined $makefiles{'lcc'}) { } foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; + if ($forceobj{$d->{obj_orig}}) { + printf("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } if ($d->{obj} =~ /\.obj$/) { print &splitline("\tlcc -O -p6 \$(COMPAT)". - " \$(XFLAGS) \$(CFLAGS) ".$d->{deps}->[0],69)."\n"; + " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n"; } else { - print &splitline("\tlrc \$(RCFL) -r ".$d->{deps}->[0],69)."\n"; + print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ". + $d->{deps}->[0],69)."\n"; } } print "\n"; @@ -1199,7 +1243,9 @@ if (defined $makefiles{'lcc'}) { print "\nclean:\n". "\t-del *.obj\n". "\t-del *.exe\n". - "\t-del *.res\n"; + "\t-del *.res\n". + "\n". + "FORCE:\n"; select STDOUT; close OUT; } @@ -1214,7 +1260,7 @@ if (defined $makefiles{'osx'}) { "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; # gcc command line option is -D not /D - ($_ = $help) =~ s/=\/D/=-D/gs; + ($_ = $help) =~ s/([=" ])\/D/\1-D/gs; print $_; print "CC = \$(TOOLPATH)gcc\n". @@ -1263,19 +1309,25 @@ if (defined $makefiles{'osx'}) { $objstr . " $libstr", 69), "\n\n"; } foreach $d (&deps("X.o", undef, $dirpfx, "/")) { - print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), - "\n"; + if ($forceobj{$d->{obj_orig}}) { + printf("%s: FORCE\n", $d->{obj}); + } else { + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @{$d->{deps}})), "\n"; + } $firstdep = $d->{deps}->[0]; if ($firstdep =~ /\.c$/) { - print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n"; + print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n"; } elsif ($firstdep =~ /\.m$/) { - print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n"; + print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n"; } } print "\n".$makefile_extra{'osx'}->{'end'}; print "\nclean:\n". - "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n"; + "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n". "\trm -rf *.app\n"; + "\n". + "FORCE:\n"; select STDOUT; close OUT; }