3 # Copyright 2000 Francois Gouget for CodeWeavers
4 # fgouget@codeweavers.com
20 # The following constants define what we do with the case of filenames
23 # Never rename a file to lowercase
27 # Rename all files to lowercase
31 # Rename only files that are all uppercase to lowercase
32 my $OPT_LOWER_UPPERCASE=2;
35 # The following constants define whether to ask questions or not
38 # No (synonym of never)
46 # Skip the questions till the end of this scope
53 # This is the directory in which winemaker will operate.
57 # Make a backup of the files
61 # Defines which files to rename
65 # If we don't find the file referenced by an include, lower it
66 my $opt_lower_include;
69 # Options for the 'Source' method
72 # Specifies that we have only one target so that all sources relate
73 # to this target. By default this variable is left undefined which
74 # means winemaker should try to find out by itself what the targets
75 # are. If not undefined then this contains the name of the default
76 # target (without the extension).
77 my $opt_single_target;
80 # If '$opt_single_target' has been specified then this is the type of
81 # that target. Otherwise it specifies whether the default target type
82 # is guiexe or cuiexe.
86 # Contains the default set of flags to be used when creating a new target.
90 # If true then winemaker should ask questions to the user as it goes
92 my $opt_is_interactive;
93 my $opt_ask_project_options;
94 my $opt_ask_target_options;
97 # If false then winemaker should not generate any file, i.e.
98 # no makefiles, but also no .spec files, no configure.in, etc.
99 my $opt_no_generated_files;
102 # Specifies not to print the banner if set.
109 # Target modelization
113 # The description of a target is stored in an array. The constants
114 # below identify what is stored at each index of the array.
117 # This is the name of the target.
121 # Defines the type of target we want to build. See the TT_xxx
126 # Defines the target's enty point, i.e. the function that is called
131 # This is a bitfield containing flags refining the way the target
132 # should be handled. See the TF_xxx constants below
136 # This is a reference to an array containing the list of the
137 # resp. C, C++, RC, other (.h, .hxx, etc.) source files.
141 my $T_SOURCES_MISC=7;
144 # This is a reference to an array containing the list of macro
149 # This is a reference to an array containing the list of directory
150 # names that constitute the include path
151 my $T_INCLUDE_PATH=9;
154 # Same as T_INCLUDE_PATH but for the library search path
155 my $T_LIBRARY_PATH=10;
158 # The list of Windows libraries to import
162 # The list of Unix libraries to link with
166 # The list of dependencies between targets
170 # The following constants define the recognized types of target
173 # This is not a real target. This type of target is used to collect
174 # the sources that don't seem to belong to any other target. Thus no
175 # real target is generated for them, we just put the sources of the
176 # fake target in the global source list.
180 # For executables in the windows subsystem
184 # For executables in the console subsystem
188 # For dynamically linked libraries
192 # The following constants further refine how the target should be handled
195 # This target needs a wrapper
199 # This target is a wrapper
203 # This target is an MFC-based target
207 # Initialize a target:
208 # - set the target type to TT_SETTINGS, i.e. no real target will
214 @$target[$T_TYPE]=$TT_SETTINGS;
215 # leaving $T_INIT undefined
216 @$target[$T_FLAGS]=$opt_flags;
217 @$target[$T_SOURCES_C]=[];
218 @$target[$T_SOURCES_CXX]=[];
219 @$target[$T_SOURCES_RC]=[];
220 @$target[$T_SOURCES_MISC]=[];
221 @$target[$T_DEFINES]=[];
222 @$target[$T_INCLUDE_PATH]=[];
223 @$target[$T_LIBRARY_PATH]=[];
224 @$target[$T_IMPORTS]=[];
225 @$target[$T_LIBRARIES]=[];
226 @$target[$T_DEPENDS]=[];
232 if ($type == $TT_GUIEXE) {
234 } elsif ($type == $TT_CUIEXE) {
236 } elsif ($type == $TT_DLL) {
245 # Project modelization
249 # First we have the notion of project. A project is described by an
250 # array (since we don't have structs in perl). The constants below
251 # identify what is stored at each index of the array.
254 # This is the path in which this project is located. In other
255 # words, this is the path to the Makefile.
259 # This index contains a reference to an array containing the project-wide
260 # settings. The structure of that arrray is actually identical to that of
261 # a regular target since it can also contain extra sources.
265 # This index contains a reference to an array of targets for this
266 # project. Each target describes how an executable or library is to
267 # be built. For each target this description takes the same form as
268 # that of the project: an array. So this entry is an array of arrays.
272 # Initialize a project:
273 # - set the project's path
274 # - initialize the target list
275 # - create a default target (will be removed later if unnecessary)
281 my $project_settings=[];
282 target_init($project_settings);
284 @$project[$P_PATH]=$path;
285 @$project[$P_SETTINGS]=$project_settings;
286 @$project[$P_TARGETS]=[];
302 # Contains the list of all projects. This list tells us what are
303 # the subprojects of the main Makefile and where we have to generate
308 # This is the main project, i.e. the one in the "." directory.
309 # It may well be empty in which case the main Makefile will only
310 # call out subprojects.
314 # Contains the defaults for the include path, etc.
315 # We store the defaults as if this were a target except that we only
316 # exploit the defines, include path, library path, library list and misc
321 # If one of the projects requires the MFc then we set this global variable
322 # to true so that configure asks the user to provide a path tothe MFC
334 # Cleans up a name to make it an acceptable Makefile
340 $name =~ tr/a-zA-Z0-9_/_/c;
345 # Returns true is the specified pathname is absolute.
346 # Note: pathnames that start with a variable '$' or
347 # '~' are considered absolute.
352 return ($path =~ /^[\/~\$]/);
356 # Performs a binary search looking for the specified item
361 my $last=@{$array}-1;
364 while ($first<=$last) {
365 my $index=int(($first+$last)/2);
366 my $cmp=@$array[$index] cmp $item;
381 # 'Source'-based Project analysis
386 # Allows the user to specify makefile and target specific options
387 # - target: the structure in which to store the results
388 # - options: the string containing the options
389 sub source_set_options
394 #FIXME: we must deal with escaping of stuff and all
395 foreach $option (split / /,$options) {
396 if (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-D/) {
397 push @{@$target[$T_DEFINES]},$option;
398 } elsif (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-I/) {
399 push @{@$target[$T_INCLUDE_PATH]},$option;
400 } elsif ($option =~ /^-L/) {
401 push @{@$target[$T_LIBRARY_PATH]},$option;
402 } elsif ($option =~ /^-i/) {
403 push @{@$target[$T_IMPORTS]},$';
404 } elsif ($option =~ /^-l/) {
405 push @{@$target[$T_LIBRARIES]},$';
406 } elsif (@$target[$T_TYPE] != $TT_DLL and
407 $option =~ /^--wrap/) {
408 @$target[$T_FLAGS]|=$TF_WRAP;
409 } elsif (@$target[$T_TYPE] != $TT_DLL and
410 $option =~ /^--nowrap/) {
411 @$target[$T_FLAGS]&=~$TF_WRAP;
412 } elsif ($option =~ /^--mfc/) {
413 @$target[$T_FLAGS]|=$TF_MFC;
414 if (@$target[$T_TYPE] != $TT_DLL) {
415 @$target[$T_FLAGS]|=$TF_WRAP;
417 } elsif ($option =~ /^--nomfc/) {
418 @$target[$T_FLAGS]&=~$TF_MFC;
419 @$target[$T_FLAGS]&=~($TF_MFC|$TF_WRAP);
421 print STDERR "error: unknown option \"$option\"\n";
429 # Scans the specified directory to:
430 # - see if we should create a Makefile in this directory. We normally do
431 # so if we find a project file and sources
432 # - get a list of targets for this directory
433 # - get the list of source files
434 sub source_scan_directory
436 # a reference to the parent's project
437 my $parent_project=$_[0];
438 # the full relative path to the current directory, including a
439 # trailing '/', or an empty string if this is the top level directory
441 # the name of this directory, including a trailing '/', or an empty
442 # string if this is the top level directory
444 # if set then no targets will be looked for and the sources will all
445 # end up in the parent_project's 'misc' bucket
448 # reference to the project for this directory. May not be used
450 # list of targets found in the 'current' directory
452 # list of sources found in the current directory
457 # true if this directory contains a Windows project
458 my $has_win_project=0;
459 # If we don't find any executable/library then we might make up targets
460 # from the list of .dsp/.mak files we find since they usually have the
461 # same name as their target.
465 if (defined $opt_single_target or $dirname eq "") {
466 # Either there is a single target and thus a single project,
467 # or we are in the top level directory for which a project
469 $project=$parent_project;
472 project_init($project,$path);
474 my $project_settings=@$project[$P_SETTINGS];
476 # First find out what this directory contains:
477 # collect all sources, targets and subdirectories
478 my $directory=get_directory_contents($path);
479 foreach $dentry (@$directory) {
480 if ($dentry =~ /^\./) {
483 my $fullentry="$path$dentry";
484 if (-d "$fullentry") {
485 if ($dentry =~ /^(Release|Debug)/i) {
486 # These directories are often used to store the object files and the
487 # resulting executable/library. They should not contain anything else.
488 my @candidates=grep /\.(exe|dll)$/i, @{get_directory_contents("$fullentry")};
489 foreach $candidate (@candidates) {
490 if ($candidate =~ s/\.exe$//i) {
491 $targets{$candidate}=1;
492 } elsif ($candidate =~ s/^(.*)\.dll$/lib$1.so/i) {
493 $targets{$candidate}=1;
496 } elsif ($dentry =~ /^include/i) {
497 # This directory must contain headers we're going to need
498 push @{@$project_settings[$T_INCLUDE_PATH]},"-I$dentry";
499 source_scan_directory($project,"$fullentry/","$dentry/",1);
501 # Recursively scan this directory. Any source file that cannot be
502 # attributed to a project in one of the subdirectories will be
503 # attributed to this project.
504 source_scan_directory($project,"$fullentry/","$dentry/",$no_target);
506 } elsif (-f "$fullentry") {
507 if ($dentry =~ s/\.exe$//i) {
509 } elsif ($dentry =~ s/^(.*)\.dll$/lib$1.so/i) {
511 } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.spec\.c$/) {
512 push @sources_c,"$dentry";
513 } elsif ($dentry =~ /\.(cpp|cxx)$/i) {
514 if ($dentry =~ /^stdafx.cpp$/i) {
515 push @sources_misc,"$dentry";
516 @$project_settings[$T_FLAGS]|=$TF_MFC;
518 push @sources_cxx,"$dentry";
520 } elsif ($dentry =~ /\.rc$/i) {
521 push @sources_rc,"$dentry";
522 } elsif ($dentry =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
523 push @sources_misc,"$dentry";
524 if ($dentry =~ /^stdafx.h$/i) {
525 @$project_settings[$T_FLAGS]|=$TF_MFC;
527 } elsif ($dentry =~ /\.dsp$/i) {
528 push @dsp_files,"$dentry";
530 } elsif ($dentry =~ /\.mak$/i) {
531 push @mak_files,"$dentry";
533 } elsif ($dentry =~ /^makefile/i) {
540 # If we have a single target then all we have to do is assign
541 # all the sources to it and we're done
542 # FIXME: does this play well with the --interactive mode?
543 if ($opt_single_target) {
544 my $target=@{@$project[$P_TARGETS]}[0];
545 push @{@$target[$T_SOURCES_C]},map "$path$_",@sources_c;
546 push @{@$target[$T_SOURCES_CXX]},map "$path$_",@sources_cxx;
547 push @{@$target[$T_SOURCES_RC]},map "$path$_",@sources_rc;
548 push @{@$target[$T_SOURCES_MISC]},map "$path$_",@sources_misc;
552 my $parent_settings=@$parent_project[$P_SETTINGS];
553 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_c;
554 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_cxx;
555 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_rc;
556 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
557 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
561 my $source_count=@sources_c+@sources_cxx+@sources_rc+
562 @{@$project_settings[$T_SOURCES_C]}+
563 @{@$project_settings[$T_SOURCES_CXX]}+
564 @{@$project_settings[$T_SOURCES_RC]};
565 if ($source_count == 0) {
566 # A project without real sources is not a project, get out!
567 if ($project!=$parent_project) {
568 my $parent_settings=@$parent_project[$P_SETTINGS];
569 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
570 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
574 #print "targets=",%targets,"\n";
575 #print "target_count=$target_count\n";
576 #print "has_win_project=$has_win_project\n";
577 #print "dirname=$dirname\n";
580 if (($has_win_project != 0) or ($dirname eq "")) {
581 # Deal with cases where we could not find any executable/library, and
582 # thus have no target, although we did find some sort of windows project.
583 $target_count=keys %targets;
584 if ($target_count == 0) {
585 # Try to come up with a target list based on .dsp/.mak files
587 if (@dsp_files > 0) {
588 $prj_list=\@dsp_files;
590 $prj_list=\@mak_files;
592 foreach $filename (@$prj_list) {
593 $filename =~ s/\.(dsp|mak)$//i;
594 if ($opt_target_type == $TT_DLL) {
595 $filename = "lib$filename.so";
597 $targets{$filename}=1;
599 $target_count=keys %targets;
600 if ($target_count == 0) {
601 # Still nothing, try the name of the directory
603 if ($dirname eq "") {
604 # Bad luck, this is the top level directory!
605 $name=(split /\//, cwd)[-1];
608 # Remove the trailing '/'. Also eliminate whatever is after the last
609 # '.' as it is likely to be meaningless (.orig, .new, ...)
610 $name =~ s+(/|\.[^.]*)$++;
611 if ($name eq "src") {
612 # 'src' is probably a subdirectory of the real project directory.
613 # Try again with the parent (if any).
615 if ($parent =~ s+([^/]*)/[^/]*/$+$1+) {
618 $name=(split /\//, cwd)[-1];
622 $name =~ s+(/|\.[^.]*)$++;
623 if ($opt_target_type == $TT_DLL) {
624 $name = "lib$name.so";
630 # Ask confirmation to the user if he wishes so
631 if ($opt_is_interactive == $OPT_ASK_YES) {
632 my $target_list=join " ",keys %targets;
633 print "\n*** In ",($path?$path:"./"),"\n";
634 print "* winemaker found the following list of (potential) targets\n";
635 print "* $target_list\n";
636 print "* Type enter to use it as is, your own comma-separated list of\n";
637 print "* targets, 'none' to assign the source files to a parent directory,\n";
638 print "* or 'ignore' to ignore everything in this directory tree.\n";
639 print "* Target list:\n";
640 $target_list=<STDIN>;
642 if ($target_list eq "") {
643 # Keep the target list as is, i.e. do nothing
644 } elsif ($target_list eq "none") {
645 # Empty the target list
647 } elsif ($target_list eq "ignore") {
648 # Ignore this subtree altogether
652 foreach $target (split /,/,$target_list) {
655 # Also accept .exe and .dll as a courtesy
656 $target =~ s+(.*)\.dll$+lib$1.so+;
657 $target =~ s+\.exe$++;
664 # If we have no project at this level, then transfer all
665 # the sources to the parent project
666 $target_count=keys %targets;
667 if ($target_count == 0) {
668 if ($project!=$parent_project) {
669 my $parent_settings=@$parent_project[$P_SETTINGS];
670 push @{@$parent_settings[$T_SOURCES_C]},map "$dirname$_",@sources_c;
671 push @{@$parent_settings[$T_SOURCES_CXX]},map "$dirname$_",@sources_cxx;
672 push @{@$parent_settings[$T_SOURCES_RC]},map "$dirname$_",@sources_rc;
673 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
674 push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
679 # Otherwise add this project to the project list, except for
680 # the main project which is already in the list.
681 if ($dirname ne "") {
682 push @projects,$project;
685 # Ask for project-wide options
686 if ($opt_ask_project_options == $OPT_ASK_YES) {
688 if ((@$project_settings[$T_FLAGS] & $TF_MFC)!=0) {
691 if ((@$project_settings[$T_FLAGS] & $TF_WRAP)!=0) {
692 if ($flag_desc ne "") {
695 $flag_desc.="wrapped";
697 print "* Type any project-wide options (-D/-I/-L/-i/-l/--mfc/--wrap),\n";
698 if (defined $flag_desc) {
699 print "* (currently $flag_desc)\n";
701 print "* or 'skip' to skip the target specific options,\n";
702 print "* or 'never' to not be asked this question again:\n";
706 if ($options eq "skip") {
707 $opt_ask_target_options=$OPT_ASK_SKIP;
709 } elsif ($options eq "never") {
710 $opt_ask_project_options=$OPT_ASK_NO;
712 } elsif (source_set_options($project_settings,$options)) {
715 print "Please re-enter the options:\n";
719 # - Create the targets
720 # - Check if we have both libraries and programs
721 # - Match each target with source files (sort in reverse
722 # alphabetical order to get the longest matches first)
723 my @local_imports=();
724 my @local_depends=();
726 foreach $target_name (sort { $b cmp $a } keys %targets) {
727 # Create the target...
730 target_init($target);
731 @$target[$T_NAME]=$target_name;
732 @$target[$T_FLAGS]|=@$project_settings[$T_FLAGS];
733 if ($target_name =~ /^lib(.*)\.so$/) {
734 @$target[$T_TYPE]=$TT_DLL;
735 @$target[$T_INIT]=get_default_init($TT_DLL);
736 @$target[$T_FLAGS]&=~$TF_WRAP;
738 push @local_depends,$target_name;
739 push @local_imports,$basename;
741 @$target[$T_TYPE]=$opt_target_type;
742 @$target[$T_INIT]=get_default_init($opt_target_type);
743 $basename=$target_name;
744 push @exe_list,$target;
746 # This is the default link list of Visual Studio, except odbccp32
747 # which we don't have in Wine. Also I add ntdll which seems
748 # necessary for Winelib.
749 my @std_imports=qw(advapi32.dll comdlg32.dll gdi32.dll kernel32.dll ntdll.dll odbc32.dll ole32.dll oleaut32.dll shell32.dll user32.dll winspool.drv);
750 @$target[$T_IMPORTS]=\@std_imports;
751 push @{@$project[$P_TARGETS]},$target;
753 # Ask for target-specific options
754 if ($opt_ask_target_options == $OPT_ASK_YES) {
756 if ((@$target[$T_FLAGS] & $TF_MFC)!=0) {
759 if ((@$target[$T_FLAGS] & $TF_WRAP)!=0) {
760 if ($flag_desc ne "") {
765 $flag_desc.="wrapped";
767 if ($flag_desc ne "") {
770 print "* Specify any link option (-L/-i/-l/--mfc/--wrap) specific to the target\n";
771 print "* \"$target_name\"$flag_desc or 'never' to not be asked this question again:\n";
775 if ($options eq "never") {
776 $opt_ask_target_options=$OPT_ASK_NO;
778 } elsif (source_set_options($target,$options)) {
781 print "Please re-enter the options:\n";
784 if (@$target[$T_FLAGS] & $TF_MFC) {
785 @$project_settings[$T_FLAGS]|=$TF_MFC;
786 push @{@$target[$T_LIBRARY_PATH]},"\$(MFC_LIBRARY_PATH)";
787 push @{@$target[$T_IMPORTS]},"mfc.dll";
788 # FIXME: Link with the MFC in the Unix sense, until we
789 # start exporting the functions properly.
790 push @{@$target[$T_LIBRARIES]},"mfc";
794 if ($target_count == 1) {
795 push @{@$target[$T_SOURCES_C]},@{@$project_settings[$T_SOURCES_C]},@sources_c;
796 @$project_settings[$T_SOURCES_C]=[];
799 push @{@$target[$T_SOURCES_CXX]},@{@$project_settings[$T_SOURCES_CXX]},@sources_cxx;
800 @$project_settings[$T_SOURCES_CXX]=[];
803 push @{@$target[$T_SOURCES_RC]},@{@$project_settings[$T_SOURCES_RC]},@sources_rc;
804 @$project_settings[$T_SOURCES_RC]=[];
807 push @{@$target[$T_SOURCES_MISC]},@{@$project_settings[$T_SOURCES_MISC]},@sources_misc;
808 # No need for sorting these sources
809 @$project_settings[$T_SOURCES_MISC]=[];
812 foreach $source (@sources_c) {
813 if ($source =~ /^$basename/i) {
814 push @{@$target[$T_SOURCES_C]},$source;
818 foreach $source (@sources_cxx) {
819 if ($source =~ /^$basename/i) {
820 push @{@$target[$T_SOURCES_CXX]},$source;
824 foreach $source (@sources_rc) {
825 if ($source =~ /^$basename/i) {
826 push @{@$target[$T_SOURCES_RC]},$source;
830 foreach $source (@sources_misc) {
831 if ($source =~ /^$basename/i) {
832 push @{@$target[$T_SOURCES_MISC]},$source;
837 @$target[$T_SOURCES_C]=[sort @{@$target[$T_SOURCES_C]}];
838 @$target[$T_SOURCES_CXX]=[sort @{@$target[$T_SOURCES_CXX]}];
839 @$target[$T_SOURCES_RC]=[sort @{@$target[$T_SOURCES_RC]}];
840 @$target[$T_SOURCES_MISC]=[sort @{@$target[$T_SOURCES_MISC]}];
842 if ($opt_ask_target_options == $OPT_ASK_SKIP) {
843 $opt_ask_target_options=$OPT_ASK_YES;
846 if (@$project_settings[$T_FLAGS] & $TF_MFC) {
847 push @{@$project_settings[$T_INCLUDE_PATH]},"\$(MFC_INCLUDE_PATH)";
849 # The sources that did not match, if any, go to the extra
850 # source list of the project settings
851 foreach $source (@sources_c) {
853 push @{@$project_settings[$T_SOURCES_C]},$source;
856 @$project_settings[$T_SOURCES_C]=[sort @{@$project_settings[$T_SOURCES_C]}];
857 foreach $source (@sources_cxx) {
859 push @{@$project_settings[$T_SOURCES_CXX]},$source;
862 @$project_settings[$T_SOURCES_CXX]=[sort @{@$project_settings[$T_SOURCES_CXX]}];
863 foreach $source (@sources_rc) {
865 push @{@$project_settings[$T_SOURCES_RC]},$source;
868 @$project_settings[$T_SOURCES_RC]=[sort @{@$project_settings[$T_SOURCES_RC]}];
869 foreach $source (@sources_misc) {
871 push @{@$project_settings[$T_SOURCES_MISC]},$source;
874 @$project_settings[$T_SOURCES_MISC]=[sort @{@$project_settings[$T_SOURCES_MISC]}];
876 # Finally if we are building both libraries and programs in
877 # this directory, then the programs should be linked with all
879 if (@local_imports > 0 and @exe_list > 0) {
880 foreach $target (@exe_list) {
881 push @{@$target[$T_LIBRARY_PATH]},"-L.";
882 push @{@$target[$T_IMPORTS]},map { "$_.dll" } @local_imports;
883 # Also link in the Unix sense since none of the functions
885 push @{@$target[$T_LIBRARIES]},@local_imports;
886 push @{@$target[$T_DEPENDS]},@local_depends;
892 # Scan the source directories in search of things to build
895 # If there's a single target then this is going to be the default target
896 if (defined $opt_single_target) {
897 # Create the main target
899 target_init($main_target);
900 if ($opt_target_type == $TT_DLL) {
901 @$main_target[$T_NAME]="lib$opt_single_target.so";
903 @$main_target[$T_NAME]="$opt_single_target";
905 @$main_target[$T_TYPE]=$opt_target_type;
908 push @{$main_project[$P_TARGETS]},$main_target;
911 # The main directory is always going to be there
912 push @projects,\@main_project;
914 # Now scan the directory tree looking for source files and, maybe, targets
915 print "Scanning the source directories...\n";
916 source_scan_directory(\@main_project,"","",0);
918 @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
925 # 'vc.dsp'-based Project analysis
938 # Creating the wrapper targets
942 sub postprocess_targets
944 foreach $project (@projects) {
945 foreach $target (@{@$project[$P_TARGETS]}) {
946 if ((@$target[$T_FLAGS] & $TF_WRAP) != 0) {
948 target_init($wrapper);
949 @$wrapper[$T_NAME]=@$target[$T_NAME];
950 @$wrapper[$T_TYPE]=@$target[$T_TYPE];
951 @$wrapper[$T_INIT]=get_default_init(@$target[$T_TYPE]);
952 @$wrapper[$T_FLAGS]=$TF_WRAPPER | (@$target[$T_FLAGS] & $TF_MFC);
953 @$wrapper[$T_IMPORTS]=[ "kernel32.dll", "ntdll.dll", "user32.dll" ];
954 push @{@$wrapper[$T_SOURCES_C]},"@$wrapper[$T_NAME]_wrapper.c";
956 my $index=bsearch(@$target[$T_SOURCES_C],"@$wrapper[$T_NAME]_wrapper.c");
957 if (defined $index) {
958 splice(@{@$target[$T_SOURCES_C]},$index,1);
960 @$target[$T_NAME]="lib@$target[$T_NAME].so";
961 @$target[$T_TYPE]=$TT_DLL;
963 push @{@$project[$P_TARGETS]},$wrapper;
965 if ((@$target[$T_FLAGS] & $TF_MFC) != 0) {
966 @{@$project[$P_SETTINGS]}[$T_FLAGS]|=$TF_MFC;
982 # Performs a directory traversal and renames the files so that:
983 # - they have the case desired by the user
984 # - their extension is of the appropriate case
985 # - they don't contain annoying characters like ' ', '$', '#', ...
986 sub fix_file_and_directory_names
990 if (opendir(DIRECTORY, "$dirname")) {
991 foreach $dentry (readdir DIRECTORY) {
992 if ($dentry =~ /^\./ or $dentry eq "CVS") {
995 # Set $warn to 1 if the user should be warned of the renaming
998 # autoconf and make don't support these characters well
999 my $new_name=$dentry;
1000 $new_name =~ s/[ \$]/_/g;
1002 # Only all lowercase extensions are supported (because of the
1003 # transformations ':.c=.o') .
1004 if (-f "$dirname/$new_name") {
1005 if ($new_name =~ /\.C$/) {
1006 $new_name =~ s/\.C$/.c/;
1008 if ($new_name =~ /\.cpp$/i) {
1009 $new_name =~ s/\.cpp$/.cpp/i;
1011 if ($new_name =~ s/\.cxx$/.cpp/i) {
1014 if ($new_name =~ /\.rc$/i) {
1015 $new_name =~ s/\.rc$/.rc/i;
1017 # And this last one is to avoid confusion then running make
1018 if ($new_name =~ s/^makefile$/makefile.win/) {
1023 # Adjust the case to the user's preferences
1024 if (($opt_lower == $OPT_LOWER_ALL and $dentry =~ /[A-Z]/) or
1025 ($opt_lower == $OPT_LOWER_UPPERCASE and $dentry !~ /[a-z]/)
1027 $new_name=lc $new_name;
1030 # And finally, perform the renaming
1031 if ($new_name ne $dentry) {
1033 print STDERR "warning: in \"$dirname\", renaming \"$dentry\" to \"$new_name\"\n";
1035 if (!rename("$dirname/$dentry","$dirname/$new_name")) {
1036 print STDERR "error: in \"$dirname\", unable to rename \"$dentry\" to \"$new_name\"\n";
1037 print STDERR " $!\n";
1041 if (-d "$dirname/$new_name") {
1042 fix_file_and_directory_names("$dirname/$new_name");
1045 closedir(DIRECTORY);
1058 # This maps a directory name to a reference to an array listing
1059 # its contents (files and directories)
1063 # Retrieves the contents of the specified directory.
1064 # We either get it from the directories hashtable which acts as a
1065 # cache, or use opendir, readdir, closedir and store the result
1067 sub get_directory_contents
1072 #print "getting the contents of $dirname\n";
1074 # check for a cached version
1076 if ($dirname eq "") {
1079 $directory=$directories{$dirname};
1080 if (defined $directory) {
1081 #print "->@$directory\n";
1085 # Read this directory
1086 if (opendir(DIRECTORY, "$dirname")) {
1087 my @files=readdir DIRECTORY;
1088 closedir(DIRECTORY);
1091 # Return an empty list
1092 #print "error: cannot open $dirname\n";
1096 #print "->@$directory\n";
1097 $directories{$dirname}=$directory;
1102 # Try to find a file for the specified filename. The attempt is
1103 # case-insensitive which is why it's not trivial. If a match is
1104 # found then we return the pathname with the correct case.
1111 if ($dirname eq "" or $dirname eq ".") {
1113 } elsif ($dirname =~ m+^[^/]+) {
1114 $dirname=cwd . "/" . $dirname;
1116 if ($dirname !~ m+/$+) {
1120 foreach $component (@$path) {
1121 #print " looking for $component in \"$dirname\"\n";
1122 if ($component eq ".") {
1125 } elsif ($component eq "..") {
1127 $dirname=dirname($dirname) . "/";
1130 # The file/directory may have been renamed before. Also try to
1131 # match the renamed file.
1132 my $renamed=$component;
1133 $renamed =~ s/[ \$]/_/g;
1134 if ($renamed eq $component) {
1138 my $directory=get_directory_contents $dirname;
1140 foreach $dentry (@$directory) {
1141 if ($dentry =~ /^$component$/i or
1142 (defined $renamed and $dentry =~ /^$renamed$/i)
1144 $dirname.="$dentry/";
1145 $real_path.="$dentry/";
1150 if (!defined $found) {
1152 #print " could not find $component in $dirname\n";
1157 $real_path=~ s+/$++;
1158 #print " -> found $real_path\n";
1163 # Performs a case-insensitive search for the specified file in the
1165 # $line is the line number that should be referenced when an error occurs
1166 # $filename is the file we are looking for
1167 # $dirname is the directory of the file containing the '#include' directive
1168 # if '"' was used, it is an empty string otherwise
1169 # $project and $target specify part of the include path
1170 sub get_real_include_name
1178 if ($filename =~ /^([a-zA-Z]:)?[\/]/ or $filename =~ /^[a-zA-Z]:[\/]?/) {
1179 # This is not a relative path, we cannot make any check
1180 my $warning="path:$filename";
1181 if (!defined $warnings{$warning}) {
1182 $warnings{$warning}="1";
1183 print STDERR "warning: cannot check the case of absolute pathnames:\n";
1184 print STDERR "$line: $filename\n";
1187 # Here's how we proceed:
1188 # - split the filename we look for into its components
1189 # - then for each directory in the include path
1190 # - trace the directory components starting from that directory
1191 # - if we fail to find a match at any point then continue with
1192 # the next directory in the include path
1193 # - otherwise, rejoice, our quest is over.
1194 my @file_components=split /[\/\\]+/, $filename;
1195 #print " Searching for $filename from @$project[$P_PATH]\n";
1198 if ($dirname ne "") {
1199 # This is an 'include ""' -> look in dirname first.
1200 #print " in $dirname (include \"\")\n";
1201 $real_filename=search_from($dirname,\@file_components);
1202 if (defined $real_filename) {
1203 return $real_filename;
1206 my $project_settings=@$project[$P_SETTINGS];
1207 foreach $include (@{@$target[$T_INCLUDE_PATH]}, @{@$project_settings[$T_INCLUDE_PATH]}) {
1208 my $dirname=$include;
1210 if (!is_absolute($dirname)) {
1211 $dirname="@$project[$P_PATH]$dirname";
1213 $dirname=~ s+^\$\(TOPSRCDIR\)/++;
1214 $dirname=~ s+^\$\(SRCDIR\)/+@$project[$P_PATH]+;
1216 #print " in $dirname\n";
1217 $real_filename=search_from("$dirname",\@file_components);
1218 if (defined $real_filename) {
1219 return $real_filename;
1222 my $dotdotpath=@$project[$P_PATH];
1223 $dotdotpath =~ s/[^\/]+/../g;
1224 foreach $include (@{$global_settings[$T_INCLUDE_PATH]}) {
1225 my $dirname=$include;
1227 $dirname=~ s+^\$\(TOPSRCDIR\)\/++;
1228 $dirname=~ s+^\$\(SRCDIR\)\/+@$project[$P_PATH]+;
1229 #print " in $dirname (global setting)\n";
1230 $real_filename=search_from("$dirname",\@file_components);
1231 if (defined $real_filename) {
1232 return $real_filename;
1236 $filename =~ s+\\\\+/+g; # in include ""
1237 $filename =~ s+\\+/+g; # in include <> !
1238 if ($opt_lower_include) {
1239 return lc "$filename";
1250 if ($size =~ /^(1|2|4|8)$/) {
1251 print FILEO "$indent#include <pshpack$size.h>$trailer";
1253 print FILEO "$indent/* winemaker:warning: Unknown size \"$size\". Defaulting to 4 */\n";
1254 print FILEO "$indent#include <pshpack4.h>$trailer";
1259 # 'Parses' a source file and fixes constructs that would not work with
1260 # Winelib. The parsing is rather simple and not all non-portable features
1261 # are corrected. The most important feature that is corrected is the case
1262 # and path separator of '#include' directives. This requires that each
1263 # source file be associated to a project & target so that the proper
1264 # include path is used.
1265 # Also note that the include path is relative to the directory in which the
1266 # compiler is run, i.e. that of the project, not to that of the file.
1272 $filename="@$project[$P_PATH]$filename";
1273 if (! -e $filename) {
1277 my $is_rc=($filename =~ /\.(rc2?|dlg)$/i);
1278 my $dirname=dirname($filename);
1280 if (defined $target and (@$target[$T_FLAGS] & $TF_MFC)) {
1284 print " $filename\n";
1285 #FIXME:assuming that because there is a .bak file, this is what we want is
1286 #probably flawed. Or is it???
1287 if (! -e "$filename.bak") {
1288 if (!copy("$filename","$filename.bak")) {
1289 print STDERR "error: unable to make a backup of $filename:\n";
1290 print STDERR " $!\n";
1294 if (!open(FILEI,"$filename.bak")) {
1295 print STDERR "error: unable to open $filename.bak for reading:\n";
1296 print STDERR " $!\n";
1299 if (!open(FILEO,">$filename")) {
1300 print STDERR "error: unable to open $filename for writing:\n";
1301 print STDERR " $!\n";
1306 my $rc_block_depth=0;
1307 my $rc_textinclude_state=0;
1313 # Make sure all files are '\n' terminated
1316 if ($is_rc and !$is_mfc and /^(\s*)(\#\s*include\s*)\"afxres\.h\"/) {
1317 # VC6 automatically includes 'afxres.h', an MFC specific header, in
1318 # the RC files it generates (even in non-MFC projects). So we replace
1319 # it with 'winres.h' its very close standard cousin so that non MFC
1320 # projects can compile in Wine without the MFC sources.
1321 my $warning="mfc:afxres.h";
1322 if (!defined $warnings{$warning}) {
1323 $warnings{$warning}="1";
1324 print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winres.h'\n";
1325 print STDERR "warning: the above warning is issued only once\n";
1327 print FILEO "$1/* winemaker: $2\"afxres.h\" */\n";
1328 print FILEO "$1/* winemaker:warning: 'afxres.h' is an MFC specific header. Replacing it with 'winres.h' */\n";
1329 print FILEO "$1$2\"winres.h\"$'";
1332 } elsif (/^(\s*\#\s*include\s*)([\"<])([^\"]+)([\">])/) {
1333 my $from_file=($2 eq "<"?"":$dirname);
1334 my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
1335 print FILEO "$1$2$real_include_name$4$'";
1336 $modified|=($real_include_name ne $3);
1338 } elsif (s/^(\s*)(\#\s*pragma\s+pack\s*\(\s*)//) {
1339 # Pragma pack handling
1341 # pack_stack is an array of references describing the stack of
1342 # pack directives currently in effect. Each directive if described
1343 # by a reference to an array containing:
1344 # - "push" for pack(push,...) directives, "" otherwise
1345 # - the directive's identifier at index 1
1346 # - the directive's alignement value at index 2
1348 # Don't believe a word of what the documentation says: it's all wrong.
1349 # The code below is based on the actual behavior of Visual C/C++ 6.
1354 # Pushes the default stack alignment
1355 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1356 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1357 print_pack($pack_indent,4,$');
1358 push @pack_stack, [ "", "", 4 ];
1360 } elsif (/^(pop\s*(,\s*\d+\s*)?\))/) {
1362 # pragma pack(pop,n)
1363 # Goes up the stack until it finds a pack(push,...), and pops it
1364 # Ignores any pack(n) entry
1365 # Issues a warning if the pack is of the form pack(push,label)
1366 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1367 my $pack_comment=$';
1368 $pack_comment =~ s/^\s*//;
1369 if ($pack_comment ne "") {
1370 print FILEO "$pack_indent$pack_comment";
1373 my $alignment=pop @pack_stack;
1374 if (!defined $alignment) {
1375 print FILEO "$pack_indent/* winemaker:warning: No pack(push,...) found. All the stack has been popped */\n";
1378 if (@$alignment[1]) {
1379 print FILEO "$pack_indent/* winemaker:warning: Anonymous pop of pack(push,@$alignment[1]) (@$alignment[2]) */\n";
1381 print FILEO "$pack_indent#include <poppack.h>\n";
1382 if (@$alignment[0]) {
1387 } elsif (/^(pop\s*,\s*(\w+)\s*(,\s*\d+\s*)?\))/) {
1388 # pragma pack(pop,label[,n])
1389 # Goes up the stack until finding a pack(push,...) and pops it.
1390 # 'n', if specified, is ignored.
1391 # Ignores any pack(n) entry
1392 # Issues a warning if the label of the pack does not match,
1393 # or if it is in fact a pack(push,n)
1395 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1396 my $pack_comment=$';
1397 $pack_comment =~ s/^\s*//;
1398 if ($pack_comment ne "") {
1399 print FILEO "$pack_indent$pack_comment";
1402 my $alignment=pop @pack_stack;
1403 if (!defined $alignment) {
1404 print FILEO "$pack_indent/* winemaker:warning: No pack(push,$label) found. All the stack has been popped */\n";
1407 if (@$alignment[1] and @$alignment[1] ne $label) {
1408 print FILEO "$pack_indent/* winemaker:warning: Push/pop mismatch: \"@$alignment[1]\" (@$alignment[2]) != \"$label\" */\n";
1410 print FILEO "$pack_indent#include <poppack.h>\n";
1411 if (@$alignment[0]) {
1416 } elsif (/^(push\s*\))/) {
1418 # Push the current alignment
1419 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1420 if (@pack_stack > 0) {
1421 my $alignment=$pack_stack[$#pack_stack];
1422 print_pack($pack_indent,@$alignment[2],$');
1423 push @pack_stack, [ "push", "", @$alignment[2] ];
1425 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1426 print_pack($pack_indent,4,$');
1427 push @pack_stack, [ "push", "", 4 ];
1430 } elsif (/^((push\s*,\s*)?(\d+)\s*\))/) {
1431 # pragma pack([push,]n)
1432 # Push new alignment n
1433 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1434 print_pack($pack_indent,$3,"$'");
1435 push @pack_stack, [ ($2 ? "push" : ""), "", $3 ];
1437 } elsif (/^((\w+)\s*\))/) {
1438 # pragma pack(label)
1439 # label must in fact be a macro that resolves to an integer
1440 # Then behaves like 'pragma pack(n)'
1441 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1442 print FILEO "$pack_indent/* winemaker:warning: Assuming $2 == 4 */\n";
1443 print_pack($pack_indent,4,$');
1444 push @pack_stack, [ "", "", 4 ];
1446 } elsif (/^(push\s*,\s*(\w+)\s*(,\s*(\d+)\s*)?\))/) {
1447 # pragma pack(push,label[,n])
1448 # Pushes a new label on the stack. It is possible to push the same
1449 # label multiple times. If 'n' is omitted then the alignment is
1450 # unchanged. Otherwise it becomes 'n'.
1451 print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
1455 } elsif (@pack_stack > 0) {
1456 my $alignment=$pack_stack[$#pack_stack];
1457 $size=@$alignment[2];
1459 print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
1462 print_pack($pack_indent,$size,$');
1463 push @pack_stack, [ "push", $2, $size ];
1466 # pragma pack(??? -> What's that?
1467 print FILEO "$pack_indent/* winemaker:warning: Unknown type of pragma pack directive */\n";
1468 print FILEO "$pack_indent$pack_header$_";
1474 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]+)([\">]?)/) {
1475 my $from_file=($5 eq "<"?"":$dirname);
1476 my $real_include_name=get_real_include_name($line,$6,$from_file,$project,$target);
1477 print FILEO "$1$5$real_include_name$7$'";
1478 $modified|=($real_include_name ne $6);
1480 } elsif (/^(\s*RCINCLUDE\s*)([\"<]?)([^\">\r\n]+)([\">]?)/) {
1481 my $from_file=($2 eq "<"?"":$dirname);
1482 my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
1483 print FILEO "$1$2$real_include_name$4$'";
1484 $modified|=($real_include_name ne $3);
1486 } elsif ($is_rc and !$is_mfc and $rc_block_depth == 0 and /^\s*\d+\s+TEXTINCLUDE\s*/) {
1487 $rc_textinclude_state=1;
1490 } elsif ($rc_textinclude_state == 3 and /^(\s*\"\#\s*include\s*\"\")afxres\.h(\"\"\\r\\n\")/) {
1491 print FILEO "$1winres.h$2$'";
1494 } elsif (/^\s*BEGIN(\W.*)?$/) {
1495 $rc_textinclude_state|=2;
1499 } elsif (/^\s*END(\W.*)?$/) {
1500 $rc_textinclude_state=0;
1501 if ($rc_block_depth>0) {
1517 if ($opt_backup == 0 or $modified == 0) {
1518 if (!unlink("$filename.bak")) {
1519 print STDERR "error: unable to delete $filename.bak:\n";
1520 print STDERR " $!\n";
1526 # Analyzes each source file in turn to find and correct issues
1527 # that would cause it not to compile.
1530 print "Fixing the source files...\n";
1531 foreach $project (@projects) {
1532 foreach $target (@$project[$P_SETTINGS],@{@$project[$P_TARGETS]}) {
1533 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1536 foreach $source (@{@$target[$T_SOURCES_C]}, @{@$target[$T_SOURCES_CXX]}, @{@$target[$T_SOURCES_RC]}, @{@$target[$T_SOURCES_MISC]}) {
1537 fix_file($source,$project,$target);
1552 # Generates a target's .spec file
1553 sub generate_spec_file
1557 my $project_settings=$_[2];
1559 my $basename=@$target[$T_NAME];
1560 $basename =~ s+\.so$++;
1561 if (@$target[$T_FLAGS] & $TF_WRAP) {
1562 $basename =~ s+^lib++;
1563 } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) {
1564 $basename.="_wrapper";
1567 if (!open(FILEO,">$path$basename.spec")) {
1568 print STDERR "error: could not open \"$path$basename.spec\" for writing\n";
1569 print STDERR " $!\n";
1573 my $module=$basename;
1574 $module =~ s+^lib++;
1575 $module=canonize($module);
1576 print FILEO "name $module\n";
1577 print FILEO "type win32\n";
1578 if (@$target[$T_TYPE] == $TT_GUIEXE) {
1579 print FILEO "mode guiexe\n";
1580 } elsif (@$target[$T_TYPE] == $TT_CUIEXE) {
1581 print FILEO "mode cuiexe\n";
1583 print FILEO "mode dll\n";
1585 if (defined @$target[$T_INIT] and ((@$target[$T_FLAGS] & $TF_WRAP) == 0)) {
1586 print FILEO "init @$target[$T_INIT]\n";
1588 if (@{@$target[$T_SOURCES_RC]} > 0) {
1589 if (@{@$target[$T_SOURCES_RC]} > 1) {
1590 print STDERR "warning: the target $basename has more than one RC file. Modify the Makefile.in to remove redundant RC files, and fix the spec file\n";
1592 my $rcname=@{@$target[$T_SOURCES_RC]}[0];
1593 $rcname =~ s+\.rc$++i;
1594 $rcname =~ s+([^/\w])+\\$1+g;
1595 print FILEO "rsrc $rcname.res\n";
1599 foreach $library (@{$global_settings[$T_IMPORTS]}) {
1600 if (!defined $imports{$library}) {
1601 print FILEO "import $library\n";
1602 $imports{$library}=1;
1605 if (defined $project_settings) {
1606 foreach $library (@{@$project_settings[$T_IMPORTS]}) {
1607 if (!defined $imports{$library}) {
1608 print FILEO "import $library\n";
1609 $imports{$library}=1;
1613 foreach $library (@{@$target[$T_IMPORTS]}) {
1614 if (!defined $imports{$library}) {
1615 print FILEO "import $library\n";
1616 $imports{$library}=1;
1620 # Don't forget to export the 'Main' function for wrapped executables,
1621 # except for MFC ones!
1622 if (@$target[$T_FLAGS] == $TF_WRAP) {
1623 if (@$target[$T_TYPE] == $TT_GUIEXE) {
1624 print FILEO "\n@ stdcall @$target[$T_INIT](long long ptr long) @$target[$T_INIT]\n";
1625 } elsif (@$target[$T_TYPE] == $TT_CUIEXE) {
1626 print FILEO "\n@ stdcall @$target[$T_INIT](long ptr ptr) @$target[$T_INIT]\n";
1628 print FILEO "\n@ stdcall @$target[$T_INIT](ptr long ptr) @$target[$T_INIT]\n";
1636 # Generates a target's wrapper file
1637 sub generate_wrapper_file
1642 if (!defined $templates{"wrapper.c"}) {
1643 print STDERR "winemaker: internal error: No template called 'wrapper.c'\n";
1647 if (!open(FILEO,">$path@$target[$T_NAME]_wrapper.c")) {
1648 print STDERR "error: unable to open \"$path$basename.c\" for writing:\n";
1649 print STDERR " $!\n";
1652 my $app_name="\"@$target[$T_NAME]\"";
1653 my $app_type=(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE");
1654 my $app_init=(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"");
1655 my $app_mfc=(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":NULL);
1656 foreach $line (@{$templates{"wrapper.c"}}) {
1658 $l =~ s/\#\#WINEMAKER_APP_NAME\#\#/$app_name/;
1659 $l =~ s/\#\#WINEMAKER_APP_TYPE\#\#/$app_type/;
1660 $l =~ s/\#\#WINEMAKER_APP_INIT\#\#/$app_init/;
1661 $l =~ s/\#\#WINEMAKER_APP_MFC\#\#/$app_mfc/;
1668 # A convenience function to generate all the lists (defines,
1669 # C sources, C++ source, etc.) in the Makefile
1679 printf FILEO "%-22s=",$name;
1681 if (defined $list) {
1682 foreach $item (@$list) {
1684 if (defined $data) {
1685 $value=&$data($item);
1691 print FILEO " $value";
1694 print FILEO " \\\n\t\t\t$value";
1705 # Generates a project's Makefile.in and all the target files
1706 sub generate_project_files
1709 my $project_settings=@$project[$P_SETTINGS];
1713 # Then sort the targets and separate the libraries from the programs
1714 foreach $target (sort { @$a[$T_NAME] cmp @$b[$T_NAME] } @{@$project[$P_TARGETS]}) {
1715 if (@$target[$T_TYPE] == $TT_DLL) {
1716 push @dll_list,$target;
1718 push @exe_list,$target;
1721 @$project[$P_TARGETS]=[];
1722 push @{@$project[$P_TARGETS]}, @dll_list;
1723 push @{@$project[$P_TARGETS]}, @exe_list;
1725 if (!open(FILEO,">@$project[$P_PATH]Makefile.in")) {
1726 print STDERR "error: could not open \"@$project[$P_PATH]/Makefile.in\" for writing\n";
1727 print STDERR " $!\n";
1731 print FILEO "### Generated by Winemaker\n";
1734 print FILEO "### Generic autoconf variables\n\n";
1735 generate_list("TOPSRCDIR",1,[ "\@top_srcdir\@" ]);
1736 generate_list("TOPOBJDIR",1,[ "." ]);
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 "### Global settings\n\n";
1765 # Make it so that the project-wide settings override the global settings
1766 generate_list("DEFINES",0,@$project_settings[$T_DEFINES]);
1767 generate_list("",1,$global_settings[$T_DEFINES]);
1768 generate_list("INCLUDE_PATH",$no_extra,@$project_settings[$T_INCLUDE_PATH]);
1769 generate_list("",1,$global_settings[$T_INCLUDE_PATH],sub
1771 if ($_[0] !~ /^-I/ or is_absolute($')) {
1774 return "-I\$(TOPSRCDIR)/$'";
1776 generate_list("LIBRARY_PATH",$no_extra,@$project_settings[$T_LIBRARY_PATH]);
1777 generate_list("",1,$global_settings[$T_LIBRARY_PATH],sub
1779 if ($_[0] !~ /^-L/ or is_absolute($')) {
1782 return "-L\$(TOPSRCDIR)/$'";
1784 generate_list("LIBRARIES",$no_extra,@$project_settings[$T_LIBRARIES]);
1785 generate_list("",1,$global_settings[$T_LIBRARIES]);
1788 my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+
1789 @{@$project_settings[$T_SOURCES_CXX]}+
1790 @{@$project_settings[$T_SOURCES_RC]};
1791 my $no_extra=($extra_source_count == 0);
1793 print FILEO "### Extra source lists\n\n";
1794 generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]);
1795 generate_list("EXTRA_CXX_SRCS",1,@$project_settings[$T_SOURCES_CXX]);
1796 generate_list("EXTRA_RC_SRCS",1,@$project_settings[$T_SOURCES_RC]);
1798 generate_list("EXTRA_OBJS",1,["\$(EXTRA_C_SRCS:.c=.o)","\$(EXTRA_CXX_SRCS:.cpp=.o)"]);
1799 print FILEO "\n\n\n";
1802 # Iterate over all the targets...
1803 foreach $target (@{@$project[$P_TARGETS]}) {
1804 print FILEO "### @$target[$T_NAME] sources and settings\n\n";
1805 my $canon=canonize("@$target[$T_NAME]");
1807 generate_list("${canon}_C_SRCS",1,@$target[$T_SOURCES_C]);
1808 generate_list("${canon}_CXX_SRCS",1,@$target[$T_SOURCES_CXX]);
1809 generate_list("${canon}_RC_SRCS",1,@$target[$T_SOURCES_RC]);
1810 my $basename=@$target[$T_NAME];
1811 $basename =~ s+\.so$++;
1812 if (@$target[$T_FLAGS] & $TF_WRAP) {
1813 $basename =~ s+^lib++;
1814 } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) {
1815 $basename.="_wrapper";
1817 generate_list("${canon}_SPEC_SRCS",1,[ "$basename.spec" ]);
1818 generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]);
1819 generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES]);
1820 generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS]);
1822 generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(EXTRA_OBJS)"]);
1823 print FILEO "\n\n\n";
1825 print FILEO "### Global source lists\n\n";
1826 generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub
1828 my $canon=canonize(@{$_[0]}[$T_NAME]);
1830 return "\$(${canon}_C_SRCS)";
1833 generate_list("",1,[ "\$(EXTRA_C_SRCS)" ]);
1835 generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub
1837 my $canon=canonize(@{$_[0]}[$T_NAME]);
1839 return "\$(${canon}_CXX_SRCS)";
1842 generate_list("",1,[ "\$(EXTRA_CXX_SRCS)" ]);
1844 generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub
1846 my $canon=canonize(@{$_[0]}[$T_NAME]);
1848 return "\$(${canon}_RC_SRCS)";
1851 generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]);
1853 generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub
1855 my $canon=canonize(@{$_[0]}[$T_NAME]);
1857 return "\$(${canon}_SPEC_SRCS)";
1860 print FILEO "\n\n\n";
1862 print FILEO "### Generic autoconf targets\n\n";
1864 if (@$project[$P_PATH] eq "") {
1865 print FILEO " \$(SUBDIRS)";
1867 if (@{@$project[$P_TARGETS]} > 0) {
1868 print FILEO " \$(DLLS) \$(EXES:%=%.so)";
1871 print FILEO "\@MAKE_RULES\@\n";
1873 print FILEO "install::\n";
1874 if (@$project[$P_PATH] eq "") {
1875 # This is the main project. It is also responsible for recursively
1876 # calling the other projects
1877 print FILEO "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) install) || exit 1; done\n";
1879 if (@{@$project[$P_TARGETS]} > 0) {
1880 print FILEO "\tfor i in \$(EXES); do \$(INSTALL_PROGRAM) \$\$i \$(bindir); done\n";
1881 print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(INSTALL_PROGRAM) \$\$i \$(libdir); done\n";
1884 print FILEO "uninstall::\n";
1885 if (@$project[$P_PATH] eq "") {
1886 # This is the main project. It is also responsible for recursively
1887 # calling the other projects
1888 print FILEO "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) uninstall) || exit 1; done\n";
1890 if (@{@$project[$P_TARGETS]} > 0) {
1891 print FILEO "\tfor i in \$(EXES); do \$(RM) \$(bindir)/\$\$i;done\n";
1892 print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(RM) \$(libdir)/\$\$i;done\n";
1894 print FILEO "\n\n\n";
1896 if (@{@$project[$P_TARGETS]} > 0) {
1897 print FILEO "### Target specific build rules\n\n";
1898 foreach $target (@{@$project[$P_TARGETS]}) {
1899 my $canon=canonize("@$target[$T_NAME]");
1901 print FILEO "\$(${canon}_SPEC_SRCS:.spec=.tmp.o): \$(${canon}_OBJS)\n";
1902 print FILEO "\t\$(LDCOMBINE) \$(${canon}_OBJS) -o \$\@\n";
1903 print FILEO "\t-\$(STRIP) \$(STRIPFLAGS) \$\@\n";
1905 print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS:.spec) \$(${canon}_SPEC_SRCS:.spec=.tmp.o) \$(${canon}_RC_SRCS:.rc=.res)\n";
1906 print FILEO "\t\$(LD_PATH) \$(WINEBUILD) -fPIC \$(${canon}_LIBRARY_PATH) \$(WINE_LIBRARY_PATH) -sym \$(${canon}_SPEC_SRCS:.spec=.tmp.o) -o \$\@ -spec \$(SRCDIR)/\$(${canon}_SPEC_SRCS)\n";
1908 my $t_name=@$target[$T_NAME];
1909 if (@$target[$T_TYPE]!=$TT_DLL) {
1912 print FILEO "$t_name: \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_OBJS) \$(${canon}_DEPENDS) \n";
1913 if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) {
1914 print FILEO "\t\$(LDXXSHARED)";
1916 print FILEO "\t\$(LDSHARED)";
1918 print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
1919 if (@$target[$T_TYPE] ne $TT_DLL) {
1920 print FILEO "\ttest -e @$target[$T_NAME] || \$(LN_S) \$(WINE) @$target[$T_NAME]\n";
1927 foreach $target (@{@$project[$P_TARGETS]}) {
1928 generate_spec_file(@$project[$P_PATH],$target,$project_settings);
1929 if (@$target[$T_FLAGS] & $TF_WRAPPER) {
1930 generate_wrapper_file(@$project[$P_PATH],$target);
1936 # Perform the replacements in the template configure files
1937 # Return 1 for success, 0 for failure
1938 sub generate_configure
1941 my $a_source_file=$_[1];
1943 if (!defined $templates{$filename}) {
1944 if ($filename ne "configure") {
1945 print STDERR "winemaker: internal error: No template called '$filename'\n";
1950 if (!open(FILEO,">$filename")) {
1951 print STDERR "error: unable to open \"$filename\" for writing:\n";
1952 print STDERR " $!\n";
1955 foreach $line (@{$templates{$filename}}) {
1956 if ($line =~ /^\#\#WINEMAKER_PROJECTS\#\#$/) {
1957 foreach $project (@projects) {
1958 print FILEO "@$project[$P_PATH]Makefile\n";
1961 $line =~ s+\#\#WINEMAKER_SOURCE\#\#+$a_source_file+;
1962 $line =~ s+\#\#WINEMAKER_NEEDS_MFC\#\#+$needs_mfc+;
1970 sub generate_generic
1974 if (!defined $templates{$filename}) {
1975 print STDERR "winemaker: internal error: No template called '$filename'\n";
1978 if (!open(FILEO,">$filename")) {
1979 print STDERR "error: unable to open \"$filename\" for writing:\n";
1980 print STDERR " $!\n";
1983 foreach $line (@{$templates{$filename}}) {
1990 # Generates the global files:
1994 sub generate_global_files
1996 generate_generic("Make.rules.in");
1998 # Get the name of a source file for configure.in
2000 search_a_file: foreach $project (@projects) {
2001 foreach $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) {
2002 $a_source_file=@{@$target[$T_SOURCES_C]}[0];
2003 if (!defined $a_source_file) {
2004 $a_source_file=@{@$target[$T_SOURCES_CXX]}[0];
2006 if (!defined $a_source_file) {
2007 $a_source_file=@{@$target[$T_SOURCES_RC]}[0];
2009 if (defined $a_source_file) {
2010 $a_source_file="@$project[$P_PATH]$a_source_file";
2015 if (!defined $a_source_file) {
2016 $a_source_file="Makefile.in";
2019 generate_configure("configure.in",$a_source_file);
2020 unlink("configure");
2021 if (generate_configure("configure",$a_source_file) == 0) {
2024 # Add execute permission to configure for whoever has the right to read it
2025 my @st=stat("configure");
2028 $mode|=($mode & 0444) >>2;
2029 chmod($mode,"configure");
2031 print "warning: could not generate the configure script. You need to run autoconf\n";
2037 sub generate_read_templates
2042 if (/^--- ((\w\.?)+) ---$/) {
2044 if (defined $templates{$filename}) {
2045 print STDERR "winemaker: internal error: There is more than one template for $filename\n";
2049 $templates{$filename}=$file;
2051 } elsif (defined $file) {
2058 # This is where we finally generate files. In fact this method does not
2059 # do anything itself but calls the methods that do the actual work.
2062 print "Generating project files...\n";
2063 generate_read_templates();
2064 generate_global_files();
2066 foreach $project (@projects) {
2067 my $path=@$project[$P_PATH];
2074 generate_project_files($project);
2087 $opt_lower=$OPT_LOWER_UPPERCASE;
2088 $opt_lower_include=1;
2090 # $opt_work_dir=<undefined>
2091 # $opt_single_target=<undefined>
2092 $opt_target_type=$TT_GUIEXE;
2094 $opt_is_interactive=$OPT_ASK_NO;
2095 $opt_ask_project_options=$OPT_ASK_NO;
2096 $opt_ask_target_options=$OPT_ASK_NO;
2097 $opt_no_generated_files=0;
2110 print "Winemaker $version\n";
2111 print "Copyright 2000 Francois Gouget <fgouget\@codeweavers.com> for CodeWeavers\n";
2117 print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup]\n";
2118 print STDERR " [--lower-none|--lower-all|--lower-uppercase]\n";
2119 print STDERR " [--lower-include|--nolower-include]\n";
2120 print STDERR " [--guiexe|--windows|--cuiexe|--console|--dll]\n";
2121 print STDERR " [--wrap|--nowrap] [--mfc|--nomfc]\n";
2122 print STDERR " [-Dmacro[=defn]] [-Idir] [-Ldir] [-idll] [-llibrary]\n";
2123 print STDERR " [--interactive] [--single-target name]\n";
2124 print STDERR " [--generated-files|--nogenerated-files]\n";
2125 print STDERR " work_directory\n";
2126 print STDERR "\nWinemaker is designed to recursively convert all the Windows sources found in\n";
2127 print STDERR "the specified directory so that they can be compiled with Winelib. During this\n";
2128 print STDERR "process it will modify and rename some of the files in that directory.\n";
2129 print STDERR "\tPlease read the manual page before use.\n";
2134 project_init(\@main_project,"");
2137 my $arg=shift @ARGV;
2139 if ($arg eq "--nobanner") {
2141 } elsif ($arg eq "--backup") {
2143 } elsif ($arg eq "--nobackup") {
2145 } elsif ($arg eq "--single-target") {
2146 $opt_single_target=shift @ARGV;
2147 } elsif ($arg eq "--lower-none") {
2148 $opt_lower=$OPT_LOWER_NONE;
2149 } elsif ($arg eq "--lower-all") {
2150 $opt_lower=$OPT_LOWER_ALL;
2151 } elsif ($arg eq "--lower-uppercase") {
2152 $opt_lower=$OPT_LOWER_UPPERCASE;
2153 } elsif ($arg eq "--lower-include") {
2154 $opt_lower_include=1;
2155 } elsif ($arg eq "--nolower-include") {
2156 $opt_lower_include=0;
2157 } elsif ($arg eq "--generated-files") {
2158 $opt_no_generated_files=0;
2159 } elsif ($arg eq "--nogenerated-files") {
2160 $opt_no_generated_files=1;
2162 } elsif ($arg =~ /^-D/) {
2163 push @{$global_settings[$T_DEFINES]},$arg;
2164 } elsif ($arg =~ /^-I/) {
2165 push @{$global_settings[$T_INCLUDE_PATH]},$arg;
2166 } elsif ($arg =~ /^-L/) {
2167 push @{$global_settings[$T_LIBRARY_PATH]},$arg;
2168 } elsif ($arg =~ /^-i/) {
2169 push @{$global_settings[$T_IMPORTS]},$';
2170 } elsif ($arg =~ /^-l/) {
2171 push @{$global_settings[$T_LIBRARIES]},$';
2173 # 'Source'-based method options
2174 } elsif ($arg eq "--dll") {
2175 $opt_target_type=$TT_DLL;
2176 } elsif ($arg eq "--guiexe" or $arg eq "--windows") {
2177 $opt_target_type=$TT_GUIEXE;
2178 } elsif ($arg eq "--cuiexe" or $arg eq "--console") {
2179 $opt_target_type=$TT_CUIEXE;
2180 } elsif ($arg eq "--interactive") {
2181 $opt_is_interactive=$OPT_ASK_YES;
2182 $opt_ask_project_options=$OPT_ASK_YES;
2183 $opt_ask_target_options=$OPT_ASK_YES;
2184 } elsif ($arg eq "--wrap") {
2185 $opt_flags|=$TF_WRAP;
2186 } elsif ($arg eq "--nowrap") {
2187 $opt_flags&=~$TF_WRAP;
2188 } elsif ($arg eq "--mfc") {
2189 $opt_flags|=$TF_MFC;
2190 $opt_flags|=$TF_MFC|$TF_WRAP;
2192 } elsif ($arg eq "--nomfc") {
2193 $opt_flags&=~($TF_MFC|$TF_WRAP);
2198 if ($arg ne "--help" and $arg ne "-h" and $arg ne "-?") {
2199 if (!defined $opt_work_dir) {
2202 print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n";
2211 if (!defined $opt_work_dir) {
2212 print STDERR "error: you must specify the directory containing the sources to be converted\n";
2214 } elsif (!chdir $opt_work_dir) {
2215 print STDERR "error: could not chdir to the work directory\n";
2216 print STDERR " $!\n";
2220 if ($opt_no_banner == 0) {
2224 # Fix the file and directory names
2225 fix_file_and_directory_names(".");
2227 # Scan the sources to identify the projects and targets
2230 # Create targets for wrappers, etc.
2231 postprocess_targets();
2233 # Fix the source files
2236 # Generate the Makefile and the spec file
2237 if (! $opt_no_generated_files) {
2243 --- configure.in ---
2244 dnl Process this file with autoconf to produce a configure script.
2245 dnl Author: Michael Patra <micky@marie.physik.tu-berlin.de>
2246 dnl <patra@itp1.physik.tu-berlin.de>
2247 dnl Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
2249 AC_REVISION([configure.in 1.00])
2250 AC_INIT(##WINEMAKER_SOURCE##)
2252 NEEDS_MFC=##WINEMAKER_NEEDS_MFC##
2254 dnl **** Command-line arguments ****
2258 dnl **** Check for some programs ****
2266 dnl **** Check for some libraries ****
2268 dnl Check for -lm for BeOS
2269 AC_CHECK_LIB(m,sqrt)
2270 dnl Check for -lw for Solaris
2271 AC_CHECK_LIB(w,iswalnum)
2272 dnl Check for -lnsl for Solaris
2273 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))
2274 dnl Check for -lsocket for Solaris
2275 AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
2277 dnl **** If ln -s doesn't work, use cp instead ****
2278 if test "$ac_cv_prog_LN_S" = "ln -s"; then : ; else LN_S=cp ; fi
2280 dnl **** Check for gcc strength-reduce bug ****
2282 if test "x${GCC}" = "xyes"
2284 AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
2287 static int Array[[3]];
2290 for(i=0; i<B; i++) Array[[i]] = i - 3;
2291 exit( Array[[1]] != -2 );
2293 ac_cv_c_gcc_strength_bug="no",
2294 ac_cv_c_gcc_strength_bug="yes",
2295 ac_cv_c_gcc_strength_bug="yes") )
2296 if test "$ac_cv_c_gcc_strength_bug" = "yes"
2298 CFLAGS="$CFLAGS -fno-strength-reduce"
2302 dnl **** Check for underscore on external symbols ****
2304 AC_CACHE_CHECK("whether external symbols need an underscore prefix",
2305 ac_cv_c_extern_prefix,
2307 LIBS="conftest_asm.s $LIBS"
2308 cat > conftest_asm.s <<EOF
2313 AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
2314 ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
2316 if test "$ac_cv_c_extern_prefix" = "yes"
2318 AC_DEFINE(NEED_UNDERSCORE_PREFIX)
2321 dnl **** Check for working dll ****
2326 AC_CACHE_CHECK("whether we can build a Linux dll",
2328 [saved_cflags=$CFLAGS
2329 CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
2330 AC_TRY_LINK(,[return 1],ac_cv_c_dll_linux="yes",ac_cv_c_dll_linux="no")
2331 CFLAGS=$saved_cflags
2333 if test "$ac_cv_c_dll_linux" = "yes"
2335 LDSHARED="\$(CC) -shared -Wl,-rpath,\$(libdir)"
2336 LDXXSHARED="\$(CXX) -shared -Wl,-rpath,\$(libdir)"
2337 LDDLLFLAGS="-Wl,-Bsymbolic"
2339 AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
2340 ac_cv_c_dll_unixware,
2341 [saved_cflags=$CFLAGS
2342 CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
2343 AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
2344 CFLAGS=$saved_cflags
2346 if test "$ac_cv_c_dll_unixware" = "yes"
2348 LDSHARED="\$(CC) -Wl,-G"
2349 LDXXSHARED="\$(CXX) -Wl,-G"
2350 LDDLLFLAGS="-Wl,-B,symbolic"
2352 AC_CACHE_CHECK("whether we can build a NetBSD dll",
2354 [saved_cflags=$CFLAGS
2355 CFLAGS="$CFLAGS -fPIC -Wl,-Bshareable,-Bforcearchive"
2356 AC_TRY_LINK(,[return 1],ac_cv_c_dll_netbsd="yes",ac_cv_c_dll_netbsd="no")
2357 CFLAGS=$saved_cflags
2359 if test "$ac_cv_c_dll_netbsd" = "yes"
2361 LDSHARED="\$(CC) -Wl,-Bshareable,-Bforcearchive"
2362 LDXXSHARED="\$(CXX) -Wl,-Bshareable,-Bforcearchive"
2363 LDDLLFLAGS="" #FIXME
2367 if test "$ac_cv_c_dll_linux" = "no" -a "$ac_cv_c_dll_unixware" = "no" -a "$ac_cv_c_dll_netbsd" = "no"
2369 AC_MSG_ERROR([Could not find how to build a dynamically linked library])
2372 CFLAGS="$CFLAGS -fPIC"
2373 DLL_LINK="\$(WINE_LIBRARY_PATH) \$(LIBRARY_PATH) \$(LIBRARIES:%=-l%) -lwine -lwine_unicode -lwine_uuid"
2377 AC_SUBST(LDXXSHARED)
2378 AC_SUBST(LDDLLFLAGS)
2380 dnl *** check for the need to define __i386__
2382 AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
2383 AC_EGREP_CPP(yes,[#if (defined(i386) || defined(__i386)) && !defined(__i386__)
2386 ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no"))
2387 if test "$ac_cv_cpp_def_i386" = "yes"
2389 CFLAGS="$CFLAGS -D__i386__"
2392 dnl $GCC is set by autoconf
2394 if test "$GCC" = "yes"
2396 GCC_NO_BUILTIN="-fno-builtin"
2398 AC_SUBST(GCC_NO_BUILTIN)
2400 dnl **** Test Winelib-related features of the C++ compiler
2402 if test "x${GCC}" = "xyes"
2404 OLDCXXFLAGS="$CXXFLAGS";
2405 CXXFLAGS="-fpermissive";
2406 AC_CACHE_CHECK("for g++ -fpermissive option", has_gxx_permissive,
2408 for (int i=0;i<2;i++);
2411 [has_gxx_permissive="yes"],
2412 [has_gxx_permissive="no"])
2414 CXXFLAGS="-fno-for-scope";
2415 AC_CACHE_CHECK("for g++ -fno-for-scope option", has_gxx_no_for_scope,
2417 for (int i=0;i<2;i++);
2420 [has_gxx_no_for_scope="yes"],
2421 [has_gxx_no_for_scope="no"])
2423 CXXFLAGS="$OLDCXXFLAGS";
2424 if test "$has_gxx_permissive" = "yes"
2426 CXXFLAGS="$CXXFLAGS -fpermissive"
2428 if test "$has_gxx_no_for_scope" = "yes"
2430 CXXFLAGS="$CXXFLAGS -fno-for-scope"
2435 dnl **** Test Winelib-related features of the C compiler
2438 dnl **** Macros for finding a headers/libraries in a collection of places
2440 dnl AC_PATH_HEADER(variable,header,action-if-not-found,default-locations)
2441 dnl Note that the above may set variable to an empty value if the header is
2442 dnl already in the include path
2443 AC_DEFUN(AC_PATH_HEADER,[
2444 AC_MSG_CHECKING([for $2])
2445 AC_CACHE_VAL(ac_cv_path_$1,
2448 ac_dummy="ifelse([$4], , :/usr/local/include, [$4])"
2449 save_CPPFLAGS="$CPPFLAGS"
2450 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2451 for ac_dir in $ac_dummy; do
2453 if test -z "$ac_dir"
2455 CPPFLAGS="$save_CPPFLAGS"
2457 CPPFLAGS="-I$ac_dir $save_CPPFLAGS"
2459 AC_TRY_COMPILE([#include <$2>],,ac_found=1;ac_cv_path_$1="$ac_dir";break)
2461 CPPFLAGS="$save_CPPFLAGS"
2462 ifelse([$3],,,[if test -z "$ac_found"
2469 if test -n "$ac_found" -o -n "[$]$1"
2471 AC_MSG_RESULT([$]$1)
2478 dnl AC_PATH_LIBRARY(variable,libraries,extra libs,action-if-not-found,default-locations)
2479 AC_DEFUN(AC_PATH_LIBRARY,[
2480 AC_MSG_CHECKING([for $2])
2481 AC_CACHE_VAL(ac_cv_path_$1,
2484 ac_dummy="ifelse([$5], , :/usr/local/lib, [$5])"
2486 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
2487 for ac_dir in $ac_dummy; do
2489 if test -z "$ac_dir"
2491 LIBS="$2 $3 $save_LIBS"
2493 LIBS="-L$ac_dir $2 $3 $save_LIBS"
2495 AC_TRY_LINK(,,ac_found=1;ac_cv_path_$1="$ac_dir";break)
2498 ifelse([$4],,,[if test -z "$ac_found"
2505 if test -n "$ac_found" -o -n "[$]$1"
2507 AC_MSG_RESULT([$]$1)
2514 dnl **** Try to find where winelib is located ****
2517 WINE_INCLUDE_ROOT="";
2518 WINE_INCLUDE_PATH="";
2519 WINE_LIBRARY_ROOT="";
2520 WINE_LIBRARY_PATH="";
2527 [ --with-wine=DIR the Wine package (or sources) is in DIR],
2528 [if test "$withval" != "no"; then
2529 WINE_ROOT="$withval";
2536 if test -n "$WINE_ROOT"
2538 WINE_INCLUDE_ROOT="$WINE_ROOT/include:$WINE_ROOT/include/wine";
2539 WINE_LIBRARY_ROOT="$WINE_ROOT";
2540 WINE_TOOL_PATH="$WINE_ROOT:$WINE_ROOT/bin:$WINE_ROOT/tools/wrc:$WINE_ROOT/tools/winebuild:$PATH";
2543 AC_ARG_WITH(wine-includes,
2544 [ --with-wine-includes=DIR the Wine includes are in DIR],
2545 [if test "$withval" != "no"; then
2546 WINE_INCLUDES="$withval";
2550 if test -n "$WINE_INCLUDES"
2552 WINE_INCLUDE_ROOT="$WINE_INCLUDES";
2555 AC_ARG_WITH(wine-libraries,
2556 [ --with-wine-libraries=DIR the Wine libraries are in DIR],
2557 [if test "$withval" != "no"; then
2558 WINE_LIBRARIES="$withval";
2562 if test -n "$WINE_LIBRARIES"
2564 WINE_LIBRARY_ROOT="$WINE_LIBRARIES";
2567 AC_ARG_WITH(wine-tools,
2568 [ --with-wine-tools=DIR the Wine tools are in DIR],
2569 [if test "$withval" != "no"; then
2570 WINE_TOOLS="$withval";
2574 if test -n "$WINE_TOOLS"
2576 WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/wrc:$WINE_TOOLS/winebuild";
2579 if test -z "$WINE_INCLUDE_ROOT"
2581 WINE_INCLUDE_ROOT=":/usr/include/wine:/usr/local/include/wine:/opt/wine/include:/opt/wine/include/wine";
2583 AC_PATH_HEADER(WINE_INCLUDE_ROOT,windef.h,[
2584 AC_MSG_ERROR([Could not find the Wine includes])
2585 ],$WINE_INCLUDE_ROOT)
2586 if test -n "$WINE_INCLUDE_ROOT"
2588 WINE_INCLUDE_PATH="-I$WINE_INCLUDE_ROOT"
2590 WINE_INCLUDE_PATH=""
2593 if test -z "$WINE_LIBRARY_ROOT"
2595 WINE_LIBRARY_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib";
2597 WINE_LIBRARY_ROOT="$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/lib";
2599 AC_PATH_LIBRARY(WINE_LIBRARY_ROOT,[-lwine],[-lutil],[
2600 AC_MSG_ERROR([Could not find the Wine libraries (libwine.so)])
2601 ],$WINE_LIBRARY_ROOT)
2602 if test -n "$WINE_LIBRARY_ROOT"
2604 WINE_LIBRARY_PATH="-L$WINE_LIBRARY_ROOT"
2606 WINE_LIBRARY_PATH=""
2608 AC_PATH_LIBRARY(LIBNTDLL_PATH,[-lntdll],[$WINE_LIBRARY_PATH -lwine -lwine_unicode -lncurses -ldl -lutil],[
2609 AC_MSG_ERROR([Could not find the Wine libraries (libntdll.so)])
2610 ],[$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/dlls])
2611 if test -n "$LIBNTDLL_PATH" -a "-L$LIBNTDLL_PATH" != "$WINE_LIBRARY_PATH"
2613 WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$LIBNTDLL_PATH"
2615 if test -n "$WINE_LIBRARY_PATH"
2617 LD_PATH="LD_LIBRARY_PATH=\"`echo $WINE_LIBRARY_PATH | sed -e 's/ *-L/:/g' -e 's/^://' -e 's/ *$//'`:\$\$LD_LIBRARY_PATH\""
2620 if test -z "$WINE_TOOL_PATH"
2622 WINE_TOOL_PATH="$PATH:/usr/local/bin:/opt/wine/bin";
2624 AC_PATH_PROG(WINE,wine,,$WINE_TOOL_PATH)
2627 AC_MSG_ERROR([Could not find Wine's wine tool])
2629 AC_PATH_PROG(WINEBUILD,winebuild,,$WINE_TOOL_PATH)
2630 if test -z "$WINEBUILD"
2632 AC_MSG_ERROR([Could not find Wine's winebuild tool])
2634 AC_PATH_PROG(WRC,wrc,,$WINE_TOOL_PATH)
2637 AC_MSG_ERROR([Could not find Wine's wrc tool])
2641 AC_SUBST(WINE_INCLUDE_PATH)
2642 AC_SUBST(WINE_LIBRARY_PATH)
2644 dnl **** Try to find where the MFC are located ****
2647 if test "x$NEEDS_MFC" = "x1"
2649 ATL_INCLUDE_ROOT="";
2650 ATL_INCLUDE_PATH="";
2651 MFC_INCLUDE_ROOT="";
2652 MFC_INCLUDE_PATH="";
2653 MFC_LIBRARY_ROOT="";
2654 MFC_LIBRARY_PATH="";
2657 [ --with-mfc=DIR the MFC package (or sources) is in DIR],
2658 [if test "$withval" != "no"; then
2659 MFC_ROOT="$withval";
2666 if test -n "$MFC_ROOT"
2668 ATL_INCLUDE_ROOT="$MFC_ROOT";
2669 MFC_INCLUDE_ROOT="$MFC_ROOT";
2670 MFC_LIBRARY_ROOT="$MFC_ROOT";
2673 AC_ARG_WITH(atl-includes,
2674 [ --with-atl-includes=DIR the ATL includes are in DIR],
2675 [if test "$withval" != "no"; then
2676 ATL_INCLUDES="$withval";
2680 if test -n "$ATL_INCLUDES"
2682 ATL_INCLUDE_ROOT="$ATL_INCLUDES";
2685 AC_ARG_WITH(mfc-includes,
2686 [ --with-mfc-includes=DIR the MFC includes are in DIR],
2687 [if test "$withval" != "no"; then
2688 MFC_INCLUDES="$withval";
2692 if test -n "$MFC_INCLUDES"
2694 MFC_INCLUDE_ROOT="$MFC_INCLUDES";
2697 AC_ARG_WITH(mfc-libraries,
2698 [ --with-mfc-libraries=DIR the MFC libraries are in DIR],
2699 [if test "$withval" != "no"; then
2700 MFC_LIBRARIES="$withval";
2704 if test -n "$MFC_LIBRARIES"
2706 MFC_LIBRARY_ROOT="$MFC_LIBRARIES";
2709 OLDCPPFLAGS="$CPPFLAGS"
2710 dnl FIXME: We should not have defines in any of the include paths
2711 CPPFLAGS="$WINE_INCLUDE_PATH -I$WINE_INCLUDE_ROOT/mixedcrt -D_DLL -D_MT $CPPFLAGS"
2712 ATL_INCLUDE_PATH="-I\$(WINE_INCLUDE_ROOT)/mixedcrt -D_DLL -D_MT"
2713 if test -z "$ATL_INCLUDE_ROOT"
2715 ATL_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/atl:/usr/include/atl:/usr/local/include/atl:/opt/mfc/include/atl:/opt/atl/include"
2717 ATL_INCLUDE_ROOT="$ATL_INCLUDE_ROOT:$ATL_INCLUDE_ROOT/atl:$ATL_INCLUDE_ROOT/atl/include"
2719 AC_PATH_HEADER(ATL_INCLUDE_ROOT,atldef.h,[
2720 AC_MSG_ERROR([Could not find the ATL includes])
2721 ],$ATL_INCLUDE_ROOT)
2722 if test -n "$ATL_INCLUDE_ROOT"
2724 ATL_INCLUDE_PATH="$ATL_INCLUDE_PATH -I$ATL_INCLUDE_ROOT"
2727 MFC_INCLUDE_PATH="$ATL_INCLUDE_PATH"
2728 if test -z "$MFC_INCLUDE_ROOT"
2730 MFC_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/mfc:/usr/include/mfc:/usr/local/include/mfc:/opt/mfc/include/mfc:/opt/mfc/include"
2732 MFC_INCLUDE_ROOT="$MFC_INCLUDE_ROOT:$MFC_INCLUDE_ROOT/mfc:$MFC_INCLUDE_ROOT/mfc/include"
2734 AC_PATH_HEADER(MFC_INCLUDE_ROOT,afx.h,[
2735 AC_MSG_ERROR([Could not find the MFC includes])
2736 ],$MFC_INCLUDE_ROOT)
2737 if test -n "$MFC_INCLUDE_ROOT" -a "$ATL_INCLUDE_ROOT" != "$MFC_INCLUDE_ROOT"
2739 MFC_INCLUDE_PATH="$MFC_INCLUDE_PATH -I$MFC_INCLUDE_ROOT"
2741 CPPFLAGS="$OLDCPPFLAGS"
2743 if test -z "$MFC_LIBRARY_ROOT"
2745 MFC_LIBRARY_ROOT=":$WINE_LIBRARY_ROOT:/usr/lib/mfc:/usr/local/lib:/usr/local/lib/mfc:/opt/mfc/lib";
2747 MFC_LIBRARY_ROOT="$MFC_LIBRARY_ROOT:$MFC_LIBRARY_ROOT/lib:$MFC_LIBRARY_ROOT/mfc/src";
2749 AC_PATH_LIBRARY(MFC_LIBRARY_ROOT,[-lmfc],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[
2750 AC_MSG_ERROR([Could not find the MFC library])
2751 ],$MFC_LIBRARY_ROOT)
2752 if test -n "$MFC_LIBRARY_ROOT" -a "$MFC_LIBRARY_ROOT" != "$WINE_LIBRARY_ROOT"
2754 MFC_LIBRARY_PATH="-L$MFC_LIBRARY_ROOT"
2759 AC_SUBST(ATL_INCLUDE_PATH)
2760 AC_SUBST(MFC_INCLUDE_PATH)
2761 AC_SUBST(MFC_LIBRARY_PATH)
2766 dnl **** Generate output files ****
2768 MAKE_RULES=Make.rules
2769 AC_SUBST_FILE(MAKE_RULES)
2773 ##WINEMAKER_PROJECTS##
2777 echo "Configure finished. Do 'make' to build the project."
2780 dnl Local Variables:
2781 dnl comment-start: "dnl "
2783 dnl comment-start-skip: "\\bdnl\\b\\s *"
2784 dnl compile-command: "autoconf"
2786 --- Make.rules.in ---
2787 # Copyright 2000 Francois Gouget for CodeWeavers
2788 # fgouget@codeweavers.com
2790 # Global rules shared by all makefiles -*-Makefile-*-
2792 # Each individual makefile must define the following variables:
2793 # TOPOBJDIR : top-level object directory
2794 # SRCDIR : source directory for this module
2796 # Each individual makefile may define the following additional variables:
2798 # SUBDIRS : subdirectories that contain a Makefile
2799 # DLLS : WineLib libraries to be built
2800 # EXES : WineLib executables to be built
2802 # CEXTRA : extra c flags (e.g. '-Wall')
2803 # CXXEXTRA : extra c++ flags (e.g. '-Wall')
2804 # WRCEXTRA : extra wrc flags (e.g. '-p _SysRes')
2805 # DEFINES : defines (e.g. -DSTRICT)
2806 # INCLUDE_PATH : additional include path
2807 # LIBRARY_PATH : additional library path
2808 # LIBRARIES : additional Unix libraries to link with
2810 # C_SRCS : C sources for the module
2811 # CXX_SRCS : C++ sources for the module
2812 # RC_SRCS : resource source files
2813 # SPEC_SRCS : interface definition files
2818 WINE_INCLUDE_ROOT = @WINE_INCLUDE_ROOT@
2819 WINE_INCLUDE_PATH = @WINE_INCLUDE_PATH@
2820 WINE_LIBRARY_ROOT = @WINE_LIBRARY_ROOT@
2821 WINE_LIBRARY_PATH = @WINE_LIBRARY_PATH@
2827 ATL_INCLUDE_ROOT = @ATL_INCLUDE_ROOT@
2828 ATL_INCLUDE_PATH = @ATL_INCLUDE_PATH@
2829 MFC_INCLUDE_ROOT = @MFC_INCLUDE_ROOT@
2830 MFC_INCLUDE_PATH = @MFC_INCLUDE_PATH@
2831 MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@
2832 MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@
2834 # First some useful definitions
2842 CXXFLAGS = @CXXFLAGS@
2844 OPTIONS = @OPTIONS@ -D_REENTRANT -DWINELIB
2845 DLL_LINK = @DLL_LINK@
2846 LIBS = @LIBS@ $(LIBRARY_PATH)
2848 ALLFLAGS = $(DEFINES) -I$(SRCDIR) $(WINE_INCLUDE_PATH) $(INCLUDE_PATH)
2849 ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
2850 ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
2851 ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS)
2853 LDSHARED = @LDSHARED@
2854 LDXXSHARED= @LDXXSHARED@
2855 LDDLLFLAGS= @LDDLLFLAGS@
2857 STRIPFLAGS= --strip-unneeded
2862 WINEBUILD = @WINEBUILD@
2865 # Installation infos
2868 INSTALL_PROGRAM = $(INSTALL)
2869 INSTALL_DATA = $(INSTALL) -m 644
2871 exec_prefix = @exec_prefix@
2879 OBJS = $(C_SRCS:.c=.o) $(CXX_SRCS:.cpp=.o) \
2880 $(SPEC_SRCS:.spec=.spec.o)
2881 CLEAN_FILES = *.spec.c y.tab.c y.tab.h lex.yy.c \
2883 \\\#*\\\# *~ *% .\\\#*
2887 .SUFFIXES: .cpp .rc .res .tmp.o .spec .spec.c .spec.o
2890 $(CC) -c $(ALLCFLAGS) -o $@ $<
2893 $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
2896 $(CXX) -c $(ALLCXXFLAGS) -o $@ $<
2899 $(LD_PATH) $(WRC) $(ALLWRCFLAGS) -o $@ $<
2901 .PHONY: all install uninstall clean distclean depend dummy
2903 # 'all' target first in case the enclosing Makefile didn't define any target
2907 # Rules for makefile
2909 Makefile: Makefile.in $(TOPSRCDIR)/configure
2910 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
2913 # Rules for cleaning
2915 $(SUBDIRS:%=%/__clean__): dummy
2916 cd `dirname $@` && $(MAKE) clean
2918 $(EXTRASUBDIRS:%=%/__clean__): dummy
2919 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
2921 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
2922 $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(OBJS) $(SPEC_SRCS:.spec=.tmp.o) $(EXES) $(EXES:%=%.so) $(DLLS)
2924 # Rules for installing
2926 $(SUBDIRS:%=%/__install__): dummy
2927 cd `dirname $@` && $(MAKE) install
2929 $(SUBDIRS:%=%/__uninstall__): dummy
2930 cd `dirname $@` && $(MAKE) uninstall
2939 # End of global rules
2942 * Copyright 2000 Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
2946 #include <windows.h>
2951 * Describe the wrapped application
2955 * This is either CUIEXE for a console based application or
2956 * GUIEXE for a regular windows application.
2958 #define APP_TYPE ##WINEMAKER_APP_TYPE##
2961 * This is the application library's base name, i.e. 'hello' if the
2962 * library is called 'libhello.so'.
2964 static char* appName = ##WINEMAKER_APP_NAME##;
2967 * This is the name of the application's Windows module. If left NULL
2968 * then appName is used.
2970 static char* appModule = NULL;
2973 * This is the application's entry point. This is usually "WinMain" for a
2974 * GUIEXE and 'main' for a CUIEXE application.
2976 static char* appInit = ##WINEMAKER_APP_INIT##;
2979 * This is either non-NULL for MFC-based applications and is the name of the
2980 * MFC's module. This is the module in which we will take the 'WinMain'
2983 static char* mfcModule = ##WINEMAKER_APP_MFC##;
2988 * Implement the main.
2991 #if APP_TYPE == GUIEXE
2992 typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance,
2993 PSTR szCmdLine, int iCmdShow);
2995 typedef int WINAPI (*MainFunc)(int argc, char** argv, char** envp);
2998 #if APP_TYPE == GUIEXE
2999 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
3000 PSTR szCmdLine, int iCmdShow)
3002 int WINAPI Main(int argc, char** argv, char** envp)
3006 HINSTANCE hApp,hMFC,hMain;
3011 /* Load the application's library */
3012 libName=(char*)malloc(strlen(appName)+5+3+1);
3013 /* FIXME: we should get the wrapper's path and use that as the base for
3016 sprintf(libName,"./lib%s.so",appName);
3017 appLibrary=dlopen(libName,RTLD_NOW);
3018 if (appLibrary==NULL) {
3019 sprintf(libName,"lib%s.so",appName);
3020 appLibrary=dlopen(libName,RTLD_NOW);
3022 if (appLibrary==NULL) {
3023 char format[]="Could not load the %s library:\r\n%s";
3028 msg=(char*)malloc(strlen(format)+strlen(libName)+strlen(error));
3029 sprintf(msg,format,libName,error);
3030 MessageBox(NULL,msg,"dlopen error",MB_OK);
3035 /* Then if this application is MFC based, load the MFC module */
3036 /* FIXME: I'm not sure this is really necessary */
3037 if (mfcModule!=NULL) {
3038 hMFC=LoadLibrary(mfcModule);
3040 char format[]="Could not load the MFC module %s (%d)";
3043 msg=(char*)malloc(strlen(format)+strlen(mfcModule)+11);
3044 sprintf(msg,format,mfcModule,GetLastError());
3045 MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
3049 /* MFC is a special case: the WinMain is in the MFC library,
3050 * instead of the application's library.
3057 /* Load the application's module */
3058 if (appModule==NULL) {
3061 hApp=LoadLibrary(appModule);
3063 char format[]="Could not load the application's module %s (%d)";
3066 msg=(char*)malloc(strlen(format)+strlen(appModule)+11);
3067 sprintf(msg,format,appModule,GetLastError());
3068 MessageBox(NULL,msg,"LoadLibrary error",MB_OK);
3071 } else if (hMain==NULL) {
3075 /* Get the address of the application's entry point */
3076 appMain=(WinMainFunc*)GetProcAddress(hMain, appInit);
3077 if (appMain==NULL) {
3078 char format[]="Could not get the address of %s (%d)";
3081 msg=(char*)malloc(strlen(format)+strlen(appInit)+11);
3082 sprintf(msg,format,appInit,GetLastError());
3083 MessageBox(NULL,msg,"GetProcAddress error",MB_OK);
3088 /* And finally invoke the application's entry point */
3089 #if APP_TYPE == GUIEXE
3090 retcode=(*((WinMainFunc)appMain))(hApp,hPrevInstance,szCmdLine,iCmdShow);
3092 retcode=(*((MainFunc)appMain))(argc,argv,envp);
3095 /* Cleanup and done */
3100 dlclose(appLibrary);