⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkfiles.pl

📁 putty
💻 PL
📖 第 1 页 / 共 4 页
字号:
    "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
    # gcc command line option is -D not /D
    ($_ = $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 = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
    "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
    "CC = \$(TOOLPATH)gcc\n".
    "RC = \$(TOOLPATH)windres\n".
    "# Uncomment the following two lines to compile under Winelib\n".
    "# CC = winegcc\n".
    "# RC = wrc\n".
    "# You may also need to tell windres where to find include files:\n".
    "# RCINC = --include-dir c:\\cygwin\\include\\\n".
    "\n".
    &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
      " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
	       (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
	       "\n".
    "LDFLAGS = -mno-cygwin -s\n".
    &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
      " --define WINVER=0x0400")."\n".
    "\n".
    $makefile_extra{'cygwin'}->{'vars'} .
    "\n".
    ".SUFFIXES:\n".
    "\n";
    print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
    print "\n\n";
    foreach $p (&prognames("G:C")) {
      ($prog, $type) = split ",", $p;
      $objstr = &objects($p, "X.o", "X.res.o", undef);
      print &splitline($prog . ".exe: " . $objstr), "\n";
      my $mw = $type eq "G" ? " -mwindows" : "";
      $libstr = &objects($p, undef, undef, "-lX");
      print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
                       "-Wl,-Map,$prog.map " .
                       $objstr . " $libstr", 69), "\n\n";
    }
    foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
      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) \$(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".
    "FORCE:\n";
    select STDOUT; close OUT;

}

