4 # Copyright 2000-2002 Francois Gouget for CodeWeavers
5 # fgouget@codeweavers.com
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 # The following constants define what we do with the case of filenames
39 # Never rename a file to lowercase
43 # Rename all files to lowercase
47 # Rename only files that are all uppercase to lowercase
48 my $OPT_LOWER_UPPERCASE=2;
51 # The following constants define whether to ask questions or not
54 # No (synonym of never)
62 # Skip the questions till the end of this scope
69 # This is the directory in which winemaker will operate.
73 # Make a backup of the files
77 # Defines which files to rename
81 # If we don't find the file referenced by an include, lower it
82 my $opt_lower_include;
85 # If true then winemaker should not attempt to fix the source. This is
86 # useful if the source is known to be already in a suitable form and is
88 my $opt_no_source_fix;
90 # Options for the 'Source' method
93 # Specifies that we have only one target so that all sources relate
94 # to this target. By default this variable is left undefined which
95 # means winemaker should try to find out by itself what the targets
96 # are. If not undefined then this contains the name of the default
97 # target (without the extension).
98 my $opt_single_target;
101 # If '$opt_single_target' has been specified then this is the type of
102 # that target. Otherwise it specifies whether the default target type
103 # is guiexe or cuiexe.
107 # Contains the default set of flags to be used when creating a new target.
111 # If true then winemaker should ask questions to the user as it goes
113 my $opt_is_interactive;
114 my $opt_ask_project_options;
115 my $opt_ask_target_options;
118 # If false then winemaker should not generate any file, i.e.
119 # no makefiles, but also no .spec files, no configure.in, etc.
120 my $opt_no_generated_files;
123 # If true then winemaker should not generate the spec files.
124 # This is useful if winemaker is being used to create a build environment
125 my $opt_no_generated_specs;
128 # Specifies not to print the banner if set.
135 # Target modelization
139 # The description of a target is stored in an array. The constants
140 # below identify what is stored at each index of the array.
143 # This is the name of the target.
147 # Defines the type of target we want to build. See the TT_xxx
152 # Defines the target's enty point, i.e. the function that is called
157 # This is a bitfield containing flags refining the way the target
158 # should be handled. See the TF_xxx constants below
162 # This is a reference to an array containing the list of the
163 # resp. C, C++, RC, other (.h, .hxx, etc.) source files.
167 my $T_SOURCES_MISC=7;
170 # This is a reference to an array containing the list of macro
175 # This is a reference to an array containing the list of directory
176 # names that constitute the include path
177 my $T_INCLUDE_PATH=9;
180 # Same as T_INCLUDE_PATH but for the dll search path
184 # The list of Windows dlls to import
188 # Same as T_INCLUDE_PATH but for the library search path
189 my $T_LIBRARY_PATH=12;
192 # The list of Unix libraries to link with
196 # The list of dependencies between targets
200 # The following constants define the recognized types of target
203 # This is not a real target. This type of target is used to collect
204 # the sources that don't seem to belong to any other target. Thus no
205 # real target is generated for them, we just put the sources of the
206 # fake target in the global source list.
210 # For executables in the windows subsystem
214 # For executables in the console subsystem
218 # For dynamically linked libraries
222 # The following constants further refine how the target should be handled
225 # This target needs a wrapper
229 # This target is a wrapper
233 # This target is an MFC-based target
237 # User has specified --nomfc option for this target or globally
241 # --nodlls option: Do not use standard DLL set
245 # Initialize a target:
246 # - set the target type to TT_SETTINGS, i.e. no real target will
252 @$target[$T_TYPE]=$TT_SETTINGS;
253 # leaving $T_INIT undefined
254 @$target[$T_FLAGS]=$opt_flags;
255 @$target[$T_SOURCES_C]=[];
256 @$target[$T_SOURCES_CXX]=[];
257 @$target[$T_SOURCES_RC]=[];
258 @$target[$T_SOURCES_MISC]=[];
259 @$target[$T_DEFINES]=[];
260 @$target[$T_INCLUDE_PATH]=[];
261 @$target[$T_DLL_PATH]=[];
262 @$target[$T_DLLS]=[];
263 @$target[$T_LIBRARY_PATH]=[];
264 @$target[$T_LIBRARIES]=[];
265 @$target[$T_DEPENDS]=[];
268 sub get_default_init($)
271 if ($type == $TT_GUIEXE) {
273 } elsif ($type == $TT_CUIEXE) {
275 } elsif ($type == $TT_DLL) {
284 # Project modelization
288 # First we have the notion of project. A project is described by an
289 # array (since we don't have structs in perl). The constants below
290 # identify what is stored at each index of the array.
293 # This is the path in which this project is located. In other
294 # words, this is the path to the Makefile.
298 # This index contains a reference to an array containing the project-wide
299 # settings. The structure of that arrray is actually identical to that of
300 # a regular target since it can also contain extra sources.
304 # This index contains a reference to an array of targets for this
305 # project. Each target describes how an executable or library is to
306 # be built. For each target this description takes the same form as
307 # that of the project: an array. So this entry is an array of arrays.
311 # Initialize a project:
312 # - set the project's path
313 # - initialize the target list
314 # - create a default target (will be removed later if unnecessary)
320 my $project_settings=[];
321 target_init($project_settings);
323 @$project[$P_PATH]=$path;
324 @$project[$P_SETTINGS]=$project_settings;
325 @$project[$P_TARGETS]=[];
341 # Contains the list of all projects. This list tells us what are
342 # the subprojects of the main Makefile and where we have to generate
347 # This is the main project, i.e. the one in the "." directory.
348 # It may well be empty in which case the main Makefile will only
349 # call out subprojects.
353 # Contains the defaults for the include path, etc.
354 # We store the defaults as if this were a target except that we only
355 # exploit the defines, include path, library path, library list and misc
360 # If one of the projects requires the MFc then we set this global variable
361 # to true so that configure asks the user to provide a path tothe MFC
373 # Cleans up a name to make it an acceptable Makefile
379 $name =~ tr/a-zA-Z0-9_/_/c;
384 # Returns true is the specified pathname is absolute.
385 # Note: pathnames that start with a variable '$' or
386 # '~' are considered absolute.
391 return ($path =~ /^[\/~\$]/);
395 # Performs a binary search looking for the specified item
400 my $last=@{$array}-1;
403 while ($first<=$last) {
404 my $index=int(($first+$last)/2);
405 my $cmp=@$array[$index] cmp $item;
420 # 'Source'-based Project analysis
425 # Allows the user to specify makefile and target specific options
426 # - target: the structure in which to store the results
427 # - options: the string containing the options
428 sub source_set_options($$)
433 #FIXME: we must deal with escaping of stuff and all
434 foreach my $option (split / /,$options) {
435 if (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-D/) {
436 push @{@$target[$T_DEFINES]},$option;
437 } elsif (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-I/) {
438 push @{@$target[$T_INCLUDE_PATH]},$option;
439 } elsif ($option =~ /^-P/) {
440 push @{@$target[$T_DLL_PATH]},"-L$'";
441 } elsif ($option =~ /^-i/) {
443 if ($dllname =~ /^[^.]*$/) {
446 if ($dllname =~ /^msvcrt\.dll$/) {
447 push @{@$target[$T_INCLUDE_PATH]},"-I\$(WINE_INCLUDE_ROOT)/msvcrt";
449 push @{@$target[$T_DLLS]},$dllname;
450 } elsif ($option =~ /^-L/) {
451 push @{@$target[$T_LIBRARY_PATH]},$option;
452 } elsif ($option =~ /^-l/) {
453 push @{@$target[$T_LIBRARIES]},"$'";
454 } elsif ($option =~ /^--wrap/) {
455 if (@$target[$T_TYPE] != $TT_DLL) {
456 @$target[$T_FLAGS]|=$TF_WRAP;
458 print STDERR "warning: option --wrap is illegal for DLLs - ignoring";
460 } elsif ($option =~ /^--nowrap/) {
461 if (@$target[$T_TYPE] != $TT_DLL) {
462 @$target[$T_FLAGS]&=~$TF_WRAP;
464 print STDERR "warning: option --nowrap is illegal for DLLs - ignoring";
466 } elsif ($option =~ /^--mfc/) {
467 @$target[$T_FLAGS]|=$TF_MFC;
468 @$target[$T_FLAGS]&=~$TF_NOMFC;
469 } elsif ($option =~ /^--nomfc/) {
470 @$target[$T_FLAGS]&=~$TF_MFC;
471 @$target[$T_FLAGS]|=$TF_NOMFC;
472 } elsif ($option =~ /^--nodlls/) {
473 @$target[$T_FLAGS]|=$TF_NODLLS;
475 print STDERR "error: unknown option \"$option\"\n";
479 if (@$target[$T_TYPE] != $TT_DLL &&
480 @$target[$T_FLAGS] & $TF_MFC &&
481 !(@$target[$T_FLAGS] & $TF_WRAP)) {
482 print STDERR "info: option --mfc requires --wrap";
483 @$target[$T_FLAGS]|=$TF_WRAP;
489 # Scans the specified directory to:
490 # - see if we should create a Makefile in this directory. We normally do
491 # so if we find a project file and sources
492 # - get a list of targets for this directory
493 # - get the list of source files
494 sub source_scan_directory($$$$);
495 sub source_scan_directory($$$$)
497 # a reference to the parent's project
498 my $parent_project=$_[0];
499 # the full relative path to the current directory, including a
500 # trailing '/', or an empty string if this is the top level directory
502 # the name of this directory, including a trailing '/', or an empty
503 # string if this is the top level directory
505 # if set then no targets will be looked for and the sources will all
506 # end up in the parent_project's 'misc' bucket
509 # reference to the project for this directory. May not be used
511 # list of targets found in the 'current' directory
513 # list of sources found in the current directory
518 # true if this directory contains a Windows project
519 my $has_win_project=0;
520 # If we don't find any executable/library then we might make up targets
521 # from the list of .dsp/.mak files we find since they usually have the
522 # same name as their target.
526 if (defined $opt_single_target or $dirname eq "") {
527 # Either there is a single target and thus a single project,
528 # or we are in the top level directory for which a project
530 $project=$parent_project;
533 project_init($project,$path);
535 my $project_settings=@$project[$P_SETTINGS];
537 # First find out what this directory contains:
538 # collect all sources, targets and subdirectories
539 my $directory=get_directory_contents($path);
540 foreach my $dentry (@$directory) {
541 if ($dentry =~ /^\./) {
544 my $fullentry="$path$dentry";
545 if (-d "$fullentry") {
546 if ($dentry =~ /^(Release|Debug)/i) {
547 # These directories are often used to store the object files and the
548 # resulting executable/library. They should not contain anything else.
549 my @candidates=grep /\.(exe|dll)$/i, @{get_directory_contents("$fullentry")};
550 foreach my $candidate (@candidates) {
551 $targets{$candidate}=1;
553 } elsif ($dentry =~ /^include/i) {
554 # This directory must contain headers we're going to need
555 push @{@$project_settings[$T_INCLUDE_PATH]},"-I$dentry";
556 source_scan_directory($project,"$fullentry/","$dentry/",1);
558 # Recursively scan this directory. Any source file that cannot be
559 # attributed to a project in one of the subdirectories will be
560 # attributed to this project.
561 source_scan_directory($project,"$fullentry/","$dentry/",$no_target);
563 } elsif (-f "$fullentry") {
564 if ($dentry =~ /\.(exe|dll)$/i) {
566 } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.spec\.c$/) {
567 push @sources_c,"$dentry";
568 } elsif ($dentry =~ /\.(cpp|cxx)$/i) {
569 if ($dentry =~ /^stdafx.cpp$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
570 push @sources_misc,"$dentry";
571 @$project_settings[$T_FLAGS]|=$TF_MFC;
573 push @sources_cxx,"$dentry";
575 } elsif ($dentry =~ /\.rc$/i) {
576 push @sources_rc,"$dentry";
577 } elsif ($dentry =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
578 push @sources_misc,"$dentry";
579 if ($dentry =~ /^stdafx.h$/i && !(@$project_settings[$T_FLAGS] & $TF_NOMFC)) {
580 @$project_settings[$T_FLAGS]|=$TF_MFC;
582 } elsif ($dentry =~ /\.dsp$/i) {
583 push @dsp_files,"$dentry";
585 } elsif ($dentry =~ /\.mak$/i) {
586 push @mak_files,"$dentry";
588 } elsif ($dentry =~ /^makefile/i) {
595 # If we have a single target then all we have to do is assign
596 # all the sources to it and we're done
597 # FIXME: does this play well with the --interactive mode?
598 if ($opt_single_target) {
599 my $target=@{@$project[$P_TARGETS]}[0];
600 push @{@$target[$T_SOURCES_C]},map "$path$_",@sources_c;
601 push @{@$target[$T_SOURCES_CXX]},map "$path$_",@sources_cxx;
602 push @{@$target[$T_SOURCES_RC]},map "$path$_",@sources_rc;
603 push @{@$target[$T_SOURCES_MISC]},map "$path$_",@sources_misc;
607 my $parent_settings=@$parent_project[$P_SETTINGS];
608 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_c;
609 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_cxx;
610 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_rc;
611 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
612 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
616 my $source_count=@sources_c+@sources_cxx+@sources_rc+
617 @{@$project_settings[$T_SOURCES_C]}+
618 @{@$project_settings[$T_SOURCES_CXX]}+
619 @{@$project_settings[$T_SOURCES_RC]};
620 if ($source_count == 0) {
621 # A project without real sources is not a project, get out!
622 if ($project!=$parent_project) {
623 my $parent_settings=@$parent_project[$P_SETTINGS];
624 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
625 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
629 #print "targets=",%targets,"\n";
630 #print "target_count=$target_count\n";
631 #print "has_win_project=$has_win_project\n";
632 #print "dirname=$dirname\n";
635 if (($has_win_project != 0) or ($dirname eq "")) {
636 # Deal with cases where we could not find any executable/library, and
637 # thus have no target, although we did find some sort of windows project.
638 $target_count=keys %targets;
639 if ($target_count == 0) {
640 # Try to come up with a target list based on .dsp/.mak files
642 if (@dsp_files > 0) {
643 $prj_list=\@dsp_files;
645 $prj_list=\@mak_files;
647 foreach my $filename (@$prj_list) {
648 $filename =~ s/\.(dsp|mak)$//i;
649 if ($opt_target_type == $TT_DLL) {
650 $filename = "$filename.dll";
652 $targets{$filename}=1;
654 $target_count=keys %targets;
655 if ($target_count == 0) {
656 # Still nothing, try the name of the directory
658 if ($dirname eq "") {
659 # Bad luck, this is the top level directory!
660 $name=(split /\//, cwd)[-1];
663 # Remove the trailing '/'. Also eliminate whatever is after the last
664 # '.' as it is likely to be meaningless (.orig, .new, ...)
665 $name =~ s+(/|\.[^.]*)$++;
666 if ($name eq "src") {
667 # 'src' is probably a subdirectory of the real project directory.
668 # Try again with the parent (if any).
670 if ($parent =~ s+([^/]*)/[^/]*/$+$1+) {
673 $name=(split /\//, cwd)[-1];
677 $name =~ s+(/|\.[^.]*)$++;
678 if ($opt_target_type == $TT_DLL) {
687 # Ask confirmation to the user if he wishes so
688 if ($opt_is_interactive == $OPT_ASK_YES) {
689 my $target_list=join " ",keys %targets;
690 print "\n*** In ",($path?$path:"./"),"\n";
691 print "* winemaker found the following list of (potential) targets\n";
692 print "* $target_list\n";
693 print "* Type enter to use it as is, your own comma-separated list of\n";
694 print "* targets, 'none' to assign the source files to a parent directory,\n";
695 print "* or 'ignore' to ignore everything in this directory tree.\n";
696 print "* Target list:\n";
697 $target_list=<STDIN>;
699 if ($target_list eq "") {
700 # Keep the target list as is, i.e. do nothing
701 } elsif ($target_list eq "none") {
702 # Empty the target list
704 } elsif ($target_list eq "ignore") {
705 # Ignore this subtree altogether
709 foreach my $target (split /,/,$target_list) {
718 # If we have no project at this level, then transfer all
719 # the sources to the parent project
720 $target_count=keys %targets;
721 if ($target_count == 0) {
722 if ($project!=$parent_project) {
723 my $parent_settings=@$parent_project[$P_SETTINGS];
724 push @{@$parent_settings[$T_SOURCES_C]},map "$dirname$_",@sources_c;
725 push @{@$parent_settings[$T_SOURCES_CXX]},map "$dirname$_",@sources_cxx;
726 push @{@$parent_settings[$T_SOURCES_RC]},map "$dirname$_",@sources_rc;
727 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
728 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
733 # Otherwise add this project to the project list, except for
734 # the main project which is already in the list.
735 if ($dirname ne "") {
736 push @projects,$project;
739 # Ask for project-wide options
740 if ($opt_ask_project_options == $OPT_ASK_YES) {
742 if ((@$project_settings[$T_FLAGS] & $TF_MFC)!=0) {
745 if ((@$project_settings[$T_FLAGS] & $TF_WRAP)!=0) {
746 if ($flag_desc ne "") {
749 $flag_desc.="wrapped";
751 print "* Type any project-wide options (-D/-I/-P/-i/-L/-l/--mfc/--wrap),\n";
752 if (defined $flag_desc) {
753 print "* (currently $flag_desc)\n";
755 print "* or 'skip' to skip the target specific options,\n";
756 print "* or 'never' to not be asked this question again:\n";
760 if ($options eq "skip") {
761 $opt_ask_target_options=$OPT_ASK_SKIP;
763 } elsif ($options eq "never") {
764 $opt_ask_project_options=$OPT_ASK_NO;
766 } elsif (source_set_options($project_settings,$options)) {
769 print "Please re-enter the options:\n";
773 # - Create the targets
774 # - Check if we have both libraries and programs
775 # - Match each target with source files (sort in reverse
776 # alphabetical order to get the longest matches first)
778 my @local_depends=();
780 foreach my $target_name (map (lc, (sort { $b cmp $a } keys %targets))) {
781 # Create the target...
783 target_init($target);
784 @$target[$T_NAME]=$target_name;
785 @$target[$T_FLAGS]|=@$project_settings[$T_FLAGS];
786 if ($target_name =~ /\.dll$/) {
787 @$target[$T_TYPE]=$TT_DLL;
788 @$target[$T_INIT]=get_default_init($TT_DLL);
789 @$target[$T_FLAGS]&=~$TF_WRAP;
790 push @local_depends,"$target_name.so";
791 push @local_dlls,$target_name;
793 @$target[$T_TYPE]=$opt_target_type;
794 @$target[$T_INIT]=get_default_init($opt_target_type);
795 push @exe_list,$target;
797 my $basename=$target_name;
798 $basename=~ s/\.(dll|exe)$//i;
799 # This is the default link list of Visual Studio, except odbccp32
800 # and uuid which we don't have in Wine.
801 my @std_imports=qw(advapi32 comdlg32 gdi32 kernel32 odbc32 ole32 oleaut32 shell32 user32 winspool);
802 if ((@$target[$T_FLAGS] & $TF_NODLLS) == 0) {
803 @$target[$T_DLLS]=\@std_imports;
805 @$target[$T_DLLS]=[];
807 push @{@$project[$P_TARGETS]},$target;
809 # Ask for target-specific options
810 if ($opt_ask_target_options == $OPT_ASK_YES) {
812 if ((@$target[$T_FLAGS] & $TF_MFC)!=0) {
815 if ((@$target[$T_FLAGS] & $TF_WRAP)!=0) {
816 if ($flag_desc ne "") {
821 $flag_desc.="wrapped";
823 if ($flag_desc ne "") {
826 print "* Specify any link option (-P/-i/-L/-l/--mfc/--wrap) specific to the target\n";
827 print "* \"$target_name\"$flag_desc or 'never' to not be asked this question again:\n";
831 if ($options eq "never") {
832 $opt_ask_target_options=$OPT_ASK_NO;
834 } elsif (source_set_options($target,$options)) {
837 print "Please re-enter the options:\n";
840 push @{@$target[$T_DLL_PATH]},"-L\$(WINE_DLL_ROOT)";
841 if (@$target[$T_FLAGS] & $TF_MFC) {
842 @$project_settings[$T_FLAGS]|=$TF_MFC;
843 push @{@$target[$T_DLL_PATH]},"\$(MFC_LIBRARY_PATH)";
844 push @{@$target[$T_DLLS]},"mfc.dll";
845 # FIXME: Link with the MFC in the Unix sense, until we
846 # start exporting the functions properly.
847 push @{@$target[$T_LIBRARY_PATH]},"\$(MFC_LIBRARY_PATH)";
848 push @{@$target[$T_LIBRARIES]},"mfc";
852 if ($target_count == 1) {
853 push @{@$target[$T_SOURCES_C]},@{@$project_settings[$T_SOURCES_C]},@sources_c;
854 @$project_settings[$T_SOURCES_C]=[];
857 push @{@$target[$T_SOURCES_CXX]},@{@$project_settings[$T_SOURCES_CXX]},@sources_cxx;
858 @$project_settings[$T_SOURCES_CXX]=[];
861 push @{@$target[$T_SOURCES_RC]},@{@$project_settings[$T_SOURCES_RC]},@sources_rc;
862 @$project_settings[$T_SOURCES_RC]=[];
865 push @{@$target[$T_SOURCES_MISC]},@{@$project_settings[$T_SOURCES_MISC]},@sources_misc;
866 # No need for sorting these sources
867 @$project_settings[$T_SOURCES_MISC]=[];
870 foreach my $source (@sources_c) {
871 if ($source =~ /^$basename/i) {
872 push @{@$target[$T_SOURCES_C]},$source;
876 foreach my $source (@sources_cxx) {
877 if ($source =~ /^$basename/i) {
878 push @{@$target[$T_SOURCES_CXX]},$source;
882 foreach my $source (@sources_rc) {
883 if ($source =~ /^$basename/i) {
884 push @{@$target[$T_SOURCES_RC]},$source;
888 foreach my $source (@sources_misc) {
889 if ($source =~ /^$basename/i) {
890 push @{@$target[$T_SOURCES_MISC]},$source;
895 @$target[$T_SOURCES_C]=[sort @{@$target[$T_SOURCES_C]}];
896 @$target[$T_SOURCES_CXX]=[sort @{@$target[$T_SOURCES_CXX]}];
897 @$target[$T_SOURCES_RC]=[sort @{@$target[$T_SOURCES_RC]}];
898 @$target[$T_SOURCES_MISC]=[sort @{@$target[$T_SOURCES_MISC]}];
900 if ($opt_ask_target_options == $OPT_ASK_SKIP) {
901 $opt_ask_target_options=$OPT_ASK_YES;
904 if (@$project_settings[$T_FLAGS] & $TF_MFC) {
905 push @{@$project_settings[$T_INCLUDE_PATH]},"\$(MFC_INCLUDE_PATH)";
907 # The sources that did not match, if any, go to the extra
908 # source list of the project settings
909 foreach my $source (@sources_c) {
911 push @{@$project_settings[$T_SOURCES_C]},$source;
914 @$project_settings[$T_SOURCES_C]=[sort @{@$project_settings[$T_SOURCES_C]}];
915 foreach my $source (@sources_cxx) {
917 push @{@$project_settings[$T_SOURCES_CXX]},$source;
920 @$project_settings[$T_SOURCES_CXX]=[sort @{@$project_settings[$T_SOURCES_CXX]}];
921 foreach my $source (@sources_rc) {
923 push @{@$project_settings[$T_SOURCES_RC]},$source;
926 @$project_settings[$T_SOURCES_RC]=[sort @{@$project_settings[$T_SOURCES_RC]}];
927 foreach my $source (@sources_misc) {
929 push @{@$project_settings[$T_SOURCES_MISC]},$source;
932 @$project_settings[$T_SOURCES_MISC]=[sort @{@$project_settings[$T_SOURCES_MISC]}];
934 # Finally if we are building both libraries and programs in
935 # this directory, then the programs should be linked with all
937 if (@local_dlls > 0 and @exe_list > 0) {
938 foreach my $target (@exe_list) {
939 push @{@$target[$T_DLL_PATH]},"-L.";
940 push @{@$target[$T_DLLS]},@local_dlls;
941 push @{@$target[$T_DEPENDS]},@local_depends;
947 # Scan the source directories in search of things to build
950 # If there's a single target then this is going to be the default target
951 if (defined $opt_single_target) {
952 # Create the main target
954 target_init($main_target);
955 @$main_target[$T_NAME]=$opt_single_target;
956 @$main_target[$T_TYPE]=$opt_target_type;
959 push @{$main_project[$P_TARGETS]},$main_target;
962 # The main directory is always going to be there
963 push @projects,\@main_project;
965 # Now scan the directory tree looking for source files and, maybe, targets
966 print "Scanning the source directories...\n";
967 source_scan_directory(\@main_project,"","",0);
969 @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
976 # 'vc.dsp'-based Project analysis
989 # Creating the wrapper targets
993 sub postprocess_targets()
995 foreach my $project (@projects) {
996 foreach my $target (@{@$project[$P_TARGETS]}) {
997 if ((@$target[$T_FLAGS] & $TF_WRAP) != 0) {
999 target_init($wrapper);
1000 @$wrapper[$T_NAME]=@$target[$T_NAME];
1001 @$wrapper[$T_TYPE]=@$target[$T_TYPE];
1002 @$wrapper[$T_INIT]=get_default_init(@$target[$T_TYPE]);
1003 @$wrapper[$T_FLAGS]=$TF_WRAPPER | (@$target[$T_FLAGS] & $TF_MFC);
1004 @$wrapper[$T_DLLS]=[ "kernel32", "user32" ];
1005 push @{@$wrapper[$T_LIBRARIES]}, "dl";
1006 push @{@$wrapper[$T_SOURCES_C]},"@$wrapper[$T_NAME]_wrapper.c";
1008 my $index=bsearch(@$target[$T_SOURCES_C],"@$wrapper[$T_NAME]_wrapper.c");
1009 if (defined $index) {
1010 splice(@{@$target[$T_SOURCES_C]},$index,1);
1012 @$target[$T_NAME]=@$target[$T_NAME];
1013 @$target[$T_NAME]=~ s/.exe$/.dll/;
1014 @$target[$T_TYPE]=$TT_DLL;
1016 push @{@$project[$P_TARGETS]},$wrapper;
1018 if ((@$target[$T_FLAGS] & $TF_MFC) != 0) {
1019 @{@$project[$P_SETTINGS]}[$T_FLAGS]|=$TF_MFC;
1035 # Performs a directory traversal and renames the files so that:
1036 # - they have the case desired by the user
1037 # - their extension is of the appropriate case
1038 # - they don't contain annoying characters like ' ', '$', '#', ...
1039 sub fix_file_and_directory_names($);
1040 sub fix_file_and_directory_names($)
1044 if (opendir(DIRECTORY, "$dirname")) {
1045 foreach my $dentry (readdir DIRECTORY) {
1046 if ($dentry =~ /^\./ or $dentry eq "CVS") {
1049 # Set $warn to 1 if the user should be warned of the renaming
1052 # autoconf and make don't support these characters well
1053 my $new_name=$dentry;
1054 $new_name =~ s/[ \$]/_/g;
1056 # Only all lowercase extensions are supported (because of the
1057 # transformations ':.c=.o') .
1058 if (-f "$dirname/$new_name") {
1059 if ($new_name =~ /\.C$/) {
1060 $new_name =~ s/\.C$/.c/;
1062 if ($new_name =~ /\.cpp$/i) {
1063 $new_name =~ s/\.cpp$/.cpp/i;
1065 if ($new_name =~ s/\.cxx$/.cpp/i) {
1068 if ($new_name =~ /\.rc$/i) {
1069 $new_name =~ s/\.rc$/.rc/i;
1071 # And this last one is to avoid confusion then running make
1072 if ($new_name =~ s/^makefile$/makefile.win/) {
1077 # Adjust the case to the user's preferences
1078 if (($opt_lower == $OPT_LOWER_ALL and $dentry =~ /[A-Z]/) or
1079 ($opt_lower == $OPT_LOWER_UPPERCASE and $dentry !~ /[a-z]/)
1081 $new_name=lc $new_name;
1084 # And finally, perform the renaming
1085 if ($new_name ne $dentry) {
1087 print STDERR "warning: in \"$dirname\", renaming \"$dentry\" to \"$new_name\"\n";
1089 if (!rename("$dirname/$dentry","$dirname/$new_name")) {
1090 print STDERR "error: in \"$dirname\", unable to rename \"$dentry\" to \"$new_name\"\n";
1091 print STDERR " $!\n";
1095 if (-d "$dirname/$new_name") {
1096 fix_file_and_directory_names("$dirname/$new_name");
1099 closedir(DIRECTORY);
1112 # This maps a directory name to a reference to an array listing
1113 # its contents (files and directories)
1117 # Retrieves the contents of the specified directory.
1118 # We either get it from the directories hashtable which acts as a
1119 # cache, or use opendir, readdir, closedir and store the result
1121 sub get_directory_contents($)
1126 #print "getting the contents of $dirname\n";
1128 # check for a cached version
1130 if ($dirname eq "") {
1133 $directory=$directories{$dirname};
1134 if (defined $directory) {
1135 #print "->@$directory\n";
1139 # Read this directory
1140 if (opendir(DIRECTORY, "$dirname")) {
1141 my @files=readdir DIRECTORY;
1142 closedir(DIRECTORY);
1145 # Return an empty list
1146 #print "error: cannot open $dirname\n";
1150 #print "->@$directory\n";
1151 $directories{$dirname}=$directory;
1156 # Try to find a file for the specified filename. The attempt is
1157 # case-insensitive which is why it's not trivial. If a match is
1158 # found then we return the pathname with the correct case.
1165 if ($dirname eq "" or $dirname eq ".") {
1167 } elsif ($dirname =~ m+^[^/]+) {
1168 $dirname=cwd . "/" . $dirname;
1170 if ($dirname !~ m+/$+) {
1174 foreach my $component (@$path) {
1175 #print " looking for $component in \"$dirname\"\n";
1176 if ($component eq ".") {
1179 } elsif ($component eq "..") {
1181 $dirname=dirname($dirname) . "/";
1184 # The file/directory may have been renamed before. Also try to
1185 # match the renamed file.
1186 my $renamed=$component;
1187 $renamed =~ s/[ \$]/_/g;
1188 if ($renamed eq $component) {
1192 my $directory=get_directory_contents $dirname;
1194 foreach my $dentry (@$directory) {
1195 if ($dentry =~ /^$component$/i or
1196 (defined $renamed and $dentry =~ /^$renamed$/i)
1198 $dirname.="$dentry/";
1199 $real_path.="$dentry/";
1204 if (!defined $found) {
1206 #print " could not find $component in $dirname\n";
1211 $real_path=~ s+/$++;
1212 #print " -> found $real_path\n";
1217 # Performs a case-insensitive search for the specified file in the
1219 # $line is the line number that should be referenced when an error occurs
1220 # $filename is the file we are looking for
1221 # $dirname is the directory of the file containing the '#include' directive
1222 # if '"' was used, it is an empty string otherwise
1223 # $project and $target specify part of the include path
1224 sub get_real_include_name($$$$$)
1232 if ($filename =~ /^([a-zA-Z]:)?[\/]/ or $filename =~ /^[a-zA-Z]:[\/]?/) {
1233 # This is not a relative path, we cannot make any check
1234 my $warning="path:$filename";
1235 if (!defined $warnings{$warning}) {
1236 $warnings{$warning}="1";
1237 print STDERR "warning: cannot check the case of absolute pathnames:\n";
1238 print STDERR "$line: $filename\n";
1241 # Here's how we proceed:
1242 # - split the filename we look for into its components
1243 # - then for each directory in the include path
1244 # - trace the directory components starting from that directory
1245 # - if we fail to find a match at any point then continue with
1246 # the next directory in the include path
1247 # - otherwise, rejoice, our quest is over.
1248 my @file_components=split /[\/\\]+/, $filename;
1249 #print " Searching for $filename from @$project[$P_PATH]\n";
1252 if ($dirname ne "") {
1253 # This is an 'include ""' -> look in dirname first.
1254 #print " in $dirname (include \"\")\n";
1255 $real_filename=search_from($dirname,\@file_components);
1256 if (defined $real_filename) {
1257 return $real_filename;
1260 my $project_settings=@$project[$P_SETTINGS];
1261 foreach my $include (@{@$target[$T_INCLUDE_PATH]}, @{@$project_settings[$T_INCLUDE_PATH]}) {
1262 my $dirname=$include;
1264 if (!is_absolute($dirname)) {
1265 $dirname="@$project[$P_PATH]$dirname";
1267 $dirname=~ s+^\$\(TOPSRCDIR\)/++;
1268 $dirname=~ s+^\$\(SRCDIR\)/+@$project[$P_PATH]+;
1270 #print " in $dirname\n";
1271 $real_filename=search_from("$dirname",\@file_components);
1272 if (defined $real_filename) {
1273 return $real_filename;
1276 my $dotdotpath=@$project[$P_PATH];
1277 $dotdotpath =~ s/[^\/]+/../g;
1278 foreach my $include (@{$global_settings[$T_INCLUDE_PATH]}) {
1279 my $dirname=$include;
1281 $dirname=~ s+^\$\(TOPSRCDIR\)\/++;
1282 $dirname=~ s+^\$\(SRCDIR\)\/+@$project[$P_PATH]+;
1283 #print " in $dirname (global setting)\n";
1284 $real_filename=search_from("$dirname",\@file_components);
1285 if (defined $real_filename) {
1286 return $real_filename;
1290 $filename =~ s+\\\\+/+g; # in include ""
1291 $filename =~ s+\\+/+g; # in include <> !
1292 if ($opt_lower_include) {
1293 return lc "$filename";
1304 if ($size =~ /^(1|2|4|8)$/) {
1305 print FILEO "$indent#include <pshpack$size.h>$trailer";
1307 print FILEO "$indent/* winemaker:warning: Unknown size \"$size\". Defaulting to 4 */\n";
1308 print FILEO "$indent#include <pshpack4.h>$trailer";
1313 # 'Parses' a source file and fixes constructs that would not work with
1314 # Winelib. The parsing is rather simple and not all non-portable features
1315 # are corrected. The most important feature that is corrected is the case
1316 # and path separator of '#include' directives. This requires that each
1317 # source file be associated to a project & target so that the proper
1318 # include path is used.
1319 # Also note that the include path is relative to the directory in which the
1320 # compiler is run, i.e. that of the project, not to that of the file.
1326 $filename="@$project[$P_PATH]$filename";
1327 if (! -e $filename) {
1331 my $is_rc=($filename =~ /\.(rc2?|dlg)$/i);
1332 my $dirname=dirname($filename);
1334 if (defined $target and (@$target[$T_FLAGS] & $TF_MFC)) {
1338 print " $filename\n";
1339 #FIXME:assuming that because there is a .bak file, this is what we want is
1340 #probably flawed. Or is it???
1341 if (! -e "$filename.bak") {
1342 if (!copy("$filename","$filename.bak")) {
1343 print STDERR "error: unable to make a backup of $filename:\n";
1344 print STDERR " $!\n";
1348 if (!open(FILEI,"$filename.bak")) {
1349 print STDERR "error: unable to open $filename.bak for reading:\n";
1350 print STDERR " $!\n";
1353 if (!open(FILEO,">$filename")) {
1354 print STDERR "error: unable to open $filename for writing:\n";
1355 print STDERR " $!\n";
1360 my $rc_block_depth=0;
1361 my $rc_textinclude_state=0;
1364 # Remove any trailing CtrlZ, which isn't strictly in the file
1372 # Make sure all files are '\n' terminated
1375 if ($is_rc and !$is_mfc and /^(\s*)(\#\s*include\s*)\"afxres\.h\"/) {
1376 # VC6 automatically includes 'afxres.h', an MFC specific header, in
1377 # the RC files it generates (even in non-MFC projects). So we replace
1378 # it with 'winres.h' its very close standard cousin so that non MFC
1379 # projects can compile in Wine without the MFC sources.
1380 my $warning="mfc:afxres.h";
1381 if (!defined $warnings{$warning}) {
1382 $warnings{$warning}="1";
1383 print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winres.h'\n";
1384 print STDERR "warning: the above warning is issued only once\n";
1386 print FILEO "$1/* winemaker: $2\"afxres.h\" */\n";
1387 print FILEO "$1/* winemaker:warning: 'afxres.h' is an MFC specific header. Replacing it with 'winres.h' */\n";
1388 print FILEO "$1$2\"winres.h\"$'";
1391 } elsif (/^(\s*\#\s*include\s*)([\"<])([^\"]+)([\">])/) {
1392 my $from_file=($2 eq "<"?"":$dirname);
1393 my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
1394 print FILEO "$1$2$real_include_name$4$'";
1395 $modified|=($real_include_name ne $3);
1397 } elsif (s/^(\s*)(\#\s*pragma\s+pack\s*\(\s*)//) {
1398 # Pragma pack handling
1400 # pack_stack is an array of references describing the stack of
1401 # pack directives currently in effect. Each directive if described
1402 # by a reference to an array containing:
1403 # - "push" for pack(push,...) directives, "" otherwise
1404 # - the directive's identifier at index 1
1405 # - the directive's alignement value at index 2
1407 # Don't believe a word of what the documentation says: it's all wrong.
1408 # The code below is based on the actual behavior of Visual C/C++ 6.
1413 # Pushes the default stack alignment
1414 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1415 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1416 print_pack($pack_indent,4,$');
1417 push @pack_stack, [ "", "", 4 ];
1419 } elsif (/^(pop\s*(,\s*\d+\s*)?\))/) {
1421 # pragma pack(pop,n)
1422 # Goes up the stack until it finds a pack(push,...), and pops it
1423 # Ignores any pack(n) entry
1424 # Issues a warning if the pack is of the form pack(push,label)
1425 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1426 my $pack_comment=$';
1427 $pack_comment =~ s/^\s*//;
1428 if ($pack_comment ne "") {
1429 print FILEO "$pack_indent$pack_comment";
1432 my $alignment=pop @pack_stack;
1433 if (!defined $alignment) {
1434 print FILEO "$pack_indent/* winemaker:warning: No pack(push,...) found. All the stack has been popped */\n";
1437 if (@$alignment[1]) {
1438 print FILEO "$pack_indent/* winemaker:warning: Anonymous pop of pack(push,@$alignment[1]) (@$alignment[2]) */\n";
1440 print FILEO "$pack_indent#include <poppack.h>\n";
1441 if (@$alignment[0]) {
1446 } elsif (/^(pop\s*,\s*(\w+)\s*(,\s*\d+\s*)?\))/) {
1447 # pragma pack(pop,label[,n])
1448 # Goes up the stack until finding a pack(push,...) and pops it.
1449 # 'n', if specified, is ignored.
1450 # Ignores any pack(n) entry
1451 # Issues a warning if the label of the pack does not match,
1452 # or if it is in fact a pack(push,n)
1454 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1455 my $pack_comment=$';
1456 $pack_comment =~ s/^\s*//;
1457 if ($pack_comment ne "") {
1458 print FILEO "$pack_indent$pack_comment";
1461 my $alignment=pop @pack_stack;
1462 if (!defined $alignment) {
1463 print FILEO "$pack_indent/* winemaker:warning: No pack(push,$label) found. All the stack has been popped */\n";
1466 if (@$alignment[1] and @$alignment[1] ne $label) {
1467 print FILEO "$pack_indent/* winemaker:warning: Push/pop mismatch: \"@$alignment[1]\" (@$alignment[2]) != \"$label\" */\n";
1469 print FILEO "$pack_indent#include <poppack.h>\n";
1470 if (@$alignment[0]) {
1475 } elsif (/^(push\s*\))/) {
1477 # Push the current alignment
1478 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1479 if (@pack_stack > 0) {
1480 my $alignment=$pack_stack[$#pack_stack];
1481 print_pack($pack_indent,@$alignment[2],$');
1482 push @pack_stack, [ "push", "", @$alignment[2] ];
1484 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1485 print_pack($pack_indent,4,$');
1486 push @pack_stack, [ "push", "", 4 ];
1489 } elsif (/^((push\s*,\s*)?(\d+)\s*\))/) {
1490 # pragma pack([push,]n)
1491 # Push new alignment n
1492 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1493 print_pack($pack_indent,$3,"$'");
1494 push @pack_stack, [ ($2 ? "push" : ""), "", $3 ];
1496 } elsif (/^((\w+)\s*\))/) {
1497 # pragma pack(label)
1498 # label must in fact be a macro that resolves to an integer
1499 # Then behaves like 'pragma pack(n)'
1500 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1501 print FILEO "$pack_indent/* winemaker:warning: Assuming $2 == 4 */\n";
1502 print_pack($pack_indent,4,$');
1503 push @pack_stack, [ "", "", 4 ];
1505 } elsif (/^(push\s*,\s*(\w+)\s*(,\s*(\d+)\s*)?\))/) {
1506 # pragma pack(push,label[,n])
1507 # Pushes a new label on the stack. It is possible to push the same
1508 # label multiple times. If 'n' is omitted then the alignment is
1509 # unchanged. Otherwise it becomes 'n'.
1510 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1514 } elsif (@pack_stack > 0) {
1515 my $alignment=$pack_stack[$#pack_stack];
1516 $size=@$alignment[2];
1518 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1521 print_pack($pack_indent,$size,$');
1522 push @pack_stack, [ "push", $2, $size ];
1525 # pragma pack(??? -> What's that?
1526 print FILEO "$pack_indent/* winemaker:warning: Unknown type of pragma pack directive */\n";
1527 print FILEO "$pack_indent$pack_header$_";
1533 if ($rc_block_depth == 0 and /^(\w+\s+(BITMAP|CURSOR|FONT|FONTDIR|ICON|MESSAGETABLE|TEXT|RTF)\s+((DISCARDABLE|FIXED|IMPURE|LOADONCALL|MOVEABLE|PRELOAD|PURE)\s+)*)([\"<]?)([^\">\r\n]+)([\">]?)/) {
1534 my $from_file=($5 eq "<"?"":$dirname);
1535 my $real_include_name=get_real_include_name($line,$6,$from_file,$project,$target);
1536 print FILEO "$1$5$real_include_name$7$'";
1537 $modified|=($real_include_name ne $6);
1539 } elsif (/^(\s*RCINCLUDE\s*)([\"<]?)([^\">\r\n]+)([\">]?)/) {
1540 my $from_file=($2 eq "<"?"":$dirname);
1541 my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
1542 print FILEO "$1$2$real_include_name$4$'";
1543 $modified|=($real_include_name ne $3);
1545 } elsif ($is_rc and !$is_mfc and $rc_block_depth == 0 and /^\s*\d+\s+TEXTINCLUDE\s*/) {
1546 $rc_textinclude_state=1;
1549 } elsif ($rc_textinclude_state == 3 and /^(\s*\"\#\s*include\s*\"\")afxres\.h(\"\"\\r\\n\")/) {
1550 print FILEO "$1winres.h$2$'";
1553 } elsif (/^\s*BEGIN(\W.*)?$/) {
1554 $rc_textinclude_state|=2;
1558 } elsif (/^\s*END(\W.*)?$/) {
1559 $rc_textinclude_state=0;
1560 if ($rc_block_depth>0) {
1576 if ($opt_backup == 0 or $modified == 0) {
1577 if (!unlink("$filename.bak")) {
1578 print STDERR "error: unable to delete $filename.bak:\n";
1579 print STDERR " $!\n";
1585 # Analyzes each source file in turn to find and correct issues
1586 # that would cause it not to compile.
1589 print "Fixing the source files...\n";
1590 foreach my $project (@projects) {
1591 foreach my $target (@$project[$P_SETTINGS],@{@$project[$P_TARGETS]}) {
1592 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1595 foreach my $source (@{@$target[$T_SOURCES_C]}, @{@$target[$T_SOURCES_CXX]}, @{@$target[$T_SOURCES_RC]}, @{@$target[$T_SOURCES_MISC]}) {
1596 fix_file($source,$project,$target);
1611 # Generates a target's .spec file
1612 sub generate_spec_file($$$)
1614 return if ($opt_no_generated_specs);
1618 my $project_settings=$_[2];
1620 my $basename=@$target[$T_NAME];
1621 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1622 $basename.="_wrapper";
1625 if (!open(FILEO,">$path$basename.spec")) {
1626 print STDERR "error: could not open \"$path$basename.spec\" for writing\n";
1627 print STDERR " $!\n";
1631 # Don't forget to export the 'Main' function for wrapped executables,
1632 # except for MFC ones!
1633 if ((@$target[$T_FLAGS]&($TF_WRAP|$TF_WRAPPER|$TF_MFC)) == $TF_WRAP) {
1634 if (@$target[$T_TYPE] == $TT_GUIEXE) {
1635 print FILEO "\n@ stdcall @$target[$T_INIT](long long ptr long) @$target[$T_INIT]\n";
1636 } elsif (@$target[$T_TYPE] == $TT_CUIEXE) {
1637 print FILEO "\n@ stdcall @$target[$T_INIT](long ptr ptr) @$target[$T_INIT]\n";
1639 print FILEO "\n@ stdcall @$target[$T_INIT](ptr long ptr) @$target[$T_INIT]\n";
1647 # Generates a target's wrapper file
1648 sub generate_wrapper_file($$)
1652 my $app_name=@$target[$T_NAME];
1653 my $wrapper_name=$app_name;
1654 $app_name=~ s/\.exe$/\.dll/;
1656 return generate_from_template("$path${wrapper_name}_wrapper.c","wrapper.c",[
1657 ["APP_NAME",$app_name],
1658 ["APP_TYPE",(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE")],
1659 ["APP_INIT",(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"")],
1660 ["APP_MFC",(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":"NULL")]]);
1664 # A convenience function to generate all the lists (defines,
1665 # C sources, C++ source, etc.) in the Makefile
1666 sub generate_list($$$;$)
1675 printf FILEO "%-22s=",$name;
1677 if (defined $list) {
1678 foreach my $item (@$list) {
1680 if (defined $data) {
1681 $value=&$data($item);
1687 print FILEO " $value";
1690 print FILEO " \\\n\t\t\t$value";
1701 # Generates a project's Makefile.in and all the target files
1702 sub generate_project_files($)
1705 my $project_settings=@$project[$P_SETTINGS];
1709 # Then sort the targets and separate the libraries from the programs
1710 foreach my $target (sort { @$a[$T_NAME] cmp @$b[$T_NAME] } @{@$project[$P_TARGETS]}) {
1711 if (@$target[$T_TYPE] == $TT_DLL) {
1712 push @dll_list,$target;
1714 push @exe_list,$target;
1717 @$project[$P_TARGETS]=[];
1718 push @{@$project[$P_TARGETS]}, @dll_list;
1719 push @{@$project[$P_TARGETS]}, @exe_list;
1721 if (!open(FILEO,">@$project[$P_PATH]Makefile.in")) {
1722 print STDERR "error: could not open \"@$project[$P_PATH]/Makefile.in\" for writing\n";
1723 print STDERR " $!\n";
1727 print FILEO "### Generated by Winemaker\n";
1730 print FILEO "### Generic autoconf variables\n\n";
1731 generate_list("TOPSRCDIR",1,[ "\@top_srcdir\@" ]);
1732 my $dotdotpath=@$project[$P_PATH];
1733 $dotdotpath =~ s%[^/]+%..%g;
1734 $dotdotpath =~ s%/$%%;
1735 $dotdotpath = "." if ($dotdotpath eq "");
1736 generate_list("TOPOBJDIR",1,[ $dotdotpath ]);
1737 generate_list("SRCDIR",1,[ "\@srcdir\@" ]);
1738 generate_list("VPATH",1,[ "\@srcdir\@" ]);
1740 if (@$project[$P_PATH] eq "") {
1741 # This is the main project. It is also responsible for recursively
1742 # calling the other projects
1743 generate_list("SUBDIRS",1,\@projects,sub
1745 if ($_[0] != \@main_project) {
1746 my $subdir=@{$_[0]}[$P_PATH];
1750 # Eliminating the main project by returning undefined!
1753 if (@{@$project[$P_TARGETS]} > 0) {
1754 generate_list("DLLS",1,\@dll_list,sub
1756 return @{$_[0]}[$T_NAME];
1758 generate_list("EXES",1,\@exe_list,sub
1760 return "@{$_[0]}[$T_NAME]";
1762 print FILEO "\n\n\n";
1764 print FILEO "### Common settings\n\n";
1765 # Make it so that the project-wide settings override the global settings
1766 generate_list("DEFINES",1,@$project_settings[$T_DEFINES]);
1767 generate_list("INCLUDE_PATH",1,@$project_settings[$T_INCLUDE_PATH]);
1768 generate_list("DLL_PATH",1,@$project_settings[$T_DLL_PATH]);
1769 generate_list("LIBRARY_PATH",1,@$project_settings[$T_LIBRARY_PATH]);
1770 generate_list("LIBRARIES",1,@$project_settings[$T_LIBRARIES]);
1773 my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+
1774 @{@$project_settings[$T_SOURCES_CXX]}+
1775 @{@$project_settings[$T_SOURCES_RC]};
1776 my $no_extra=($extra_source_count == 0);
1778 print FILEO "### Extra source lists\n\n";
1779 generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]);
1780 generate_list("EXTRA_CXX_SRCS",1,@$project_settings[$T_SOURCES_CXX]);
1781 generate_list("EXTRA_RC_SRCS",1,@$project_settings[$T_SOURCES_RC]);
1783 generate_list("EXTRA_OBJS",1,["\$(EXTRA_C_SRCS:.c=.o)","\$(EXTRA_CXX_SRCS:.cpp=.o)"]);
1784 print FILEO "\n\n\n";
1787 # Iterate over all the targets...
1788 foreach my $target (@{@$project[$P_TARGETS]}) {
1789 print FILEO "### @$target[$T_NAME] sources and settings\n\n";
1791 my $basemodule=@$target[$T_NAME];
1792 my $canon=canonize("@$target[$T_NAME]");
1794 if (@$target[$T_TYPE] == $TT_CUIEXE) {
1796 $basemodule =~ s/\.exe$//;
1797 } elsif (@$target[$T_TYPE] == $TT_GUIEXE) {
1799 $basemodule =~ s/\.exe$//;
1802 $basemodule =~ s/\.dll$//;
1805 generate_list("${canon}_MODULE",1,[@$target[$T_NAME]]);
1806 generate_list("${canon}_BASEMODULE",1,[$basemodule]);
1807 generate_list("${canon}_APPMODE",1,[$appmode]);
1808 generate_list("${canon}_C_SRCS",1,@$target[$T_SOURCES_C]);
1809 generate_list("${canon}_CXX_SRCS",1,@$target[$T_SOURCES_CXX]);
1810 generate_list("${canon}_RC_SRCS",1,@$target[$T_SOURCES_RC]);
1811 generate_list("${canon}_SPEC_SRCS",1,[ (@$target[$T_TYPE] == $TT_DLL?"@$target[$T_NAME].spec":"") ]);
1812 generate_list("${canon}_DLL_PATH",1,@$target[$T_DLL_PATH]);
1813 generate_list("${canon}_DLLS",1,@$target[$T_DLLS]);
1814 generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]);
1815 generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES]);
1816 generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS]);
1818 generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(EXTRA_OBJS)"]);
1819 print FILEO "\n\n\n";
1821 print FILEO "### Global source lists\n\n";
1822 generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub
1824 my $canon=canonize(@{$_[0]}[$T_NAME]);
1826 return "\$(${canon}_C_SRCS)";
1829 generate_list("",1,[ "\$(EXTRA_C_SRCS)" ]);
1831 generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub
1833 my $canon=canonize(@{$_[0]}[$T_NAME]);
1835 return "\$(${canon}_CXX_SRCS)";
1838 generate_list("",1,[ "\$(EXTRA_CXX_SRCS)" ]);
1840 generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub
1842 my $canon=canonize(@{$_[0]}[$T_NAME]);
1844 return "\$(${canon}_RC_SRCS)";
1847 generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]);
1849 generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub
1851 my $canon=canonize(@{$_[0]}[$T_NAME]);
1853 return "\$(${canon}_SPEC_SRCS)";
1856 print FILEO "\n\n\n";
1858 print FILEO "### Generic autoconf targets\n\n";
1860 if (@$project[$P_PATH] eq "") {
1861 print FILEO " wineapploader";
1862 print FILEO " \$(SUBDIRS)";
1864 if (@{@$project[$P_TARGETS]} > 0) {
1865 print FILEO " \$(DLLS:%=%.so) \$(EXES:%=%.so)";
1868 if (@$project[$P_PATH] eq "") {
1869 print FILEO "wineapploader: wineapploader.in\n";
1870 print FILEO "\tsed -e 's,\@bindir\\\@,\$(bindir),g' " .
1871 "-e 's,\@winelibdir\\\@,.,g' " .
1872 "\$(SRCDIR)/wineapploader.in >\$\@ || \$(RM) \$\@\n";
1875 print FILEO "\@MAKE_RULES\@\n";
1877 print FILEO "install::\n";
1878 if (@$project[$P_PATH] eq "") {
1879 # This is the main project. It is also responsible for recursively
1880 # calling the other projects
1881 print FILEO "\t_list=\"\$(SUBDIRS)\"; for i in \$\$_list; do (cd \$\$i; \$(MAKE) install) || exit 1; done\n";
1883 if (@{@$project[$P_TARGETS]} > 0) {
1884 print FILEO "\t_list=\"\$(EXES:%.exe=%)\"; for i in \$\$_list; do \$(INSTALL_SCRIPT) \$\$i \$(bindir); done\n";
1885 print FILEO "\t_list=\"\$(EXES:%=%.so) \$(DLLS:%=%.so)\"; for i in \$\$_list; do \$(INSTALL_PROGRAM) \$\$i \$(dlldir); done\n";
1888 print FILEO "uninstall::\n";
1889 if (@$project[$P_PATH] eq "") {
1890 # This is the main project. It is also responsible for recursively
1891 # calling the other projects
1892 print FILEO "\t_list=\"\$(SUBDIRS)\"; for i in \$\$_list; do (cd \$\$i; \$(MAKE) uninstall) || exit 1; done\n";
1894 if (@{@$project[$P_TARGETS]} > 0) {
1895 print FILEO "\t_list=\"\$(EXES:%.exe=%)\"; for i in \$\$_list; do \$(RM) \$(bindir)/\$\$i;done\n";
1896 print FILEO "\t_list=\"\$(EXES:%=%.so) \$(DLLS:%=%.so)\"; for i in \$\$_list; do \$(RM) \$(dlldir)/\$\$i;done\n";
1899 print FILEO "clean::\n";
1900 print FILEO "\t\$(RM)";
1901 if (@$project[$P_PATH] eq "") {
1902 print FILEO " wineapploader";
1904 if (@{@$project[$P_TARGETS]} > 0) {
1905 print FILEO " \$(EXES:%.exe=%)";
1909 if (@{@$project[$P_TARGETS]} > 0) {
1910 print FILEO "### Target specific build rules\n\n";
1911 foreach my $target (@{@$project[$P_TARGETS]}) {
1912 my $canon=canonize("@$target[$T_NAME]");
1918 if ((@$target[$T_TYPE]==$TT_GUIEXE) || (@$target[$T_TYPE]==$TT_CUIEXE)) {
1919 $mode = "--exe \$(${canon}_MODULE) -m\$(${canon}_APPMODE)";
1924 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1925 $all_dlls="\$(${canon}_DLLS:%=-l%)";
1926 $all_libs="\$(${canon}_LIBRARIES:%=-l%) \$(WINE_LIBRARIES)";
1928 $all_dlls="\$(${canon}_DLLS:%=-l%) \$(GLOBAL_DLLS:%=-l%)";
1929 $all_libs="\$(${canon}_LIBRARIES:%=-l%) \$(ALL_LIBRARIES)";
1932 print FILEO "\$(${canon}_MODULE).spec.c: \$(${canon}_SPEC_SRCS) \$(${canon}_RC_SRCS:.rc=.res) \$(${canon}_OBJS)\n";
1933 print FILEO "\t\$(LDPATH) \$(WINEBUILD) -fPIC -o \$\@ $mode \$(${canon}_SPEC_SRCS:%=--spec %) \$(${canon}_RC_SRCS:%.rc=%.res) \$(${canon}_OBJS) \$(${canon}_DLL_PATH) \$(WINE_DLL_PATH) \$(GLOBAL_DLL_PATH) $all_dlls\n";
1935 print FILEO "\$(${canon}_MODULE).so: \$(${canon}_MODULE).spec.o \$(${canon}_OBJS) \$(${canon}_DEPENDS)\n";
1936 if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) {
1937 print FILEO "\t\$(LDXXSHARED)";
1939 print FILEO "\t\$(LDSHARED)";
1941 print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_MODULE).spec.o \$(${canon}_LIBRARY_PATH) \$(ALL_LIBRARY_PATH) $all_libs \$(LIBS)\n";
1942 if (@$target[$T_TYPE] != $TT_DLL) {
1943 print FILEO "\ttest -f \$(${canon}_BASEMODULE) || \$(INSTALL_SCRIPT) wineapploader \$(${canon}_BASEMODULE)\n";
1950 foreach my $target (@{@$project[$P_TARGETS]}) {
1951 if (@$target[$T_TYPE] == $TT_DLL) {
1952 generate_spec_file(@$project[$P_PATH],$target,$project_settings);
1954 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1955 generate_wrapper_file(@$project[$P_PATH],$target);
1961 # Perform the replacements in the template configure files
1962 # Return 1 for success, 0 for failure
1963 sub generate_from_template($$;$)
1967 my $substitutions=$_[2];
1969 if (!defined $templates{$template}) {
1970 print STDERR "winemaker: internal error: No template called '$template'\n";
1974 if (!open(FILEO,">$filename")) {
1975 print STDERR "error: unable to open \"$filename\" for writing:\n";
1976 print STDERR " $!\n";
1980 foreach my $line (@{$templates{$template}}) {
1981 if ($line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
1982 if (defined $substitutions) {
1983 foreach my $pattern (@$substitutions) {
1984 $line =~ s%\#\#WINEMAKER_@$pattern[0]\#\#%@$pattern[1]%;
1987 if (!$warned and $line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
1988 print STDERR "warning: no value was provided for template $1 in \"$filename\"\n";
1999 # Generates the global files:
2004 sub generate_global_files()
2007 foreach my $path (@{$global_settings[$T_INCLUDE_PATH]}) {
2008 if ($path !~ /^-L/ or is_absolute($')) {
2009 push @include_path, $path;
2011 push @include_path, "-L\$(TOPSRCDIR)/$'";
2015 foreach my $path (@{$global_settings[$T_DLL_PATH]}) {
2016 if ($path !~ /^-L/ or is_absolute($')) {
2017 push @dll_path, $path;
2019 push @dll_path, "-L\$(TOPSRCDIR)/$'";
2023 foreach my $path (@{$global_settings[$T_LIBRARY_PATH]}) {
2024 if ($path !~ /^-L/ or is_absolute($')) {
2025 push @library_path, $path;
2027 push @library_path, "-L\$(TOPSRCDIR)/$'";
2030 generate_from_template("Make.rules.in","Make.rules.in",[
2031 ["DEFINES", join(" ", @{$global_settings[$T_DEFINES]}) ],
2032 ["INCLUDE_PATH", join(" ", @include_path) ],
2033 ["DLL_PATH", join(" ", @dll_path) ],
2034 ["DLLS", join(" ", @{$global_settings[$T_DLLS]}) ],
2035 ["LIBRARY_PATH", join(" ", @library_path) ],
2036 ["LIBRARIES", join(" ", @{$global_settings[$T_LIBRARIES]}) ]]);
2037 generate_from_template("wineapploader.in","wineapploader.in");
2039 # Get the name of a source file for configure.ac
2041 search_a_file: foreach my $project (@projects) {
2042 foreach my $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) {
2043 $a_source_file=@{@$target[$T_SOURCES_C]}[0];
2044 if (!defined $a_source_file) {
2045 $a_source_file=@{@$target[$T_SOURCES_CXX]}[0];
2047 if (!defined $a_source_file) {
2048 $a_source_file=@{@$target[$T_SOURCES_RC]}[0];
2050 if (defined $a_source_file) {
2051 $a_source_file="@$project[$P_PATH]$a_source_file";
2056 if (!defined $a_source_file) {
2057 $a_source_file="Makefile.in";
2059 generate_from_template("configure.ac","configure.ac",[
2060 ["PROJECTS",join("\n",map { "@$_[$P_PATH]Makefile" } @projects)],
2061 ["SOURCE","$a_source_file"],
2062 ["NEEDS_MFC","$needs_mfc"]]);
2063 system("autoconf configure.ac > configure");
2065 # Add execute permission to configure for whoever has the right to read it
2066 my @st=stat("configure");
2069 $mode|=($mode & 0444) >>2;
2070 chmod($mode,"configure");
2072 print "warning: could not generate the configure script. You need to run autoconf\n";
2078 sub generate_read_templates()
2083 if (/^--- ((\w\.?)+) ---$/) {
2085 if (defined $templates{$filename}) {
2086 print STDERR "winemaker: internal error: There is more than one template for $filename\n";
2090 $templates{$filename}=$file;
2092 } elsif (defined $file) {
2099 # This is where we finally generate files. In fact this method does not
2100 # do anything itself but calls the methods that do the actual work.
2103 print "Generating project files...\n";
2104 generate_read_templates();
2105 generate_global_files();
2107 foreach my $project (@projects) {
2108 my $path=@$project[$P_PATH];
2115 generate_project_files($project);
2128 $opt_lower=$OPT_LOWER_UPPERCASE;
2129 $opt_lower_include=1;
2131 # $opt_work_dir=<undefined>
2132 # $opt_single_target=<undefined>
2133 $opt_target_type=$TT_GUIEXE;
2135 $opt_is_interactive=$OPT_ASK_NO;
2136 $opt_ask_project_options=$OPT_ASK_NO;
2137 $opt_ask_target_options=$OPT_ASK_NO;
2138 $opt_no_generated_files=0;
2139 $opt_no_generated_specs=0;
2140 $opt_no_source_fix=0;
2153 print "Winemaker $version\n";
2154 print "Copyright 2000 Francois Gouget <fgouget\@codeweavers.com> for CodeWeavers\n";
2160 print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup] [--nosource-fix]\n";
2161 print STDERR " [--lower-none|--lower-all|--lower-uppercase]\n";
2162 print STDERR " [--lower-include|--nolower-include]\n";
2163 print STDERR " [--guiexe|--windows|--cuiexe|--console|--dll]\n";
2164 print STDERR " [--wrap|--nowrap] [--mfc|--nomfc]\n";
2165 print STDERR " [-Dmacro[=defn]] [-Idir] [-Pdir] [-idll] [-Ldir] [-llibrary]\n";
2166 print STDERR " [--nodlls] [--interactive] [--single-target name]\n";
2167 print STDERR " [--generated-files|--nogenerated-files] [--nogenerated-specs]\n";
2168 print STDERR " work_directory\n";
2169 print STDERR "\nWinemaker is designed to recursively convert all the Windows sources found in\n";
2170 print STDERR "the specified directory so that they can be compiled with Winelib. During this\n";
2171 print STDERR "process it will modify and rename some of the files in that directory.\n";
2172 print STDERR "\tPlease read the manual page before use.\n";
2176 target_init(\@global_settings);
2179 my $arg=shift @ARGV;
2181 if ($arg eq "--nobanner") {
2183 } elsif ($arg eq "--backup") {
2185 } elsif ($arg eq "--nobackup") {
2187 } elsif ($arg eq "--single-target") {
2188 $opt_single_target=shift @ARGV;
2189 } elsif ($arg eq "--lower-none") {
2190 $opt_lower=$OPT_LOWER_NONE;
2191 } elsif ($arg eq "--lower-all") {
2192 $opt_lower=$OPT_LOWER_ALL;
2193 } elsif ($arg eq "--lower-uppercase") {
2194 $opt_lower=$OPT_LOWER_UPPERCASE;
2195 } elsif ($arg eq "--lower-include") {
2196 $opt_lower_include=1;
2197 } elsif ($arg eq "--nolower-include") {
2198 $opt_lower_include=0;
2199 } elsif ($arg eq "--nosource-fix") {
2200 $opt_no_source_fix=1;
2201 } elsif ($arg eq "--generated-files") {
2202 $opt_no_generated_files=0;
2203 } elsif ($arg eq "--nogenerated-files") {
2204 $opt_no_generated_files=1;
2205 } elsif ($arg eq "--nogenerated-specs") {
2206 $opt_no_generated_specs=1;
2208 } elsif ($arg =~ /^-D/) {
2209 push @{$global_settings[$T_DEFINES]},$arg;
2210 } elsif ($arg =~ /^-I/) {
2211 push @{$global_settings[$T_INCLUDE_PATH]},$arg;
2212 } elsif ($arg =~ /^-P/) {
2213 push @{$global_settings[$T_DLL_PATH]},"-L$'";
2214 } elsif ($arg =~ /^-i/) {
2216 if ($dllname =~ /^[^.]*$/) {
2219 if ($dllname =~ /^msvcrt\.dll$/) {
2220 push @{$global_settings[$T_INCLUDE_PATH]},"-I\$(WINE_INCLUDE_ROOT)/msvcrt";
2222 push @{$global_settings[$T_DLLS]},$dllname;
2223 } elsif ($arg =~ /^-L/) {
2224 push @{$global_settings[$T_LIBRARY_PATH]},$arg;
2225 } elsif ($arg =~ /^-l/) {
2226 push @{$global_settings[$T_LIBRARIES]},$';
2228 # 'Source'-based method options
2229 } elsif ($arg eq "--dll") {
2230 $opt_target_type=$TT_DLL;
2231 } elsif ($arg eq "--guiexe" or $arg eq "--windows") {
2232 $opt_target_type=$TT_GUIEXE;
2233 } elsif ($arg eq "--cuiexe" or $arg eq "--console") {
2234 $opt_target_type=$TT_CUIEXE;
2235 } elsif ($arg eq "--interactive") {
2236 $opt_is_interactive=$OPT_ASK_YES;
2237 $opt_ask_project_options=$OPT_ASK_YES;
2238 $opt_ask_target_options=$OPT_ASK_YES;
2239 } elsif ($arg eq "--wrap") {
2240 $opt_flags|=$TF_WRAP;
2241 } elsif ($arg eq "--nowrap") {
2242 $opt_flags&=~$TF_WRAP;
2243 } elsif ($arg eq "--mfc") {
2244 $opt_flags|=$TF_MFC;
2246 } elsif ($arg eq "--nomfc") {
2247 $opt_flags&=~$TF_MFC;
2248 $opt_flags|=$TF_NOMFC;
2250 } elsif ($arg eq "--nodlls") {
2251 $opt_flags|=$TF_NODLLS;
2255 if ($arg ne "--help" and $arg ne "-h" and $arg ne "-?") {
2256 if (!defined $opt_work_dir) {
2259 print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n";
2267 if ($opt_flags & $TF_MFC && $opt_target_type != $TT_DLL) {
2268 print STDERR "info: option --mfc requires --wrap\n";
2269 $opt_flags |= $TF_WRAP;
2273 if (!defined $opt_work_dir) {
2274 print STDERR "error: you must specify the directory containing the sources to be converted\n";
2276 } elsif (!chdir $opt_work_dir) {
2277 print STDERR "error: could not chdir to the work directory\n";
2278 print STDERR " $!\n";
2282 if ($opt_no_banner == 0) {
2286 project_init(\@main_project,"");
2288 # Fix the file and directory names
2289 fix_file_and_directory_names(".");
2291 # Scan the sources to identify the projects and targets
2294 # Create targets for wrappers, etc.
2295 postprocess_targets();
2297 # Fix the source files
2298 if (! $opt_no_source_fix) {
2302 # Generate the Makefile and the spec file
2303 if (! $opt_no_generated_files) {
2309 --- configure.ac ---
2310 dnl Process this file with autoconf to produce a configure script.
2311 dnl Author: Michael Patra <micky@marie.physik.tu-berlin.de>
2312 dnl <patra@itp1.physik.tu-berlin.de>
2313 dnl Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
2315 AC_REVISION([configure.ac 1.00])
2316 AC_INIT(##WINEMAKER_SOURCE##)
2318 NEEDS_MFC=##WINEMAKER_NEEDS_MFC##
2320 dnl **** Command-line arguments ****
2324 dnl **** Check for some programs ****
2332 dnl **** Check for some libraries ****
2334 dnl Check for -lm for BeOS
2335 AC_CHECK_LIB(m,sqrt)
2336 dnl Check for -lw for Solaris
2337 AC_CHECK_LIB(w,iswalnum)
2338 dnl Check for -lnsl for Solaris
2339 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))
2340 dnl Check for -lsocket for Solaris
2341 AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
2343 dnl **** Check for gcc strength-reduce bug ****
2345 if test "x${GCC}" = "xyes"
2347 AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
2350 static int Array[[3]];
2353 for(i=0; i<B; i++) Array[[i]] = i - 3;
2354 exit( Array[[1]] != -2 );
2356 ac_cv_c_gcc_strength_bug="no",
2357 ac_cv_c_gcc_strength_bug="yes",
2358 ac_cv_c_gcc_strength_bug="yes") )
2359 if test "$ac_cv_c_gcc_strength_bug" = "yes"
2361 CFLAGS="$CFLAGS -fno-strength-reduce"
2365 dnl **** Check for working dll ****
2370 AC_CACHE_CHECK("whether we can build a Linux dll",
2372 [saved_cflags=$CFLAGS
2373 CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
2374 AC_TRY_LINK(,[return 1],ac_cv_c_dll_linux="yes",ac_cv_c_dll_linux="no")
2375 CFLAGS=$saved_cflags
2377 if test "$ac_cv_c_dll_linux" = "yes"
2379 LDSHARED="\$(CC) -shared"
2380 LDXXSHARED="\$(CXX) -shared"
2381 LDDLLFLAGS="-Wl,-Bsymbolic"
2383 AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
2384 ac_cv_c_dll_unixware,
2385 [saved_cflags=$CFLAGS
2386 CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
2387 AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
2388 CFLAGS=$saved_cflags
2390 if test "$ac_cv_c_dll_unixware" = "yes"
2392 LDSHARED="\$(CC) -Wl,-G"
2393 LDXXSHARED="\$(CXX) -Wl,-G"
2394 LDDLLFLAGS="-Wl,-B,symbolic"
2396 AC_CACHE_CHECK("whether we can build a NetBSD dll",
2398 [saved_cflags=$CFLAGS
2399 CFLAGS="$CFLAGS -fPIC -Wl,-Bshareable,-Bforcearchive"
2400 AC_TRY_LINK(,[return 1],ac_cv_c_dll_netbsd="yes",ac_cv_c_dll_netbsd="no")
2401 CFLAGS=$saved_cflags
2403 if test "$ac_cv_c_dll_netbsd" = "yes"
2405 LDSHARED="\$(CC) -Wl,-Bshareable,-Bforcearchive"
2406 LDXXSHARED="\$(CXX) -Wl,-Bshareable,-Bforcearchive"
2407 LDDLLFLAGS="" #FIXME
2411 if test "$ac_cv_c_dll_linux" = "no" -a "$ac_cv_c_dll_unixware" = "no" -a "$ac_cv_c_dll_netbsd" = "no"
2413 AC_MSG_ERROR([Could not find how to build a dynamically linked library])
2416 CFLAGS="$CFLAGS -fPIC"
2419 AC_SUBST(LDXXSHARED)
2420 AC_SUBST(LDDLLFLAGS)
2422 dnl *** check for the need to define __i386__
2424 AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
2425 AC_EGREP_CPP(yes,[#if (defined(i386) || defined(__i386)) && !defined(__i386__)
2428 ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no"))
2429 if test "$ac_cv_cpp_def_i386" = "yes"
2431 CFLAGS="$CFLAGS -D__i386__"
2434 dnl *** check for the need to define __sparc__
2436 AC_CACHE_CHECK("whether we need to define __sparc__",ac_cv_cpp_def_sparc,
2437 AC_EGREP_CPP(yes,[#if (defined(sparc) || defined(__sparc)) && !defined(__sparc__)
2440 ac_cv_cpp_def_sparc="yes", ac_cv_cpp_def_sparc="no"))
2441 if test "$ac_cv_cpp_def_sparc" = "yes"
2443 CFLAGS="$CFLAGS -D__sparc__"
2444 CXXFLAGS="$CXXFLAGS -D__sparc__"
2447 dnl *** check for the need to define __sun__
2449 AC_CACHE_CHECK("whether we need to define __sun__",ac_cv_cpp_def_sun,
2450 AC_EGREP_CPP(yes,[#if (defined(sun) || defined(__sun)) && !defined(__sun__)
2453 ac_cv_cpp_def_sun="yes", ac_cv_cpp_def_sun="no"))
2454 if test "$ac_cv_cpp_def_sun" = "yes"
2456 CFLAGS="$CFLAGS -D__sun__"
2457 CXXFLAGS="$CXXFLAGS -D__sun__"
2460 dnl **** Test Winelib-related features of the C++ compiler
2462 if test "x${GCC}" = "xyes"
2464 OLDCXXFLAGS="$CXXFLAGS";
2465 CXXFLAGS="-fpermissive";
2466 AC_CACHE_CHECK("for g++ -fpermissive option", has_gxx_permissive,
2468 for (int i=0;i<2;i++);
2471 [has_gxx_permissive="yes"],
2472 [has_gxx_permissive="no"])
2474 CXXFLAGS="-fno-for-scope";
2475 AC_CACHE_CHECK("for g++ -fno-for-scope option", has_gxx_no_for_scope,
2477 for (int i=0;i<2;i++);
2480 [has_gxx_no_for_scope="yes"],
2481 [has_gxx_no_for_scope="no"])
2483 CXXFLAGS="$OLDCXXFLAGS";
2484 if test "$has_gxx_permissive" = "yes"
2486 CXXFLAGS="$CXXFLAGS -fpermissive"
2488 if test "$has_gxx_no_for_scope" = "yes"
2490 CXXFLAGS="$CXXFLAGS -fno-for-scope"
2495 dnl **** Test Winelib-related features of the C compiler
2498 dnl **** Macros for finding a headers/libraries in a collection of places
2500 dnl AC_PATH_FILE(variable,file,action-if-not-found,default-locations)
2501 AC_DEFUN(AC_PATH_FILE,[
2502 AC_MSG_CHECKING([for $2])
2503 AC_CACHE_VAL(ac_cv_pfile_$1,
2506 ac_dummy="ifelse([$4], , , [$4])"
2507 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2508 for ac_dir in $ac_dummy; do
2510 if test -z "$ac_dir"
2514 ac_file="$ac_dir/$2"
2516 if test -f "$ac_file"
2519 ac_cv_pfile_$1="$ac_dir"
2523 ifelse([$3],,,[if test -z "$ac_found"
2529 $1="$ac_cv_pfile_$1"
2530 if test -n "$ac_found" -o -n "[$]$1"
2532 AC_MSG_RESULT([$]$1)
2539 dnl AC_PATH_HEADER(variable,header,action-if-not-found,default-locations)
2540 dnl Note that the above may set variable to an empty value if the header is
2541 dnl already in the include path
2542 AC_DEFUN(AC_PATH_HEADER,[
2543 AC_MSG_CHECKING([for $2 header])
2544 AC_CACHE_VAL(ac_cv_pheader_$1,
2547 ac_dummy="ifelse([$4], , :/usr/local/include, [$4])"
2548 save_CPPFLAGS="$CPPFLAGS"
2549 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2550 for ac_dir in $ac_dummy; do
2552 if test -z "$ac_dir"
2554 CPPFLAGS="$save_CPPFLAGS"
2556 CPPFLAGS="-I$ac_dir $save_CPPFLAGS"
2558 AC_TRY_COMPILE([#include <$2>],,ac_found=1;ac_cv_pheader_$1="$ac_dir";break)
2560 CPPFLAGS="$save_CPPFLAGS"
2561 ifelse([$3],,,[if test -z "$ac_found"
2567 $1="$ac_cv_pheader_$1"
2568 if test -n "$ac_found" -o -n "[$]$1"
2570 AC_MSG_RESULT([$]$1)
2577 dnl AC_PATH_LIBRARY(variable,libraries,extra libs,action-if-not-found,default-locations)
2578 AC_DEFUN(AC_PATH_LIBRARY,[
2579 AC_MSG_CHECKING([for $2])
2580 AC_CACHE_VAL(ac_cv_plibrary_$1,
2583 ac_dummy="ifelse([$5], , :/usr/local/lib, [$5])"
2585 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2586 for ac_dir in $ac_dummy; do
2588 if test -z "$ac_dir"
2590 LIBS="$2 $3 $save_LIBS"
2592 LIBS="-L$ac_dir $2 $3 $save_LIBS"
2594 AC_TRY_LINK(,,ac_found=1;ac_cv_plibrary_$1="$ac_dir";break)
2597 ifelse([$4],,,[if test -z "$ac_found"
2603 $1="$ac_cv_plibrary_$1"
2604 if test -n "$ac_found" -o -n "[$]$1"
2606 AC_MSG_RESULT([$]$1)
2613 dnl **** Try to find where winelib is located ****
2616 WINE_INCLUDE_ROOT=""
2617 WINE_INCLUDE_PATH=""
2618 WINE_LIBRARY_ROOT=""
2619 WINE_LIBRARY_PATH=""
2628 [ --with-wine=DIR the Wine package (or sources) is in DIR],
2629 [if test "$withval" != "no"; then
2630 WINE_ROOT="$withval";
2637 if test -n "$WINE_ROOT"
2639 WINE_INCLUDE_ROOT="$WINE_ROOT/include:$WINE_ROOT/include/wine:$WINE_ROOT/include/wine/windows:$WINE_ROOT/include/windows"
2640 WINE_LIBRARY_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/library"
2641 WINE_UNICODE_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/unicode"
2642 WINE_UUID_ROOT="$WINE_ROOT:$WINE_ROOT/lib:$WINE_ROOT/ole"
2643 WINE_TOOL_PATH="$WINE_ROOT:$WINE_ROOT/bin:$WINE_ROOT/tools/wrc:$WINE_ROOT/tools/winebuild"
2644 WINE_DLL_ROOT="$WINE_ROOT/dlls:$WINE_ROOT/lib"
2647 AC_ARG_WITH(wine-includes,
2648 [ --with-wine-includes=DIR the Wine includes are in DIR],
2649 [if test "$withval" != "no"; then
2650 WINE_INCLUDES="$withval";
2654 if test -n "$WINE_INCLUDES"
2656 WINE_INCLUDE_ROOT="$WINE_INCLUDES"
2659 AC_ARG_WITH(wine-libraries,
2660 [ --with-wine-libraries=DIR the Wine libraries are in DIR],
2661 [if test "$withval" != "no"; then
2662 WINE_LIBRARIES="$withval";
2666 if test -n "$WINE_LIBRARIES"
2668 WINE_LIBRARY_ROOT="$WINE_LIBRARIES"
2669 WINE_UNICODE_ROOT="$WINE_LIBRARIES:$WINE_LIBRARIES/unicode:$WINE_LIBRARIES/../unicode"
2670 WINE_UUID_ROOT="$WINE_LIBRARIES:$WINE_LIBRARIES/ole:$WINE_LIBRARIES/../ole"
2673 AC_ARG_WITH(wine-dlls,
2674 [ --with-wine-dlls=DIR the Wine dlls are in DIR],
2675 [if test "$withval" != "no"; then
2676 WINE_DLLS="$withval";
2680 if test -n "$WINE_DLLS"
2682 WINE_DLL_ROOT="$WINE_DLLS"
2685 AC_ARG_WITH(wine-tools,
2686 [ --with-wine-tools=DIR the Wine tools are in DIR],
2687 [if test "$withval" != "no"; then
2688 WINE_TOOLS="$withval";
2692 if test -n "$WINE_TOOLS"
2694 WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/tools/wrc:$WINE_TOOLS/tools/winebuild"
2697 if test -z "$WINE_INCLUDE_ROOT"
2699 WINE_INCLUDE_ROOT=":/usr/include/wine/windows:/usr/include/wine:/usr/local/include/wine/windows:/opt/wine/include/windows:/opt/wine/include/wine";
2701 AC_PATH_FILE(WINE_INCLUDE_ROOT,[windef.h],[
2702 AC_MSG_ERROR([Could not find the Wine headers (windef.h)])
2703 ],$WINE_INCLUDE_ROOT)
2705 AC_PATH_HEADER(WINE_INCLUDE_ROOT,[windef.h],[
2706 AC_MSG_ERROR([Could not include the Wine headers (windef.h)])
2707 ],$WINE_INCLUDE_ROOT)
2708 if test -n "$WINE_INCLUDE_ROOT"
2710 WINE_INCLUDE_PATH="-I$WINE_INCLUDE_ROOT"
2712 WINE_INCLUDE_PATH=""
2715 if test -z "$WINE_LIBRARY_ROOT"
2717 WINE_LIBRARY_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
2719 AC_PATH_FILE(WINE_LIBRARY_ROOT,[libwine.so],[
2720 AC_MSG_ERROR([Could not find the Wine libraries (libwine.so)])
2721 ],$WINE_LIBRARY_ROOT)
2723 AC_PATH_LIBRARY(WINE_LIBRARY_ROOT,[-lwine],[],[
2724 AC_MSG_ERROR([Could not link with the Wine libraries (libwine.so)])
2725 ],$WINE_LIBRARY_ROOT)
2726 if test -n "$WINE_LIBRARY_ROOT"
2728 WINE_LIBRARY_PATH="-L$WINE_LIBRARY_ROOT"
2729 LDPATH="$WINE_LIBRARY_ROOT"
2731 WINE_LIBRARY_PATH=""
2734 if test -z "$WINE_UNICODE_ROOT"
2736 WINE_UNICODE_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
2738 AC_PATH_FILE(WINE_UNICODE_ROOT,[libwine_unicode.so],[
2739 AC_MSG_ERROR([Could not find the Wine libraries (libwine_unicode.so)])
2740 ],$WINE_UNICODE_ROOT)
2742 AC_PATH_LIBRARY(WINE_UNICODE_ROOT,[-lwine_unicode],[$WINE_LIBRARY_PATH -lwine],[
2743 AC_MSG_ERROR([Could not link with the Wine libraries (libwine_unicode.so)])
2744 ],[$WINE_UNICODE_ROOT])
2746 if test -n "$WINE_UNICODE_ROOT" -a "$WINE_UNICODE_ROOT" != "$WINE_LIBRARY_ROOT"
2748 WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$WINE_UNICODE_ROOT"
2749 LDPATH="$LDPATH:$WINE_UNICODE_ROOT"
2752 if test -z "$WINE_UUID_ROOT"
2754 WINE_UUID_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"
2756 AC_PATH_FILE(WINE_UUID_ROOT,[libwine_uuid.a],[
2757 AC_MSG_ERROR([Could not find the Wine libraries (libwine_uuid.a)])
2760 AC_PATH_LIBRARY(WINE_UUID_ROOT,[-lwine_uuid],[$WINE_LIBRARY_PATH -lwine],[
2761 AC_MSG_ERROR([Could not link with the Wine libraries (libwine_uuid.a)])
2762 ],[$WINE_UUID_ROOT])
2764 if test -n "$WINE_UUID_ROOT" -a "$WINE_UUID_ROOT" != "$WINE_LIBRARY_ROOT"
2766 WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$WINE_UUID_ROOT"
2769 if test -z "$WINE_DLL_ROOT"
2771 if test -n "$WINE_LIBRARY_ROOT"
2773 WINE_DLL_ROOT="$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/dlls"
2775 WINE_DLL_ROOT="/lib:/lib/wine:/usr/lib:/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine"
2778 AC_PATH_FILE(WINE_DLL_ROOT,[libntdll.dll.so],[
2779 AC_MSG_ERROR([Could not find the Wine dlls (libntdll.dll.so)])
2782 AC_PATH_LIBRARY(WINE_DLL_ROOT,[-lntdll.dll],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
2783 AC_MSG_ERROR([Could not link with the Wine dlls (libntdll.dll.so)])
2785 WINE_DLL_PATH="-L$WINE_DLL_ROOT/wine"
2787 if test -z "$WINE_TOOL_PATH"
2789 WINE_TOOL_PATH="$PATH:/usr/local/bin:/opt/wine/bin"
2791 AC_PATH_PROG(WINE,wine,,$WINE_TOOL_PATH)
2794 AC_MSG_ERROR([Could not find Wine's wine tool])
2796 AC_PATH_PROG(WINEBUILD,winebuild,,$WINE_TOOL_PATH)
2797 if test -z "$WINEBUILD"
2799 AC_MSG_ERROR([Could not find Wine's winebuild tool])
2801 AC_PATH_PROG(WRC,wrc,,$WINE_TOOL_PATH)
2804 AC_MSG_ERROR([Could not find Wine's wrc tool])
2807 LDPATH="LD_LIBRARY_PATH=\"$LDPATH:\$\$LD_LIBRARY_PATH\""
2809 AC_SUBST(WINE_INCLUDE_PATH)
2810 AC_SUBST(WINE_LIBRARY_PATH)
2811 AC_SUBST(WINE_DLL_PATH)
2813 dnl **** Try to find where the MFC are located ****
2816 if test "x$NEEDS_MFC" = "x1"
2818 ATL_INCLUDE_ROOT="";
2819 ATL_INCLUDE_PATH="";
2820 MFC_INCLUDE_ROOT="";
2821 MFC_INCLUDE_PATH="";
2822 MFC_LIBRARY_ROOT="";
2823 MFC_LIBRARY_PATH="";
2826 [ --with-mfc=DIR the MFC package (or sources) is in DIR],
2827 [if test "$withval" != "no"; then
2828 MFC_ROOT="$withval";
2835 if test -n "$MFC_ROOT"
2837 ATL_INCLUDE_ROOT="$MFC_ROOT";
2838 MFC_INCLUDE_ROOT="$MFC_ROOT";
2839 MFC_LIBRARY_ROOT="$MFC_ROOT";
2842 AC_ARG_WITH(atl-includes,
2843 [ --with-atl-includes=DIR the ATL includes are in DIR],
2844 [if test "$withval" != "no"; then
2845 ATL_INCLUDES="$withval";
2849 if test -n "$ATL_INCLUDES"
2851 ATL_INCLUDE_ROOT="$ATL_INCLUDES";
2854 AC_ARG_WITH(mfc-includes,
2855 [ --with-mfc-includes=DIR the MFC includes are in DIR],
2856 [if test "$withval" != "no"; then
2857 MFC_INCLUDES="$withval";
2861 if test -n "$MFC_INCLUDES"
2863 MFC_INCLUDE_ROOT="$MFC_INCLUDES";
2866 AC_ARG_WITH(mfc-libraries,
2867 [ --with-mfc-libraries=DIR the MFC libraries are in DIR],
2868 [if test "$withval" != "no"; then
2869 MFC_LIBRARIES="$withval";
2873 if test -n "$MFC_LIBRARIES"
2875 MFC_LIBRARY_ROOT="$MFC_LIBRARIES";
2878 OLDCPPFLAGS="$CPPFLAGS"
2879 dnl FIXME: We should not have defines in any of the include paths
2880 CPPFLAGS="$WINE_INCLUDE_PATH -I$WINE_INCLUDE_ROOT/msvcrt -D_DLL -D_MT $CPPFLAGS"
2881 ATL_INCLUDE_PATH="-I\$(WINE_INCLUDE_ROOT)/msvcrt -D_DLL -D_MT"
2882 if test -z "$ATL_INCLUDE_ROOT"
2884 ATL_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/atl:/usr/include/atl:/usr/local/include/atl:/opt/mfc/include/atl:/opt/atl/include"
2886 ATL_INCLUDE_ROOT="$ATL_INCLUDE_ROOT:$ATL_INCLUDE_ROOT/atl:$ATL_INCLUDE_ROOT/atl/include"
2888 AC_PATH_HEADER(ATL_INCLUDE_ROOT,atldef.h,[
2889 AC_MSG_ERROR([Could not find the ATL includes])
2890 ],$ATL_INCLUDE_ROOT)
2891 if test -n "$ATL_INCLUDE_ROOT"
2893 ATL_INCLUDE_PATH="$ATL_INCLUDE_PATH -I$ATL_INCLUDE_ROOT"
2896 MFC_INCLUDE_PATH="$ATL_INCLUDE_PATH"
2897 if test -z "$MFC_INCLUDE_ROOT"
2899 MFC_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/mfc:/usr/include/mfc:/usr/local/include/mfc:/opt/mfc/include/mfc:/opt/mfc/include"
2901 MFC_INCLUDE_ROOT="$MFC_INCLUDE_ROOT:$MFC_INCLUDE_ROOT/mfc:$MFC_INCLUDE_ROOT/mfc/include"
2903 AC_PATH_HEADER(MFC_INCLUDE_ROOT,afx.h,[
2904 AC_MSG_ERROR([Could not find the MFC includes])
2905 ],$MFC_INCLUDE_ROOT)
2906 if test -n "$MFC_INCLUDE_ROOT" -a "$ATL_INCLUDE_ROOT" != "$MFC_INCLUDE_ROOT"
2908 MFC_INCLUDE_PATH="$MFC_INCLUDE_PATH -I$MFC_INCLUDE_ROOT"
2910 CPPFLAGS="$OLDCPPFLAGS"
2912 if test -z "$MFC_LIBRARY_ROOT"
2914 MFC_LIBRARY_ROOT=":$WINE_LIBRARY_ROOT:/usr/lib/mfc:/usr/local/lib:/usr/local/lib/mfc:/opt/mfc/lib";
2916 MFC_LIBRARY_ROOT="$MFC_LIBRARY_ROOT:$MFC_LIBRARY_ROOT/lib:$MFC_LIBRARY_ROOT/mfc/src";
2918 AC_PATH_LIBRARY(MFC_LIBRARY_ROOT,[-lmfc],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
2919 AC_MSG_ERROR([Could not find the MFC library])
2920 ],$MFC_LIBRARY_ROOT)
2921 if test -n "$MFC_LIBRARY_ROOT" -a "$MFC_LIBRARY_ROOT" != "$WINE_LIBRARY_ROOT"
2923 MFC_LIBRARY_PATH="-L$MFC_LIBRARY_ROOT"
2928 AC_SUBST(ATL_INCLUDE_PATH)
2929 AC_SUBST(MFC_INCLUDE_PATH)
2930 AC_SUBST(MFC_LIBRARY_PATH)
2935 dnl **** Generate output files ****
2937 MAKE_RULES=Make.rules
2938 AC_SUBST_FILE(MAKE_RULES)
2942 ##WINEMAKER_PROJECTS##
2946 echo "Configure finished. Do 'make' to build the project."
2949 dnl Local Variables:
2950 dnl comment-start: "dnl "
2952 dnl comment-start-skip: "\\bdnl\\b\\s *"
2953 dnl compile-command: "autoconf"
2955 --- Make.rules.in ---
2956 # Copyright 2000 Francois Gouget for CodeWeavers
2957 # fgouget@codeweavers.com
2959 # Global rules shared by all makefiles -*-Makefile-*-
2961 # Each individual makefile must define the following variables:
2962 # TOPOBJDIR : top-level object directory
2963 # SRCDIR : source directory for this module
2965 # Each individual makefile may define the following additional variables:
2967 # SUBDIRS : subdirectories that contain a Makefile
2968 # DLLS : WineLib libraries to be built
2969 # EXES : WineLib executables to be built
2971 # CEXTRA : extra c flags (e.g. '-Wall')
2972 # CXXEXTRA : extra c++ flags (e.g. '-Wall')
2973 # WRCEXTRA : extra wrc flags (e.g. '-p _SysRes')
2974 # DEFINES : defines (e.g. -DSTRICT)
2975 # INCLUDE_PATH : additional include path
2976 # LIBRARY_PATH : additional library path
2977 # LIBRARIES : additional Unix libraries to link with
2979 # C_SRCS : C sources for the module
2980 # CXX_SRCS : C++ sources for the module
2981 # RC_SRCS : resource source files
2982 # SPEC_SRCS : interface definition files
2987 WINE_INCLUDE_ROOT = @WINE_INCLUDE_ROOT@
2988 WINE_INCLUDE_PATH = @WINE_INCLUDE_PATH@
2989 WINE_LIBRARY_ROOT = @WINE_LIBRARY_ROOT@
2990 WINE_LIBRARY_PATH = @WINE_LIBRARY_PATH@
2991 WINE_DLL_ROOT = @WINE_DLL_ROOT@
2992 WINE_DLL_PATH = @WINE_DLL_PATH@
2998 ATL_INCLUDE_ROOT = @ATL_INCLUDE_ROOT@
2999 ATL_INCLUDE_PATH = @ATL_INCLUDE_PATH@
3000 MFC_INCLUDE_ROOT = @MFC_INCLUDE_ROOT@
3001 MFC_INCLUDE_PATH = @MFC_INCLUDE_PATH@
3002 MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@
3003 MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@
3005 # Global definitions and options
3007 GLOBAL_DEFINES = ##WINEMAKER_DEFINES##
3008 GLOBAL_INCLUDE_PATH = ##WINEMAKER_INCLUDE_PATH##
3009 GLOBAL_DLL_PATH = ##WINEMAKER_DLL_PATH##
3010 GLOBAL_DLLS = ##WINEMAKER_DLLS##
3011 GLOBAL_LIBRARY_PATH = ##WINEMAKER_LIBRARY_PATH##
3012 GLOBAL_LIBRARIES = ##WINEMAKER_LIBRARIES##
3014 # First some useful definitions
3021 CFLAGS = @CFLAGS@ $(CEXTRA)
3022 CXXFLAGS = @CXXFLAGS@ $(CXXEXTRA)
3023 WRCFLAGS = $(WRCEXTRA)
3024 OPTIONS = @OPTIONS@ -D_REENTRANT
3025 LIBS = @LIBS@ $(LIBRARY_PATH)
3026 DIVINCL = $(GLOBAL_INCLUDE_PATH) -I$(SRCDIR) $(INCLUDE_PATH) $(WINE_INCLUDE_PATH)
3027 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(GLOBAL_DEFINES) $(DEFINES) $(OPTIONS)
3028 ALLCXXFLAGS=$(DIVINCL) $(CXXFLAGS) $(GLOBAL_DEFINES) $(DEFINES) $(OPTIONS)
3029 ALL_DLL_PATH = $(DLL_PATH) $(GLOBAL_DLL_PATH) $(WINE_DLL_PATH)
3030 ALL_LIBRARY_PATH = $(LIBRARY_PATH) $(GLOBAL_LIBRARY_PATH) $(WINE_LIBRARY_PATH)
3031 WINE_LIBRARIES = -lwine -lwine_unicode -lwine_uuid
3032 ALL_LIBRARIES = $(LIBRARIES:%=-l%) $(GLOBAL_LIBRARIES:%=-l%) $(WINE_LIBRARIES)
3033 LDSHARED = @LDSHARED@
3034 LDXXSHARED= @LDXXSHARED@
3035 LDDLLFLAGS= @LDDLLFLAGS@
3037 STRIPFLAGS= --strip-unneeded
3043 WINEBUILD = @WINEBUILD@
3046 # Installation infos
3049 INSTALL_PROGRAM = $(INSTALL)
3050 INSTALL_SCRIPT = $(INSTALL)
3051 INSTALL_DATA = $(INSTALL) -m 644
3053 exec_prefix = @exec_prefix@
3058 dlldir = @libdir@/wine
3063 OBJS = $(C_SRCS:.c=.o) $(CXX_SRCS:.cpp=.o) \
3064 $(SPEC_SRCS:.spec=.spec.o)
3065 CLEAN_FILES = *.spec.c y.tab.c y.tab.h lex.yy.c \
3067 \\\#*\\\# *~ *% .\\\#*
3068 DISTCLEAN_FILES = config.* Makefile Make.rules
3072 .SUFFIXES: .cpp .rc .res .spec .spec.c .spec.o
3075 $(CC) -c $(ALLCFLAGS) -o $@ $<
3078 $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
3081 $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
3084 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ $<
3086 .PHONY: all install uninstall clean distclean depend dummy
3088 # 'all' target first in case the enclosing Makefile didn't define any target
3092 # Rules for makefile
3094 Makefile: Makefile.in $(TOPSRCDIR)/configure
3095 @echo $@ is older than $?, please rerun $(TOPSRCDIR)/configure
3098 # Rules for cleaning
3100 $(SUBDIRS:%=%/__clean__): dummy
3101 cd `dirname $@` && $(MAKE) clean
3103 $(EXTRASUBDIRS:%=%/__clean__): dummy
3104 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
3106 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
3107 $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(OBJS) $(EXES:%.exe=%) $(EXES:%=%.so) $(EXES:%=%.spec.o) $(DLLS:%=%.so) $(DLLS:%=%.spec.o)
3109 # Rule for distcleaning
3112 $(RM) $(DISTCLEAN_FILES)
3114 # Rules for installing
3116 $(SUBDIRS:%=%/__install__): dummy
3117 cd `dirname $@` && $(MAKE) install
3119 $(SUBDIRS:%=%/__uninstall__): dummy
3120 cd `dirname $@` && $(MAKE) uninstall
3129 # End of global rules
3130 --- wineapploader.in ---
3133 # Wrapper script to start a Winelib application once it is installed
3135 # Copyright (C) 2002 Alexandre Julliard
3137 # determine the app Winelib library name
3138 appname=`basename "$0" .exe`.exe
3140 #allow Wine to load Winelib application from the current directory
3141 export WINEDLLPATH=$WINEDLLPATH:@winelibdir@
3143 # first try explicit WINELOADER
3144 if [ -x "$WINELOADER" ]; then exec "$WINELOADER" "$appname" "$@"; fi
3146 # then default bin directory
3147 if [ -x "@bindir@/wine" ]; then exec "@bindir@/wine" "$appname" "$@"; fi
3149 # now try the directory containing $0
3153 # $0 contains a path, use it
3154 appdir=`dirname "$0"`
3157 # no directory in $0, search in PATH
3163 if [ -x "$d/$0" ]; then appdir="$d"; break; fi
3167 if [ -x "$appdir/wine" ]; then exec "$appdir/wine" "$appname" "$@"; fi
3169 # finally look in PATH
3170 exec wine "$appname" "$@"
3173 * Copyright 2000 Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
3181 #include <windows.h>
3186 * Describe the wrapped application
3190 * This is either CUIEXE for a console based application or
3191 * GUIEXE for a regular windows application.
3195 #define APP_TYPE ##WINEMAKER_APP_TYPE##
3198 * This is the name of the library containing the application,
3199 * e.g. 'hello.dll' if the application is called 'hello.exe'.
3201 static char* appName = "##WINEMAKER_APP_NAME##";
3204 * This is the name of the application's Windows module. If left NULL
3205 * then appName is used.
3207 static char* appModule = NULL;
3210 * This is the application's entry point. This is usually "WinMain" for a
3211 * GUIEXE and 'main' for a CUIEXE application.
3213 static char* appInit = ##WINEMAKER_APP_INIT##;
3216 * This is either non-NULL for MFC-based applications and is the name of the
3217 * MFC's module. This is the module in which we will take the 'WinMain'
3220 static char* mfcModule = ##WINEMAKER_APP_MFC##;
3225 * Implement the main.
3228 #if APP_TYPE == GUIEXE
3229 typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance,
3230 PSTR szCmdLine, int iCmdShow);
3232 typedef int WINAPI (*MainFunc)(int argc, char** argv, char** envp);
3235 #if APP_TYPE == GUIEXE
3236 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
3237 PSTR szCmdLine, int iCmdShow)
3239 int WINAPI main(int argc, char** argv, char** envp)
3242 /*void* appLibrary;*/
3243 HINSTANCE hApp = 0, hMFC = 0, hMain = 0;
3248 /* Load the application's library */
3249 /*libName=(char*)malloc(2+strlen(appName)+3+1);*/
3250 /* FIXME: we should get the wrapper's path and use that as the base for
3253 /*sprintf(libName,"./%s.so",appName);*/
3254 /*appLibrary=dlopen(libName,RTLD_NOW);*/
3255 /*if (appLibrary==NULL) {*/
3256 /*sprintf(libName,"%s.so",appName);*/
3257 /*appLibrary=dlopen(libName,RTLD_NOW);*/
3259 /*if (appLibrary==NULL) {*/
3260 /*char format[]="Could not load the %s library:\r\n%s";*/
3264 /*error=dlerror();*/
3265 /*msg=(char*)malloc(strlen(format)+strlen(libName)+strlen(error));*/
3266 /*sprintf(msg,format,libName,error);*/
3267 /*MessageBox(NULL,msg,"dlopen error",MB_OK);*/
3272 /* Then if this application is MFC based, load the MFC module */
3273 /* FIXME: I'm not sure this is really necessary */
3274 if (mfcModule!=NULL) {
3275 hMFC=LoadLibrary(mfcModule);
3277 char format[]="Could not load the MFC module %s (%d)";
3280 msg=(char*)malloc(strlen(format)+strlen(mfcModule)+11);
3281 sprintf(msg,format,mfcModule,GetLastError());
3282 MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
3286 /* MFC is a special case: the WinMain is in the MFC library,
3287 * instead of the application's library.
3294 /* Load the application's module */
3295 if (appModule==NULL) {
3298 hApp=LoadLibrary(appModule);
3300 char format[]="Could not load the application's module %s (%d)";
3303 msg=(char*)malloc(strlen(format)+strlen(appModule)+11);
3304 sprintf(msg,format,appModule,GetLastError());
3305 MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
3308 } else if (hMain==NULL) {
3312 /* Get the address of the application's entry point */
3313 appMain=GetProcAddress(hMain, appInit);
3314 if (appMain==NULL) {
3315 char format[]="Could not get the address of %s (%d)";
3318 msg=(char*)malloc(strlen(format)+strlen(appInit)+11);
3319 sprintf(msg,format,appInit,GetLastError());
3320 MessageBox(NULL,msg,"GetProcAddress error",MB_OK);
3325 /* And finally invoke the application's entry point */
3326 #if APP_TYPE == GUIEXE
3327 retcode=(*((WinMainFunc)appMain))(hApp,hPrevInstance,szCmdLine,iCmdShow);
3329 retcode=(*((MainFunc)appMain))(argc,argv,envp);
3332 /* Cleanup and done */
3337 /*dlclose(appLibrary);*/