New loading scheme for Winelib apps, makes them behave like builtin
[wine] / tools / winemaker
index 867e845..ed01e1e 100755 (executable)
@@ -3,7 +3,22 @@
 # Copyright 2000 Francois Gouget for CodeWeavers
 # fgouget@codeweavers.com
 #
-my $version="0.5.7";
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# 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
+#
+
+my $version="0.5.8";
 
 use Cwd;
 use File::Basename;
@@ -65,6 +80,11 @@ my $opt_lower;
 # If we don't find the file referenced by an include, lower it
 my $opt_lower_include;
 
+##
+# If true then winemaker should not attempt to fix the source.  This is
+# useful if the source is known to be already in a suitable form and is
+# readonly
+my $opt_no_source_fix;
 
 # Options for the 'Source' method
 
@@ -98,6 +118,11 @@ my $opt_ask_target_options;
 # no makefiles, but also no .spec files, no configure.in, etc.
 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;
@@ -1564,6 +1589,9 @@ 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];
@@ -1895,22 +1923,22 @@ sub generate_project_files
   if (@$project[$P_PATH] eq "") {
     # This is the main project. It is also responsible for recursively 
     # calling the other projects
-    print FILEO "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) install) || exit 1; done\n";
+    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 "\tfor i in \$(EXES); do \$(INSTALL_PROGRAM) \$\$i \$(bindir); done\n";
-    print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(INSTALL_PROGRAM) \$\$i \$(libdir); done\n";
+    print FILEO "\t_list=\"\$(EXES) \$(EXES:%=%.so)\"; for i in \$\$_list; do \$(INSTALL_PROGRAM) \$\$i \$(bindir); done\n";
+    print FILEO "\t_list=\"\$(DLLS)\"; for i in \$\$_list; do \$(INSTALL_PROGRAM) \$\$i \$(libdir); done\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 "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) uninstall) || exit 1; done\n";
+    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 "\tfor i in \$(EXES); do \$(RM) \$(bindir)/\$\$i;done\n";
-    print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(RM) \$(libdir)/\$\$i;done\n";
+    print FILEO "\t_list=\"\$(EXES) \$(EXES:%=%.so)\"; for i in \$\$_list; do \$(RM) \$(bindir)/\$\$i;done\n";
+    print FILEO "\t_list=\"\$(DLLS)\"; for i in \$\$_list; do \$(RM) \$(libdir)/\$\$i;done\n";
   }
   print FILEO "\n\n\n";
 
@@ -1923,7 +1951,7 @@ sub generate_project_files
       print FILEO "\t\$(LDCOMBINE) \$(${canon}_OBJS) -o \$\@\n";
       print FILEO "\t-\$(STRIP) \$(STRIPFLAGS) \$\@\n";
       print FILEO "\n";
-      print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS:.spec) \$(${canon}_SPEC_SRCS:.spec=.tmp.o) \$(${canon}_RC_SRCS:.rc=.res)\n";
+      print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS) \$(${canon}_SPEC_SRCS:.spec=.tmp.o) \$(${canon}_RC_SRCS:.rc=.res)\n";
       print FILEO "\t\$(LD_PATH) \$(WINEBUILD) -fPIC \$(${canon}_DLL_PATH) \$(WINE_DLL_PATH) -sym \$(${canon}_SPEC_SRCS:.spec=.tmp.o) -o \$\@ -spec \$(SRCDIR)/\$(${canon}_SPEC_SRCS)\n";
       print FILEO "\n";
       my $t_name=@$target[$T_NAME];
@@ -1938,7 +1966,7 @@ sub generate_project_files
       }
       print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
       if (@$target[$T_TYPE] ne $TT_DLL) {
-        print FILEO "\ttest -e @$target[$T_NAME] || \$(LN_S) \$(WINE) @$target[$T_NAME]\n";
+        print FILEO "\ttest -f @$target[$T_NAME] || \$(LN_S) \$(WINE) @$target[$T_NAME]\n";
       }
       print FILEO "\n\n";
     }
@@ -2116,6 +2144,8 @@ $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;
 
 
@@ -2135,14 +2165,14 @@ sub print_banner
 sub usage
 {
   print_banner();
-  print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup]\n";
+  print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup] [--nosource-fix]\n";
   print STDERR "                 [--lower-none|--lower-all|--lower-uppercase]\n";
   print STDERR "                 [--lower-include|--nolower-include]\n";
   print STDERR "                 [--guiexe|--windows|--cuiexe|--console|--dll]\n";
   print STDERR "                 [--wrap|--nowrap] [--mfc|--nomfc]\n";
   print STDERR "                 [-Dmacro[=defn]] [-Idir] [-Pdir] [-idll] [-Ldir] [-llibrary]\n";
   print STDERR "                 [--interactive] [--single-target name]\n";
-  print STDERR "                 [--generated-files|--nogenerated-files]\n";
+  print STDERR "                 [--generated-files|--nogenerated-files] [--nogenerated-specs]\n";
   print STDERR "                 work_directory\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";
@@ -2175,10 +2205,14 @@ while (@ARGV>0) {
     $opt_lower_include=1;
   } elsif ($arg eq "--nolower-include") {
     $opt_lower_include=0;
+  } elsif ($arg eq "--nosource-fix") {
+    $opt_no_source_fix=1;
   } elsif ($arg eq "--generated-files") {
     $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 =~ /^-D/) {
     push @{$global_settings[$T_DEFINES]},$arg;
@@ -2254,7 +2288,9 @@ source_scan();
 postprocess_targets();
 
 # Fix the source files
-fix_source();
+if (! $opt_no_source_fix) {
+  fix_source();
+}
 
 # Generate the Makefile and the spec file
 if (! $opt_no_generated_files) {
@@ -2647,7 +2683,7 @@ else
 fi])
 if test -n "$WINE_TOOLS"
 then
-  WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/wrc:$WINE_TOOLS/winebuild"
+  WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/tools/wrc:$WINE_TOOLS/tools/winebuild"
 fi
 
 if test -z "$WINE_INCLUDE_ROOT"
@@ -2693,17 +2729,17 @@ then
   then
     WINE_DLL_ROOT="$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/dlls"
   else
-    WINE_DLL_ROOT="/lib:/lib/dlls:/usr/lib:/usr/lib/dlls"
+    WINE_DLL_ROOT="/lib:/lib/dlls:/usr/lib:/usr/lib/dlls:/usr/local/lib:/usr/local/lib/dlls"
   fi
 fi
-AC_PATH_FILE(WINE_DLL_ROOT,[libntdll.so],[
-  AC_MSG_ERROR([Could not find the Wine dlls (libntdll.so)])
+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],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
-  AC_MSG_ERROR([Could not link with the Wine dlls (libntdll.so)])
+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_DLL_PATH="-L$WINE_DLL_ROOT/wine"
 
 if test -n "$LD_PATH"
 then
@@ -3041,6 +3077,10 @@ dummy:
  * Copyright 2000 Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
  */
 
+#ifndef STRICT
+#define STRICT
+#endif
+
 #include <dlfcn.h>
 #include <windows.h>