tools: Fixed buildicon to support rectangular icons.
[wine] / tools / winemaker
index 0af64f5..4cd46ff 100755 (executable)
@@ -1,8 +1,9 @@
 #!/usr/bin/perl -w
 use strict;
 
-# Copyright 2000-2002 Francois Gouget for CodeWeavers
-# fgouget@codeweavers.com
+# Copyright 2000-2004 Francois Gouget for CodeWeavers
+# Copyright 2004 Dimitrie O. Paun
+# Copyright 2009 André Hentschel
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -16,10 +17,10 @@ use strict;
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 #
 
-my $version="0.5.9";
+my $version="0.7.4";
 
 use Cwd;
 use File::Basename;
@@ -63,12 +64,27 @@ my $OPT_ASK_YES=1;
 my $OPT_ASK_SKIP=-1;
 
 
+# The following constants define the architecture
+
+##
+# 32-Bit Target
+my $OPT_ARCH_32=32;
+
+##
+# 64-Bit Target
+my $OPT_ARCH_64=64;
+
+
 # General options
 
 ##
 # This is the directory in which winemaker will operate.
 my $opt_work_dir;
 
+##
+# This is the file in which winemaker will operate if a project file is specified.
+my $opt_work_file;
+
 ##
 # Make a backup of the files
 my $opt_backup;
@@ -107,6 +123,10 @@ my $opt_target_type;
 # Contains the default set of flags to be used when creating a new target.
 my $opt_flags;
 
+##
+# Contains 32 for 32-Bit-Targets and 64 for 64-Bit-Targets
+my $opt_arch;
+
 ##
 # If true then winemaker should ask questions to the user as it goes
 # along.
@@ -115,15 +135,9 @@ my $opt_ask_project_options;
 my $opt_ask_target_options;
 
 ##
-# If false then winemaker should not generate any file, i.e.
-# no makefiles, but also no .spec files, no configure.in, etc.
+# If false then winemaker should not generate the makefiles.
 my $opt_no_generated_files;
 
-##
-# If true then winemaker should not generate the spec files.
-# This is useful if winemaker is being used to create a build environment
-my $opt_no_generated_specs;
-
 ##
 # Specifies not to print the banner if set.
 my $opt_no_banner;
@@ -148,53 +162,67 @@ my $T_NAME=0;
 # constants below
 my $T_TYPE=1;
 
-##
-# Defines the target's enty point, i.e. the function that is called
-# on startup.
-my $T_INIT=2;
-
 ##
 # This is a bitfield containing flags refining the way the target
 # should be handled. See the TF_xxx constants below
-my $T_FLAGS=3;
+my $T_FLAGS=2;
 
 ##
 # This is a reference to an array containing the list of the
 # resp. C, C++, RC, other (.h, .hxx, etc.) source files.
-my $T_SOURCES_C=4;
-my $T_SOURCES_CXX=5;
-my $T_SOURCES_RC=6;
-my $T_SOURCES_MISC=7;
+my $T_SOURCES_C=3;
+my $T_SOURCES_CXX=4;
+my $T_SOURCES_RC=5;
+my $T_SOURCES_MISC=6;
+
+##
+# This is a reference to an array containing the list of
+# C compiler options
+my $T_CEXTRA=7;
+
+##
+# This is a reference to an array containing the list of
+# C++ compiler options
+my $T_CXXEXTRA=8;
+
+##
+# This is a reference to an array containing the list of
+# RC compiler options
+my $T_RCEXTRA=9;
 
 ##
 # This is a reference to an array containing the list of macro
 # definitions
-my $T_DEFINES=8;
+my $T_DEFINES=10;
 
 ##
 # This is a reference to an array containing the list of directory
 # names that constitute the include path
-my $T_INCLUDE_PATH=9;
+my $T_INCLUDE_PATH=11;
+
+##
+# Flags for the linker
+my $T_LDFLAGS=12;
 
 ##
 # Same as T_INCLUDE_PATH but for the dll search path
-my $T_DLL_PATH=10;
+my $T_DLL_PATH=13;
 
 ##
 # The list of Windows dlls to import
-my $T_DLLS=11;
+my $T_DLLS=14;
 
 ##
 # Same as T_INCLUDE_PATH but for the library search path
-my $T_LIBRARY_PATH=12;
+my $T_LIBRARY_PATH=15;
 
 ##
 # The list of Unix libraries to link with
-my $T_LIBRARIES=13;
+my $T_LIBRARIES=16;
 
 ##
 # The list of dependencies between targets
-my $T_DEPENDS=14;
+my $T_DEPENDS=17;
 
 
 # The following constants define the recognized types of target
@@ -221,14 +249,6 @@ my $TT_DLL=3;
 
 # The following constants further refine how the target should be handled
 
-##
-# This target needs a wrapper
-my $TF_WRAP=1;
-
-##
-# This target is a wrapper
-my $TF_WRAPPER=2;
-
 ##
 # This target is an MFC-based target
 my $TF_MFC=4;
@@ -241,6 +261,10 @@ my $TF_NOMFC=8;
 # --nodlls option: Do not use standard DLL set
 my $TF_NODLLS=16;
 
+##
+# --nomsvcrt option: Do not link with msvcrt
+my $TF_NOMSVCRT=32;
+
 ##
 # Initialize a target:
 # - set the target type to TT_SETTINGS, i.e. no real target will
@@ -256,25 +280,16 @@ sub target_init($)
   @$target[$T_SOURCES_CXX]=[];
   @$target[$T_SOURCES_RC]=[];
   @$target[$T_SOURCES_MISC]=[];
+  @$target[$T_CEXTRA]=[];
+  @$target[$T_CXXEXTRA]=[];
+  @$target[$T_RCEXTRA]=[];
   @$target[$T_DEFINES]=[];
   @$target[$T_INCLUDE_PATH]=[];
+  @$target[$T_LDFLAGS]=[];
   @$target[$T_DLL_PATH]=[];
   @$target[$T_DLLS]=[];
   @$target[$T_LIBRARY_PATH]=[];
   @$target[$T_LIBRARIES]=[];
-  @$target[$T_DEPENDS]=[];
-}
-
-sub get_default_init($)
-{
-  my $type=$_[0];
-  if ($type == $TT_GUIEXE) {
-    return "WinMain";
-  } elsif ($type == $TT_CUIEXE) {
-    return "main";
-  } elsif ($type == $TT_DLL) {
-    return "DllMain";
-  }
 }
 
 
@@ -312,13 +327,18 @@ my $P_TARGETS=2;
 # - set the project's path
 # - initialize the target list
 # - create a default target (will be removed later if unnecessary)
-sub project_init($$)
+sub project_init($$$)
 {
-  my $project=$_[0];
-  my $path=$_[1];
+  my ($project, $path, $global_settings)=@_;
 
   my $project_settings=[];
   target_init($project_settings);
+  @$project_settings[$T_DEFINES]=[@{@$global_settings[$T_DEFINES]}];
+  @$project_settings[$T_INCLUDE_PATH]=[@{@$global_settings[$T_INCLUDE_PATH]}];
+  @$project_settings[$T_DLL_PATH]=[@{@$global_settings[$T_DLL_PATH]}];
+  @$project_settings[$T_DLLS]=[@{@$global_settings[$T_DLLS]}];
+  @$project_settings[$T_LIBRARY_PATH]=[@{@$global_settings[$T_LIBRARY_PATH]}];
+  @$project_settings[$T_LIBRARIES]=[@{@$global_settings[$T_LIBRARIES]}];
 
   @$project[$P_PATH]=$path;
   @$project[$P_SETTINGS]=$project_settings;
@@ -337,6 +357,11 @@ my %warnings;
 
 my %templates;
 
+##
+# This maps a directory name to a reference to an array listing
+# its contents (files and directories)
+my %directories;
+
 ##
 # Contains the list of all projects. This list tells us what are
 # the subprojects of the main Makefile and where we have to generate
@@ -356,11 +381,6 @@ my @main_project;
 # sources fields.
 my @global_settings;
 
-##
-# If one of the projects requires the MFc then we set this global variable
-# to true so that configure asks the user to provide a path tothe MFC
-my $needs_mfc=0;
-
 
 
 #####
@@ -392,27 +412,52 @@ sub is_absolute($)
 }
 
 ##
-# Performs a binary search looking for the specified item
-sub bsearch($$)
+# Retrieves the contents of the specified directory.
+# We either get it from the directories hashtable which acts as a
+# cache, or use opendir, readdir, closedir and store the result
+# in the hashtable.
+sub get_directory_contents($)
 {
-  my $array=$_[0];
-  my $item=$_[1];
-  my $last=@{$array}-1;
-  my $first=0;
-
-  while ($first<=$last) {
-    my $index=int(($first+$last)/2);
-    my $cmp=@$array[$index] cmp $item;
-    if ($cmp<0) {
-      $first=$index+1;
-    } elsif ($cmp>0) {
-      $last=$index-1;
-    } else {
-      return $index;
-    }
+  my $dirname=$_[0];
+  my $directory;
+
+  #print "getting the contents of $dirname\n";
+
+  # check for a cached version
+  $dirname =~ s+/$++;
+  if ($dirname eq "") {
+    $dirname=cwd;
   }
+  $directory=$directories{$dirname};
+  if (defined $directory) {
+    #print "->@$directory\n";
+    return $directory;
+  }
+
+  # Read this directory
+  if (opendir(DIRECTORY, "$dirname")) {
+    my @files=readdir DIRECTORY;
+    closedir(DIRECTORY);
+    $directory=\@files;
+  } else {
+    # Return an empty list
+    #print "error: cannot open $dirname\n";
+    my @files;
+    $directory=\@files;
+  }
+  #print "->@$directory\n";
+  $directories{$dirname}=$directory;
+  return $directory;
 }
 
+##
+# Removes a directory from the cache.
+# This is needed if one of its files or subdirectory has been renamed.
+sub clear_directory_cache($)
+{
+    my ($dirname)=@_;
+    delete $directories{$dirname};
+}
 
 
 #####
@@ -439,30 +484,11 @@ sub source_set_options($$)
     } elsif ($option =~ /^-P/) {
       push @{@$target[$T_DLL_PATH]},"-L$'";
     } elsif ($option =~ /^-i/) {
-      my $dllname = $';
-      if ($dllname =~ /^[^.]*$/) {
-        $dllname .= ".dll";
-      }
-      if ($dllname =~ /^msvcrt\.dll$/) {
-        push @{@$target[$T_INCLUDE_PATH]},"-I\$(WINE_INCLUDE_ROOT)/msvcrt";
-      }
-      push @{@$target[$T_DLLS]},$dllname;
+      push @{@$target[$T_DLLS]},"$'";
     } elsif ($option =~ /^-L/) {
       push @{@$target[$T_LIBRARY_PATH]},$option;
     } elsif ($option =~ /^-l/) {
       push @{@$target[$T_LIBRARIES]},"$'";
-    } 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;
@@ -471,20 +497,693 @@ sub source_set_options($$)
       @$target[$T_FLAGS]|=$TF_NOMFC;
     } elsif ($option =~ /^--nodlls/) {
       @$target[$T_FLAGS]|=$TF_NODLLS;
+    } elsif ($option =~ /^--nomsvcrt/) {
+      @$target[$T_FLAGS]|=$TF_NOMSVCRT;
     } 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;
 }
 
