- Fix --nomfc option which is currrently broken.
- Add --nodlls option for small apps.

diff --git a/tools/winemaker b/tools/winemaker
index b071c2a..6a36b96 100755
--- a/tools/winemaker
+++ b/tools/winemaker
@@ -234,6 +234,14 @@
 my $TF_MFC=4;
 
 ##
+# User has specified --nomfc option for this target or globally
+my $TF_NOMFC=8;
+
+##
+# --nodlls option: Do not use standard DLL set
+my $TF_NODLLS=16;
+
+##
 # Initialize a target:
 # - set the target type to TT_SETTINGS, i.e. no real target will
 #   be generated.
@@ -436,23 +444,37 @@
       push @{@$target[$T_LIBRARY_PATH]},$option;
     } elsif ($option =~ /^-l/) {
       push @{@$target[$T_LIBRARIES]},"$'";
-    } elsif (@$target[$T_TYPE] != $TT_DLL and $option =~ /^--wrap/) {
-      @$target[$T_FLAGS]|=$TF_WRAP;
-    } elsif (@$target[$T_TYPE] != $TT_DLL and $option =~ /^--nowrap/) {
-      @$target[$T_FLAGS]&=~$TF_WRAP;
-    } elsif ($option =~ /^--mfc/) {
-      @$target[$T_FLAGS]|=$TF_MFC;
+    } elsif ($option =~ /^--wrap/) {
       if (@$target[$T_TYPE] != $TT_DLL) {
         @$target[$T_FLAGS]|=$TF_WRAP;
+      } else {
+        print STDERR "warning: option --wrap is illegal for DLLs - ignoring";
+      };
+    } elsif ($option =~ /^--nowrap/) {
+      if (@$target[$T_TYPE] != $TT_DLL) {
+        @$target[$T_FLAGS]&=~$TF_WRAP;
+      } else {
+        print STDERR "warning: option --nowrap is illegal for DLLs - ignoring";
       }
+    } elsif ($option =~ /^--mfc/) {
+      @$target[$T_FLAGS]|=$TF_MFC;
+      @$target[$T_FLAGS]&=~$TF_NOMFC;
     } elsif ($option =~ /^--nomfc/) {
       @$target[$T_FLAGS]&=~$TF_MFC;
-      @$target[$T_FLAGS]&=~($TF_MFC|$TF_WRAP);
+      @$target[$T_FLAGS]|=$TF_NOMFC;
+    } elsif ($option =~ /^--nodlls/) {
+      @$target[$T_FLAGS]|=$TF_NODLLS;
     } else {
       print STDERR "error: unknown option \"$option\"\n";
       return 0;
     }
   }
+  if (@$target[$T_TYPE] != $TT_DLL &&
+      @$target[$T_FLAGS] & $TF_MFC &&
+      !(@$target[$T_FLAGS] & $TF_WRAP)) {
+    print STDERR "info: option --mfc requires --wrap";
+    @$target[$T_FLAGS]|=$TF_WRAP;
+  }
   return 1;
 }
 