##-- Borland makefile
if (defined $makefiles{'borland'}) {
    $dirpfx = &dirpfx($makefiles{'borland'}, "\\");

    %stdlibs = (  # Borland provides many Win32 API libraries intrinsically
      "advapi32" => 1,
      "comctl32" => 1,
      "comdlg32" => 1,
      "gdi32" => 1,
      "imm32" => 1,
      "shell32" => 1,
      "user32" => 1,
      "winmm" => 1,
      "winspool" => 1,
      "wsock32" => 1,
    );
    open OUT, ">$makefiles{'borland'}"; select OUT;
    print
    "# Makefile for $project_name under Borland C.\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";
    # bcc32 command line option is -D not /D
    ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
    print $_;
    print
    "\n".
    "# If you rename this file to `Makefile', you should change this line,\n".
    "# so that the .rsp files still depend on the correct makefile.\n".
    "MAKEFILE = Makefile.bor\n".
    "\n".
    "# C compilation flags\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".
    "BCB = \$(MAKEDIR)\\..\n".
    "!endif\n".
    "\n".
    $makefile_extra{'borland'}->{'vars'} .
    "\n".
    ".c.obj:\n".
    &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
	       " \$(CFLAGS) \$(XFLAGS) ".
	       (join " ", map {"-I$dirpfx$_"} @srcdirs) .
	       " /c \$*.c",69)."\n".
    ".rc.res:\n".
    &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
      " \$(RCFLAGS) \$*.rc",69)."\n".
    "\n";
    print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
    print "\n\n";
    foreach $p (&prognames("G:C")) {
      ($prog, $type) = split ",", $p;
      $objstr = &objects($p, "X.obj", "X.res", undef);
      print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
      my $ap = ($type eq "G") ? "-aa" : "-ap";
      print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
    }
    foreach $p (&prognames("G:C")) {
      ($prog, $type) = split ",", $p;
      print $prog, ".rsp: \$(MAKEFILE)\n";
      $objstr = &objects($p, "X.obj", undef, undef);
      @objlist = split " ", $objstr;
      @objlines = ("");
      foreach $i (@objlist) {
        if (length($objlines[$#objlines] . " $i") > 50) {
          push @objlines, "";
        }
        $objlines[$#objlines] .= " $i";
      }
      $c0w = ($type eq "G") ? "c0w32" : "c0x32";
      print "\techo $c0w + > $prog.rsp\n";
      for ($i=0; $i<=$#objlines; $i++) {
        $plus = ($i < $#objlines ? " +" : "");
        print "\techo$objlines[$i]$plus >> $prog.rsp\n";
      }
      print "\techo $prog.exe >> $prog.rsp\n";
      $objstr = &objects($p, "X.obj", "X.res", undef);
      @libs = split " ", &objects($p, undef, undef, "X");
      @libs = grep { !$stdlibs{$_} } @libs;
      unshift @libs, "cw32", "import32";
      $libstr = join ' ', @libs;
      print "\techo nul,$libstr, >> $prog.rsp\n";
      print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
      print "\n";
    }
    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
      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'};
    print "\nclean:\n".
    "\t-del *.obj\n".
    "\t-del *.exe\n".
    "\t-del *.res\n".
    "\t-del *.pch\n".
    "\t-del *.aps\n".
    "\t-del *.il*\n".
    "\t-del *.pdb\n".
    "\t-del *.rsp\n".
    "\t-del *.tds\n".
    "\t-del *.\$\$\$\$\$\$\n".
    "\n".
    "FORCE:\n".
    "\t-rem dummy command\n";
    select STDOUT; close OUT;
}

if (defined $makefiles{'vc'}) {
    $dirpfx = &dirpfx($makefiles{'vc'}, "\\");

    ##-- Visual C++ makefile
    open OUT, ">$makefiles{'vc'}"; select OUT;
    print
      "# Makefile for $project_name under Visual C.\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";
    print $help;
    print
      "\n".
      "# If you rename this file to `Makefile', you should change this line,\n".
      "# so that the .rsp files still depend on the correct makefile.\n".
      "MAKEFILE = Makefile.vc\n".
      "\n".
      "# C compilation flags\n".
      "CFLAGS = /nologo /W3 /O1 " .
      (join " ", map {"-I$dirpfx$_"} @srcdirs) .
      " /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".
      "\n";
    print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
    print "\n\n";
    foreach $p (&prognames("G:C")) {
	($prog, $type) = split ",", $p;
	$objstr = &objects($p, "X.obj", "X.res", undef);
	print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
	print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
    }
    foreach $p (&prognames("G:C")) {
	($prog, $type) = split ",", $p;
	print $prog, ".rsp: \$(MAKEFILE)\n";
	$objstr = &objects($p, "X.obj", "X.res", "X.lib");
	@objlist = split " ", $objstr;
	@objlines = ("");
	foreach $i (@objlist) {
	    if (length($objlines[$#objlines] . " $i") > 50) {
		push @objlines, "";
	    }
	    $objlines[$#objlines] .= " $i";
	}
	$subsys = ($type eq "G") ? "windows" : "console";
	print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
	for ($i=0; $i<=$#objlines; $i++) {
	    print "\techo$objlines[$i] >> $prog.rsp\n";
	}
	print "\n";
    }
    foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
        $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) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
	} else {
	    print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
	}
    }
    print "\n";
    print $makefile_extra{'vc'}->{'end'};
    print "\nclean: tidy\n".
      "\t-del *.exe\n\n".
      "tidy:\n".
      "\t-del *.obj\n".
      "\t-del *.res\n".
      "\t-del *.pch\n".
      "\t-del *.aps\n".
      "\t-del *.ilk\n".
      "\t-del *.pdb\n".
      "\t-del *.rsp\n".
      "\t-del *.dsp\n".
      "\t-del *.dsw\n".
      "\t-del *.ncb\n".
      "\t-del *.opt\n".
      "\t-del *.plg\n".
      "\t-del *.map\n".
      "\t-del *.idb\n".
      "\t-del debug.log\n";
    select STDOUT; close OUT;
}

if (defined $makefiles{'vcproj'}) {
    $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");

    $orig_dir = cwd;

    ##-- MSVC 6 Workspace and projects
    #
    # Note: All files created in this section are written in binary
    # mode, because although MSVC's command-line make can deal with
    # LF-only line endings, MSVC project files really _need_ to be
    # CRLF. Hence, in order for mkfiles.pl to generate usable project
    # files even when run from Unix, I make sure all files are binary
    # and explicitly write the CRLFs.
    #
    # Create directories if necessary
    mkdir $makefiles{'vcproj'}
        if(! -d $makefiles{'vcproj'});
    chdir $makefiles{'vcproj'};
    @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
    %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
    # Create the project files
    # Get names of all Windows projects (GUI and console)
    my @prognames = &prognames("G:C");
    foreach $progname (@prognames) {
      create_vc_project(\%all_object_deps, $progname);
    }
    # Create the workspace file
    open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
    print
    "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
    "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
    "\r\n".
    "###############################################################################\r\n".
    "\r\n";
    # List projects
    foreach $progname (@prognames) {
      ($windows_project, $type) = split ",", $progname;
    	print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
    }
    print
    "\r\n".
    "Package=<5>\r\n".
    "{{{\r\n".
    "}}}\r\n".
    "\r\n".
    "Package=<4>\r\n".
    "{{{\r\n".
    "}}}\r\n".
    "\r\n".
    "###############################################################################\r\n".
    "\r\n".
    "Global:\r\n".
    "\r\n".
    "Package=<5>\r\n".
    "{{{\r\n".
    "}}}\r\n".
    "\r\n".
    "Package=<3>\r\n".
    "{{{\r\n".
    "}}}\r\n".
    "\r\n".
    "###############################################################################\r\n".
    "\r\n";
    select STDOUT; close OUT;
    chdir $orig_dir;

    sub create_vc_project {
    	my ($all_object_deps, $progname) = @_;
    	# Construct program's dependency info
    	%seen_objects = ();
    	%lib_files = ();
    	%source_files = ();
    	%header_files = ();
    	%resource_files = ();
    	@object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
    	foreach $object_file (@object_files) {
	    next if defined $seen_objects{$object_file};
	    $seen_objects{$object_file} = 1;
	    if($object_file =~ /\.lib$/io) {
		$lib_files{$object_file} = 1;
		next;
	    }
	    $object_deps = $all_object_deps{$object_file};
	    foreach $object_dep (@$object_deps) {
		if($object_dep =~ /\.c$/io) {
		    $source_files{$object_dep} = 1;
		    next;
		}
		if($object_dep =~ /\.h$/io) {
		    $header_files{$object_dep} = 1;
		    next;
		}
		if($object_dep =~ /\.(rc|ico)$/io) {
		    $resource_files{$object_dep} = 1;
		    next;
		}
	    }
    	}
    	$libs = join " ", sort keys %lib_files;
    	@source_files = sort keys %source_files;
    	@header_files = sort keys %header_files;
    	@resources = sort keys %resource_files;
	($windows_project, $type) = split ",", $progname;
    	mkdir $windows_project
	    if(! -d $windows_project);
    	chdir $windows_project;
	$subsys = ($type eq "G") ? "windows" : "console";
    	open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
    	print
    	"# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
    	"# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
    	"# ** DO NOT EDIT **\r\n".
    	"\r\n".
    	"# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
    	"\r\n".

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -