1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 20:06:18 +00:00

Store the global settings in Make.rules.in instead of duplicating them

in each Makefile.in file.
Introduce generate_from_template which replaces generate_configure
and generate_generic
Simplify the wrapper generation by using generate_from_template.
Rename configure.in to configure.ac. Now works with autoconf 2.5x.
This commit is contained in:
Francois Gouget 2002-09-11 01:09:58 +00:00 committed by Alexandre Julliard
parent 52097fd703
commit d19aa5b702

View File

@ -1671,29 +1671,11 @@ sub generate_wrapper_file($$)
my $path=$_[0]; my $path=$_[0];
my $target=$_[1]; my $target=$_[1];
if (!defined $templates{"wrapper.c"}) { return generate_from_template("wrapper.c","$path${app_name}_wrapper.c",[
print STDERR "winemaker: internal error: No template called 'wrapper.c'\n"; ["APP_NAME",@$target[$T_NAME]],
return; ["APP_TYPE",(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE")],
} ["APP_INIT",(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"")],
["APP_MFC",(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":"NULL")]]);
if (!open(FILEO,">$path@$target[$T_NAME]_wrapper.c")) {
print STDERR "error: unable to open \"$path@$target[$T_NAME]_wrapper.c\" for writing:\n";
print STDERR " $!\n";
return;
}
my $app_name="\"@$target[$T_NAME]\"";
my $app_type=(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE");
my $app_init=(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\"");
my $app_mfc=(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":"NULL");
foreach my $line (@{$templates{"wrapper.c"}}) {
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);
} }
## ##
@ -1797,45 +1779,19 @@ sub generate_project_files($)
}); });
print FILEO "\n\n\n"; print FILEO "\n\n\n";
print FILEO "### Global settings\n\n"; print FILEO "### Common settings\n\n";
# Make it so that the project-wide settings override the global settings # Make it so that the project-wide settings override the global settings
# FIXME: We should be setting no_extra for each list but this does not generate_list("DEFINES",1,@$project_settings[$T_DEFINES]);
# really matter since global settings will very soon move to Make.rules generate_list("INCLUDE_PATH",1,@$project_settings[$T_INCLUDE_PATH]);
my $no_extra; generate_list("DLL_PATH",1,@$project_settings[$T_DLL_PATH]);
generate_list("DEFINES",0,@$project_settings[$T_DEFINES]); generate_list("LIBRARY_PATH",1,@$project_settings[$T_LIBRARY_PATH]);
generate_list("",1,$global_settings[$T_DEFINES]); generate_list("LIBRARIES",1,@$project_settings[$T_LIBRARIES]);
generate_list("INCLUDE_PATH",$no_extra,@$project_settings[$T_INCLUDE_PATH]);
generate_list("",1,$global_settings[$T_INCLUDE_PATH],sub
{
if ($_[0] !~ /^-I/ or is_absolute($')) {
return "$_[0]";
}
return "-I\$(TOPSRCDIR)/$'";
});
generate_list("DLL_PATH",$no_extra,@$project_settings[$T_DLL_PATH]);
generate_list("",1,$global_settings[$T_DLL_PATH],sub
{
if ($_[0] !~ /^-L/ or is_absolute($')) {
return "$_[0]";
}
return "-L\$(TOPSRCDIR)/$'";
});
generate_list("LIBRARY_PATH",$no_extra,@$project_settings[$T_LIBRARY_PATH]);
generate_list("",1,$global_settings[$T_LIBRARY_PATH],sub
{
if ($_[0] !~ /^-L/ or is_absolute($')) {
return "$_[0]";
}
return "-L\$(TOPSRCDIR)/$'";
});
generate_list("LIBRARIES",$no_extra,@$project_settings[$T_LIBRARIES]);
generate_list("",1,$global_settings[$T_LIBRARIES]);
print FILEO "\n\n"; print FILEO "\n\n";
my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+ my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+
@{@$project_settings[$T_SOURCES_CXX]}+ @{@$project_settings[$T_SOURCES_CXX]}+
@{@$project_settings[$T_SOURCES_RC]}; @{@$project_settings[$T_SOURCES_RC]};
$no_extra=($extra_source_count == 0); my $no_extra=($extra_source_count == 0);
if (!$no_extra) { if (!$no_extra) {
print FILEO "### Extra source lists\n\n"; print FILEO "### Extra source lists\n\n";
generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]); generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]);
@ -2013,15 +1969,14 @@ sub generate_project_files($)
## ##
# Perform the replacements in the template configure files # Perform the replacements in the template configure files
# Return 1 for success, 0 for failure # Return 1 for success, 0 for failure
sub generate_configure($$) sub generate_from_template($$;$)
{ {
my $filename=$_[0]; my $filename=$_[0];
my $a_source_file=$_[1]; my $template=$_[1];
my $substitutions=$_[2];
if (!defined $templates{$filename}) { if (!defined $templates{$template}) {
if ($filename ne "configure") { print STDERR "winemaker: internal error: No template called '$template'\n";
print STDERR "winemaker: internal error: No template called '$filename'\n";
}
return 0; return 0;
} }
@ -2030,52 +1985,67 @@ sub generate_configure($$)
print STDERR " $!\n"; print STDERR " $!\n";
return 0; return 0;
} }
foreach my $line (@{$templates{$filename}}) { my $warned;
if ($line =~ /^\#\#WINEMAKER_PROJECTS\#\#$/) { foreach my $line (@{$templates{$template}}) {
foreach my $project (@projects) { if ($line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
print FILEO "@$project[$P_PATH]Makefile\n"; if (defined $substitutions) {
foreach my $pattern (@$substitutions) {
$line =~ s%\#\#WINEMAKER_@$pattern[0]\#\#%@$pattern[1]%;
}
}
if (!$warned and $line =~ /(\#\#WINEMAKER_[A-Z_]+\#\#)/) {
print STDERR "warning: no value was provided for template $1 in \"$filename\"\n";
$warned=1;
} }
} else {
$line =~ s+\#\#WINEMAKER_SOURCE\#\#+$a_source_file+;
$line =~ s+\#\#WINEMAKER_NEEDS_MFC\#\#+$needs_mfc+;
print FILEO $line;
} }
print FILEO $line;
} }
close(FILEO); close(FILEO);
return 1; return 1;
} }
sub generate_generic($)
{
my $filename=$_[0];
if (!defined $templates{$filename}) {
print STDERR "winemaker: internal error: No template called '$filename'\n";
return;
}
if (!open(FILEO,">$filename")) {
print STDERR "error: unable to open \"$filename\" for writing:\n";
print STDERR " $!\n";
return;
}
foreach my $line (@{$templates{$filename}}) {
print FILEO $line;
}
close(FILEO);
}
## ##
# Generates the global files: # Generates the global files:
# configure # configure
# configure.in # configure.ac
# Make.rules.in # Make.rules.in
# wineapploader.in # wineapploader.in
sub generate_global_files() sub generate_global_files()
{ {
generate_generic("Make.rules.in"); my @include_path;
generate_generic("wineapploader.in"); foreach my $path (@{$global_settings[$T_INCLUDE_PATH]}) {
if ($path !~ /^-L/ or is_absolute($')) {
push @include_path, $path;
} else {
push @include_path, "-L\$(TOPSRCDIR)/$'";
}
}
my @dll_path;
foreach my $path (@{$global_settings[$T_DLL_PATH]}) {
if ($path !~ /^-L/ or is_absolute($')) {
push @dll_path, $path;
} else {
push @dll_path, "-L\$(TOPSRCDIR)/$'";
}
}
my @library_path;
foreach my $path (@{$global_settings[$T_LIBRARY_PATH]}) {
if ($path !~ /^-L/ or is_absolute($')) {
push @library_path, $path;
} else {
push @library_path, "-L\$(TOPSRCDIR)/$'";
}
}
generate_from_template("Make.rules.in","Make.rules.in",[
["DEFINES", join(" ", @{$global_settings[$T_DEFINES]}) ],
["INCLUDE_PATH", join(" ", @include_path) ],
["DLL_PATH", join(" ", @dll_path) ],
["DLLS", join(" ", @{$global_settings[$T_DLLS]}) ],
["LIBRARY_PATH", join(" ", @library_path) ],
["LIBRARIES", join(" ", @{$global_settings[$T_LIBRARIES]}) ]]);
generate_from_template("wineapploader.in","wineapploader.in");
# Get the name of a source file for configure.in # Get the name of a source file for configure.ac
my $a_source_file; my $a_source_file;
search_a_file: foreach my $project (@projects) { search_a_file: foreach my $project (@projects) {
foreach my $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) { foreach my $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) {
@ -2095,12 +2065,12 @@ sub generate_global_files()
if (!defined $a_source_file) { if (!defined $a_source_file) {
$a_source_file="Makefile.in"; $a_source_file="Makefile.in";
} }
generate_from_template("configure.ac","configure.ac",[
["PROJECTS",join("\n",map { "@$_[$P_PATH]Makefile" } @projects)],
["SOURCE","$a_source_file"],
["NEEDS_MFC","$needs_mfc"]]);
system("autoconf");
generate_configure("configure.in",$a_source_file);
unlink("configure");
if (generate_configure("configure",$a_source_file) == 0) {
system("autoconf");
}
# Add execute permission to configure for whoever has the right to read it # Add execute permission to configure for whoever has the right to read it
my @st=stat("configure"); my @st=stat("configure");
if (@st) { if (@st) {
@ -2314,6 +2284,7 @@ if ($opt_no_banner == 0) {
} }
project_init(\@main_project,""); project_init(\@main_project,"");
target_init(\@global_settings);
# Fix the file and directory names # Fix the file and directory names
fix_file_and_directory_names("."); fix_file_and_directory_names(".");
@ -2336,13 +2307,13 @@ if (! $opt_no_generated_files) {
__DATA__ __DATA__
--- configure.in --- --- configure.ac ---
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl Author: Michael Patra <micky@marie.physik.tu-berlin.de> dnl Author: Michael Patra <micky@marie.physik.tu-berlin.de>
dnl <patra@itp1.physik.tu-berlin.de> dnl <patra@itp1.physik.tu-berlin.de>
dnl Francois Gouget <fgouget@codeweavers.com> for CodeWeavers dnl Francois Gouget <fgouget@codeweavers.com> for CodeWeavers
AC_REVISION([configure.in 1.00]) AC_REVISION([configure.ac 1.00])
AC_INIT(##WINEMAKER_SOURCE##) AC_INIT(##WINEMAKER_SOURCE##)
NEEDS_MFC=##WINEMAKER_NEEDS_MFC## NEEDS_MFC=##WINEMAKER_NEEDS_MFC##
@ -3067,6 +3038,15 @@ MFC_INCLUDE_PATH = @MFC_INCLUDE_PATH@
MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@ MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@
MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@ MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@
# Global definitions and options
GLOBAL_DEFINES = ##WINEMAKER_DEFINES##
GLOBAL_INCLUDE_PATH = ##WINEMAKER_INCLUDE_PATH##
GLOBAL_DLL_PATH = ##WINEMAKER_DLL_PATH##
GLOBAL_DLLS = ##WINEMAKER_DLLS##
GLOBAL_LIBRARY_PATH = ##WINEMAKER_LIBRARY_PATH##
GLOBAL_LIBRARIES = ##WINEMAKER_LIBRARIES##
# First some useful definitions # First some useful definitions
SHELL = /bin/sh SHELL = /bin/sh
@ -3077,13 +3057,13 @@ WRC = @WRC@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@ CXXFLAGS = @CXXFLAGS@
WRCFLAGS = -r -L WRCFLAGS = -r -L
OPTIONS = @OPTIONS@ -D_REENTRANT -DWINELIB OPTIONS = @OPTIONS@ -D_REENTRANT -DWINELIB $(GLOBAL_DEFINES)
LIBS = @LIBS@ $(LIBRARY_PATH) LIBS = @LIBS@ $(LIBRARY_PATH)
ALLFLAGS = $(DEFINES) -I$(SRCDIR) $(INCLUDE_PATH) $(WINE_INCLUDE_PATH) ALLFLAGS = $(DEFINES) -I$(SRCDIR) $(INCLUDE_PATH) $(WINE_INCLUDE_PATH)
ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS) ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS) ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS) ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS)
DLL_LINK = $(LIBRARY_PATH) $(LIBRARIES:%=-l%) $(WINE_LIBRARY_PATH) -lwine -lwine_unicode -lwine_uuid DLL_LINK = $(LIBRARY_PATH) $(LIBRARIES:%=-l%) $(WINE_LIBRARY_PATH) $(GLOBAL_LIBRARY_PATH) -lwine -lwine_unicode -lwine_uuid $(GLOBAL_LIBRARIES:%=-l%)
LDCOMBINE = ld -r LDCOMBINE = ld -r
LDSHARED = @LDSHARED@ LDSHARED = @LDSHARED@
LDXXSHARED= @LDXXSHARED@ LDXXSHARED= @LDXXSHARED@