@@ -543,7 +565,7 @@
       } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.spec\.c$/) {
 	push @sources_c,"$dentry";
       } elsif ($dentry =~ /\.(cpp|cxx)$/i) {
-	if ($dentry =~ /^stdafx.cpp$/i) {
+	if ($dentry =~ /^stdafx.cpp$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
 	  push @sources_misc,"$dentry";
 	  @$project_settings[$T_FLAGS]|=$TF_MFC;
 	} else {
@@ -553,7 +575,7 @@
 	push @sources_rc,"$dentry";
       } elsif ($dentry =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
 	push @sources_misc,"$dentry";
-	if ($dentry =~ /^stdafx.h$/i) {
+	if ($dentry =~ /^stdafx.h$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
 	  @$project_settings[$T_FLAGS]|=$TF_MFC;
 	}
       } elsif ($dentry =~ /\.dsp$/i) {
@@ -779,7 +801,11 @@
     # which we don't have in Wine. Also I add ntdll which seems
     # necessary for Winelib.
     my @std_dlls=qw(advapi32.dll comdlg32.dll gdi32.dll kernel32.dll ntdll.dll odbc32.dll ole32.dll oleaut32.dll shell32.dll user32.dll winspool.drv);
-    @$target[$T_DLLS]=\@std_dlls;
+    if (@$target[$T_FLAGS] & $TF_NODLLS == 0) {
+      @$target[$T_DLLS]=\@std_dlls;
+    } else {
+      @$target[$T_DLLS]=[];
+    }
     push @{@$project[$P_TARGETS]},$target;
 
     # Ask for target-specific options
@@ -2169,7 +2195,7 @@
   print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup] [--nosource-fix]\n";
   print STDERR "                 [--lower-none|--lower-all|--lower-uppercase]\n";
   print STDERR "                 [--lower-include|--nolower-include]\n";
-  print STDERR "                 [--guiexe|--windows|--cuiexe|--console|--dll]\n";
+  print STDERR "                 [--guiexe|--windows|--cuiexe|--console|--dll|--nodlls]\n";
   print STDERR "                 [--wrap|--nowrap] [--mfc|--nomfc]\n";
   print STDERR "                 [-Dmacro[=defn]] [-Idir] [-Pdir] [-idll] [-Ldir] [-llibrary]\n";
   print STDERR "                 [--interactive] [--single-target name]\n";
@@ -2182,9 +2208,6 @@
   exit (2);
 }
 
-
-project_init(\@main_project,"");
-
 while (@ARGV>0) {
   my $arg=shift @ARGV;
   # General options
@@ -2245,11 +2268,13 @@
     $opt_flags&=~$TF_WRAP;
   } elsif ($arg eq "--mfc") {
     $opt_flags|=$TF_MFC;
-    $opt_flags|=$TF_MFC|$TF_WRAP;
     $needs_mfc=1;
   } elsif ($arg eq "--nomfc") {
-    $opt_flags&=~($TF_MFC|$TF_WRAP);
+    $opt_flags&=~$TF_MFC;
+    $opt_flags|=$TF_NOMFC;
     $needs_mfc=0;
+  } elsif ($arg eq "--nodlls") {
+    $opt_flags|=$TF_NODLLS;
 
   # Catch errors
   } else {
@@ -2264,6 +2289,11 @@
       usage();
     }
   }
+
+  if ($opt_flags & $TF_MFC && $opt_target_type != $TT_DLL) {
+    print STDERR "info: option --mfc requires --wrap\n";
+    $opt_flags |= $TF_WRAP;
+  };
 }
 
 if (!defined $opt_work_dir) {
@@ -2279,6 +2309,8 @@
   print_banner();
 }
 
+project_init(\@main_project,"");
+
 # Fix the file and directory names
 fix_file_and_directory_names(".");
 
