Update make_cygwin_makefiles

Geoffrey Hausheer i134rth8d9s at phracturedblue.com
Mon Apr 8 09:19:00 CDT 2002


The following patch enhances make_cygwin_makefiles in a few ways:

adds comments explaing how to use cygwin/mingw/wine headers.

adds 'clean' and 'distclean'

adds new options to the script:
  -s sys (sys = cygwin,mingw,wine) set the default headers to use
  -i dir  override the directory where the include files live

the archives will now include the entire './include' directory instead of 
just './include/wine'

renamed makefile from Makefile.cyg to Makefile.win

The makefile is now mingw compatible as well (although it's be better if we 
could detect the correct location of the windows.h headers).

Note that the sysparams test fails on win2k, and vartest won't even compile 
in cygwin/mingw yet.  Using the wine headers doesn't really work too well 
either (no fault of this script though).

Also, I'd recommend giving the perl script a better name, since it is no 
longer cygwin specific.

.Geoff
-------------- next part --------------
Index: programs/winetest/make_cygwin_makefiles
===================================================================
RCS file: /home/wine/wine/programs/winetest/make_cygwin_makefiles,v
retrieving revision 1.1
diff -u -r1.1 make_cygwin_makefiles
--- programs/winetest/make_cygwin_makefiles	2 Apr 2002 19:21:43 -0000	1.1
+++ programs/winetest/make_cygwin_makefiles	8 Apr 2002 14:09:57 -0000
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 #
-# Script to generate a Cygwin makefile for running unit tests.
+# Script to generate a Cygwin/Mingw makefile for running unit tests.
 #
 # Copyright 2002 Geoffrey Hausheer
 #
@@ -27,7 +27,14 @@
 sub create_archive($$\@);
 
 # set this variable to point to your windows headers
-my ($windows_includes) ="/usr/include/w32api";
+my ($cygwin_windows_includes) ="/usr/include/w32api";
+my ($mingw_windows_includes) ="/mingw/include";
+my ($wine_windows_includes) ="./include";
+my ($windows_includes)="";
+
+#set the default headers to use
+my ($default_headers) =\$cygwin_windows_includes;
+
 # set this variable to your compiler options
 my($cc_opts)= "-g -O2 -Wall -mpreferred-stack-boundary=2 -D_REENTRANT";
 
@@ -58,6 +65,22 @@
       $afile = shift @ARGV;
       $archive = "g";
     }
+    if ($arg eq "-i") {
+      $windows_includes = shift @ARGV;
+      $default_headers = \$windows_includes;
+    }
+    if ($arg eq "-s") {
+      my($sys) = shift @ARGV;
+      if ($sys eq "cygwin") {
+        $default_headers = \$cygwin_windows_includes;
+      } elsif ($sys eq "mingw") {
+        $default_headers = \$mingw_windows_includes;
+      } elsif ($sys eq "wine") {
+        $default_headers = \$wine_windows_includes;
+      } else {
+        usage;
+      }
+    }
 }
 
 # check/detect topobjdir
@@ -92,13 +115,30 @@
 close FIND_FH;
 
 #start writing the makefile in the root directory
-open MAKE_FH,">Makefile.cyg";
-print MAKE_FH "CC = gcc\n";
-print MAKE_FH "WINDOWS_HEADERS = $windows_includes\n";
-print MAKE_FH "INCLUDE_DIRS = -I\$(WINDOWS_HEADERS) -I./include\n";
-print MAKE_FH "CC_OPTS = \$(INCLUDE_DIRS) $cc_opts -include \$(WINDOWS_HEADERS)/windows.h\n";
+open MAKE_FH,">Makefile.win";
+print MAKE_FH <<EOH ;
+#Define WINDOWS_HEADERS to point at the directory where windows.h lives
+#Here are some examples
+# For Cygwin
+#WINDOWS_HEADERS = $cygwin_windows_includes
+# For Mingw
+#WINDOWS_HEADERS = $mingw_windows_includes
+# For Wine
+#WINDOWS_HEADERS = $wine_windows_includes
+
+WINDOWS_HEADERS = $$default_headers
+
+CC = gcc
+RM = rm -f
+TOUCH = touch
+
+INCLUDE_DIRS = -I\$(WINDOWS_HEADERS) -I./include
+CC_OPTS = \$(INCLUDE_DIRS) $cc_opts -include \$(WINDOWS_HEADERS)/windows.h
+
+EOH
 
 # iterate over each 'tests' directory
+print MAKE_FH "TEST_O_FILES_wtmain = ./programs/winetest/wtmain.o\n";
 foreach $dir (@testdirs) {
   my($rootdir);
   my($testname)=get_testname($dir);
@@ -114,7 +154,7 @@
       push(@ok_list,$newfile);
     }
     # create the testslist.c file for each directory
-    system("./programs/winetest/make_ctests $dir/*.c > $dir/testlist.c");
+    system("./programs/winetest/make_ctests @filelist > $dir/testlist.c");
     push @filelist,"$dir/testlist.c";
     push(@gooddirs,$dir);
     print MAKE_FH "# $dir\n";
@@ -133,6 +173,7 @@
 }
 die "No C files found\n" if (!scalar(@gooddirs));
 # The prerequisites for the tests are that the .ok fiels get created
+print MAKE_FH "\n# .ok result files\n";
 print MAKE_FH "TEST_OK_FILES = \\\n";
 foreach $file (@ok_list) {
   if($file ne $ok_list[$#ok_list]) {
@@ -145,11 +186,24 @@
 print MAKE_FH "all: \$(TEST_OK_FILES)\n";
 print MAKE_FH "\n";
 
+#define how to clean everything up
+print MAKE_FH "clean:\n";
+print MAKE_FH "	\$(RM) \$(TEST_OK_FILES)\n";
+print MAKE_FH "\n";
+print MAKE_FH "distclean:\n";
+print MAKE_FH "	\$(RM) \$(TEST_OK_FILES)\n";
+print MAKE_FH "	\$(RM) \$(TEST_O_FILES_wtmain)\n";
+foreach $dir (@gooddirs) {
+  my($rootdir)=fix_dir($dir);
+  print MAKE_FH "	\$(RM) \$(TEST_EXE_${rootdir}) \$(TEST_O_FILES_${rootdir})\n";
+}
+print MAKE_FH "\n";
+
 #define how to make the executables
 foreach $dir (@gooddirs) {
   my($rootdir)=fix_dir($dir);
-  print MAKE_FH "\$(TEST_EXE_${rootdir}): \$(TEST_O_FILES_${rootdir}) ./programs/winetest/wtmain.o\n";
-  print MAKE_FH "	\$(CC) \$(CC_OPTS) \$(TEST_O_FILES_${rootdir}) ./programs/winetest/wtmain.o -o \$@\n";
+  print MAKE_FH "\$(TEST_EXE_${rootdir}): \$(TEST_O_FILES_${rootdir}) \$(TEST_O_FILES_wtmain)\n";
+  print MAKE_FH "	\$(CC) \$(CC_OPTS) \$(TEST_O_FILES_${rootdir}) \$(TEST_O_FILES_wtmain) -o \$@\n";
 }
 
 # define how to make to .ok files
@@ -157,7 +211,7 @@
   my($dir,$test) = ($file =~ /^(.*[\\\/]+tests)[\\\/]+(.*)\.ok$/);
   
   print MAKE_FH "$file: \$(TEST_EXE_". fix_dir($file) . ")\n";
-  print MAKE_FH "	\$< $test && touch \$@\n";
+  print MAKE_FH "	\$< $test && \$(TOUCH) \$@\n";
 }
 # define how to make the .o files
 
@@ -169,23 +223,6 @@
 }
 exit 0;
 
-
-sub usage
-{
-    print STDERR <<EOF;
-
-Usage: $0 [options]
-
-Options:
-    -v       verbose mode (can be specified multiple times)
-    -T dir   set Wine tree top directory (autodetected if not specified)
-    -z file  archive (zip) all needed files for test
-    -g file  archive (tar.gz) all needed files for test
-    -h       Show this message
-    NOTE: You can specify either -g or -z but not both
-EOF
-    exit 1;
-}
 sub fix_dir {
   my($dir)=shift @_;
   my($rootdir)=($dir =~ /^[^\\\/]*[\\\/]+(.+)[\\\/]+tests/);
@@ -217,7 +254,27 @@
     }
   }
   $cmd .= " ./programs/winetest/wtmain.c";
-  $cmd .= " ./include/wine";
-  $cmd .= " ./Makefile.cyg";
+  $cmd .= " ./include";
+  $cmd .= " ./Makefile.win";
   system "$cmd";
+}
+
+sub usage
+{
+    print STDERR <<EOF;
+
+Usage: $0 [options]
+
+Options:
+    -v       verbose mode (can be specified multiple times)
+    -T dir   set Wine tree top directory (autodetected if not specified)
+    -z file  archive (zip) all needed files for test
+    -g file  archive (tar.gz) all needed files for test
+    -i dir   specify directory where windows.h lives
+    -s sys   specify system to build on (this sets the default header dir)
+             Valid values for 'sys' are: cygwin, mingw, and wine
+    -h       Show this message
+    NOTE: You can specify either -g or -z but not both
+EOF
+    exit 1;
 }


More information about the wine-patches mailing list