+##
+# Scans the specified project file to:
+# - get a list of targets for this project
+# - get some settings
+# - get the list of source files
+sub source_scan_project_file($$$);
+sub source_scan_project_file($$$)
+{
+    # a reference to the parent's project
+    my $parent_project=$_[0];
+    # 0 if it is a single project, 1 if it is part of a workspace
+    my $is_sub_project=$_[1];
+    # the name of the project file, with complete path, or without if in
+    # the same directory
+    my $filename=$_[2];
+
+    # reference to the project for this file. May not be used
+    my $project;
+    # list of sources found in the current file
+    my @sources_c=();
+    my @sources_cxx=();
+    my @sources_rc=();
+    my @sources_misc=();
+    # some more settings
+    my $path=dirname($filename);
+    my $prj_target_cflags;
+    my $prj_target_defines;
+    my $prj_target_ldflags;
+    my $prj_target_libs;
+    my $prj_name;
+    my $found_cfg=0;
+    my $prj_cfg;
+    my $prj_target_type=1;
+    my @prj_target_options;
+
+    if (!($path=~/\/$/)) {
+        $path.="/";
+    }
+
+    if (defined $opt_single_target or $is_sub_project == 0) {
+        # Either there is a single target and thus a single project,
+        # or we are a single project-file for which a project
+        # already exists
+        $project=$parent_project;
+    } else {
+        $project=[];
+        project_init($project, $path, \@global_settings);
+    }
+    my $project_settings=@$project[$P_SETTINGS];
+
+    if ($filename =~ /.dsp$/i) {
+        # First find out what this project file contains:
+        # collect all sources, find targets and settings
+        if (!open(FILEI,$filename)) {
+            print STDERR "error: unable to open $filename for reading:\n";
+            print STDERR "       $!\n";
+            return;
+        }
+        my $sfilet;
+        while (<FILEI>) {
+            # Remove any trailing CtrlZ, which isn't strictly in the file
+            if (/\x1A/) {
+                s/\x1A//;
+                last if (/^$/)
+            }
+
+            # Remove any trailing CrLf
+            s/\r\n$/\n/;
+            if (!/\n$/) {
+                # Make sure all lines are '\n' terminated
+                $_ .= "\n";
+            }
+
+            if (/^\# Microsoft Developer Studio Project File - Name=\"([^\"]+)/) {
+                $prj_name="$1";
+                $prj_name=~s/\s+/_/g;
+                #print $prj_name;
+                next;
+            } elsif (/^# TARGTYPE/) {
+                if (/[[:space:]]0x0101$/) {
+                    # Win32 (x86) Application
+                    $prj_target_type=1;
+                }elsif (/[[:space:]]0x0102$/) {
+                    # Win32 (x86) Dynamic-Link Library
+                    $prj_target_type=3;
+                }elsif (/[[:space:]]0x0103$/) {
+                    # Win32 (x86) Console Application
+                    $prj_target_type=2;
+                }elsif (/[[:space:]]0x0104$/) {
+                    # Win32 (x86) Static Library
+                }
+                next;
+            } elsif (/^# ADD CPP(.*)/ && $found_cfg==1) {
+                $prj_target_cflags=$1;
+                @prj_target_options=split(" /", $prj_target_cflags);
+                $prj_target_cflags="";
+                foreach ( @prj_target_options ) {
+                    if ($_ eq "") {
+                        # empty
+                    } elsif (/nologo/) {
+                        # Suppress Startup Banner and Information Messages
+                    } elsif (/^W0$/) {
+                        # Turns off all warning messages
+                        $prj_target_cflags.="-w ";
+                    } elsif (/^W[123]$/) {
+                        # Warning Level
+                        $prj_target_cflags.="-W ";
+                    } elsif (/^W4$/) {
+                        # Warning Level
+                        $prj_target_cflags.="-Wall ";
+                    } elsif (/^WX$/) {
+                        # Warnings As Errors
+                        $prj_target_cflags.="-Werror ";
+                    } elsif (/^Gm$/) {
+                        # Enable Minimal Rebuild
+                    } elsif (/^GX$/) {
+                        # Enable Exception Handling
+                        $prj_target_cflags.="-fexceptions ";
+                    } elsif (/^Z[d7iI]$/) {
+                        # Debug Info
+                        $prj_target_cflags.="-g ";
+                    } elsif (/^Od$/) {
+                        # Disable Optimizations
+                        $prj_target_cflags.="-O0 ";
+                    } elsif (/^O1$/) {
+                        # Minimize Size
+                        $prj_target_cflags.="-Os ";
+                    } elsif (/^O2$/) {
+                        # Maximize Speed
+                        $prj_target_cflags.="-O2 ";
+                    } elsif (/^Ob0$/) {
+                        # Disables inline Expansion
+                        $prj_target_cflags.="-fno-inline ";
+                    } elsif (/^Ob1$/) {
+                        #In-line Function Expansion
+                        $prj_target_cflags.="-finline-functions ";
+                    } elsif (/^Ob2$/) {
+                        # auto In-line Function Expansion
+                        $prj_target_cflags.="-finline-functions ";
+                    } elsif (/^Ox$/) {
+                        # Use maximum optimization
+                        $prj_target_cflags.="-O3 ";
+                    } elsif (/^Oy$/) {
+                        # Frame-Pointer Omission
+                        $prj_target_cflags.="-fomit-frame-pointer ";
+                    } elsif (/^Oy-$/) {
+                        # Frame-Pointer Omission
+                        $prj_target_cflags.="-fno-omit-frame-pointer ";
+                    } elsif (/^GZ$/) {
+                        # Catch Release-Build Errors in Debug Build
+                    } elsif (/^M[DLT]d?$/) {
+                        # Use Multithreaded Run-Time Library
+                    } elsif (/^D\s*\"(.*)\"/) {
+                        # Preprocessor Definitions
+                        $prj_target_defines.="-D".$1." ";
+                    } elsif (/^I\s*\"(.*)\"/) {
+                        # Additional Include Directories
+                        $sfilet=$1;
+                        $sfilet=~s/\\/\//g;
+                        push @{@$project_settings[$T_INCLUDE_PATH]},"-I".$sfilet." ";
+                    } elsif (/^U\s*\"(.*)\"/) {
+                        # Undefines a previously defined symbol
+                        $prj_target_cflags.="-U".$1." ";
+                    } elsif (/^Fp/) {
+                        # Name .PCH File
+                    } elsif (/^F[Rr]/) {
+                        # Create .SBR File
+                    } elsif (/^YX$/) {
+                        # Automatic Use of Precompiled Headers
+                    } elsif (/^FD$/) {
+                        # Generate File Dependencies
+                    } elsif (/^c$/) {
+                        # Compile Without Linking
+                        # this option is always present and is already specified in the suffix rules
+                    } elsif (/^GB$/) {
+                        # Blend Optimization
+                        $prj_target_cflags.="-mcpu=pentiumpro -D_M_IX86=500 ";
+                    } elsif (/^G6$/) {
+                        # Pentium Pro Optimization
+                        $prj_target_cflags.="-march=pentiumpro -D_M_IX86=600 ";
+                    } elsif (/^G5$/) {
+                        # Pentium Optimization
+                        $prj_target_cflags.="-mcpu=pentium -D_M_IX86=500 ";
+                    } elsif (/^G3$/) {
+                        # 80386 Optimization
+                        $prj_target_cflags.="-mcpu=i386 -D_M_IX86=300 ";
+                    } elsif (/^G4$/) {
+                        # 80486 Optimization
+                        $prj_target_cflags.="-mcpu=i486 -D_M_IX86=400 ";
+                    } elsif (/^Yc/) {
+                        # Create Precompiled Header
+                    } elsif (/^Yu/) {
+                        # Use Precompiled Header
+                    } elsif (/^Za$/) {
+                        # Disable Language Extensions
+                        $prj_target_cflags.="-ansi ";
+                    } elsif (/^Ze$/) {
+                        # Enable Microsoft Extensions
+                    } elsif (/^Zm[[:digit:]]+$/) {
+                        # Specify Memory Allocation Limit
+                    } elsif (/^Zp1?$/) {
+                        # Packs structures on 1-byte boundaries
+                        $prj_target_cflags.="-fpack-struct ";
+                    } elsif (/^Zp(2|4|8|16)$/) {
+                        # Struct Member Alignment
+                        $prj_target_cflags.="-fpack-struct=".$1;
+                    } else {
+                        print "C compiler option $_ not implemented\n";
+                    }
+                }
+
+                #print "\nOptions: $prj_target_cflags\n";
+                next;
+            } elsif (/^# ADD LINK32(.*)/ && $found_cfg==1) {
+                $prj_target_ldflags=$1;
+                @prj_target_options=split(" /", $prj_target_ldflags);
+                $prj_target_ldflags="";
+                $prj_target_libs=$prj_target_options[0];
+                $prj_target_libs=~s/\\/\//g;
+                $prj_target_libs=~s/\.lib//g;
+                $prj_target_libs=~s/\s+/ -l/g;
+                shift (@prj_target_options);
+                foreach ( @prj_target_options ) {
+                    if ($_ eq "") {
+                        # empty
+                    } elsif (/^base:(.*)/) {
+                        # Base Address
+                        $prj_target_ldflags.="--image-base ".$1." ";
+                    } elsif (/^debug$/) {
+                        # Generate Debug Info
+                    } elsif (/^dll$/) {
+                        # Build a DLL
+                        $prj_target_type=3;
+                    } elsif (/^incremental:[[:alpha:]]+$/) {
+                        # Link Incrmentally
+                    } elsif (/^implib:/) {
+                        # Name import library
+                    } elsif (/^libpath:\"(.*)\"/) {
+                        # Additional Libpath
+                        push @{@$project_settings[$T_DLL_PATH]},"-L$1";
+                    } elsif (/^machine:[[:alnum:]]+$/) {
+                        # Specify Target Platform
+                    } elsif (/^map/) {
+                        # Generate Mapfile
+                        if (/^map:(.*)/) {
+                            $prj_target_ldflags.="-Map ".$1." ";
+                        } else {
+                            $prj_target_ldflags.="-Map ".$prj_name.".map ";
+                        }
+                    } elsif (/^nologo$/) {
+                        # Suppress Startup Banner and Information Messages
+                    } elsif (/^out:/) {
+                        # Output File Name
+                        # may use it as Target?
+                    } elsif (/^pdbtype:/) {
+                        # Program Database Storage
+                    } elsif (/^subsystem:/) {
+                        # Specify Subsystem
+                    } elsif (/^version:[[:digit:].]+$/) {
+                        # Version Information
+                    } else {
+                        print "Linker option $_ not implemented\n";
+                    }
+                }
+                next;
+            } elsif (/^LIB32=/ && $found_cfg==1) {
+                #$libflag = 1;
+                next;
+            } elsif (/^SOURCE=(.*)$/) {
+                my @components=split /[\/\\]+/, $1;
+                $sfilet=search_from($path, \@components);
+                if ($sfilet =~ /\.c$/i and $sfilet !~ /\.(dbg|spec)\.c$/) {
+                    push @sources_c,$sfilet;
+                } elsif ($sfilet =~ /\.(cpp|cxx)$/i) {
+                    if ($sfilet =~ /^stdafx.cpp$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
+                        push @sources_misc,$sfilet;
+                        @$project_settings[$T_FLAGS]|=$TF_MFC;
+                    } else {
+                        push @sources_cxx,$sfilet;
+                    }
+                } elsif ($sfilet =~ /\.rc$/i) {
+                    push @sources_rc,$sfilet;
+                } elsif ($sfilet =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
+                    push @sources_misc,$sfilet;
+                    if ($sfilet =~ /^stdafx.h$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
+                        @$project_settings[$T_FLAGS]|=$TF_MFC;
+                    }
+                }
+                next;
+
+            } elsif (/^# (Begin|End) Source File/) {
+                # Source-Files already handled
+                next;
+            } elsif (/^# (Begin|End) Group/) {
+                # Groups are ignored
+                next;
+            } elsif (/^# (Begin|End) Custom Build/) {
+                # Custom Builds are ignored
+                next;
+            } elsif (/^# ADD LIB32 /) {
+                #"ARFLAGS=rus"
+                next;
+            } elsif (/^# Begin Target$/) {
+                # Targets are ignored
+                next;
+            } elsif (/^# End Target$/) {
+                # Targets are ignored
+                next;
+            } elsif (/^!/) {
+                if ($found_cfg == 1) {
+                    $found_cfg=0;
+                }
+                if (/if (.*)\(CFG\)" == "(.*)"/i) {
+                    if ($2 eq $prj_cfg) {
+                        $found_cfg=1;
+                    }
+                }
+                next;
+            } elsif (/^CFG=(.*)/i) {
+                $prj_cfg=$1;
+                next;
+            }
+                else { # Line recognized
+                # print "|\n";
+            }
+        }
+        close(FILEI);
+
+        push @{@$project_settings[$T_LIBRARIES]},$prj_target_libs;
+        push @{@$project_settings[$T_CEXTRA]},$prj_target_cflags;
+        push @{@$project_settings[$T_CXXEXTRA]},$prj_target_cflags;
+        push @{@$project_settings[$T_DEFINES]},$prj_target_defines;
+        push @{@$project_settings[$T_LDFLAGS]},$prj_target_ldflags;
+    } elsif ($filename =~ /.vcproj$/i) {
+        # Import XML::LibXML, you need the libxml package (deb: libxml-libxml-perl, rpm: perl-libxml-perl)
+        require XML::LibXML;
+
+        my $xmlparser = XML::LibXML->new();
+        my $project_xml = $xmlparser->parse_file($filename);
+        my $sfilet;
+        my $configt;
+
+        foreach my $vc_project ($project_xml->findnodes('/VisualStudioProject')) {
+            foreach my $vc_project_attr ($vc_project->attributes) {
+                if ($vc_project_attr->getName eq "Name") {
+                    $prj_name=$vc_project_attr->getValue;
+                    $prj_name=~s/\s+/_/g;
+                    last;
+                }
+            }
+        }
+
+        for (my $flevel = 0; $flevel <= 5; $flevel++) {
+            foreach my $vc_file ($project_xml->findnodes('/VisualStudioProject/Files/'.('Filter/' x $flevel).'File')) {
+                foreach my $vc_file_attr ($vc_file->attributes) {
+                    if ($vc_file_attr->getName eq "RelativePath") {
+                        $sfilet = $vc_file_attr->getValue;
+                        $sfilet=~s/\\\\/\\/g; #remove double backslash
+                        $sfilet=~s/^\.\\//; #remove starting 'this directory'
+                        $sfilet=~s/\\/\//g; #make slashes out of backslashes
+                        if ($sfilet =~ /\.c$/i and $sfilet !~ /\.(dbg|spec)\.c$/) {
+                            push @sources_c,$sfilet;
+                        } elsif ($sfilet =~ /\.(cpp|cxx)$/i) {
+                            if ($sfilet =~ /^stdafx.cpp$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
+                                push @sources_misc,$sfilet;
+                                @$project_settings[$T_FLAGS]|=$TF_MFC;
+                            } else {
+                                push @sources_cxx,$sfilet;
+                            }
+                        } elsif ($sfilet =~ /\.rc$/i) {
+                            push @sources_rc,$sfilet;
+                        } elsif ($sfilet =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
+                            push @sources_misc,$sfilet;
+                            if ($sfilet =~ /^stdafx.h$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
+                                @$project_settings[$T_FLAGS]|=$TF_MFC;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        my @vc_configurations = $project_xml->findnodes('/VisualStudioProject/Configurations/Configuration');
+        my $vc_configuration = $vc_configurations[0];
+        foreach my $vc_configuration_attr ($vc_configuration->attributes) {
+            if ($vc_configuration_attr->getName eq "ConfigurationType") {
+                if ($vc_configuration_attr->getValue==1) {
+                    $prj_target_type=1; # Win32 (x86) Application
+                } elsif ($vc_configuration_attr->getValue==2) {
+                    $prj_target_type=3; # Win32 (x86) Dynamic-Link Library
+                }
+            }
+        }
+
+        foreach my $vc_configuration_tools ($vc_configuration->findnodes('Tool')) {
+            my @find_tool = $vc_configuration_tools->attributes;
+            if ($find_tool[0]->getValue eq "VCCLCompilerTool") {
+                foreach my $vc_compiler_tool ($vc_configuration_tools->attributes) {
+                    if ($vc_compiler_tool->getName eq "Optimization") {$prj_target_cflags.="-O".$vc_compiler_tool->getValue." ";}
+                    if ($vc_compiler_tool->getName eq "WarningLevel") {
+                        if ($vc_compiler_tool->getValue==0) {
+                            $prj_target_cflags.="-w ";
+                        } elsif ($vc_compiler_tool->getValue<4) {
+                            $prj_target_cflags.="-W ";
+                        } elsif ($vc_compiler_tool->getValue==4) {
+                            $prj_target_cflags.="-Wall ";
+                        } elsif ($vc_compiler_tool->getValue eq "X") {
+                            $prj_target_cflags.="-Werror ";
+                        }
+                    }
+                    if ($vc_compiler_tool->getName eq "PreprocessorDefinitions") {
+                        $configt=$vc_compiler_tool->getValue;
+                        $configt=~s/;/ -D/g;
+                        $prj_target_defines.="-D".$configt." ";
+                    }
+                    if ($vc_compiler_tool->getName eq "AdditionalIncludeDirectories") {
+                        $configt=$vc_compiler_tool->getValue;
+                        $configt=~s/\\/\//g;
+                        $configt=~s/;/ -I/g;
+                        push @{@$project_settings[$T_INCLUDE_PATH]},"-I".$configt;
+                    }
+                }
+            }
+            if ($find_tool[0]->getValue eq "VCLinkerTool") {
+                foreach my $vc_linker_tool ($vc_configuration_tools->attributes) {
+                    if ($vc_linker_tool->getName eq "AdditionalDependencies") {
+                        $prj_target_libs=" ".$vc_linker_tool->getValue;
+                        $prj_target_libs=~s/\\/\//g;
+                        $prj_target_libs=~s/\.lib//g;
+                        $prj_target_libs=~s/\s+/ -l/g;
+                    }
+                }
+            }
+        }
+
+        push @{@$project_settings[$T_LIBRARIES]},$prj_target_libs;
+        push @{@$project_settings[$T_CEXTRA]},$prj_target_cflags;
+        push @{@$project_settings[$T_CXXEXTRA]},$prj_target_cflags;
+        push @{@$project_settings[$T_DEFINES]},$prj_target_defines;
+    }
+
+    # Add this project to the project list, except for
+    # the main project which is already in the list.
+    if ($is_sub_project == 1) {
+        push @projects,$project;
+    }
+
+    # Ask for project-wide options
+    if ($opt_ask_project_options == $OPT_ASK_YES) {
+        my $flag_desc="";
+        if ((@$project_settings[$T_FLAGS] & $TF_MFC)!=0) {
+            $flag_desc="mfc";
+        }
+        print "* Type any project-wide options (-D/-I/-P/-i/-L/-l/--mfc),\n";
+        if (defined $flag_desc) {
+            print "* (currently $flag_desc)\n";
+        }
+        print "* or 'skip' to skip the target specific options,\n";
+        print "* or 'never' to not be asked this question again:\n";
+        while (1) {
+            my $options=<STDIN>;
+            chomp $options;
+            if ($options eq "skip") {
+                $opt_ask_target_options=$OPT_ASK_SKIP;
+                last;
+            } elsif ($options eq "never") {
+                $opt_ask_project_options=$OPT_ASK_NO;
+                last;
+            } elsif (source_set_options($project_settings,$options)) {
+                last;
+            }
+            print "Please re-enter the options:\n";
+        }
+    }
+
+    my @local_dlls=();
+    my @local_depends=();
+    my @exe_list=();
+
+    # Create the target...
+    my $target=[];
+    target_init($target);
+
+    if ($prj_target_type!=3) {
+        $prj_name=lc($prj_name.".exe");
+        @$target[$T_TYPE]=$opt_target_type;
+        push @exe_list,$target;
+        push @{@$target[$T_LDFLAGS]},(@$target[$T_TYPE] == $TT_CUIEXE ? "-mconsole" : "-mwindows");
+    } else {
+        $prj_name=lc($prj_name.".dll");
+        @$target[$T_TYPE]=$TT_DLL;
+        push @local_depends,"$prj_name.so";
+        push @local_dlls,$prj_name;
+        my $canon=canonize($prj_name);
+        push @{@$target[$T_LDFLAGS]},("-shared","\$(${canon}_MODULE:%=%.spec)");
+    }
+
+    @$target[$T_NAME]=$prj_name;
+    @$target[$T_FLAGS]|=@$project_settings[$T_FLAGS];
+
+    # This is the default link list of Visual Studio
+    my @std_imports=qw(odbc32 ole32 oleaut32 winspool odbccp32);
+    my @std_libraries=qw(uuid);
+    if ((@$target[$T_FLAGS] & $TF_NODLLS) == 0) {
+        @$target[$T_DLLS]=\@std_imports;
+        @$target[$T_LIBRARIES]=\@std_libraries;
+    } else {
+        @$target[$T_DLLS]=[];
+        @$target[$T_LIBRARIES]=[];
+    }
+    if ((@$target[$T_FLAGS] & $TF_NOMSVCRT) == 0) {
+        push @{@$target[$T_LDFLAGS]},"-mno-cygwin";
+        push @{@$target[$T_LDFLAGS]},"-m$opt_arch";
+    }
+    push @{@$project[$P_TARGETS]},$target;
+
+    # Ask for target-specific options
+    if ($opt_ask_target_options == $OPT_ASK_YES) {
+        my $flag_desc="";
+        if ((@$target[$T_FLAGS] & $TF_MFC)!=0) {
+            $flag_desc=" (mfc";
+        }
+        if ($flag_desc ne "") {
+            $flag_desc.=")";
+        }
+        print "* Specify any link option (-P/-i/-L/-l/--mfc) specific to the target\n";
+        print "* \"$prj_name\"$flag_desc or 'never' to not be asked this question again:\n";
+        while (1) {
+        my $options=<STDIN>;
+        chomp $options;
+        if ($options eq "never") {
+            $opt_ask_target_options=$OPT_ASK_NO;
+            last;
+        } elsif (source_set_options($target,$options)) {
+            last;
+        }
+        print "Please re-enter the options:\n";
+        }
+    }
+    if (@$target[$T_FLAGS] & $TF_MFC) {
+        @$project_settings[$T_FLAGS]|=$TF_MFC;
+        push @{@$target[$T_DLL_PATH]},"\$(MFC_LIBRARY_PATH)";
+        push @{@$target[$T_DLLS]},"mfc.dll";
+        # FIXME: Link with the MFC in the Unix sense, until we
+        # start exporting the functions properly.
+        push @{@$target[$T_LIBRARY_PATH]},"\$(MFC_LIBRARY_PATH)";
+        push @{@$target[$T_LIBRARIES]},"mfc";
+    }
+
+    # Match sources...
+    push @{@$target[$T_SOURCES_C]},@{@$project_settings[$T_SOURCES_C]},@sources_c;
+    @$project_settings[$T_SOURCES_C]=[];
+    @sources_c=();
+    push @{@$target[$T_SOURCES_CXX]},@{@$project_settings[$T_SOURCES_CXX]},@sources_cxx;
+    @$project_settings[$T_SOURCES_CXX]=[];
+    @sources_cxx=();
+    push @{@$target[$T_SOURCES_RC]},@{@$project_settings[$T_SOURCES_RC]},@sources_rc;
+    @$project_settings[$T_SOURCES_RC]=[];
+    @sources_rc=();
+    push @{@$target[$T_SOURCES_MISC]},@{@$project_settings[$T_SOURCES_MISC]},@sources_misc;
+    @$project_settings[$T_SOURCES_MISC]=[];
+    @sources_misc=();
+
+    @$target[$T_SOURCES_C]=[sort @{@$target[$T_SOURCES_C]}];
+    @$target[$T_SOURCES_CXX]=[sort @{@$target[$T_SOURCES_CXX]}];
+    @$target[$T_SOURCES_RC]=[sort @{@$target[$T_SOURCES_RC]}];
+    @$target[$T_SOURCES_MISC]=[sort @{@$target[$T_SOURCES_MISC]}];
+
+    if ($opt_ask_target_options == $OPT_ASK_SKIP) {
+        $opt_ask_target_options=$OPT_ASK_YES;
+    }
+
+    if ((@$project_settings[$T_FLAGS] & $TF_NOMSVCRT) == 0) {
+        push @{@$project_settings[$T_CEXTRA]},"-mno-cygwin";
+        push @{@$project_settings[$T_CXXEXTRA]},"-mno-cygwin";
+    }
+
+    if (@$project_settings[$T_FLAGS] & $TF_MFC) {
+        push @{@$project_settings[$T_INCLUDE_PATH]},"\$(MFC_INCLUDE_PATH)";
+    }
+    # The sources that did not match, if any, go to the extra
+    # source list of the project settings
+    foreach my $source (@sources_c) {
+        if ($source ne "") {
+            push @{@$project_settings[$T_SOURCES_C]},$source;
+        }
+    }
+    @$project_settings[$T_SOURCES_C]=[sort @{@$project_settings[$T_SOURCES_C]}];
+    foreach my $source (@sources_cxx) {
+        if ($source ne "") {
+            push @{@$project_settings[$T_SOURCES_CXX]},$source;
+        }
+    }
+    @$project_settings[$T_SOURCES_CXX]=[sort @{@$project_settings[$T_SOURCES_CXX]}];
+    foreach my $source (@sources_rc) {
+        if ($source ne "") {
+            push @{@$project_settings[$T_SOURCES_RC]},$source;
+        }
+    }
+    @$project_settings[$T_SOURCES_RC]=[sort @{@$project_settings[$T_SOURCES_RC]}];
+    foreach my $source (@sources_misc) {
+        if ($source ne "") {
+            push @{@$project_settings[$T_SOURCES_MISC]},$source;
+        }
+    }
+    @$project_settings[$T_SOURCES_MISC]=[sort @{@$project_settings[$T_SOURCES_MISC]}];
+}
+
+##
+# Scans the specified workspace file to find the project files
+sub source_scan_workspace_file($);
+sub source_scan_workspace_file($)
+{
+    my $filename=$_[0];
+    my $path=dirname($filename);
+    my @components;
+
+    if (! -e $filename) {
+        return;
+    }
+
+    if (!open(FILEIWS,$filename)) {
+        print STDERR "error: unable to open $filename for reading:\n";
+        print STDERR "       $!\n";
+        return;
+    }
+
+    my $prj_name;
+    my $prj_path;
+
+    if ($filename =~ /.dsw$/i) {
+        while (<FILEIWS>) {
+            # Remove any trailing CrLf
+            s/\r\n$/\n/;
+
+            # catch a project definition
+            if (/^Project:\s\"(.*)\"=(.*)\s-/) {
+                $prj_name=$1;
+                $prj_path=$2;
+                @components=split /[\/\\]+/, $prj_path;
+                $prj_path=search_from($path, \@components);
+                print "Name: $prj_name\nPath: $prj_path\n";
+                source_scan_project_file(\@main_project,1,$prj_path);
+                next;
+            } elsif (/^#/) {
+                # ignore Comments
+            } elsif (/\w:/) {
+                print STDERR "unknown section $_\n";
+            } elsif (/^Microsoft(.*)Studio(.*)File,\sFormat Version\s(.*)/) {
+                print "\nFileversion: $3\n";
+            }
+        }
+        close(FILEIWS);
+    } elsif ($filename =~ /.sln$/i) {
+        while (<FILEIWS>) {
+            # Remove any trailing CrLf
+            s/\r\n$/\n/;
+
+            # catch a project definition
+            if (/^Project(.*)=\s*"(.*)",\s*"(.*)",\s*"(.*)"/) {
+                $prj_name=$2;
+                $prj_path=$3;
+                @components=split /[\/\\]+/, $3;
+                $prj_path=search_from($path, \@components);
+                print "Name: $prj_name\nPath: $prj_path\n";
+                source_scan_project_file(\@main_project,1,$prj_path);
+                next;
+            } elsif (/^Microsoft(.*)Studio(.*)File,\sFormat Version\s(.*)/) {
+                print "\nFileversion: $3\n";
+            }
+        }
+        close(FILEIWS);
+    }
+
+    @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
+}
+
 ##
 # Scans the specified directory to:
 # - see if we should create a Makefile in this directory. We normally do
@@ -517,6 +1216,8 @@ sub source_scan_directory($$$$)
   my @sources_misc=();
   # true if this directory contains a Windows project
   my $has_win_project=0;
+  # true if this directory contains headers
+  my $has_headers=0;
   # If we don't find any executable/library then we might make up targets
   # from the list of .dsp/.mak files we find since they usually have the
   # same name as their target.
@@ -530,7 +1231,7 @@ sub source_scan_directory($$$$)
     $project=$parent_project;
   } else {
     $project=[];
-    project_init($project,$path);
+    project_init($project, $path, \@global_settings);
   }
   my $project_settings=@$project[$P_SETTINGS];
 
@@ -548,11 +1249,7 @@ sub source_scan_directory($$$$)
        # resulting executable/library. They should not contain anything else.
        my @candidates=grep /\.(exe|dll)$/i, @{get_directory_contents("$fullentry")};
        foreach my $candidate (@candidates) {
-         if ($candidate =~ s/\.exe$//i) {
-           $targets{$candidate}=1;
-         } elsif ($candidate =~ s/^(.*)\.dll$/lib$1.so/i) {
-           $targets{$candidate}=1;
-         }
+         $targets{$candidate}=1;
        }
       } elsif ($dentry =~ /^include/i) {
         # This directory must contain headers we're going to need
@@ -565,11 +1262,9 @@ sub source_scan_directory($$$$)
        source_scan_directory($project,"$fullentry/","$dentry/",$no_target);
       }
     } elsif (-f "$fullentry") {
-      if ($dentry =~ s/\.exe$//i) {
+      if ($dentry =~ /\.(exe|dll)$/i) {
        $targets{$dentry}=1;
-      } elsif ($dentry =~ s/^(.*)\.dll$/lib$1.so/i) {
-       $targets{$dentry}=1;
-      } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.spec\.c$/) {
+      } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.(dbg|spec)\.c$/) {
        push @sources_c,"$dentry";
       } elsif ($dentry =~ /\.(cpp|cxx)$/i) {
        if ($dentry =~ /^stdafx.cpp$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
@@ -581,6 +1276,7 @@ sub source_scan_directory($$$$)
       } elsif ($dentry =~ /\.rc$/i) {
        push @sources_rc,"$dentry";
       } elsif ($dentry =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
+       $has_headers=1;
        push @sources_misc,"$dentry";
        if ($dentry =~ /^stdafx.h$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
          @$project_settings[$T_FLAGS]|=$TF_MFC;
@@ -596,8 +1292,10 @@ sub source_scan_directory($$$$)
       }
     }
   }
-  closedir(DIRECTORY);
 
+  if ($has_headers) {
+    push @{@$project_settings[$T_INCLUDE_PATH]},"-I.";
+  }
   # If we have a single target then all we have to do is assign
   # all the sources to it and we're done
   # FIXME: does this play well with the --interactive mode?
@@ -653,7 +1351,7 @@ sub source_scan_directory($$$$)
       foreach my $filename (@$prj_list) {
        $filename =~ s/\.(dsp|mak)$//i;
        if ($opt_target_type == $TT_DLL) {
-         $filename = "lib$filename.so";
+         $filename = "$filename.dll";
        }
        $targets{$filename}=1;
       }
@@ -682,7 +1380,9 @@ sub source_scan_directory($$$$)
        }
        $name =~ s+(/|\.[^.]*)$++;
        if ($opt_target_type == $TT_DLL) {
-         $name = "lib$name.so";
+         $name = canonize($name).".dll";
+       } else {
+         $name = canonize($name).".exe";
        }
        $targets{$name}=1;
       }
@@ -713,9 +1413,6 @@ sub source_scan_directory($$$$)
        foreach my $target (split /,/,$target_list) {
          $target =~ s+^\s*++;
          $target =~ s+\s*$++;
-         # Also accept .exe and .dll as a courtesy
-         $target =~ s+(.*)\.dll$+lib$1.so+;
-         $target =~ s+\.exe$++;
          $targets{$target}=1;
        }
       }