diff --git a/tools/winemaker.man b/tools/winemaker.man
index 787b07c..ea2742e 100644
--- a/tools/winemaker.man
+++ b/tools/winemaker.man
@@ -17,7 +17,7 @@
 ]
 .br
   [
-.IR               "--guiexe " "| " "--windows " "| " "--cuiexe " "| " "--console " "| " "--dll "
+.IR               "--guiexe " "| " "--windows " "| " "--cuiexe " "| " "--console " "| " "--dll " "| " "--nodlls "
 ]
 .br
   [
@@ -39,32 +39,32 @@
 .SH DESCRIPTION
 .PP
 .B winemaker
-is a perl script designed to help you bootstrap the 
+is a perl script designed to help you bootstrap the
 process of converting your Windows sources to Winelib programs.
 .PP
 In order to do this winemaker can perform the following operations:
 .PP
-- rename your source files and directories to lowercase in the event they 
+- rename your source files and directories to lowercase in the event they
 got all uppercased during the transfer.
 .PP
 - perform Dos to Unix (CRLF to LF) conversions.
 .PP
-- scan the include statements and resource file references to replace the 
+- scan the include statements and resource file references to replace the
 backslashes with forward slashes.
 .PP
-- during the above step winemaker will also perform a case insensitive search 
-of the referenced file in the include path and rewrite the include statement 
+- during the above step winemaker will also perform a case insensitive search
+of the referenced file in the include path and rewrite the include statement
 with the right case if necessary.
 .PP
-- winemaker will also check other more exotic issues like '#pragma pack' 
-usage, use of "afxres.h" in non MFC projects, and more. Whenever it 
+- winemaker will also check other more exotic issues like '#pragma pack'
+usage, use of "afxres.h" in non MFC projects, and more. Whenever it
 encounters something out of the ordinary, winemaker will warn you about it.
 .PP
-- winemaker can also scan a complete directory tree at once, guess what are 
-the executables and libraries you are trying to build, match them with 
+- winemaker can also scan a complete directory tree at once, guess what are
+the executables and libraries you are trying to build, match them with
 source files, and generate the corresponding Makefile.in files.
 .PP
-- finally winemaker will generate a global Makefile.in file calling out to all 
+- finally winemaker will generate a global Makefile.in file calling out to all
 the others, and a configure script customized for use with Winelib.
 .PP
 - winemaker knows about MFC-based project and will generate customized files.
@@ -75,7 +75,7 @@
 Disables the printing of the banner.
 .TP
 .I --backup
-Directs winemaker to perform a backup of all the source files in which it 
+Directs winemaker to perform a backup of all the source files in which it
 makes changes. This is the default.
 .TP
 .I --nobackup
@@ -89,58 +89,68 @@
 Tells winemaker to rename all files and directories to lowercase.
 .TP
 .I --lower-uppercase
-Tells winemaker to only rename files and directories that have an all 
-uppercase name. 
+Tells winemaker to only rename files and directories that have an all
+uppercase name.
 So "HELLO.C" would be renamed but not "World.c".
 .TP
 .I --lower-none
-Tells winemaker not to rename files and directories to lower case. Note 
-that this does not prevent the renaming of a file if its extension cannot 
+Tells winemaker not to rename files and directories to lower case. Note
+that this does not prevent the renaming of a file if its extension cannot
 be handled as is, e.g. ".Cxx". This is the default.
 .TP
 .I "--lower-include "
-Tells winemaker that if it does not find the file corresponding to an 
-include statement (or other form of file reference for resource files), 
+Tells winemaker that if it does not find the file corresponding to an
+include statement (or other form of file reference for resource files),
 then it should convert that filename to lowercase. This is the default.
 .TP
 .I "--nolower-include "
-Tells winemaker not to modify the include statement if it cannot find the 
+Tells winemaker not to modify the include statement if it cannot find the
 referenced file.
 .TP
 .IR "--guiexe " "| " "--windows"
-Specifies that whenever winemaker finds an executable target, or a target of 
+Specifies that whenever winemaker finds an executable target, or a target of
 unknown type, it should assume that it is a graphical application.
 This is the default.
 .TP
 .IR "--cuiexe " "| " "--console"
-Specifies that whenever winemaker finds an executable target, or a target of 
+Specifies that whenever winemaker finds an executable target, or a target of
 unknown type, it should assume that it is a console application.
 .TP
 .I --dll
-This option tells winemaker that whenever it finds a target of unknown type, 
-i.e. for which it does not know whether it is an executable or a library, 
+This option tells winemaker that whenever it finds a target of unknown type,
+i.e. for which it does not know whether it is an executable or a library,
 it should assume it is a library.
 .TP
+.I --nodlls
+This option tells winemaker not to use the standard set of winelib libraries
+for imports. That is, any DLL your code uses must be explicitly passed to
+winemaker with -i options.
+The standard set of libraries is: advapi32.dll, comdlg32.dll, gdi32.dll,
+kernel32.dll, odbc32.dll, ole32.dll, oleaut32.dll, shell32.dll, user32.dll,
+winspool.drv.
+.TP
 .I --wrap
-Specifies that executable targets should be built as libraries and a small 
-executable wrapper generated for them. This technique is sometimes required 
+Specifies that executable targets should be built as libraries and a small
+executable wrapper generated for them. This technique is sometimes required
 to solve initialization problems occuring on the application startup.
 .TP
 .I --nowrap
-Specifies that no wrapper should be generated for executable targets. This is 
+Specifies that no wrapper should be generated for executable targets. This is
 the default.
 .TP
 .I --mfc
-Specifies that the targets are MFC based. In such a case winemaker generates a 
-configure script with MFC specific options, modifies the include and 
-library paths accordingly, links the target with the MFC library and 
+Specifies that the targets are MFC based. In such a case winemaker generates a
+configure script with MFC specific options, modifies the include and
+library paths accordingly, links the target with the MFC library and
 generates wrappers for these targets that are executables.
 .TP
 .I --nomfc
-Specifies that targets are not MFC-based. This is the default.
+Specifies that targets are not MFC-based. This option disables use of MFC libraries
+even if winemaker encounters files "stdafx.cpp" or "stdafx.h" that would cause it
+to enable MFC automatically if neither --nomfc nor --mfc was specified.
 .TP
 .I -Dmacro[=defn]
-Adds the specified macro definition to the global list of macro definitions. 
+Adds the specified macro definition to the global list of macro definitions.
 .TP
 .I -Idir
 Appends the specified directory to the global include path.
@@ -149,23 +159,22 @@
 Appends the specified directory to the global library path.
 .TP
 .I -idll
-Adds the Winelib library to the global list of Winelib libraries to import 
-in the spec file.
+Adds the Winelib library to the global list of Winelib libraries to import.
 .TP
 .I -llibrary
 Adds the specified library to the global list of libraries to link with.
 .TP
 .I --interactive
-Puts winemaker in interactive mode. In this mode winemaker will ask you to 
-confirm each directory's list of targets, and then to provide directory and 
+Puts winemaker in interactive mode. In this mode winemaker will ask you to
+confirm each directory's list of targets, and then to provide directory and
 target specific options.
 .TP
 .I --single-target name
 Specifies that there is only one target, and that it is called "name".
 .TP
 .I --generated-files
-Tells winemaker to generate the build infrastructure files, i.e. the spec 
-files, the wrapper files, the Makefile.in files, the Make.rules.in file, the 
+Tells winemaker to generate the build infrastructure files, i.e. the spec
+files, the wrapper files, the Makefile.in files, the Make.rules.in file, the
 configure.in file and the configure script. This is the default.
 .TP
 .I --nogenerated-files
@@ -182,28 +191,28 @@
 .PP
 $ winemaker --lower-uppercase -DSTRICT
 .PP
-The above tells winemaker to scan the current directory and its 
-subdirectories for source files. Whenever if finds a file or directory which 
-name is all uppercase, it should rename it to lowercase. It should then fix 
-all these source files for compilation with Winelib and generate Makefiles. 
-The '-DSTRICT' specifies that the STRICT macro must be set when compiling 
-these sources. Finally winemaker will create a global Makefile.in and 
+The above tells winemaker to scan the current directory and its
+subdirectories for source files. Whenever if finds a file or directory which
+name is all uppercase, it should rename it to lowercase. It should then fix
+all these source files for compilation with Winelib and generate Makefiles.
+The '-DSTRICT' specifies that the STRICT macro must be set when compiling
+these sources. Finally winemaker will create a global Makefile.in and
 configure.in, and run autoconf to generate the configure script.
 .PP
 The next step would be:
 .PP
 $ ./configure --with-wine=/usr/local/opt/wine
 .PP
-This generates the makefiles from the Makefile.in files. The generated 
-makefiles will fetch the Winelib headers and libraries from the Wine 
+This generates the makefiles from the Makefile.in files. The generated
+makefiles will fetch the Winelib headers and libraries from the Wine
 installation located in /usr/local/opt/wine.
 .PP
 And finally:
 .PP
 $ make
 .PP
-If at this point you get compilation errors (which is quite likely for a 
-reasonably sized project) then you should consult the Winelib User Guide to 
+If at this point you get compilation errors (which is quite likely for a
+reasonably sized project) then you should consult the Winelib User Guide to
 find tips on how to resolve them.
 .PP
 For an MFC-based project one would have run the following commands instead:
@@ -219,23 +228,23 @@
 
 .SH TODO / BUGS
 .PP
-Winemaker should support the Visual Studio project files (.dsp for newer 
-versions and .mak for some older versions). This would allow it to be much 
-more accurate, especially for the macro, include and library path 
+Winemaker should support the Visual Studio project files (.dsp for newer
+versions and .mak for some older versions). This would allow it to be much
+more accurate, especially for the macro, include and library path
 settings.
 .PP
-Assuming that the windows executable/library is available, we could 
-use a pedump-like tool to determine what kind of executable it is (graphical 
-or console), which libraries it is linked with, and which functions it 
-exports (for libraries). We could then restore all these settings for the 
-corresponding Winelib target. The problem is that we should have such a tool 
+Assuming that the windows executable/library is available, we could
+use a pedump-like tool to determine what kind of executable it is (graphical
+or console), which libraries it is linked with, and which functions it
+exports (for libraries). We could then restore all these settings for the
+corresponding Winelib target. The problem is that we should have such a tool
 available under the Wine license first.
 .PP
-The wrapper code should be generic, i.e. you should be able to have just one 
+The wrapper code should be generic, i.e. you should be able to have just one
 wrapper and specify which library to load using an option.
 .PP
-Furthermore it is not very good at finding the library containing the 
-executable: it must either be in the current directory or in the 
+Furthermore it is not very good at finding the library containing the
+executable: it must either be in the current directory or in the
 .IR LD_LIBRARY_PATH .
 .PP
 Winemaker does not support message files and the message compiler yet.