# Copyright 2000 Francois Gouget for CodeWeavers
# fgouget@codeweavers.com
#
-my $version="0.5.5";
+my $version="0.5.7";
use Cwd;
use File::Basename;
push @{@$target[$T_LIBRARIES]},$';
} elsif (@$target[$T_TYPE] != $TT_DLL and
$option =~ /^--wrap/) {
- print STDERR "warning: --wrap no longer supported, ignoring\n";
- #@$target[$T_FLAGS]|=$TF_WRAP;
+ @$target[$T_FLAGS]|=$TF_WRAP;
} elsif (@$target[$T_TYPE] != $TT_DLL and
$option =~ /^--nowrap/) {
@$target[$T_FLAGS]&=~$TF_WRAP;
} elsif ($option =~ /^--mfc/) {
@$target[$T_FLAGS]|=$TF_MFC;
- #if (@$target[$T_TYPE] != $TT_DLL) {
- # @$target[$T_FLAGS]|=$TF_WRAP;
- #}
+ if (@$target[$T_TYPE] != $TT_DLL) {
+ @$target[$T_FLAGS]|=$TF_WRAP;
+ }
} elsif ($option =~ /^--nomfc/) {
@$target[$T_FLAGS]&=~$TF_MFC;
- #@$target[$T_FLAGS]&=~($TF_MFC|$TF_WRAP);
+ @$target[$T_FLAGS]&=~($TF_MFC|$TF_WRAP);
} else {
print STDERR "error: unknown option \"$option\"\n";
return 0;
# the name of this directory, including a trailing '/', or an empty
# string if this is the top level directory
my $dirname=$_[2];
+ # if set then no targets will be looked for and the sources will all
+ # end up in the parent_project's 'misc' bucket
+ my $no_target=$_[3];
# reference to the project for this directory. May not be used
my $project;
} elsif ($dentry =~ /^include/i) {
# This directory must contain headers we're going to need
push @{@$project_settings[$T_INCLUDE_PATH]},"-I$dentry";
+ source_scan_directory($project,"$fullentry/","$dentry/",1);
} else {
# Recursively scan this directory. Any source file that cannot be
- # attributed to a project in one of the subdirectories will be attributed
- # to this project.
- source_scan_directory($project,"$fullentry/","$dentry/");
+ # attributed to a project in one of the subdirectories will be
+ # attributed to this project.
+ source_scan_directory($project,"$fullentry/","$dentry/",$no_target);
}
} elsif (-f "$fullentry") {
if ($dentry =~ s/\.exe$//i) {
}
} elsif ($dentry =~ /\.rc$/i) {
push @sources_rc,"$dentry";
- } elsif ($dentry =~ /\.(h|hxx|inl|rc2|dlg)$/i) {
+ } elsif ($dentry =~ /\.(h|hxx|hpp|inl|rc2|dlg)$/i) {
push @sources_misc,"$dentry";
if ($dentry =~ /^stdafx.h$/i) {
@$project_settings[$T_FLAGS]|=$TF_MFC;
push @{@$target[$T_SOURCES_MISC]},map "$path$_",@sources_misc;
return;
}
+ if ($no_target) {
+ my $parent_settings=@$parent_project[$P_SETTINGS];
+ push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_c;
+ push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_cxx;
+ push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_rc;
+ push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
+ push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
+ return;
+ }
my $source_count=@sources_c+@sources_cxx+@sources_rc+
@{@$project_settings[$T_SOURCES_C]}+
if ($source_count == 0) {
# A project without real sources is not a project, get out!
if ($project!=$parent_project) {
- $parent_settings=@$parent_project[$P_SETTINGS];
+ my $parent_settings=@$parent_project[$P_SETTINGS];
push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc;
push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]};
}
# This is the default link list of Visual Studio, except odbccp32
# which we don't have in Wine. Also I add ntdll which seems
# necessary for Winelib.
- my @std_imports=qw(advapi32.dll comdlg32.dll gdi32.dll kernel32.dll ntdll.dll odbc32.dll ole32 oleaut32.dll shell32.dll user32.dll winspool.drv);
+ 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);
@$target[$T_IMPORTS]=\@std_imports;
push @{@$project[$P_TARGETS]},$target;
# Now scan the directory tree looking for source files and, maybe, targets
print "Scanning the source directories...\n";
- source_scan_directory(\@main_project,"","");
+ source_scan_directory(\@main_project,"","",0);
@projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects;
}
@$wrapper[$T_TYPE]=@$target[$T_TYPE];
@$wrapper[$T_INIT]=get_default_init(@$target[$T_TYPE]);
@$wrapper[$T_FLAGS]=$TF_WRAPPER | (@$target[$T_FLAGS] & $TF_MFC);
+ @$wrapper[$T_IMPORTS]=[ "kernel32.dll", "ntdll.dll", "user32.dll" ];
push @{@$wrapper[$T_SOURCES_C]},"@$wrapper[$T_NAME]_wrapper.c";
my $index=bsearch(@$target[$T_SOURCES_C],"@$wrapper[$T_NAME]_wrapper.c");
$dirname=dirname($dirname) . "/";
$real_path.="../";
} else {
+ # The file/directory may have been renamed before. Also try to
+ # match the renamed file.
+ my $renamed=$component;
+ $renamed =~ s/[ \$]/_/g;
+ if ($renamed eq $component) {
+ undef $renamed;
+ }
+
my $directory=get_directory_contents $dirname;
my $found;
foreach $dentry (@$directory) {
- if ($dentry =~ /^$component$/i) {
+ if ($dentry =~ /^$component$/i or
+ (defined $renamed and $dentry =~ /^$renamed$/i)
+ ) {
$dirname.="$dentry/";
$real_path.="$dentry/";
$found=1;
if (!is_absolute($dirname)) {
$dirname="@$project[$P_PATH]$dirname";
} else {
- $dirname=~ s+^\$\(TOPSRCDIR\)/++;
+ $dirname=~ s+^\$\(TOPSRCDIR\)/++;
+ $dirname=~ s+^\$\(SRCDIR\)/+@$project[$P_PATH]+;
}
#print " in $dirname\n";
$real_filename=search_from("$dirname",\@file_components);
my $dirname=$include;
$dirname=~ s+^-I++;
$dirname=~ s+^\$\(TOPSRCDIR\)\/++;
+ $dirname=~ s+^\$\(SRCDIR\)\/+@$project[$P_PATH]+;
#print " in $dirname (global setting)\n";
$real_filename=search_from("$dirname",\@file_components);
if (defined $real_filename) {
return $filename;
}
+sub print_pack
+{
+ my $indent=$_[0];
+ my $size=$_[1];
+ my $trailer=$_[2];
+
+ if ($size =~ /^(1|2|4|8)$/) {
+ print FILEO "$indent#include <pshpack$size.h>$trailer";
+ } else {
+ print FILEO "$indent/* winemaker:warning: Unknown size \"$size\". Defaulting to 4 */\n";
+ print FILEO "$indent#include <pshpack4.h>$trailer";
+ }
+}
+
##
# 'Parses' a source file and fixes constructs that would not work with
# Winelib. The parsing is rather simple and not all non-portable features
my $modified=0;
my $rc_block_depth=0;
my $rc_textinclude_state=0;
+ my @pack_stack;
while (<FILEI>) {
+ # Remove any trailing CtrlZ, which isn't strictly in the file
+ if (/\x1A/) {
+ s/\x1A//;
+ last if (/^$/)
+ }
$line++;
- $_ =~ s/\r\n$/\n/;
- if ($is_rc and !$is_mfc and /^(\s*\#\s*include\s*)\"afxres\.h\"/) {
+ s/\r\n$/\n/;
+ if (!/\n$/) {
+ # Make sure all files are '\n' terminated
+ $_ .= "\n";
+ }
+ if ($is_rc and !$is_mfc and /^(\s*)(\#\s*include\s*)\"afxres\.h\"/) {
# VC6 automatically includes 'afxres.h', an MFC specific header, in
# the RC files it generates (even in non-MFC projects). So we replace
# it with 'winres.h' its very close standard cousin so that non MFC
- # projects can compile in Wine without the MFC sources. This does not
- # harm VC but it will put 'afxres.h' back the next time the file is
- # edited.
+ # projects can compile in Wine without the MFC sources.
my $warning="mfc:afxres.h";
if (!defined $warnings{$warning}) {
$warnings{$warning}="1";
print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winres.h'\n";
print STDERR "warning: the above warning is issued only once\n";
}
- print FILEO "/* winemaker: $1\"afxres.h\" */\n";
- print FILEO "$1\"winres.h\"$'";
+ print FILEO "$1/* winemaker: $2\"afxres.h\" */\n";
+ print FILEO "$1/* winemaker:warning: 'afxres.h' is an MFC specific header. Replacing it with 'winres.h' */\n";
+ print FILEO "$1$2\"winres.h\"$'";
$modified=1;
+
} elsif (/^(\s*\#\s*include\s*)([\"<])([^\"]+)([\">])/) {
my $from_file=($2 eq "<"?"":$dirname);
my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
print FILEO "$1$2$real_include_name$4$'";
$modified|=($real_include_name ne $3);
- } elsif (/^(\s*\#\s*pragma\s*pack\s*\((\s*push\s*,?)?\s*)(\w*)(\s*\))/) {
- my $pragma_header=$1;
- my $size=$3;
- my $pragma_trailer=$4;
- #print "$pragma_header$size$pragma_trailer$'";
- #print "pragma push: size=$size\n";
- print FILEO "/* winemaker: $pragma_header$size$pragma_trailer */\n";
- $line++;
- if ($size eq "pop") {
- print FILEO "#include <poppack.h>$'";
- } elsif ($size eq "1") {
- print FILEO "#include <pshpack1.h>$'";
- } elsif ($size eq "2") {
- print FILEO "#include <pshpack2.h>$'";
- } elsif ($size eq "8") {
- print FILEO "#include <pshpack8.h>$'";
- } elsif ($size eq "4" or $size eq "") {
- print FILEO "#include <pshpack4.h>$'";
+
+ } elsif (s/^(\s*)(\#\s*pragma\s+pack\s*\(\s*)//) {
+ # Pragma pack handling
+ #
+ # pack_stack is an array of references describing the stack of
+ # pack directives currently in effect. Each directive if described
+ # by a reference to an array containing:
+ # - "push" for pack(push,...) directives, "" otherwise
+ # - the directive's identifier at index 1
+ # - the directive's alignement value at index 2
+ #
+ # Don't believe a word of what the documentation says: it's all wrong.
+ # The code below is based on the actual behavior of Visual C/C++ 6.
+ my $pack_indent=$1;
+ my $pack_header=$2;
+ if (/^(\))/) {
+ # pragma pack()
+ # Pushes the default stack alignment
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
+ print_pack($pack_indent,4,$');
+ push @pack_stack, [ "", "", 4 ];
+
+ } elsif (/^(pop\s*(,\s*\d+\s*)?\))/) {
+ # pragma pack(pop)
+ # pragma pack(pop,n)
+ # Goes up the stack until it finds a pack(push,...), and pops it
+ # Ignores any pack(n) entry
+ # Issues a warning if the pack is of the form pack(push,label)
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ my $pack_comment=$';
+ $pack_comment =~ s/^\s*//;
+ if ($pack_comment ne "") {
+ print FILEO "$pack_indent$pack_comment";
+ }
+ while (1) {
+ my $alignment=pop @pack_stack;
+ if (!defined $alignment) {
+ print FILEO "$pack_indent/* winemaker:warning: No pack(push,...) found. All the stack has been popped */\n";
+ last;
+ }
+ if (@$alignment[1]) {
+ print FILEO "$pack_indent/* winemaker:warning: Anonymous pop of pack(push,@$alignment[1]) (@$alignment[2]) */\n";
+ }
+ print FILEO "$pack_indent#include <poppack.h>\n";
+ if (@$alignment[0]) {
+ last;
+ }
+ }
+
+ } elsif (/^(pop\s*,\s*(\w+)\s*(,\s*\d+\s*)?\))/) {
+ # pragma pack(pop,label[,n])
+ # Goes up the stack until finding a pack(push,...) and pops it.
+ # 'n', if specified, is ignored.
+ # Ignores any pack(n) entry
+ # Issues a warning if the label of the pack does not match,
+ # or if it is in fact a pack(push,n)
+ my $label=$2;
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ my $pack_comment=$';
+ $pack_comment =~ s/^\s*//;
+ if ($pack_comment ne "") {
+ print FILEO "$pack_indent$pack_comment";
+ }
+ while (1) {
+ my $alignment=pop @pack_stack;
+ if (!defined $alignment) {
+ print FILEO "$pack_indent/* winemaker:warning: No pack(push,$label) found. All the stack has been popped */\n";
+ last;
+ }
+ if (@$alignment[1] and @$alignment[1] ne $label) {
+ print FILEO "$pack_indent/* winemaker:warning: Push/pop mismatch: \"@$alignment[1]\" (@$alignment[2]) != \"$label\" */\n";
+ }
+ print FILEO "$pack_indent#include <poppack.h>\n";
+ if (@$alignment[0]) {
+ last;
+ }
+ }
+
+ } elsif (/^(push\s*\))/) {
+ # pragma pack(push)
+ # Push the current alignment
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ if (@pack_stack > 0) {
+ my $alignment=$pack_stack[$#pack_stack];
+ print_pack($pack_indent,@$alignment[2],$');
+ push @pack_stack, [ "push", "", @$alignment[2] ];
+ } else {
+ print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
+ print_pack($pack_indent,4,$');
+ push @pack_stack, [ "push", "", 4 ];
+ }
+
+ } elsif (/^((push\s*,\s*)?(\d+)\s*\))/) {
+ # pragma pack([push,]n)
+ # Push new alignment n
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ print_pack($pack_indent,$3,"$'");
+ push @pack_stack, [ ($2 ? "push" : ""), "", $3 ];
+
+ } elsif (/^((\w+)\s*\))/) {
+ # pragma pack(label)
+ # label must in fact be a macro that resolves to an integer
+ # Then behaves like 'pragma pack(n)'
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ print FILEO "$pack_indent/* winemaker:warning: Assuming $2 == 4 */\n";
+ print_pack($pack_indent,4,$');
+ push @pack_stack, [ "", "", 4 ];
+
+ } elsif (/^(push\s*,\s*(\w+)\s*(,\s*(\d+)\s*)?\))/) {
+ # pragma pack(push,label[,n])
+ # Pushes a new label on the stack. It is possible to push the same
+ # label multiple times. If 'n' is omitted then the alignment is
+ # unchanged. Otherwise it becomes 'n'.
+ print FILEO "$pack_indent/* winemaker: $pack_header$1 */\n";
+ my $size;
+ if (defined $4) {
+ $size=$4;
+ } elsif (@pack_stack > 0) {
+ my $alignment=$pack_stack[$#pack_stack];
+ $size=@$alignment[2];
+ } else {
+ print FILEO "$pack_indent/* winemaker:warning: Using 4 as the default alignment */\n";
+ $size=4;
+ }
+ print_pack($pack_indent,$size,$');
+ push @pack_stack, [ "push", $2, $size ];
+
} else {
- my $warning="pack:$size";
- if (!defined $warnings{$warning}) {
- $warnings{$warning}="1";
- print STDERR "warning: assuming that the value of $size is 4 in\n";
- print STDERR "$line: $pragma_header$size$pragma_trailer\n";
- print STDERR "warning: the above warning is issued only once\n";
- }
- print FILEO "#include <pshpack4.h>$'";
- $modified=1;
+ # pragma pack(??? -> What's that?
+ print FILEO "$pack_indent/* winemaker:warning: Unknown type of pragma pack directive */\n";
+ print FILEO "$pack_indent$pack_header$_";
+
}
+ $modified=1;
+
} elsif ($is_rc) {
- if ($rc_block_depth == 0 and /^(\w+\s+(BITMAP|CURSOR|FONT|FONTDIR|ICON|MESSAGETABLE|TEXT)\s+((DISCARDABLE|FIXED|IMPURE|LOADONCALL|MOVEABLE|PRELOAD|PURE)\s+)*)([\"<]?)([^\">\r\n]+)([\">]?)/) {
+ 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]+)([\">]?)/) {
my $from_file=($5 eq "<"?"":$dirname);
my $real_include_name=get_real_include_name($line,$6,$from_file,$project,$target);
print FILEO "$1$5$real_include_name$7$'";
$modified|=($real_include_name ne $6);
+
} elsif (/^(\s*RCINCLUDE\s*)([\"<]?)([^\">\r\n]+)([\">]?)/) {
my $from_file=($2 eq "<"?"":$dirname);
my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target);
print FILEO "$1$2$real_include_name$4$'";
$modified|=($real_include_name ne $3);
+
} elsif ($is_rc and !$is_mfc and $rc_block_depth == 0 and /^\s*\d+\s+TEXTINCLUDE\s*/) {
$rc_textinclude_state=1;
print FILEO;
+
} elsif ($rc_textinclude_state == 3 and /^(\s*\"\#\s*include\s*\"\")afxres\.h(\"\"\\r\\n\")/) {
print FILEO "$1winres.h$2$'";
$modified=1;
+
} elsif (/^\s*BEGIN(\W.*)?$/) {
$rc_textinclude_state|=2;
$rc_block_depth++;
print FILEO;
+
} elsif (/^\s*END(\W.*)?$/) {
$rc_textinclude_state=0;
if ($rc_block_depth>0) {
$rc_block_depth--;
}
print FILEO;
+
} else {
print FILEO;
}
+
} else {
print FILEO;
}
}
+
close(FILEI);
close(FILEO);
if ($opt_backup == 0 or $modified == 0) {
}
my $rcname=@{@$target[$T_SOURCES_RC]}[0];
$rcname =~ s+\.rc$++i;
+ $rcname =~ s+([^/\w])+\\$1+g;
print FILEO "rsrc $rcname.res\n";
}
print FILEO "\n";
my $app_init=(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"");
my $app_mfc=(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":NULL);
foreach $line (@{$templates{"wrapper.c"}}) {
- $line =~ s/\#\#WINEMAKER_APP_NAME\#\#/$app_name/;
- $line =~ s/\#\#WINEMAKER_APP_TYPE\#\#/$app_type/;
- $line =~ s/\#\#WINEMAKER_APP_INIT\#\#/$app_init/;
- $line =~ s/\#\#WINEMAKER_APP_MFC\#\#/$app_mfc/;
- print FILEO $line;
+ my $l=$line;
+ $l =~ s/\#\#WINEMAKER_APP_NAME\#\#/$app_name/;
+ $l =~ s/\#\#WINEMAKER_APP_TYPE\#\#/$app_type/;
+ $l =~ s/\#\#WINEMAKER_APP_INIT\#\#/$app_init/;
+ $l =~ s/\#\#WINEMAKER_APP_MFC\#\#/$app_mfc/;
+ print FILEO $l;
}
close(FILEO);
}
});
}
if (@{@$project[$P_TARGETS]} > 0) {
- generate_list("DLLS",1,\@dll_list,sub
+ generate_list("DLLS",1,\@dll_list,sub
{
return @{$_[0]}[$T_NAME];
});
- generate_list("EXES",1,\@exe_list,sub
+ generate_list("EXES",1,\@exe_list,sub
{
return "@{$_[0]}[$T_NAME]";
});
print FILEO "### Global settings\n\n";
# Make it so that the project-wide settings override the global settings
- generate_list("DEFINES",0,@$project_settings[$T_DEFINES],sub
- {
- return "$_[0]";
- });
- generate_list("",1,$global_settings[$T_DEFINES],sub
- {
- return "$_[0]";
- });
- generate_list("INCLUDE_PATH",$no_extra,@$project_settings[$T_INCLUDE_PATH],sub
- {
- return "$_[0]";
- });
- generate_list("",1,$global_settings[$T_INCLUDE_PATH],sub
+ generate_list("DEFINES",0,@$project_settings[$T_DEFINES]);
+ generate_list("",1,$global_settings[$T_DEFINES]);
+ generate_list("INCLUDE_PATH",$no_extra,@$project_settings[$T_INCLUDE_PATH]);
+ generate_list("",1,$global_settings[$T_INCLUDE_PATH],sub
{
- if ($_[0] !~ /^-I/) {
- return "$_[0]";
- }
- if (is_absolute($')) {
+ if ($_[0] !~ /^-I/ or is_absolute($')) {
return "$_[0]";
}
return "-I\$(TOPSRCDIR)/$'";
});
- generate_list("LIBRARY_PATH",$no_extra,@$project_settings[$T_LIBRARY_PATH],sub
+ generate_list("LIBRARY_PATH",$no_extra,@$project_settings[$T_LIBRARY_PATH]);
+ generate_list("",1,$global_settings[$T_LIBRARY_PATH],sub
{
- return "$_[0]";
- });
- generate_list("",1,$global_settings[$T_LIBRARY_PATH],sub
- {
- if ($_[0] !~ /^-L/) {
- return "$_[0]";
- }
- if (is_absolute($')) {
+ if ($_[0] !~ /^-L/ or is_absolute($')) {
return "$_[0]";
}
return "-L\$(TOPSRCDIR)/$'";
});
- generate_list("LIBRARIES",$no_extra,@$project_settings[$T_LIBRARIES],sub
- {
- return "$_[0]";
- });
- generate_list("",1,$global_settings[$T_LIBRARIES],sub
- {
- return "$_[0]";
- });
+ generate_list("LIBRARIES",$no_extra,@$project_settings[$T_LIBRARIES]);
+ generate_list("",1,$global_settings[$T_LIBRARIES]);
print FILEO "\n\n";
my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+
generate_list("EXTRA_OBJS",1,["\$(EXTRA_C_SRCS:.c=.o)","\$(EXTRA_CXX_SRCS:.cpp=.o)"]);
print FILEO "\n\n\n";
}
-
+
# Iterate over all the targets...
foreach $target (@{@$project[$P_TARGETS]}) {
print FILEO "### @$target[$T_NAME] sources and settings\n\n";
} elsif (@$target[$T_FLAGS] & $TF_WRAPPER) {
$basename.="_wrapper";
}
- generate_list("${canon}_SPEC_SRCS",1,[ "$basename.spec"]);
- generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH],sub
- {
- return "$_[0]";
- });
- generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES],sub
- {
- return "$_[0]";
- });
- generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS],sub
- {
- return "$_[0]";
- });
+ generate_list("${canon}_SPEC_SRCS",1,[ "$basename.spec" ]);
+ generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]);
+ generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES]);
+ generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS]);
print FILEO "\n";
generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(EXTRA_OBJS)"]);
print FILEO "\n\n\n";
}
print FILEO "### Global source lists\n\n";
- generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub
+ generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub
{
my $canon=canonize(@{$_[0]}[$T_NAME]);
$canon =~ s+_so$++;
if (!$no_extra) {
generate_list("",1,[ "\$(EXTRA_C_SRCS)" ]);
}
- generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub
+ generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub
{
my $canon=canonize(@{$_[0]}[$T_NAME]);
$canon =~ s+_so$++;
if (!$no_extra) {
generate_list("",1,[ "\$(EXTRA_CXX_SRCS)" ]);
}
- generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub
+ generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub
{
my $canon=canonize(@{$_[0]}[$T_NAME]);
$canon =~ s+_so$++;
if (!$no_extra) {
generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]);
}
- generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub
+ generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub
{
my $canon=canonize(@{$_[0]}[$T_NAME]);
$canon =~ s+_so$++;
print FILEO "\n\n\n";
print FILEO "### Generic autoconf targets\n\n";
- print FILEO "all: ";
+ print FILEO "all:";
if (@$project[$P_PATH] eq "") {
- print FILEO "\$(SUBDIRS)";
+ print FILEO " \$(SUBDIRS)";
}
if (@{@$project[$P_TARGETS]} > 0) {
- print FILEO "\$(DLLS) \$(EXES:%=%.so)";
+ print FILEO " \$(DLLS) \$(EXES:%=%.so)";
}
print FILEO "\n\n";
print FILEO "\@MAKE_RULES\@\n";
}
if (@{@$project[$P_TARGETS]} > 0) {
print FILEO "\tfor i in \$(EXES); do \$(INSTALL_PROGRAM) \$\$i \$(bindir); done\n";
- print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(INSTALL_LIBRARY) \$\$i \$(libdir); done\n";
+ print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(INSTALL_PROGRAM) \$\$i \$(libdir); done\n";
}
print FILEO "\n";
print FILEO "uninstall::\n";
print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(RM) \$(libdir)/\$\$i;done\n";
}
print FILEO "\n\n\n";
-
+
if (@{@$project[$P_TARGETS]} > 0) {
print FILEO "### Target specific build rules\n\n";
foreach $target (@{@$project[$P_TARGETS]}) {
print FILEO "\t-\$(STRIP) \$(STRIPFLAGS) \$\@\n";
print FILEO "\n";
print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS:.spec) \$(${canon}_SPEC_SRCS:.spec=.tmp.o) \$(${canon}_RC_SRCS:.rc=.res)\n";
- print FILEO "\t\$(WINEBUILD) -fPIC \$(${canon}_LIBRARY_PATH) \$(WINE_LIBRARY_PATH) -sym \$(${canon}_SPEC_SRCS:.spec=.tmp.o) -o \$\@ -spec \$(${canon}_SPEC_SRCS)\n";
+ 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";
print FILEO "\n";
my $t_name=@$target[$T_NAME];
if (@$target[$T_TYPE]!=$TT_DLL) {
$t_name.=".so";
}
print FILEO "$t_name: \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_OBJS) \$(${canon}_DEPENDS) \n";
- print FILEO "\t\$(LDSHARED) \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
+ if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) {
+ print FILEO "\t\$(LDXXSHARED)";
+ } else {
+ print FILEO "\t\$(LDSHARED)";
+ }
+ print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n";
if (@$target[$T_TYPE] ne $TT_DLL) {
print FILEO "\ttest -e @$target[$T_NAME] || \$(LN_S) \$(WINE) @$target[$T_NAME]\n";
}
}
}
close(FILEO);
-
+
foreach $target (@{@$project[$P_TARGETS]}) {
generate_spec_file(@$project[$P_PATH],$target,$project_settings);
if (@$target[$T_FLAGS] & $TF_WRAPPER) {
$opt_ask_project_options=$OPT_ASK_YES;
$opt_ask_target_options=$OPT_ASK_YES;
} elsif ($arg eq "--wrap") {
- print STDERR "warning: --wrap no longer supported, ignoring the option\n";
- #$opt_flags|=$TF_WRAP;
+ $opt_flags|=$TF_WRAP;
} elsif ($arg eq "--nowrap") {
$opt_flags&=~$TF_WRAP;
} elsif ($arg eq "--mfc") {
$opt_flags|=$TF_MFC;
- #$opt_flags|=$TF_MFC|$TF_WRAP;
+ $opt_flags|=$TF_MFC|$TF_WRAP;
$needs_mfc=1;
} elsif ($arg eq "--nomfc") {
$opt_flags&=~($TF_MFC|$TF_WRAP);
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
-AC_PATH_XTRA
-AC_PROG_RANLIB
AC_PROG_LN_S
-AC_PATH_PROG(LDCONFIG, ldconfig, true, /sbin:/usr/sbin:$PATH)
dnl **** Check for some libraries ****
dnl Check for -lm for BeOS
AC_CHECK_LIB(m,sqrt)
-dnl Check for -li386 for NetBSD and OpenBSD
-AC_CHECK_LIB(i386,i386_set_ldt)
-dnl Check for -lossaudio for NetBSD
-AC_CHECK_LIB(ossaudio,_oss_ioctl)
dnl Check for -lw for Solaris
AC_CHECK_LIB(w,iswalnum)
dnl Check for -lnsl for Solaris
AC_CHECK_FUNCS(gethostbyname,, AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", AC_CHECK_LIB(socket, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", , -lnsl), -lsocket))
dnl Check for -lsocket for Solaris
AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
-dnl Check for -lxpg4 for FreeBSD
-AC_CHECK_LIB(xpg4,setrunelocale)
-dnl Check for -lmmap for OS/2
-AC_CHECK_LIB(mmap,mmap)
-dnl Check for openpty
-AC_CHECK_FUNCS(openpty,,
- AC_CHECK_LIB(util,openpty,
- AC_DEFINE(HAVE_OPENPTY)
- LIBS="$LIBS -lutil"
- ))
-
-AC_CHECK_HEADERS(dlfcn.h,
- AC_CHECK_FUNCS(dlopen,
- AC_DEFINE(HAVE_DL_API),
- AC_CHECK_LIB(dl,dlopen,
- AC_DEFINE(HAVE_DL_API)
- LIBS="$LIBS -ldl",
- )
- ),
-)
-
-dnl **** Check which curses lib to use ***
-if test "$CURSES" = "yes"
-then
- AC_CHECK_HEADERS(ncurses.h)
- if test "$ac_cv_header_ncurses_h" = "yes"
- then
- AC_CHECK_LIB(ncurses,waddch)
- fi
- if test "$ac_cv_lib_ncurses_waddch" = "yes"
- then
- AC_CHECK_LIB(ncurses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
- AC_CHECK_LIB(ncurses,getbkgd,AC_DEFINE(HAVE_GETBKGD))
- else
- AC_CHECK_HEADERS(curses.h)
- if test "$ac_cv_header_curses_h" = "yes"
- then
- AC_CHECK_LIB(curses,waddch)
- if test "$ac_cv_lib_curses_waddch" = "yes"
- then
- AC_CHECK_LIB(curses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
- AC_CHECK_LIB(curses,getbkgd,AC_DEFINE(HAVE_GETBKGD))
- fi
- fi
- fi
-fi
dnl **** If ln -s doesn't work, use cp instead ****
if test "$ac_cv_prog_LN_S" = "ln -s"; then : ; else LN_S=cp ; fi
dnl **** Check for working dll ****
LDSHARED=""
+LDXXSHARED=""
LDDLLFLAGS=""
AC_CACHE_CHECK("whether we can build a Linux dll",
ac_cv_c_dll_linux,
if test "$ac_cv_c_dll_linux" = "yes"
then
LDSHARED="\$(CC) -shared -Wl,-rpath,\$(libdir)"
+ LDXXSHARED="\$(CXX) -shared -Wl,-rpath,\$(libdir)"
LDDLLFLAGS="-Wl,-Bsymbolic"
else
AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
])
if test "$ac_cv_c_dll_unixware" = "yes"
then
- LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,h,\$(libdir)/%)"#FIXME: why SONAME here?
+ LDSHARED="\$(CC) -Wl,-G"
+ LDXXSHARED="\$(CXX) -Wl,-G"
LDDLLFLAGS="-Wl,-B,symbolic"
else
AC_CACHE_CHECK("whether we can build a NetBSD dll",
if test "$ac_cv_c_dll_netbsd" = "yes"
then
LDSHARED="\$(CC) -Wl,-Bshareable,-Bforcearchive"
+ LDXXSHARED="\$(CXX) -Wl,-Bshareable,-Bforcearchive"
LDDLLFLAGS="" #FIXME
fi
fi
AC_SUBST(DLL_LINK)
AC_SUBST(LDSHARED)
+AC_SUBST(LDXXSHARED)
AC_SUBST(LDDLLFLAGS)
dnl *** check for the need to define __i386__
dnl **** Try to find where winelib is located ****
+LD_PATH="";
WINE_INCLUDE_ROOT="";
WINE_INCLUDE_PATH="";
WINE_LIBRARY_ROOT="";
then
WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$LIBNTDLL_PATH"
fi
+if test -n "$WINE_LIBRARY_PATH"
+then
+ LD_PATH="LD_LIBRARY_PATH=\"`echo $WINE_LIBRARY_PATH | sed -e 's/ *-L/:/g' -e 's/^://' -e 's/ *$//'`:\$\$LD_LIBRARY_PATH\""
+fi
if test -z "$WINE_TOOL_PATH"
then
AC_MSG_ERROR([Could not find Wine's wrc tool])
fi
+AC_SUBST(LD_PATH)
AC_SUBST(WINE_INCLUDE_PATH)
AC_SUBST(WINE_LIBRARY_PATH)
# Global rules shared by all makefiles -*-Makefile-*-
#
# Each individual makefile must define the following variables:
-# WINE_INCLUDE_ROOT: Wine's headers location
-# WINE_LIBRARY_ROOT: Wine's libraries location
# TOPOBJDIR : top-level object directory
# SRCDIR : source directory for this module
#
# SPEC_SRCS : interface definition files
-# Where is Winelib
+# Where is Wine
WINE_INCLUDE_ROOT = @WINE_INCLUDE_ROOT@
WINE_INCLUDE_PATH = @WINE_INCLUDE_PATH@
WINE_LIBRARY_ROOT = @WINE_LIBRARY_ROOT@
WINE_LIBRARY_PATH = @WINE_LIBRARY_PATH@
+LD_PATH = @LD_PATH@
+
# Where are the MFC
ATL_INCLUDE_ROOT = @ATL_INCLUDE_ROOT@
SHELL = /bin/sh
CC = @CC@
CPP = @CPP@
+CXX = @CXX@
WRC = @WRC@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
WRCFLAGS = -r -L
OPTIONS = @OPTIONS@ -D_REENTRANT -DWINELIB
-X_CFLAGS = @X_CFLAGS@
-X_LIBS = @X_LIBS@
-XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
DLL_LINK = @DLL_LINK@
LIBS = @LIBS@ $(LIBRARY_PATH)
-YACC = @YACC@
-LEX = @LEX@
-LEXLIB = @LEXLIB@
LN_S = @LN_S@
ALLFLAGS = $(DEFINES) -I$(SRCDIR) $(WINE_INCLUDE_PATH) $(INCLUDE_PATH)
-ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(X_CFLAGS) $(ALLFLAGS)
-ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(X_CFLAGS) $(ALLFLAGS)
+ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
+ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS)
LDCOMBINE = ld -r
LDSHARED = @LDSHARED@
+LDXXSHARED= @LDXXSHARED@
LDDLLFLAGS= @LDDLLFLAGS@
STRIP = strip
STRIPFLAGS= --strip-unneeded
# Installation infos
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
+INSTALL = install
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
$(CXX) -c $(ALLCXXFLAGS) -o $@ $<
.rc.res:
- $(WRC) $(ALLWRCFLAGS) -o $@ $<
+ $(LD_PATH) $(WRC) $(ALLWRCFLAGS) -o $@ $<
.PHONY: all install uninstall clean distclean depend dummy