@@ -749,13 +1446,7 @@ sub source_scan_directory($$$$)
     if ((@$project_settings[$T_FLAGS] & $TF_MFC)!=0) {
       $flag_desc="mfc";
     }
-    if ((@$project_settings[$T_FLAGS] & $TF_WRAP)!=0) {
-      if ($flag_desc ne "") {
-       $flag_desc.=", ";
-      }
-      $flag_desc.="wrapped";
-    }
-    print "* Type any project-wide options (-D/-I/-P/-i/-L/-l/--mfc/--wrap),\n";
+    print "* Type any project-wide options (-D/-I/-P/-i/-L/-l/--mfc),\n";
     if (defined $flag_desc) {
       print "* (currently $flag_desc)\n";
     }
@@ -784,34 +1475,38 @@ sub source_scan_directory($$$$)
   my @local_dlls=();
   my @local_depends=();
   my @exe_list=();
-  foreach my $target_name (sort { $b cmp $a } keys %targets) {
+  foreach my $target_name (map (lc, (sort { $b cmp $a } keys %targets))) {
     # Create the target...
-    my $basename;
     my $target=[];
     target_init($target);
     @$target[$T_NAME]=$target_name;
     @$target[$T_FLAGS]|=@$project_settings[$T_FLAGS];
-    if ($target_name =~ /^lib(.*)\.so$/) {
+    if ($target_name =~ /\.dll$/) {
       @$target[$T_TYPE]=$TT_DLL;
-      @$target[$T_INIT]=get_default_init($TT_DLL);
-      @$target[$T_FLAGS]&=~$TF_WRAP;
-      $basename=$1;
-      push @local_depends,$target_name;
-      push @local_dlls,$basename;
+      push @local_depends,"$target_name.so";
+      push @local_dlls,$target_name;
+      my $canon=canonize($target_name);
+      push @{@$target[$T_LDFLAGS]},("-shared","\$(${canon}_MODULE:%=%.spec)");
     } else {
       @$target[$T_TYPE]=$opt_target_type;
-      @$target[$T_INIT]=get_default_init($opt_target_type);
-      $basename=$target_name;
       push @exe_list,$target;
+      push @{@$target[$T_LDFLAGS]},(@$target[$T_TYPE] == $TT_CUIEXE ? "-mconsole" : "-mwindows");
     }
-    # This is the default link list of Visual Studio, except odbccp32
-    # 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);
+    my $basename=$target_name;
+    $basename=~ s/\.(dll|exe)$//i;
+    # This is the default link list of Visual Studio
+    my @std_imports=qw(odbc32 ole32 oleaut32 winspool odbccp32);
+    my @std_libraries=qw(uuid);
     if ((@$target[$T_FLAGS] & $TF_NODLLS) == 0) {
-      @$target[$T_DLLS]=\@std_dlls;
+      @$target[$T_DLLS]=\@std_imports;
+      @$target[$T_LIBRARIES]=\@std_libraries;
     } else {
       @$target[$T_DLLS]=[];
+      @$target[$T_LIBRARIES]=[];
+    }
+    if ((@$target[$T_FLAGS] & $TF_NOMSVCRT) == 0) {
+      push @{@$target[$T_LDFLAGS]},"-mno-cygwin";
+      push @{@$target[$T_LDFLAGS]},"-m$opt_arch";
     }
     push @{@$project[$P_TARGETS]},$target;
 
@@ -821,18 +1516,10 @@ sub source_scan_directory($$$$)
       if ((@$target[$T_FLAGS] & $TF_MFC)!=0) {
        $flag_desc=" (mfc";
       }
-      if ((@$target[$T_FLAGS] & $TF_WRAP)!=0) {
-       if ($flag_desc ne "") {
-         $flag_desc.=", ";
-       } else {
-         $flag_desc=" (";
-       }
-       $flag_desc.="wrapped";
-      }
       if ($flag_desc ne "") {
        $flag_desc.=")";
       }
-      print "* Specify any link option (-P/-i/-L/-l/--mfc/--wrap) specific to the target\n";
+      print "* Specify any link option (-P/-i/-L/-l/--mfc) specific to the target\n";
       print "* \"$target_name\"$flag_desc or 'never' to not be asked this question again:\n";
       while (1) {
         my $options=<STDIN>;
@@ -846,7 +1533,6 @@ sub source_scan_directory($$$$)
         print "Please re-enter the options:\n";
       }
     }
-    push @{@$target[$T_DLL_PATH]},"-L\$(WINE_DLL_ROOT)";
     if (@$target[$T_FLAGS] & $TF_MFC) {
       @$project_settings[$T_FLAGS]|=$TF_MFC;
       push @{@$target[$T_DLL_PATH]},"\$(MFC_LIBRARY_PATH)";
@@ -910,6 +1596,11 @@ sub source_scan_directory($$$$)
     $opt_ask_target_options=$OPT_ASK_YES;
   }
 
+  if ((@$project_settings[$T_FLAGS] & $TF_NOMSVCRT) == 0) {
+    push @{@$project_settings[$T_CEXTRA]},"-mno-cygwin";
+    push @{@$project_settings[$T_CXXEXTRA]},"-mno-cygwin";
+  }
+
   if (@$project_settings[$T_FLAGS] & $TF_MFC) {
     push @{@$project_settings[$T_INCLUDE_PATH]},"\$(MFC_INCLUDE_PATH)";
   }
@@ -946,12 +1637,7 @@ sub source_scan_directory($$$$)
   if (@local_dlls > 0 and @exe_list > 0) {
     foreach my $target (@exe_list) {
       push @{@$target[$T_DLL_PATH]},"-L.";
-      push @{@$target[$T_DLLS]},map { "$_.dll" } @local_dlls;
-      # Also link in the Unix sense since none of the functions
-      # will be exported.
-      push @{@$target[$T_LIBRARY_PATH]},"-L.";
-      push @{@$target[$T_LIBRARIES]},@local_dlls;
-      push @{@$target[$T_DEPENDS]},@local_depends;
+      push @{@$target[$T_DLLS]},@local_dlls;
     }
   }
 }
@@ -965,11 +1651,7 @@ sub source_scan()
     # Create the main target
     my $main_target=[];
     target_init($main_target);
-    if ($opt_target_type == $TT_DLL) {
-      @$main_target[$T_NAME]="lib$opt_single_target.so";
-    } else {
-      @$main_target[$T_NAME]="$opt_single_target";
-    }
+    @$main_target[$T_NAME]=$opt_single_target;
     @$main_target[$T_TYPE]=$opt_target_type;
 
     # Add it to the list
@@ -979,68 +1661,20 @@ sub source_scan()
   # The main directory is always going to be there
   push @projects,\@main_project;
 
-  # Now scan the directory tree looking for source files and, maybe, targets
-  print "Scanning the source directories...\n";
-  source_scan_directory(\@main_project,"","",0);
-
-  @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
-}
-
-
-
-#####
-#
-# 'vc.dsp'-based Project analysis
-#
-#####
-
-#sub analyze_vc_dsp
-#{
-#
-#}
-
-
-
-#####
-#
-# Creating the wrapper targets
-#
-#####
-
-sub postprocess_targets()
-{
-  foreach my $project (@projects) {
-    foreach my $target (@{@$project[$P_TARGETS]}) {
-      if ((@$target[$T_FLAGS] & $TF_WRAP) != 0) {
-       my $wrapper=[];
-       target_init($wrapper);
-       @$wrapper[$T_NAME]=@$target[$T_NAME];
-       @$wrapper[$T_TYPE]=@$target[$T_TYPE];
-       @$wrapper[$T_INIT]=get_default_init(@$target[$T_TYPE]);
-       @$wrapper[$T_FLAGS]=$TF_WRAPPER | (@$target[$T_FLAGS] & $TF_MFC);
-       @$wrapper[$T_DLLS]=[ "kernel32.dll", "ntdll.dll", "user32.dll" ];
-       push @{@$wrapper[$T_LIBRARIES]}, "dl";
-       push @{@$wrapper[$T_SOURCES_C]},"@$wrapper[$T_NAME]_wrapper.c";
-
-       my $index=bsearch(@$target[$T_SOURCES_C],"@$wrapper[$T_NAME]_wrapper.c");
-       if (defined $index) {
-         splice(@{@$target[$T_SOURCES_C]},$index,1);
-       }
-       @$target[$T_NAME]="lib@$target[$T_NAME].so";
-       @$target[$T_TYPE]=$TT_DLL;
-
-       push @{@$project[$P_TARGETS]},$wrapper;
-      }
-      if ((@$target[$T_FLAGS] & $TF_MFC) != 0) {
-       @{@$project[$P_SETTINGS]}[$T_FLAGS]|=$TF_MFC;
-       $needs_mfc=1;
-      }
+    if (defined $opt_work_dir) {
+        # Now scan the directory tree looking for source files and, maybe, targets
+        print "Scanning the source directories...\n";
+        source_scan_directory(\@main_project,"","",0);
+        @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
+    } elsif (defined $opt_work_file) {
+        if ($opt_work_file =~ /.dsp$/i or $opt_work_file =~ /.vcproj$/i) {
+            source_scan_project_file(\@main_project,0,$opt_work_file);
+        } elsif ($opt_work_file =~ /.dsw$/i or $opt_work_file =~ /.sln$/i) {
+            source_scan_workspace_file($opt_work_file);
+        }
     }
-  }
 }
 
-
-
 #####
 #
 # Source search
@@ -1052,67 +1686,70 @@ sub postprocess_targets()
 # - they have the case desired by the user
 # - their extension is of the appropriate case
 # - they don't contain annoying characters like ' ', '$', '#', ...
+# But only perform these changes for source files and directories.
 sub fix_file_and_directory_names($);
 sub fix_file_and_directory_names($)
 {
   my $dirname=$_[0];
 
-  if (opendir(DIRECTORY, "$dirname")) {
-    foreach my $dentry (readdir DIRECTORY) {
+  my $directory=get_directory_contents($dirname);
+  foreach my $dentry (@$directory)
+  {
       if ($dentry =~ /^\./ or $dentry eq "CVS") {
-       next;
+          next;
       }
       # Set $warn to 1 if the user should be warned of the renaming
-      my $warn=0;
-
-      # autoconf and make don't support these characters well
+      my $warn;
       my $new_name=$dentry;
-      $new_name =~ s/[ \$]/_/g;
 
-      # Only all lowercase extensions are supported (because of the
-      # transformations ':.c=.o') .
-      if (-f "$dirname/$new_name") {
-       if ($new_name =~ /\.C$/) {
-         $new_name =~ s/\.C$/.c/;
-       }
-       if ($new_name =~ /\.cpp$/i) {
-         $new_name =~ s/\.cpp$/.cpp/i;
-       }
-       if ($new_name =~ s/\.cxx$/.cpp/i) {
-         $warn=1;
-       }
-       if ($new_name =~ /\.rc$/i) {
-         $new_name =~ s/\.rc$/.rc/i;
-       }
-       # And this last one is to avoid confusion then running make
-       if ($new_name =~ s/^makefile$/makefile.win/) {
-         $warn=1;
-       }
+      if (-f "$dirname/$dentry")
+      {
+          # Don't rename Winemaker's makefiles
+          next if ($dentry eq "Makefile" and
+                   `head -n 1 "$dirname/$dentry"` =~ /Generated by Winemaker/);
+
+          # Leave non-source files alone
+          next if ($new_name !~ /(^makefile|\.(c|cpp|h|rc))$/i);
+
+          # Only all lowercase extensions are supported (because of
+          # rules like '.c.o:'.
+          $new_name =~ s/\.C$/.c/;
+          $new_name =~ s/\.cpp$/.cpp/i;
+          $warn=1 if ($new_name =~ s/\.cxx$/.cpp/i);
+          $new_name =~ s/\.rc$/.rc/i;
+          # And this last one is to avoid confusion then running make
+          $warn=1 if ($new_name =~ s/^makefile$/makefile.win/i);
       }
 
       # Adjust the case to the user's preferences
       if (($opt_lower == $OPT_LOWER_ALL and $dentry =~ /[A-Z]/) or
           ($opt_lower == $OPT_LOWER_UPPERCASE and $dentry !~ /[a-z]/)
          ) {
-       $new_name=lc $new_name;
+          $new_name=lc $new_name;
       }
 
+      # autoconf and make don't support these characters well
+      $new_name =~ s/[ \$]/_/g;
+
       # And finally, perform the renaming
-      if ($new_name ne $dentry) {
-       if ($warn) {
-         print STDERR "warning: in \"$dirname\", renaming \"$dentry\" to \"$new_name\"\n";
-       }
-       if (!rename("$dirname/$dentry","$dirname/$new_name")) {
-         print STDERR "error: in \"$dirname\", unable to rename \"$dentry\" to \"$new_name\"\n";
-         print STDERR "       $!\n";
-         $new_name=$dentry;
-       }
+      if ($new_name ne $dentry)
+      {
+          if ($warn) {
+              print STDERR "warning: in \"$dirname\", renaming \"$dentry\" to \"$new_name\"\n";
+          }
+          if (!rename("$dirname/$dentry","$dirname/$new_name")) {
+              print STDERR "error: in \"$dirname\", unable to rename \"$dentry\" to \"$new_name\"\n";
+              print STDERR "       $!\n";
+              $new_name=$dentry;
+          }
+          else
+          {
+              clear_directory_cache($dirname);
+          }
       }
       if (-d "$dirname/$new_name") {
-       fix_file_and_directory_names("$dirname/$new_name");
+          fix_file_and_directory_names("$dirname/$new_name");
       }
-    }
-    closedir(DIRECTORY);
   }
 }
 
@@ -1124,50 +1761,6 @@ sub fix_file_and_directory_names($)
 #
 #####
 
-##
-# This maps a directory name to a reference to an array listing
-# its contents (files and directories)
-my %directories;
-
-##
-# Retrieves the contents of the specified directory.
-# We either get it from the directories hashtable which acts as a
-# cache, or use opendir, readdir, closedir and store the result
-# in the hashtable.
-sub get_directory_contents($)
-{
-  my $dirname=$_[0];
-  my $directory;
-
-  #print "getting the contents of $dirname\n";
-
-  # check for a cached version
-  $dirname =~ s+/$++;
-  if ($dirname eq "") {
-    $dirname=cwd;
-  }
-  $directory=$directories{$dirname};
-  if (defined $directory) {
-    #print "->@$directory\n";
-    return $directory;
-  }
-
-  # Read this directory
-  if (opendir(DIRECTORY, "$dirname")) {
-    my @files=readdir DIRECTORY;
-    closedir(DIRECTORY);
-    $directory=\@files;
-  } else {
-    # Return an empty list
-    #print "error: cannot open $dirname\n";
-    my @files;
-    $directory=\@files;
-  }
-  #print "->@$directory\n";
-  $directories{$dirname}=$directory;
-  return $directory;
-}
-
 ##
 # Try to find a file for the specified filename. The attempt is
 # case-insensitive which is why it's not trivial. If a match is
@@ -1178,9 +1771,9 @@ sub search_from($$)
   my $path=$_[1];
   my $real_path="";
 
-  if ($dirname eq "" or $dirname eq ".") {
+  if ($dirname eq "" or $dirname eq "." or $dirname eq "./") {
     $dirname=cwd;
-  } elsif ($dirname =~ m+^[^/]+) {
+  } elsif ($dirname !~ m+^/+) {
     $dirname=cwd . "/" . $dirname;
   }
   if ($dirname !~ m+/$+) {
@@ -1188,6 +1781,8 @@ sub search_from($$)
   }
 
   foreach my $component (@$path) {
+    $component=~s/^\"//;
+    $component=~s/\"$//;
     #print "    looking for $component in \"$dirname\"\n";
     if ($component eq ".") {
       # Pass it as is
@@ -1208,7 +1803,7 @@ sub search_from($$)
       my $directory=get_directory_contents $dirname;
       my $found;
       foreach my $dentry (@$directory) {
-       if ($dentry =~ /^$component$/i or
+       if ($dentry =~ /^\Q$component\E$/i or
             (defined $renamed and $dentry =~ /^$renamed$/i)
            ) {
          $dirname.="$dentry/";
@@ -1277,6 +1872,7 @@ sub get_real_include_name($$$$$)
     foreach my $include (@{@$target[$T_INCLUDE_PATH]}, @{@$project_settings[$T_INCLUDE_PATH]}) {
       my $dirname=$include;
       $dirname=~ s+^-I++;
+      $dirname=~ s+\s$++;
       if (!is_absolute($dirname)) {
        $dirname="@$project[$P_PATH]$dirname";
       } else {
@@ -1391,17 +1987,17 @@ sub fix_file($$$)
     if ($is_rc and !$is_mfc and /^(\s*)(\#\s*include\s*)\"afxres\.h\"/) {
       # VC6 automatically includes 'afxres.h', an MFC specific header, in
       # the RC files it generates (even in non-MFC projects). So we replace
-      # it with 'winres.h' its very close standard cousin so that non MFC
+      # it with 'winresrc.h' its very close standard cousin so that non MFC
       # projects can compile in Wine without the MFC sources.
       my $warning="mfc:afxres.h";
       if (!defined $warnings{$warning}) {
        $warnings{$warning}="1";
-       print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winres.h'\n";
+       print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winresrc.h'\n";
        print STDERR "warning: the above warning is issued only once\n";
       }
       print FILEO "$1/* winemaker: $2\"afxres.h\" */\n";
-      print FILEO "$1/* winemaker:warning: 'afxres.h' is an MFC specific header. Replacing it with 'winres.h' */\n";
-      print FILEO "$1$2\"winres.h\"$'";
+      print FILEO "$1/* winemaker:warning: 'afxres.h' is an MFC specific header. Replacing it with 'winresrc.h' */\n";
+      print FILEO "$1$2\"winresrc.h\"$'";
       $modified=1;
 
     } elsif (/^(\s*\#\s*include\s*)([\"<])([^\"]+)([\">])/) {
@@ -1418,7 +2014,7 @@ sub fix_file($$$)
       # by a reference to an array containing:
       # - "push" for pack(push,...) directives, "" otherwise
       # - the directive's identifier at index 1
-      # - the directive's alignement value at index 2
+      # - the directive's alignment value at index 2
       #
       # Don't believe a word of what the documentation says: it's all wrong.
       # The code below is based on the actual behavior of Visual C/C++ 6.
@@ -1563,7 +2159,7 @@ sub fix_file($$$)
        print FILEO;
 
       } elsif ($rc_textinclude_state == 3 and /^(\s*\"\#\s*include\s*\"\")afxres\.h(\"\"\\r\\n\")/) {
-       print FILEO "$1winres.h$2$'";
+       print FILEO "$1winresrc.h$2$'";
        $modified=1;
 
       } elsif (/^\s*BEGIN(\W.*)?$/) {
@@ -1605,9 +2201,6 @@ sub fix_source()
   print "Fixing the source files...\n";
   foreach my $project (@projects) {
     foreach my $target (@$project[$P_SETTINGS],@{@$project[$P_TARGETS]}) {
-      if (@$target[$T_FLAGS] & $TF_WRAPPER) {
-       next;
-      }
       foreach my $source (@{@$target[$T_SOURCES_C]}, @{@$target[$T_SOURCES_CXX]}, @{@$target[$T_SOURCES_RC]}, @{@$target[$T_SOURCES_MISC]}) {
        fix_file($source,$project,$target);
       }
@@ -1623,69 +2216,6 @@ sub fix_source()
 #
 #####
 
-##
-# Generates a target's .spec file
-sub generate_spec_file($$$)
-{
-  if ($opt_no_generated_specs) {
-    return;
-  }
-  my $path=$_[0];
-  my $target=$_[1];
-  my $project_settings=$_[2];
-
-  my $basename=@$target[$T_NAME];
-  $basename =~ s+\.so$++;
-  if (@$target[$T_FLAGS] & $TF_WRAP) {
-    $basename =~ s+^lib++;
-  } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) {
-    $basename.="_wrapper";
-  }
-  if (@$target[$T_TYPE] != $TT_DLL) {
-      $basename .= '.exe';
-  }
-
-  if (!open(FILEO,">$path$basename.spec")) {
-    print STDERR "error: could not open \"$path$basename.spec\" for writing\n";
-    print STDERR "       $!\n";
-    return;
-  }
-
-  if (defined @$target[$T_INIT] and ((@$target[$T_FLAGS] & $TF_WRAP) == 0)) {
-    print FILEO "init    @$target[$T_INIT]\n";
-  }
-  print FILEO "\n";
-
-  # Don't forget to export the 'Main' function for wrapped executables,
-  # except for MFC ones!
-  if ((@$target[$T_FLAGS]&($TF_WRAP|$TF_WRAPPER|$TF_MFC)) == $TF_WRAP) {
-    if (@$target[$T_TYPE] == $TT_GUIEXE) {
-      print FILEO "\n@ stdcall @$target[$T_INIT](long long ptr long) @$target[$T_INIT]\n";
-    } elsif (@$target[$T_TYPE] == $TT_CUIEXE) {
-      print FILEO "\n@ stdcall @$target[$T_INIT](long ptr ptr) @$target[$T_INIT]\n";
-    } else {
-      print FILEO "\n@ stdcall @$target[$T_INIT](ptr long ptr) @$target[$T_INIT]\n";
-    }
-  }
-
-  close(FILEO);
-}
-
-##
-# Generates a target's wrapper file
-sub generate_wrapper_file($$)
-{
-  my $path=$_[0];
-  my $target=$_[1];
-  my $app_name=@$target[$T_NAME];
-
-  return generate_from_template("$path${app_name}_wrapper.c","wrapper.c",[
-      ["APP_NAME",@$target[$T_NAME]],
-      ["APP_TYPE",(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE")],
-      ["APP_INIT",(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"")],
-      ["APP_MFC",(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":"NULL")]]);
-}
-
 ##
 # A convenience function to generate all the lists (defines,
 # C sources, C++ source, etc.) in the Makefile
@@ -1724,7 +2254,7 @@ sub generate_list($$$;$)
 }
 
 ##
-# Generates a project's Makefile.in and all the target files
+# Generates a project's Makefile and all the target files
 sub generate_project_files($)
 {
   my $project=$_[0];
@@ -1744,25 +2274,16 @@ sub generate_project_files($)
   push @{@$project[$P_TARGETS]}, @dll_list;
   push @{@$project[$P_TARGETS]}, @exe_list;
 
-  if (!open(FILEO,">@$project[$P_PATH]Makefile.in")) {
-    print STDERR "error: could not open \"@$project[$P_PATH]/Makefile.in\" for writing\n";
+  if (!open(FILEO,">@$project[$P_PATH]Makefile")) {
+    print STDERR "error: could not open \"@$project[$P_PATH]/Makefile\" for writing\n";
     print STDERR "       $!\n";
     return;
   }
 
-  print FILEO "### Generated by Winemaker\n";
+  print FILEO "### Generated by Winemaker $version\n";
   print FILEO "\n\n";
 
-  print FILEO "### Generic autoconf variables\n\n";
-  generate_list("TOPSRCDIR",1,[ "\@top_srcdir\@" ]);
-  my $dotdotpath=@$project[$P_PATH];
-  $dotdotpath =~ s%[^/]+%..%g;
-  $dotdotpath =~ s%/$%%;
-  $dotdotpath = "." if ($dotdotpath eq "");
-  generate_list("TOPOBJDIR",1,[ $dotdotpath ]);
-  generate_list("SRCDIR",1,[ "\@srcdir\@" ]);
-  generate_list("VPATH",1,[ "\@srcdir\@" ]);
-  print FILEO "\n";
+  generate_list("SRCDIR",1,[ "." ]);
   if (@$project[$P_PATH] eq "") {
     # This is the main project. It is also responsible for recursively
     # calling the other projects
@@ -1783,15 +2304,19 @@ sub generate_project_files($)
                  });
     generate_list("EXES",1,\@exe_list,sub
                  {
-                   return "@{$_[0]}[$T_NAME].exe";
+                   return "@{$_[0]}[$T_NAME]";
                  });
     print FILEO "\n\n\n";
 
     print FILEO "### Common settings\n\n";
     # Make it so that the project-wide settings override the global settings
+    generate_list("CEXTRA",1,@$project_settings[$T_CEXTRA]);
+    generate_list("CXXEXTRA",1,@$project_settings[$T_CXXEXTRA]);
+    generate_list("RCEXTRA",1,@$project_settings[$T_RCEXTRA]);
     generate_list("DEFINES",1,@$project_settings[$T_DEFINES]);
     generate_list("INCLUDE_PATH",1,@$project_settings[$T_INCLUDE_PATH]);
     generate_list("DLL_PATH",1,@$project_settings[$T_DLL_PATH]);
+    generate_list("DLL_IMPORTS",1,@$project_settings[$T_DLLS]);
     generate_list("LIBRARY_PATH",1,@$project_settings[$T_LIBRARY_PATH]);
     generate_list("LIBRARIES",1,@$project_settings[$T_LIBRARIES]);
     print FILEO "\n\n";
@@ -1815,28 +2340,18 @@ sub generate_project_files($)
       print FILEO "### @$target[$T_NAME] sources and settings\n\n";
       my $canon=canonize("@$target[$T_NAME]");
       $canon =~ s+_so$++;
+
+      generate_list("${canon}_MODULE",1,[@$target[$T_NAME]]);
       generate_list("${canon}_C_SRCS",1,@$target[$T_SOURCES_C]);
       generate_list("${canon}_CXX_SRCS",1,@$target[$T_SOURCES_CXX]);
       generate_list("${canon}_RC_SRCS",1,@$target[$T_SOURCES_RC]);
-      my $basename=@$target[$T_NAME];
-      $basename =~ s+\.so$++;
-      if (@$target[$T_FLAGS] & $TF_WRAP) {
-       $basename =~ s+^lib++;
-      } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) {
-       $basename.="_wrapper";
-      }
-      if (@$target[$T_TYPE] != $TT_DLL) {
-        generate_list("${canon}_SPEC_SRCS",1,[ "$basename.exe.spec" ]);
-      } else {
-        generate_list("${canon}_SPEC_SRCS",1,[ "$basename.spec" ]);
-      }
+      generate_list("${canon}_LDFLAGS",1,@$target[$T_LDFLAGS]);
       generate_list("${canon}_DLL_PATH",1,@$target[$T_DLL_PATH]);
       generate_list("${canon}_DLLS",1,@$target[$T_DLLS]);
       generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]);
       generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES]);
-      generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS]);
       print FILEO "\n";
-      generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(EXTRA_OBJS)"]);
+      generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(${canon}_RC_SRCS:.rc=.res)"]);
       print FILEO "\n\n\n";
     }
     print FILEO "### Global source lists\n\n";
@@ -1867,258 +2382,84 @@ sub generate_project_files($)
     if (!$no_extra) {
       generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]);
     }
-    generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub
-                 {
-                   my $canon=canonize(@{$_[0]}[$T_NAME]);
-                   $canon =~ s+_so$++;
-                   return "\$(${canon}_SPEC_SRCS)";
-                 });
   }
-  print FILEO "\n\n\n";
+  print FILEO "\n\n";
+  print FILEO "### Tools\n\n";
+  print FILEO "CC = winegcc\n";
+  print FILEO "CXX = wineg++\n";
+  print FILEO "RC = wrc\n";
+  print FILEO "\n\n";
 
-  print FILEO "### Generic autoconf targets\n\n";
+  print FILEO "### Generic targets\n\n";
   print FILEO "all:";
   if (@$project[$P_PATH] eq "") {
-    print FILEO " wineapploader";
     print FILEO " \$(SUBDIRS)";
   }
   if (@{@$project[$P_TARGETS]} > 0) {
-    print FILEO " \$(DLLS) \$(EXES:%=%.so)";
+    print FILEO " \$(DLLS:%=%.so) \$(EXES:%=%.so)";
   }
   print FILEO "\n\n";
-  if (@$project[$P_PATH] eq "") {
-      print FILEO "wineapploader: wineapploader.in\n";
-      print FILEO "\tsed -e 's,\@bindir\\\@,\$(bindir),g' " .
-         "-e 's,\@winelibdir\\\@,.,g' " .
-         "\$(SRCDIR)/wineapploader.in >\$\@ || \$(RM) \$\@\n";
-      print FILEO "\n";
-  }
-  print FILEO "\@MAKE_RULES\@\n";
+  print FILEO "### Build rules\n";
   print FILEO "\n";
-  print FILEO "install::\n";
-  if (@$project[$P_PATH] eq "") {
-    # This is the main project. It is also responsible for recursively
-    # calling the other projects
-    print FILEO "\t_list=\"\$(SUBDIRS)\"; for i in \$\$_list; do (cd \$\$i; \$(MAKE) install) || exit 1; done\n";
-  }
-  if (@{@$project[$P_TARGETS]} > 0) {
-    print FILEO "\t_list=\"\$(EXES:%=%.so)\"; for i in \$\$_list; do \$(INSTALL_PROGRAM) \$\$i \$(dlldir); done\n";
-    print FILEO "\t_list=\"\$(DLLS)\"; for i in \$\$_list; do \$(INSTALL_PROGRAM) \$\$i \$(libdir); done\n";
-  }
+  print FILEO ".PHONY: all clean dummy\n";
   print FILEO "\n";
-  print FILEO "uninstall::\n";
-  if (@$project[$P_PATH] eq "") {
-    # This is the main project. It is also responsible for recursively
-    # calling the other projects
-    print FILEO "\t_list=\"\$(SUBDIRS)\"; for i in \$\$_list; do (cd \$\$i; \$(MAKE) uninstall) || exit 1; done\n";
-  }
-  if (@{@$project[$P_TARGETS]} > 0) {
-    print FILEO "\t_list=\"\$(EXES:%=%.so)\"; for i in \$\$_list; do \$(RM) \$(dlldir)/\$\$i;done\n";
-    print FILEO "\t_list=\"\$(DLLS)\"; for i in \$\$_list; do \$(RM) \$(libdir)/\$\$i;done\n";
-  }
+  print FILEO "\$(SUBDIRS): dummy\n";
+  print FILEO "\t\@cd \$\@ && \$(MAKE)\n";
+  print FILEO "\n";
+  print FILEO "# Implicit rules\n";
+  print FILEO "\n";
+  print FILEO ".SUFFIXES: .cpp .rc .res\n";
+  print FILEO "DEFINCL = \$(INCLUDE_PATH) \$(DEFINES) \$(OPTIONS)\n";
+  print FILEO "\n";
+  print FILEO ".c.o:\n";
+  print FILEO "\t\$(CC) -c \$(CFLAGS) \$(CEXTRA) \$(DEFINCL) -o \$\@ \$<\n";
+  print FILEO "\n";
+  print FILEO ".cpp.o:\n";
+  print FILEO "\t\$(CXX) -c \$(CXXFLAGS) \$(CXXEXTRA) \$(DEFINCL) -o \$\@ \$<\n";
+  print FILEO "\n";
+  print FILEO ".cxx.o:\n";
+  print FILEO "\t\$(CXX) -c \$(CXXFLAGS) \$(CXXEXTRA) \$(DEFINCL) -o \$\@ \$<\n";
+  print FILEO "\n";
+  print FILEO ".rc.res:\n";
+  print FILEO "\t\$(RC) \$(RCFLAGS) \$(RCEXTRA) \$(DEFINCL) -fo\$@ \$<\n";
+  print FILEO "\n";
+  print FILEO "# Rules for cleaning\n";
+  print FILEO "\n";
+  print FILEO "CLEAN_FILES     = y.tab.c y.tab.h lex.yy.c core *.orig *.rej \\\n";
+  print FILEO "                  \\\\\\#*\\\\\\# *~ *% .\\\\\\#*\n";
+  print FILEO "\n";
+  print FILEO "clean:: \$(SUBDIRS:%=%/__clean__) \$(EXTRASUBDIRS:%=%/__clean__)\n";
+  print FILEO "\t\$(RM) \$(CLEAN_FILES) \$(RC_SRCS:.rc=.res) \$(C_SRCS:.c=.o) \$(CXX_SRCS:.cpp=.o)\n";
+  print FILEO "\t\$(RM) \$(DLLS:%=%.so) \$(EXES:%=%.so) \$(EXES:%.exe=%)\n";
+  print FILEO "\n";
+  print FILEO "\$(SUBDIRS:%=%/__clean__): dummy\n";
+  print FILEO "\tcd `dirname \$\@` && \$(MAKE) clean\n";
+  print FILEO "\n";
+  print FILEO "\$(EXTRASUBDIRS:%=%/__clean__): dummy\n";
+  print FILEO "\t-cd `dirname \$\@` && \$(RM) \$(CLEAN_FILES)\n";
   print FILEO "\n";
-  print FILEO "clean::\n";
-  print FILEO "\t\$(RM)";
-  if (@$project[$P_PATH] eq "") {
-      print FILEO " wineapploader";
-  }
-  if (@{@$project[$P_TARGETS]} > 0) {
-      print FILEO " \$(EXES)";
-  }
-  print FILEO "\n\n";
 
   if (@{@$project[$P_TARGETS]} > 0) {
-    print FILEO "### Target specific build rules\n\n";
+    print FILEO "### Target specific build rules\n";
+    print FILEO "DEFLIB = \$(LIBRARY_PATH) \$(LIBRARIES) \$(DLL_PATH) \$(DLL_IMPORTS:%=-l%)\n\n";
     foreach my $target (@{@$project[$P_TARGETS]}) {
       my $canon=canonize("@$target[$T_NAME]");
-      my $mode;
-      my $all_dlls;
-      my $all_libs;
-
       $canon =~ s/_so$//;
-      if (@$target[$T_TYPE] == $TT_GUIEXE) {
-         $mode = '-m gui';
-      } elsif (@$target[$T_TYPE] == $TT_CUIEXE) {
-         $mode = '-m cui';
-      } else {
-         $mode = '';
-      }
-
-      if (@$target[$T_FLAGS] & $TF_WRAPPER) {
-        $all_dlls="\$(${canon}_DLLS:%=-l%)";
-        $all_libs="\$(${canon}_LIBRARIES:%=-l%) \$(WINE_LIBRARIES)";
-      } else {
-        $all_dlls="\$(${canon}_DLLS:%=-l%) \$(GLOBAL_DLLS:%=-l%)";
-        $all_libs="\$(${canon}_LIBRARIES:%=-l%) \$(ALL_LIBRARIES)";
-      }
 
-      print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS) \$(${canon}_OBJS) \$(${canon}_RC_SRCS:.rc=.res)\n";
-      print FILEO "\t\$(LD_PATH) \$(WINEBUILD) -fPIC \$(${canon}_DLL_PATH) \$(ALL_DLL_PATH) $all_dlls \$(${canon}_RC_SRCS:%.rc=-res %.res) $mode \$(${canon}_OBJS) -o \$\@ -spec \$(SRCDIR)/\$(${canon}_SPEC_SRCS)\n";
-      print FILEO "\n";
-      my $t_name=@$target[$T_NAME];
-      if (@$target[$T_TYPE]!=$TT_DLL) {
-        $t_name.=".exe.so";
-      }
-      print FILEO "$t_name: \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_OBJS) \$(${canon}_DEPENDS) \n";
+      print FILEO "\$(${canon}_MODULE).so: \$(${canon}_OBJS)\n";
       if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) {
-        print FILEO "\t\$(LDXXSHARED)";
+        print FILEO "\t\$(CXX)";
       } else {
-        print FILEO "\t\$(LDSHARED)";
-      }
-      print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(ALL_LIBRARY_PATH) $all_libs \$(LIBS)\n";
-      if (@$target[$T_TYPE] ne $TT_DLL) {
-        print FILEO "\ttest -f @$target[$T_NAME] || \$(INSTALL_SCRIPT) wineapploader @$target[$T_NAME]\n";
+        print FILEO "\t\$(CC)";
       }
+      print FILEO " \$(${canon}_LDFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_LIBRARY_PATH) \$(DEFLIB) \$(${canon}_DLLS:%=-l%) \$(${canon}_LIBRARIES:%=-l%)\n";
       print FILEO "\n\n";
     }
   }
   close(FILEO);
 
-  foreach my $target (@{@$project[$P_TARGETS]}) {
-    generate_spec_file(@$project[$P_PATH],$target,$project_settings);
-    if (@$target[$T_FLAGS] & $TF_WRAPPER) {
-      generate_wrapper_file(@$project[$P_PATH],$target);
-    }
-  }
 }
 
-##
-# Perform the replacements in the template configure files
-# Return 1 for success, 0 for failure
-sub generate_from_template($$;$)
-{
-  my $filename=$_[0];
-  my $template=$_[1];
-  my $substitutions=$_[2];
-
-  if (!defined $templates{$template}) {
-    print STDERR "winemaker: internal error: No template called '$template'\n";
-    return 0;
-  }
-
-  if (!open(FILEO,">$filename")) {
-    print STDERR "error: unable to open \"$filename\" for writing:\n";
-    print STDERR "       $!\n";
-    return 0;
-  }
-  my $warned;
-  foreach my $line (@{$templates{$template}}) {
-    if ($line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
-      if (defined $substitutions) {
-        foreach my $pattern (@$substitutions) {
-          $line =~ s%\#\#WINEMAKER_@$pattern[0]\#\#%@$pattern[1]%;
-        }
-      }
-      if (!$warned and $line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
-          print STDERR "warning: no value was provided for template $1 in \"$filename\"\n";
-          $warned=1;
-      }
-    }
-    print FILEO $line;
-  }
-  close(FILEO);
-  return 1;
-}
-
-##
-# Generates the global files:
-# configure
-# configure.ac
-# Make.rules.in
-# wineapploader.in
-sub generate_global_files()
-{
-  my @include_path;
-  foreach my $path (@{$global_settings[$T_INCLUDE_PATH]}) {
-    if ($path !~ /^-L/ or is_absolute($')) {
-      push @include_path, $path;
-    } else {
-      push @include_path, "-L\$(TOPSRCDIR)/$'";
-    }
-  }
-  my @dll_path;
-  foreach my $path (@{$global_settings[$T_DLL_PATH]}) {
-    if ($path !~ /^-L/ or is_absolute($')) {
-      push @dll_path, $path;
-    } else {
-      push @dll_path, "-L\$(TOPSRCDIR)/$'";
-    }
-  }
-  my @library_path;
-  foreach my $path (@{$global_settings[$T_LIBRARY_PATH]}) {
-    if ($path !~ /^-L/ or is_absolute($')) {
-      push @library_path, $path;
-    } else {
-      push @library_path, "-L\$(TOPSRCDIR)/$'";
-    }
-  }
-  generate_from_template("Make.rules.in","Make.rules.in",[
-      ["DEFINES", join(" ", @{$global_settings[$T_DEFINES]}) ],
-      ["INCLUDE_PATH", join(" ", @include_path) ],
-      ["DLL_PATH", join(" ", @dll_path) ],
-      ["DLLS", join(" ", @{$global_settings[$T_DLLS]}) ],
-      ["LIBRARY_PATH", join(" ", @library_path) ],
-      ["LIBRARIES", join(" ", @{$global_settings[$T_LIBRARIES]}) ]]);
-  generate_from_template("wineapploader.in","wineapploader.in");
-
-  # Get the name of a source file for configure.ac
-  my $a_source_file;
-  search_a_file: foreach my $project (@projects) {
-    foreach my $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) {
-      $a_source_file=@{@$target[$T_SOURCES_C]}[0];
-      if (!defined $a_source_file) {
-       $a_source_file=@{@$target[$T_SOURCES_CXX]}[0];
-      }
-      if (!defined $a_source_file) {
-       $a_source_file=@{@$target[$T_SOURCES_RC]}[0];
-      }
-      if (defined $a_source_file) {
-       $a_source_file="@$project[$P_PATH]$a_source_file";
-       last search_a_file;
-      }
-    }
-  }
-  if (!defined $a_source_file) {
-    $a_source_file="Makefile.in";
-  }
-  generate_from_template("configure.ac","configure.ac",[
-      ["PROJECTS",join("\n",map { "@$_[$P_PATH]Makefile" } @projects)],
-      ["SOURCE","$a_source_file"],
-      ["NEEDS_MFC","$needs_mfc"]]);
-  system("autoconf configure.ac > configure");
-
-  # Add execute permission to configure for whoever has the right to read it
-  my @st=stat("configure");
-  if (@st) {
-    my $mode=$st[2];
-    $mode|=($mode & 0444) >>2;
-    chmod($mode,"configure");
-  } else {
-    print "warning: could not generate the configure script. You need to run autoconf\n";
-  }
-}
-
-##
-#
-sub generate_read_templates()
-{
-  my $file;
-
-  while (<DATA>) {
-    if (/^--- ((\w\.?)+) ---$/) {
-      my $filename=$1;
-      if (defined $templates{$filename}) {
-        print STDERR "winemaker: internal error: There is more than one template for $filename\n";
-        undef $file;
-      } else {
-        $file=[];
-        $templates{$filename}=$file;
-      }
-    } elsif (defined $file) {
-      push @$file, $_;
-    }
-  }
-}
 
 ##
 # This is where we finally generate files. In fact this method does not
@@ -2126,8 +2467,6 @@ sub generate_read_templates()
 sub generate()
 {
   print "Generating project files...\n";
-  generate_read_templates();
-  generate_global_files();
 
   foreach my $project (@projects) {
     my $path=@$project[$P_PATH];
@@ -2153,15 +2492,15 @@ $opt_backup=1;
 $opt_lower=$OPT_LOWER_UPPERCASE;
 $opt_lower_include=1;
 
-# $opt_work_dir=<undefined>
-# $opt_single_target=<undefined>
+$opt_work_dir=undef;
+$opt_single_target=undef;
 $opt_target_type=$TT_GUIEXE;
 $opt_flags=0;
+$opt_arch=$OPT_ARCH_32;
 $opt_is_interactive=$OPT_ASK_NO;
 $opt_ask_project_options=$OPT_ASK_NO;
 $opt_ask_target_options=$OPT_ASK_NO;
 $opt_no_generated_files=0;
-$opt_no_generated_specs=0;
 $opt_no_source_fix=0;
 $opt_no_banner=0;
 
@@ -2177,6 +2516,8 @@ sub print_banner()
 {
   print "Winemaker $version\n";
   print "Copyright 2000 Francois Gouget <fgouget\@codeweavers.com> for CodeWeavers\n";
+  print "Copyright 2004 Dimitrie O. Paun\n";
+  print "Copyright 2009 André Hentschel\n";
 }
 
 sub usage()
@@ -2184,16 +2525,16 @@ sub usage()
   print_banner();
   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 "                 [--lower-include|--nolower-include] [--mfc|--nomfc]\n";
   print STDERR "                 [--guiexe|--windows|--cuiexe|--console|--dll]\n";
-  print STDERR "                 [--wrap|--nowrap] [--mfc|--nomfc]\n";
   print STDERR "                 [-Dmacro[=defn]] [-Idir] [-Pdir] [-idll] [-Ldir] [-llibrary]\n";
-  print STDERR "                 [--nodlls] [--interactive] [--single-target name]\n";
-  print STDERR "                 [--generated-files|--nogenerated-files] [--nogenerated-specs]\n";
-  print STDERR "                 work_directory\n";
+  print STDERR "                 [--nodlls] [--nomsvcrt] [--interactive] [--single-target name]\n";
+  print STDERR "                 [--generated-files|--nogenerated-files]\n";
+  print STDERR "                 [--wine64]\n";
+  print STDERR "                 work_directory|project_file|workspace_file\n";
   print STDERR "\nWinemaker is designed to recursively convert all the Windows sources found in\n";
-  print STDERR "the specified directory so that they can be compiled with Winelib. During this\n";
-  print STDERR "process it will modify and rename some of the files in that directory.\n";
+  print STDERR "the specified directory or project-file, so that they can be compiled with Winelib.\n";
+  print STDERR "During this process it will modify and rename some of the corresponding files.\n";
   print STDERR "\tPlease read the manual page before use.\n";
   exit (2);
 }
@@ -2227,9 +2568,8 @@ while (@ARGV>0) {
     $opt_no_generated_files=0;
   } elsif ($arg eq "--nogenerated-files") {
     $opt_no_generated_files=1;
-  } elsif ($arg eq "--nogenerated-specs") {
-    $opt_no_generated_specs=1;
-
+  } elsif ($arg eq "--wine64") {
+    $opt_arch=$OPT_ARCH_64;
   } elsif ($arg =~ /^-D/) {
     push @{$global_settings[$T_DEFINES]},$arg;
   } elsif ($arg =~ /^-I/) {
@@ -2237,14 +2577,7 @@ while (@ARGV>0) {
   } elsif ($arg =~ /^-P/) {
     push @{$global_settings[$T_DLL_PATH]},"-L$'";
   } elsif ($arg =~ /^-i/) {
-    my $dllname = $';
-    if ($dllname =~ /^[^.]*$/) {
-      $dllname .= ".dll";
-    }
-    if ($dllname =~ /^msvcrt\.dll$/) {
-      push @{$global_settings[$T_INCLUDE_PATH]},"-I\$(WINE_INCLUDE_ROOT)/msvcrt";
-    }
-    push @{$global_settings[$T_DLLS]},$dllname;
+    push @{$global_settings[$T_DLLS]},$';
   } elsif ($arg =~ /^-L/) {
     push @{$global_settings[$T_LIBRARY_PATH]},$arg;
   } elsif ($arg =~ /^-l/) {
@@ -2261,44 +2594,40 @@ while (@ARGV>0) {
     $opt_is_interactive=$OPT_ASK_YES;
     $opt_ask_project_options=$OPT_ASK_YES;
     $opt_ask_target_options=$OPT_ASK_YES;
-  } elsif ($arg eq "--wrap") {
-    $opt_flags|=$TF_WRAP;
-  } elsif ($arg eq "--nowrap") {
-    $opt_flags&=~$TF_WRAP;
   } elsif ($arg eq "--mfc") {
     $opt_flags|=$TF_MFC;
-    $needs_mfc=1;
   } elsif ($arg eq "--nomfc") {
     $opt_flags&=~$TF_MFC;
     $opt_flags|=$TF_NOMFC;
-    $needs_mfc=0;
   } elsif ($arg eq "--nodlls") {
     $opt_flags|=$TF_NODLLS;
+  } elsif ($arg eq "--nomsvcrt") {
+    $opt_flags|=$TF_NOMSVCRT;
 
   # Catch errors
   } else {
     if ($arg ne "--help" and $arg ne "-h" and $arg ne "-?") {
-      if (!defined $opt_work_dir) {
-        $opt_work_dir=$arg;
-      } else {
-        print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n";
-        usage();
-      }
+        if (!defined $opt_work_dir and !defined $opt_work_file) {
+            if (-f $arg) {
+                $opt_work_file=$arg;
+            }
+            else {
+                $opt_work_dir=$arg;
+            }
+        } else {
+            print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n";
+            usage();
+        }
     } else {
-      usage();
+        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) {
-  print STDERR "error: you must specify the directory containing the sources to be converted\n";
+if (!defined $opt_work_dir and !defined $opt_work_file) {
+  print STDERR "error: you must specify the directory or project file containing the sources to be converted\n";
   usage();
-} elsif (!chdir $opt_work_dir) {
+} elsif (defined $opt_work_dir and !chdir $opt_work_dir) {
   print STDERR "error: could not chdir to the work directory\n";
   print STDERR "       $!\n";
   usage();
@@ -2308,7 +2637,7 @@ if ($opt_no_banner == 0) {
   print_banner();
 }
 
-project_init(\@main_project,"");
+project_init(\@main_project, "", \@global_settings);
 
 # Fix the file and directory names
 fix_file_and_directory_names(".");
@@ -2316,9 +2645,6 @@ fix_file_and_directory_names(".");
 # Scan the sources to identify the projects and targets
 source_scan();
 
-# Create targets for wrappers, etc.
-postprocess_targets();
-
 # Fix the source files
 if (! $opt_no_source_fix) {
   fix_source();
@@ -2328,1070 +2654,3 @@ if (! $opt_no_source_fix) {
 if (! $opt_no_generated_files) {
   generate();
 }
-
-
-__DATA__
---- configure.ac ---
-dnl Process this file with autoconf to produce a configure script.
-dnl Author: Michael Patra   <micky@marie.physik.tu-berlin.de>
-dnl                         <patra@itp1.physik.tu-berlin.de>
-dnl         Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
-
-AC_REVISION([configure.ac 1.00])
-AC_INIT(##WINEMAKER_SOURCE##)
-
-NEEDS_MFC=##WINEMAKER_NEEDS_MFC##
-
-dnl **** Command-line arguments ****
-
-AC_SUBST(OPTIONS)
-
-dnl **** Check for some programs ****
-
-AC_PROG_MAKE_SET
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_CPP
-AC_PROG_LN_S
-
-dnl **** Check for some libraries ****
-
-dnl Check for -lm for BeOS
-AC_CHECK_LIB(m,sqrt)
-dnl Check for -lw for Solaris
-AC_CHECK_LIB(w,iswalnum)
-dnl Check for -lnsl for Solaris
-AC_CHECK_FUNCS(gethostbyname,, AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", AC_CHECK_LIB(socket, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", , -lnsl), -lsocket))
-dnl Check for -lsocket for Solaris
-AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
-
-dnl **** Check for gcc strength-reduce bug ****
-
-if test "x${GCC}" = "xyes"
-then
-  AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
-                  AC_TRY_RUN([
-int main(void) {
-  static int Array[[3]];
-  unsigned int B = 3;
-  int i;
-  for(i=0; i<B; i++) Array[[i]] = i - 3;
-  exit( Array[[1]] != -2 );
-}],
-    ac_cv_c_gcc_strength_bug="no",
-    ac_cv_c_gcc_strength_bug="yes",
-    ac_cv_c_gcc_strength_bug="yes") )
-  if test "$ac_cv_c_gcc_strength_bug" = "yes"
-  then
-    CFLAGS="$CFLAGS -fno-strength-reduce"
-  fi
-fi
-
-dnl **** Check for underscore on external symbols ****
-
-AC_CACHE_CHECK("whether external symbols need an underscore prefix",
-               ac_cv_c_extern_prefix,
-[saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-       .globl _ac_test
-_ac_test:
-       .long 0
-EOF
-AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
-            ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
-LIBS=$saved_libs])
-if test "$ac_cv_c_extern_prefix" = "yes"
-then
-  AC_DEFINE(NEED_UNDERSCORE_PREFIX)
-fi
-
-dnl **** Check for working dll ****
-
-LDSHARED=""
-LDXXSHARED=""
-LDDLLFLAGS=""
-AC_CACHE_CHECK("whether we can build a Linux dll",
-               ac_cv_c_dll_linux,
-[saved_cflags=$CFLAGS
-CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
-AC_TRY_LINK(,[return 1],ac_cv_c_dll_linux="yes",ac_cv_c_dll_linux="no")
-CFLAGS=$saved_cflags
-])
-if test "$ac_cv_c_dll_linux" = "yes"
-then
-  LDSHARED="\$(CC) -shared"
-  LDXXSHARED="\$(CXX) -shared"
-  LDDLLFLAGS="-Wl,-Bsymbolic"
-else
-  AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
-                ac_cv_c_dll_unixware,
-  [saved_cflags=$CFLAGS
-  CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
-  AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
-  CFLAGS=$saved_cflags
-  ])
-  if test "$ac_cv_c_dll_unixware" = "yes"
-  then
-    LDSHARED="\$(CC) -Wl,-G"
-    LDXXSHARED="\$(CXX) -Wl,-G"
-    LDDLLFLAGS="-Wl,-B,symbolic"
-  else
-    AC_CACHE_CHECK("whether we can build a NetBSD dll",
-                   ac_cv_c_dll_netbsd,
-    [saved_cflags=$CFLAGS
-    CFLAGS="$CFLAGS -fPIC -Wl,-Bshareable,-Bforcearchive"
-    AC_TRY_LINK(,[return 1],ac_cv_c_dll_netbsd="yes",ac_cv_c_dll_netbsd="no")
-    CFLAGS=$saved_cflags
-    ])
-    if test "$ac_cv_c_dll_netbsd" = "yes"
-    then
-      LDSHARED="\$(CC) -Wl,-Bshareable,-Bforcearchive"
-      LDXXSHARED="\$(CXX) -Wl,-Bshareable,-Bforcearchive"
-      LDDLLFLAGS="" #FIXME
-    fi
-  fi
-fi
-if test "$ac_cv_c_dll_linux" = "no" -a "$ac_cv_c_dll_unixware" = "no" -a "$ac_cv_c_dll_netbsd" = "no"
-then
-  AC_MSG_ERROR([Could not find how to build a dynamically linked library])
-fi
-
-CFLAGS="$CFLAGS -fPIC"
-
-AC_SUBST(LDSHARED)
-AC_SUBST(LDXXSHARED)
-AC_SUBST(LDDLLFLAGS)
-
-dnl *** check for the need to define __i386__
-
-AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
- AC_EGREP_CPP(yes,[#if (defined(i386) || defined(__i386)) && !defined(__i386__)
-yes
-#endif],
- ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no"))
-if test "$ac_cv_cpp_def_i386" = "yes"
-then
-    CFLAGS="$CFLAGS -D__i386__"
-fi
-
-dnl *** check for the need to define __sparc__
-
-AC_CACHE_CHECK("whether we need to define __sparc__",ac_cv_cpp_def_sparc,
- AC_EGREP_CPP(yes,[#if (defined(sparc) || defined(__sparc)) && !defined(__sparc__)
-yes
-#endif],
- ac_cv_cpp_def_sparc="yes", ac_cv_cpp_def_sparc="no"))
-if test "$ac_cv_cpp_def_sparc" = "yes"
-then
-    CFLAGS="$CFLAGS -D__sparc__"
-    CXXFLAGS="$CXXFLAGS -D__sparc__"
-fi
-
-dnl *** check for the need to define __sun__
-
-AC_CACHE_CHECK("whether we need to define __sun__",ac_cv_cpp_def_sun,
- AC_EGREP_CPP(yes,[#if (defined(sun) || defined(__sun)) && !defined(__sun__)
-yes
-#endif],
- ac_cv_cpp_def_sun="yes", ac_cv_cpp_def_sun="no"))
-if test "$ac_cv_cpp_def_sun" = "yes"
-then
-    CFLAGS="$CFLAGS -D__sun__"
-    CXXFLAGS="$CXXFLAGS -D__sun__"
-fi
-
-dnl $GCC is set by autoconf
-GCC_NO_BUILTIN=""
-if test "$GCC" = "yes"
-then
-    GCC_NO_BUILTIN="-fno-builtin"
-fi
-AC_SUBST(GCC_NO_BUILTIN)
-
-dnl **** Test Winelib-related features of the C++ compiler
-AC_LANG_CPLUSPLUS()
-if test "x${GCC}" = "xyes"
-then
-  OLDCXXFLAGS="$CXXFLAGS";
-  CXXFLAGS="-fpermissive";
-  AC_CACHE_CHECK("for g++ -fpermissive option", has_gxx_permissive,
-    AC_TRY_COMPILE(,[
-        for (int i=0;i<2;i++);
-        i=0;
-      ],
-      [has_gxx_permissive="yes"],
-      [has_gxx_permissive="no"])
-   )
-  CXXFLAGS="-fno-for-scope";
-  AC_CACHE_CHECK("for g++ -fno-for-scope option", has_gxx_no_for_scope,
-    AC_TRY_COMPILE(,[
-        for (int i=0;i<2;i++);
-        i=0;
-      ],
-      [has_gxx_no_for_scope="yes"],
-      [has_gxx_no_for_scope="no"])
-   )
-  CXXFLAGS="$OLDCXXFLAGS";
-  if test "$has_gxx_permissive" = "yes"
-  then
-    CXXFLAGS="$CXXFLAGS -fpermissive"
-  fi
-  if test "$has_gxx_no_for_scope" = "yes"
-  then
-    CXXFLAGS="$CXXFLAGS -fno-for-scope"
-  fi
-fi
-AC_LANG_C()
-
-dnl **** Test Winelib-related features of the C compiler
-dnl none for now
-
-dnl **** Macros for finding a headers/libraries in a collection of places
-
-dnl AC_PATH_FILE(variable,file,action-if-not-found,default-locations)
-AC_DEFUN(AC_PATH_FILE,[
-AC_MSG_CHECKING([for $2])
-AC_CACHE_VAL(ac_cv_pfile_$1,
-[
-  ac_found=
-  ac_dummy="ifelse([$4], , , [$4])"
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  for ac_dir in $ac_dummy; do
-    IFS="$ac_save_ifs"
-    if test -z "$ac_dir"
-    then
-      ac_file="$2"
-    else
-      ac_file="$ac_dir/$2"
-    fi
-    if test -f "$ac_file"
-    then
-      ac_found=1
-      ac_cv_pfile_$1="$ac_dir"
-      break
-    fi
-  done
-  ifelse([$3],,,[if test -z "$ac_found"
-    then
-      $3
-    fi
-  ])
-])
-$1="$ac_cv_pfile_$1"
-if test -n "$ac_found" -o -n "[$]$1"
-then
-  AC_MSG_RESULT([$]$1)
-else
-  AC_MSG_RESULT(no)
-fi
-AC_SUBST($1)
-])
-
-dnl AC_PATH_HEADER(variable,header,action-if-not-found,default-locations)
-dnl Note that the above may set variable to an empty value if the header is
-dnl already in the include path
-AC_DEFUN(AC_PATH_HEADER,[
-AC_MSG_CHECKING([for $2 header])
-AC_CACHE_VAL(ac_cv_pheader_$1,
-[
-  ac_found=
-  ac_dummy="ifelse([$4], , :/usr/local/include, [$4])"
-  save_CPPFLAGS="$CPPFLAGS"
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  for ac_dir in $ac_dummy; do
-    IFS="$ac_save_ifs"
-    if test -z "$ac_dir"
-    then
-      CPPFLAGS="$save_CPPFLAGS"
-    else
-      CPPFLAGS="-I$ac_dir $save_CPPFLAGS"
-    fi
-    AC_TRY_COMPILE([#include <$2>],,ac_found=1;ac_cv_pheader_$1="$ac_dir";break)
-  done
-  CPPFLAGS="$save_CPPFLAGS"
-  ifelse([$3],,,[if test -z "$ac_found"
-    then
-      $3
-    fi
-  ])
-])
-$1="$ac_cv_pheader_$1"
-if test -n "$ac_found" -o -n "[$]$1"
-then
-  AC_MSG_RESULT([$]$1)
-else
-  AC_MSG_RESULT(no)
-fi
-AC_SUBST($1)
-])
-
-dnl AC_PATH_LIBRARY(variable,libraries,extra libs,action-if-not-found,default-locations)
-AC_DEFUN(AC_PATH_LIBRARY,[
-AC_MSG_CHECKING([for $2])
-AC_CACHE_VAL(ac_cv_plibrary_$1,
-[
-  ac_found=
-  ac_dummy="ifelse([$5], , :/usr/local/lib, [$5])"
-  save_LIBS="$LIBS"
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  for ac_dir in $ac_dummy; do
-    IFS="$ac_save_ifs"
-    if test -z "$ac_dir"
-    then
-      LIBS="$2 $3 $save_LIBS"
-    else
-      LIBS="-L$ac_dir $2 $3 $save_LIBS"
-    fi
-    AC_TRY_LINK(,,ac_found=1;ac_cv_plibrary_$1="$ac_dir";break)
-  done
-  LIBS="$save_LIBS"
-  ifelse([$4],,,[if test -z "$ac_found"
-    then
-      $4
-    fi
-  ])
-])
-$1="$ac_cv_plibrary_$1"
-if test -n "$ac_found" -o -n "[$]$1"
-then
-  AC_MSG_RESULT([$]$1)
-else
-  AC_MSG_RESULT(no)
-fi
-AC_SUBST($1)
-])
-
-dnl **** Try to find where winelib is located ****
-
-LD_PATH=""
-WINE_INCLUDE_ROOT=""
-WINE_INCLUDE_PATH=""
-WINE_LIBRARY_ROOT=""
-WINE_LIBRARY_PATH=""
-WINE_DLL_ROOT=""
-WINE_DLL_PATH=""
-WINE_TOOL_PATH=""
-WINE=""
-WINEBUILD=""
-WRC=""
-
-AC_ARG_WITH(wine,
-[  --with-wine=DIR           the Wine package (or sources) is in DIR],
-[if test "$withval" != "no"; then
-  WINE_ROOT="$withval";
-  WINE_INCLUDES="";
-  WINE_LIBRARIES="";
-  WINE_TOOLS="";
-else
-  WINE_ROOT="";
-fi])
-if test -n "$WINE_ROOT"
-then
-  WINE_INCLUDE_ROOT="$WINE_ROOT/include:$WINE_ROOT/include/wine"
-  WINE_LIBRARY_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/library"
-  WINE_UNICODE_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/unicode"
-  WINE_UUID_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/ole"
-  WINE_TOOL_PATH="$WINE_ROOT:$WINE_ROOT/bin:$WINE_ROOT/tools/wrc:$WINE_ROOT/tools/winebuild"
-  WINE_DLL_ROOT="$WINE_ROOT/dlls:$WINE_ROOT/lib"
-fi
-
-AC_ARG_WITH(wine-includes,
-[  --with-wine-includes=DIR  the Wine includes are in DIR],
-[if test "$withval" != "no"; then
-  WINE_INCLUDES="$withval";
-else
-  WINE_INCLUDES="";
-fi])
-if test -n "$WINE_INCLUDES"
-then
-  WINE_INCLUDE_ROOT="$WINE_INCLUDES"
-fi
-
-AC_ARG_WITH(wine-libraries,
-[  --with-wine-libraries=DIR the Wine libraries are in DIR],
-[if test "$withval" != "no"; then
-  WINE_LIBRARIES="$withval";
-else
-  WINE_LIBRARIES="";
-fi])
-if test -n "$WINE_LIBRARIES"
-then
-  WINE_LIBRARY_ROOT="$WINE_LIBRARIES"
-  WINE_UNICODE_ROOT="$WINE_LIBRARIES:$WINE_LIBRARIES/unicode:$WINE_LIBRARIES/../unicode"
-  WINE_UUID_ROOT="$WINE_LIBRARIES:$WINE_LIBRARIES/ole:$WINE_LIBRARIES/../ole"
-fi
-
-AC_ARG_WITH(wine-dlls,
-[  --with-wine-dlls=DIR      the Wine dlls are in DIR],
-[if test "$withval" != "no"; then
-  WINE_DLLS="$withval";
-else
-  WINE_DLLS="";
-fi])
-if test -n "$WINE_DLLS"
-then
-  WINE_DLL_ROOT="$WINE_DLLS"
-fi
-
-AC_ARG_WITH(wine-tools,
-[  --with-wine-tools=DIR     the Wine tools are in DIR],
-[if test "$withval" != "no"; then
-  WINE_TOOLS="$withval";
-else
-  WINE_TOOLS="";
-fi])
-if test -n "$WINE_TOOLS"
-then
-  WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/tools/wrc:$WINE_TOOLS/tools/winebuild"
-fi
-
-if test -z "$WINE_INCLUDE_ROOT"
-then
-  WINE_INCLUDE_ROOT=":/usr/include/wine:/usr/local/include/wine:/opt/wine/include:/opt/wine/include/wine";
-else
-  AC_PATH_FILE(WINE_INCLUDE_ROOT,[windef.h],[
-    AC_MSG_ERROR([Could not find the Wine headers (windef.h)])
-  ],$WINE_INCLUDE_ROOT)
-fi
-AC_PATH_HEADER(WINE_INCLUDE_ROOT,[windef.h],[
-  AC_MSG_ERROR([Could not include the Wine headers (windef.h)])
-],$WINE_INCLUDE_ROOT)
-if test -n "$WINE_INCLUDE_ROOT"
-then
-  WINE_INCLUDE_PATH="-I$WINE_INCLUDE_ROOT"
-else
-  WINE_INCLUDE_PATH=""
-fi
-
-if test -z "$WINE_LIBRARY_ROOT"
-then
-  WINE_LIBRARY_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
-else
-  AC_PATH_FILE(WINE_LIBRARY_ROOT,[libwine.so],[
-    AC_MSG_ERROR([Could not find the Wine libraries (libwine.so)])
-  ],$WINE_LIBRARY_ROOT)
-fi
-AC_PATH_LIBRARY(WINE_LIBRARY_ROOT,[-lwine],[],[
-  AC_MSG_ERROR([Could not link with the Wine libraries (libwine.so)])
-],$WINE_LIBRARY_ROOT)
-if test -n "$WINE_LIBRARY_ROOT"
-then
-  WINE_LIBRARY_PATH="-L$WINE_LIBRARY_ROOT"
-  LD_PATH="$WINE_LIBRARY_ROOT"
-else
-  WINE_LIBRARY_PATH=""
-fi
-
-if test -z "$WINE_UNICODE_ROOT"
-then
-  WINE_UNICODE_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
-else
-  AC_PATH_FILE(WINE_UNICODE_ROOT,[libwine_unicode.so],[
-    AC_MSG_ERROR([Could not find the Wine libraries (libwine_unicode.so)])
-  ],$WINE_UNICODE_ROOT)
-fi
-AC_PATH_LIBRARY(WINE_UNICODE_ROOT,[-lwine_unicode],[$WINE_LIBRARY_PATH -lwine],[
-  AC_MSG_ERROR([Could not link with the Wine libraries (libwine_unicode.so)])
-],[$WINE_UNICODE_ROOT])
-
-if test -n "$WINE_UNICODE_ROOT" -a "$WINE_UNICODE_ROOT" != "$WINE_LIBRARY_ROOT"
-then
-  WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$WINE_UNICODE_ROOT"
-  LD_PATH="$LD_PATH:$WINE_UNICODE_ROOT"
-fi
-
-if test -z "$WINE_UUID_ROOT"
-then
-  WINE_UUID_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
-else
-  AC_PATH_FILE(WINE_UUID_ROOT,[libwine_uuid.a],[
-    AC_MSG_ERROR([Could not find the Wine libraries (libwine_uuid.a)])
-  ],$WINE_UUID_ROOT)
-fi
-AC_PATH_LIBRARY(WINE_UUID_ROOT,[-lwine_uuid],[$WINE_LIBRARY_PATH -lwine],[
-  AC_MSG_ERROR([Could not link with the Wine libraries (libwine_uuid.a)])
-],[$WINE_UUID_ROOT])
-
-if test -n "$WINE_UUID_ROOT" -a "$WINE_UUID_ROOT" != "$WINE_LIBRARY_ROOT"
-then
-  WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$WINE_UUID_ROOT"
-  LD_PATH="$LD_PATH:$WINE_UUID_ROOT"
-fi
-
-if test -z "$WINE_DLL_ROOT"
-then
-  if test -n "$WINE_LIBRARY_ROOT"
-  then
-    WINE_DLL_ROOT="$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/dlls"
-  else
-    WINE_DLL_ROOT="/lib:/lib/wine:/usr/lib:/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine"
-  fi
-fi
-AC_PATH_FILE(WINE_DLL_ROOT,[libntdll.dll.so],[
-  AC_MSG_ERROR([Could not find the Wine dlls (libntdll.dll.so)])
-],[$WINE_DLL_ROOT])
-
-AC_PATH_LIBRARY(WINE_DLL_ROOT,[-lntdll.dll],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
-  AC_MSG_ERROR([Could not link with the Wine dlls (libntdll.dll.so)])
-],[$WINE_DLL_ROOT])
-WINE_DLL_PATH="-L$WINE_DLL_ROOT/wine"
-
-if test -n "$LD_PATH"
-then
-  LD_PATH="$LD_PATH:$WINE_DLL_ROOT"
-else
-  LD_PATH="$WINE_DLL_ROOT"
-fi
-LD_PATH="LD_LIBRARY_PATH=\"$LD_PATH:\$\$LD_LIBRARY_PATH\""
-
-if test -z "$WINE_TOOL_PATH"
-then
-  WINE_TOOL_PATH="$PATH:/usr/local/bin:/opt/wine/bin"
-fi
-AC_PATH_PROG(WINE,wine,,$WINE_TOOL_PATH)
-if test -z "$WINE"
-then
-  AC_MSG_ERROR([Could not find Wine's wine tool])
-fi
-AC_PATH_PROG(WINEBUILD,winebuild,,$WINE_TOOL_PATH)
-if test -z "$WINEBUILD"
-then
-  AC_MSG_ERROR([Could not find Wine's winebuild tool])
-fi
-AC_PATH_PROG(WRC,wrc,,$WINE_TOOL_PATH)
-if test -z "$WRC"
-then
-  AC_MSG_ERROR([Could not find Wine's wrc tool])
-fi
-
-AC_SUBST(LD_PATH)
-AC_SUBST(WINE_INCLUDE_PATH)
-AC_SUBST(WINE_LIBRARY_PATH)
-AC_SUBST(WINE_DLL_PATH)
-
-dnl **** Try to find where the MFC are located ****
-AC_LANG_CPLUSPLUS()
-
-if test "x$NEEDS_MFC" = "x1"
-then
-  ATL_INCLUDE_ROOT="";
-  ATL_INCLUDE_PATH="";
-  MFC_INCLUDE_ROOT="";
-  MFC_INCLUDE_PATH="";
-  MFC_LIBRARY_ROOT="";
-  MFC_LIBRARY_PATH="";
-
-  AC_ARG_WITH(mfc,
-  [  --with-mfc=DIR            the MFC package (or sources) is in DIR],
-  [if test "$withval" != "no"; then
-    MFC_ROOT="$withval";
-    ATL_INCLUDES="";
-    MFC_INCLUDES="";
-    MFC_LIBRARIES="";
-  else
-    MFC_ROOT="";
-  fi])
-  if test -n "$MFC_ROOT"
-  then
-    ATL_INCLUDE_ROOT="$MFC_ROOT";
-    MFC_INCLUDE_ROOT="$MFC_ROOT";
-    MFC_LIBRARY_ROOT="$MFC_ROOT";
-  fi
-
-  AC_ARG_WITH(atl-includes,
-  [  --with-atl-includes=DIR   the ATL includes are in DIR],
-  [if test "$withval" != "no"; then
-    ATL_INCLUDES="$withval";
-  else
-    ATL_INCLUDES="";
-  fi])
-  if test -n "$ATL_INCLUDES"
-  then
-    ATL_INCLUDE_ROOT="$ATL_INCLUDES";
-  fi
-
-  AC_ARG_WITH(mfc-includes,
-  [  --with-mfc-includes=DIR   the MFC includes are in DIR],
-  [if test "$withval" != "no"; then
-    MFC_INCLUDES="$withval";
-  else
-    MFC_INCLUDES="";
-  fi])
-  if test -n "$MFC_INCLUDES"
-  then
-    MFC_INCLUDE_ROOT="$MFC_INCLUDES";
-  fi
-
-  AC_ARG_WITH(mfc-libraries,
-  [  --with-mfc-libraries=DIR  the MFC libraries are in DIR],
-  [if test "$withval" != "no"; then
-    MFC_LIBRARIES="$withval";
-  else
-    MFC_LIBRARIES="";
-  fi])
-  if test -n "$MFC_LIBRARIES"
-  then
-    MFC_LIBRARY_ROOT="$MFC_LIBRARIES";
-  fi
-
-  OLDCPPFLAGS="$CPPFLAGS"
-  dnl FIXME: We should not have defines in any of the include paths
-  CPPFLAGS="$WINE_INCLUDE_PATH -I$WINE_INCLUDE_ROOT/msvcrt -D_DLL -D_MT $CPPFLAGS"
-  ATL_INCLUDE_PATH="-I\$(WINE_INCLUDE_ROOT)/msvcrt -D_DLL -D_MT"
-  if test -z "$ATL_INCLUDE_ROOT"
-  then
-    ATL_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/atl:/usr/include/atl:/usr/local/include/atl:/opt/mfc/include/atl:/opt/atl/include"
-  else
-    ATL_INCLUDE_ROOT="$ATL_INCLUDE_ROOT:$ATL_INCLUDE_ROOT/atl:$ATL_INCLUDE_ROOT/atl/include"
-  fi
-  AC_PATH_HEADER(ATL_INCLUDE_ROOT,atldef.h,[
-    AC_MSG_ERROR([Could not find the ATL includes])
-  ],$ATL_INCLUDE_ROOT)
-  if test -n "$ATL_INCLUDE_ROOT"
-  then
-    ATL_INCLUDE_PATH="$ATL_INCLUDE_PATH -I$ATL_INCLUDE_ROOT"
-  fi
-
-  MFC_INCLUDE_PATH="$ATL_INCLUDE_PATH"
-  if test -z "$MFC_INCLUDE_ROOT"
-  then
-    MFC_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/mfc:/usr/include/mfc:/usr/local/include/mfc:/opt/mfc/include/mfc:/opt/mfc/include"
-  else
-    MFC_INCLUDE_ROOT="$MFC_INCLUDE_ROOT:$MFC_INCLUDE_ROOT/mfc:$MFC_INCLUDE_ROOT/mfc/include"
-  fi
-  AC_PATH_HEADER(MFC_INCLUDE_ROOT,afx.h,[
-    AC_MSG_ERROR([Could not find the MFC includes])
-  ],$MFC_INCLUDE_ROOT)
-  if test -n "$MFC_INCLUDE_ROOT" -a "$ATL_INCLUDE_ROOT" != "$MFC_INCLUDE_ROOT"
-  then
-    MFC_INCLUDE_PATH="$MFC_INCLUDE_PATH -I$MFC_INCLUDE_ROOT"
-  fi
-  CPPFLAGS="$OLDCPPFLAGS"
-
-  if test -z "$MFC_LIBRARY_ROOT"
-  then
-    MFC_LIBRARY_ROOT=":$WINE_LIBRARY_ROOT:/usr/lib/mfc:/usr/local/lib:/usr/local/lib/mfc:/opt/mfc/lib";
-  else
-    MFC_LIBRARY_ROOT="$MFC_LIBRARY_ROOT:$MFC_LIBRARY_ROOT/lib:$MFC_LIBRARY_ROOT/mfc/src";
-  fi
-  AC_PATH_LIBRARY(MFC_LIBRARY_ROOT,[-lmfc],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
-    AC_MSG_ERROR([Could not find the MFC library])
-  ],$MFC_LIBRARY_ROOT)
-  if test -n "$MFC_LIBRARY_ROOT" -a "$MFC_LIBRARY_ROOT" != "$WINE_LIBRARY_ROOT"
-  then
-    MFC_LIBRARY_PATH="-L$MFC_LIBRARY_ROOT"
-  else
-    MFC_LIBRARY_PATH=""
-  fi
-
-  AC_SUBST(ATL_INCLUDE_PATH)
-  AC_SUBST(MFC_INCLUDE_PATH)
-  AC_SUBST(MFC_LIBRARY_PATH)
-fi
-
-AC_LANG_C()
-
-dnl **** Generate output files ****
-
-MAKE_RULES=Make.rules
-AC_SUBST_FILE(MAKE_RULES)
-
-AC_OUTPUT([
-Make.rules
-##WINEMAKER_PROJECTS##
- ])
-
-echo
-echo "Configure finished.  Do 'make' to build the project."
-echo
-
-dnl Local Variables:
-dnl comment-start: "dnl "
-dnl comment-end: ""
-dnl comment-start-skip: "\\bdnl\\b\\s *"
-dnl compile-command: "autoconf"
-dnl End:
---- Make.rules.in ---
-# Copyright 2000 Francois Gouget for CodeWeavers
-# fgouget@codeweavers.com
-#
-# Global rules shared by all makefiles     -*-Makefile-*-
-#
-# Each individual makefile must define the following variables:
-# TOPOBJDIR    : top-level object directory
-# SRCDIR       : source directory for this module
-#
-# Each individual makefile may define the following additional variables:
-#
-# SUBDIRS      : subdirectories that contain a Makefile
-# DLLS         : WineLib libraries to be built
-# EXES         : WineLib executables to be built
-#
-# CEXTRA       : extra c flags (e.g. '-Wall')
-# CXXEXTRA     : extra c++ flags (e.g. '-Wall')
-# WRCEXTRA     : extra wrc flags (e.g. '-p _SysRes')
-# DEFINES      : defines (e.g. -DSTRICT)
-# INCLUDE_PATH : additional include path
-# LIBRARY_PATH : additional library path
-# LIBRARIES    : additional Unix libraries to link with
-#
-# C_SRCS       : C sources for the module
-# CXX_SRCS     : C++ sources for the module
-# RC_SRCS      : resource source files
-# SPEC_SRCS    : interface definition files
-
-
-# Where is Wine
-
-WINE_INCLUDE_ROOT = @WINE_INCLUDE_ROOT@
-WINE_INCLUDE_PATH = @WINE_INCLUDE_PATH@
-WINE_LIBRARY_ROOT = @WINE_LIBRARY_ROOT@
-WINE_LIBRARY_PATH = @WINE_LIBRARY_PATH@
-WINE_DLL_ROOT     = @WINE_DLL_ROOT@
-WINE_DLL_PATH     = @WINE_DLL_PATH@
-
-LD_PATH           = @LD_PATH@
-
-# Where are the MFC
-
-ATL_INCLUDE_ROOT = @ATL_INCLUDE_ROOT@
-ATL_INCLUDE_PATH = @ATL_INCLUDE_PATH@
-MFC_INCLUDE_ROOT = @MFC_INCLUDE_ROOT@
-MFC_INCLUDE_PATH = @MFC_INCLUDE_PATH@
-MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@
-MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@
-
-# Global definitions and options
-
-GLOBAL_DEFINES      = ##WINEMAKER_DEFINES##
-GLOBAL_INCLUDE_PATH = ##WINEMAKER_INCLUDE_PATH##
-GLOBAL_DLL_PATH     = ##WINEMAKER_DLL_PATH##
-GLOBAL_DLLS         = ##WINEMAKER_DLLS##
-GLOBAL_LIBRARY_PATH = ##WINEMAKER_LIBRARY_PATH##
-GLOBAL_LIBRARIES    = ##WINEMAKER_LIBRARIES##
-
-# First some useful definitions
-
-SHELL     = /bin/sh
-CC        = @CC@
-CPP       = @CPP@
-CXX       = @CXX@
-WRC       = @WRC@
-CFLAGS    = @CFLAGS@
-CXXFLAGS  = @CXXFLAGS@
-WRCFLAGS  = -r -L
-OPTIONS   = @OPTIONS@ -D_REENTRANT -DWINELIB $(GLOBAL_DEFINES) $(GLOBAL_INCLUDE_PATH)
-LIBS      = @LIBS@ $(LIBRARY_PATH)
-ALLFLAGS  = $(DEFINES) -I$(SRCDIR) $(INCLUDE_PATH) $(WINE_INCLUDE_PATH)
-ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
-ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
-ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS)
-ALL_DLL_PATH  = $(DLL_PATH) $(GLOBAL_DLL_PATH) $(WINE_DLL_PATH)
-ALL_LIBRARY_PATH = $(LIBRARY_PATH) $(GLOBAL_LIBRARY_PATH) $(WINE_LIBRARY_PATH)
-WINE_LIBRARIES = -lwine -lwine_unicode -lwine_uuid
-ALL_LIBRARIES = $(LIBRARIES:%=-l%) $(GLOBAL_LIBRARIES:%=-l%) $(WINE_LIBRARIES)
-LDCOMBINE = ld -r
-LDSHARED  = @LDSHARED@
-LDXXSHARED= @LDXXSHARED@
-LDDLLFLAGS= @LDDLLFLAGS@
-STRIP     = strip
-STRIPFLAGS= --strip-unneeded
-LN_S      = @LN_S@
-RM        = rm -f
-MV        = mv
-MKDIR     = mkdir -p
-WINE      = @WINE@
-WINEBUILD = @WINEBUILD@
-@SET_MAKE@
-
-# Installation infos
-
-INSTALL         = install
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_SCRIPT  = $(INSTALL)
-INSTALL_DATA    = $(INSTALL) -m 644
-prefix          = @prefix@
-exec_prefix     = @exec_prefix@
-bindir          = @bindir@
-libdir          = @libdir@
-infodir         = @infodir@
-mandir          = @mandir@
-dlldir          = @libdir@/wine
-
-prog_manext     = 1
-conf_manext     = 5
-
-OBJS            = $(C_SRCS:.c=.o) $(CXX_SRCS:.cpp=.o) \
-                  $(SPEC_SRCS:.spec=.spec.o)
-CLEAN_FILES     = *.spec.c y.tab.c y.tab.h lex.yy.c \
-                  core *.orig *.rej \
-                  \\\#*\\\# *~ *% .\\\#*
-
-# Implicit rules
-
-.SUFFIXES: .cpp .rc .res .spec .spec.c .spec.o
-
-.c.o:
-       $(CC) -c $(ALLCFLAGS) -o $@ $<
-
-.cpp.o:
-       $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
-
-.cxx.o:
-       $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
-
-.rc.res:
-       $(LD_PATH) $(WRC) $(ALLWRCFLAGS) -o $@ $<
-
-.PHONY: all install uninstall clean distclean depend dummy
-
-# 'all' target first in case the enclosing Makefile didn't define any target
-
-all: Makefile
-
-# Rules for makefile
-
-Makefile: Makefile.in $(TOPSRCDIR)/configure
-       @echo $@ is older than $?, please rerun $(TOPSRCDIR)/configure
-       @exit 1
-
-# Rules for cleaning
-
-$(SUBDIRS:%=%/__clean__): dummy
-       cd `dirname $@` && $(MAKE) clean
-
-$(EXTRASUBDIRS:%=%/__clean__): dummy
-       -cd `dirname $@` && $(RM) $(CLEAN_FILES)
-
-clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
-       $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(OBJS) $(EXES) $(EXES:%=%.so) $(DLLS)
-
-# Rules for installing
-
-$(SUBDIRS:%=%/__install__): dummy
-       cd `dirname $@` && $(MAKE) install
-
-$(SUBDIRS:%=%/__uninstall__): dummy
-       cd `dirname $@` && $(MAKE) uninstall
-
-# Misc. rules
-
-$(SUBDIRS): dummy
-       @cd $@ && $(MAKE)
-
-dummy:
-
-# End of global rules
---- wineapploader.in ---
-#!/bin/sh
-#
-# Wrapper script to start a Winelib application once it is installed
-#
-# Copyright (C) 2002 Alexandre Julliard
-
-# determine the app Winelib library name
-appname=`basename "$0" .exe`.exe
-
-#allow Wine to load Winelib application from the current directory
-export WINEDLLPATH=$WINEDLLPATH:@winelibdir@
-
-# first try explicit WINELOADER
-if [ -x "$WINELOADER" ]; then exec "$WINELOADER" "$appname" "$@"; fi
-
-# then default bin directory
-if [ -x "@bindir@/wine" ]; then exec "@bindir@/wine" "$appname" "$@"; fi
-
-# now try the directory containing $0
-appdir=""
-case "$0" in
-  */*)
-    # $0 contains a path, use it
-    appdir=`dirname "$0"`
-    ;;
-  *)
-    # no directory in $0, search in PATH
-    saved_ifs=$IFS
-    IFS=:
-    for d in $PATH
-    do
-      IFS=$saved_ifs
-      if [ -x "$d/$0" ]; then appdir="$d"; break; fi
-    done
-    ;;
-esac
-if [ -x "$appdir/wine" ]; then exec "$appdir/wine" "$appname" "$@"; fi
-
-# finally look in PATH
-exec wine "$appname" "$@"
---- wrapper.c ---
-/*
- * Copyright 2000 Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
- */
-
-#ifndef STRICT
-#define STRICT
-#endif
-
-#include <dlfcn.h>
-#include <windows.h>
-
-
-
-/*
- * Describe the wrapped application
- */
-
-/**
- * This is either CUIEXE for a console based application or
- * GUIEXE for a regular windows application.
- */
-#define GUIEXE 0
-#define CUIEXE 1
-#define      APP_TYPE      ##WINEMAKER_APP_TYPE##
-
-/**
- * This is the application library's base name, i.e. 'hello' if the
- * library is called 'libhello.so'.
- */
-static char* appName     = "##WINEMAKER_APP_NAME##";
-
-/**
- * This is the name of the application's Windows module. If left NULL
- * then appName is used.
- */
-static char* appModule   = NULL;
-
-/**
- * This is the application's entry point. This is usually "WinMain" for a
- * GUIEXE and 'main' for a CUIEXE application.
- */
-static char* appInit     = ##WINEMAKER_APP_INIT##;
-
-/**
- * This is either non-NULL for MFC-based applications and is the name of the
- * MFC's module. This is the module in which we will take the 'WinMain'
- * function.
- */
-static char* mfcModule   = ##WINEMAKER_APP_MFC##;
-
-
-
-/*
- * Implement the main.
- */
-
-#if APP_TYPE == GUIEXE
-typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance,
-                                 PSTR szCmdLine, int iCmdShow);
-#else
-typedef int WINAPI (*MainFunc)(int argc, char** argv, char** envp);
-#endif
-
-#if APP_TYPE == GUIEXE
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
-                   PSTR szCmdLine, int iCmdShow)
-#else
-int WINAPI main(int argc, char** argv, char** envp)
-#endif
-{
-    void* appLibrary;
-    HINSTANCE hApp = 0, hMFC = 0, hMain = 0;
-    void* appMain;
-    char* libName;
-    int retcode;
-
-    /* Load the application's library */
-    libName=(char*)malloc(strlen(appName)+5+3+1);
-    /* FIXME: we should get the wrapper's path and use that as the base for
-     * the library
-     */
-    sprintf(libName,"./lib%s.so",appName);
-    appLibrary=dlopen(libName,RTLD_NOW);
-    if (appLibrary==NULL) {
-        sprintf(libName,"lib%s.so",appName);
-        appLibrary=dlopen(libName,RTLD_NOW);
-    }
-    if (appLibrary==NULL) {
-        char format[]="Could not load the %s library:\r\n%s";
-        char* error;
-        char* msg;
-
-        error=dlerror();
-        msg=(char*)malloc(strlen(format)+strlen(libName)+strlen(error));
-        sprintf(msg,format,libName,error);
-        MessageBox(NULL,msg,"dlopen error",MB_OK);
-        free(msg);
-        return 1;
-    }
-
-    /* Then if this application is MFC based, load the MFC module */
-    /* FIXME: I'm not sure this is really necessary */
-    if (mfcModule!=NULL) {
-        hMFC=LoadLibrary(mfcModule);
-        if (hMFC==NULL) {
-            char format[]="Could not load the MFC module %s (%d)";
-            char* msg;
-
-            msg=(char*)malloc(strlen(format)+strlen(mfcModule)+11);
-            sprintf(msg,format,mfcModule,GetLastError());
-            MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
-            free(msg);
-            return 1;
-        }
-        /* MFC is a special case: the WinMain is in the MFC library,
-         * instead of the application's library.
-         */
-        hMain=hMFC;
-    } else {
-        hMFC=NULL;
-    }
-
-    /* Load the application's module */
-    if (appModule==NULL) {
-        appModule=appName;
-    }
-    hApp=LoadLibrary(appModule);
-    if (hApp==NULL) {
-        char format[]="Could not load the application's module %s (%d)";
-        char* msg;
-
-        msg=(char*)malloc(strlen(format)+strlen(appModule)+11);
-        sprintf(msg,format,appModule,GetLastError());
-        MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
-        free(msg);
-        return 1;
-    } else if (hMain==NULL) {
-        hMain=hApp;
-    }
-
-    /* Get the address of the application's entry point */
-    appMain=GetProcAddress(hMain, appInit);
-    if (appMain==NULL) {
-        char format[]="Could not get the address of %s (%d)";
-        char* msg;
-
-        msg=(char*)malloc(strlen(format)+strlen(appInit)+11);
-        sprintf(msg,format,appInit,GetLastError());
-        MessageBox(NULL,msg,"GetProcAddress error",MB_OK);
-        free(msg);
-        return 1;
-    }
-
-    /* And finally invoke the application's entry point */
-#if APP_TYPE == GUIEXE
-    retcode=(*((WinMainFunc)appMain))(hApp,hPrevInstance,szCmdLine,iCmdShow);
-#else
-    retcode=(*((MainFunc)appMain))(argc,argv,envp);
-#endif
-
-    /* Cleanup and done */
-    FreeLibrary(hApp);
-    if (hMFC!=NULL) {
-        FreeLibrary(hMFC);
-    }
-    dlclose(appLibrary);
-    free(libName);
-
-    return retcode;
-}