📄 mkfiles.pl
字号:
(join " ", map {"-I$dirpfx$_"} @srcdirs)) . "\n". "LDFLAGS = -mno-cygwin -s\n". &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1". " --define WINVER=0x0400 --define MINGW32_FIX=1")."\n". "\n". ".SUFFIXES:\n". "\n". "%.o: %.c\n". "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n". "\n". "%.res.o: %.rc\n". "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n". "\n"; print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); print "\n\n"; foreach $p (&prognames("GC")) { ($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, "/")) { print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), "\n"; } print "\n"; print $makefile_extra{'cygwin'}; print "\nclean:\n". "\trm -f *.o *.exe *.res.o *.map\n". "\n"; select STDOUT; close OUT;}##-- Borland makefileif (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/=-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=0x0401\n". "\n". "# Get include directory for resource compiler\n". "!if !\$d(BCB)\n". "BCB = \$(MAKEDIR)\\..\n". "!endif\n". "\n". ".c.obj:\n". &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)". " \$(XFLAGS) \$(CFLAGS) ". (join " ", map {"-I$dirpfx$_"} @srcdirs) . " /c \$*.c",69)."\n". ".rc.res:\n". &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r". " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n". "\n"; print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); print "\n\n"; foreach $p (&prognames("GC")) { ($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("GC")) { ($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, "\\")) { print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), "\n"; } print "\n"; print $makefile_extra{'borland'}; 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"; 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 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n". "LFLAGS = /incremental:no /fixed\n". "\n". ".c.obj:\n". "\tcl \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n". ".rc.res:\n". "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n". "\n"; print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); print "\n\n"; foreach $p (&prognames("GC")) { ($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("GC")) { ($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, "\\")) { print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), "\n"; } print "\n"; print $makefile_extra{'vc'}; 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'}) { $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", "", "\\"); %all_object_deps = map {$_->{obj} => $_->{deps}} @deps; # Create the project files # Get names of all Windows projects (GUI and console) my @prognames = &prognames("GC"); foreach $progname (@prognames) { create_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_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". "CFG=$windows_project - Win32 Debug\r\n". "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n". "!MESSAGE use the Export Makefile command and run\r\n". "!MESSAGE \r\n". "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n". "!MESSAGE \r\n". "!MESSAGE You can specify a configuration when running NMAKE\r\n". "!MESSAGE by defining the macro CFG on the command line. For example:\r\n". "!MESSAGE \r\n". "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n". "!MESSAGE \r\n". "!MESSAGE Possible choices for configuration are:\r\n". "!MESSAGE \r\n". "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n". "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n". "!MESSAGE \r\n". "\r\n". "# Begin Project\r\n". "# PROP AllowPerConfigDependencies 0\r\n". "# PROP Scc_ProjName \"\"\r\n". "# PROP Scc_LocalPath \"\"\r\n". "CPP=cl.exe\r\n". "MTL=midl.exe\r\n". "RSC=rc.exe\r\n". "\r\n". "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n". "\r\n". "# PROP BASE Use_MFC 0\r\n". "# PROP BASE Use_Debug_Libraries 0\r\n". "# PROP BASE Output_Dir \"Release\"\r\n". "# PROP BASE Intermediate_Dir \"Release\"\r\n".
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -