>From b32468fe4a97cff58b2dc4b947d01cd319b82834 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sun, 2 Sep 2007 15:52:39 +0400 Subject: [PATCH] winemaker: adapt to using Winemake.include As I don't know Perl, This patch requires help from winemaker maintainer. --- tools/winemaker | 163 +++++++++++++++---------------------------------------- 1 files changed, 44 insertions(+), 119 deletions(-) diff --git a/tools/winemaker b/tools/winemaker index 960804d..4bde7e4 100755 --- a/tools/winemaker +++ b/tools/winemaker @@ -19,7 +19,7 @@ use strict; # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # -my $version="0.6.0"; +my $version="0.7.0"; use Cwd; use File::Basename; @@ -204,6 +204,9 @@ my $T_LIBRARIES=16; # The list of dependencies between targets my $T_DEPENDS=17; +## +# List of linker options +my $T_LDEXTRA = 18; # The following constants define the recognized types of target @@ -270,6 +273,7 @@ sub target_init($) @$target[$T_DLLS]=[]; @$target[$T_LIBRARY_PATH]=[]; @$target[$T_LIBRARIES]=[]; + @$target[$T_LDEXTRA]=[]; } @@ -799,7 +803,6 @@ sub source_scan_directory($$$$) push @local_depends,"$target_name.so"; push @local_dlls,$target_name; my $canon=canonize($target_name); - push @{@$target[$T_LDFLAGS]},("-shared","\$(${canon}_MODULE:%=%.spec)"); } else { @$target[$T_TYPE]=$opt_target_type; push @exe_list,$target; @@ -912,6 +915,7 @@ sub source_scan_directory($$$$) if ((@$project_settings[$T_FLAGS] & $TF_NOMSVCRT) == 0) { push @{@$project_settings[$T_CEXTRA]},"-mno-cygwin"; push @{@$project_settings[$T_CXXEXTRA]},"-mno-cygwin"; + push @{@$project_settings[$T_LDEXTRA]},"-mno-cygwin"; } if (@$project_settings[$T_FLAGS] & $TF_MFC) { @@ -1527,7 +1531,7 @@ sub generate_list($$$;$) my $first=$name; if ($name) { - printf FILEO "%-22s=",$name; + printf FILEO "%-21s:=",$name; } if (defined $list) { foreach my $item (@$list) { @@ -1560,6 +1564,7 @@ sub generate_project_files($) my $project_settings=@$project[$P_SETTINGS]; my @dll_list=(); my @exe_list=(); + my @all_list=(); # Then sort the targets and separate the libraries from the programs foreach my $target (sort { @$a[$T_NAME] cmp @$b[$T_NAME] } @{@$project[$P_TARGETS]}) { @@ -1569,6 +1574,9 @@ sub generate_project_files($) push @exe_list,$target; } } + + push @all_list, @exe_list, @dll_list; + @$project[$P_TARGETS]=[]; push @{@$project[$P_TARGETS]}, @dll_list; push @{@$project[$P_TARGETS]}, @exe_list; @@ -1582,7 +1590,7 @@ sub generate_project_files($) print FILEO "### Generated by Winemaker\n"; print FILEO "\n\n"; - generate_list("SRCDIR",1,[ "." ]); + #generate_list("SRCDIR",1,[ "." ]); if (@$project[$P_PATH] eq "") { # This is the main project. It is also responsible for recursively # calling the other projects @@ -1597,20 +1605,18 @@ sub generate_project_files($) }); } if (@{@$project[$P_TARGETS]} > 0) { - generate_list("DLLS",1,\@dll_list,sub + generate_list("MODULES",1,\@all_list,sub { return @{$_[0]}[$T_NAME]; }); - generate_list("EXES",1,\@exe_list,sub - { - return "@{$_[0]}[$T_NAME]"; - }); + print FILEO "\n\n\n"; print FILEO "### Common settings\n\n"; # Make it so that the project-wide settings override the global settings generate_list("CEXTRA",1,@$project_settings[$T_CEXTRA]); generate_list("CXXEXTRA",1,@$project_settings[$T_CXXEXTRA]); + generate_list("LDEXTRA",1,@$project_settings[$T_LDEXTRA]); generate_list("RCEXTRA",1,@$project_settings[$T_RCEXTRA]); generate_list("INCLUDE_PATH",1,@$project_settings[$T_INCLUDE_PATH]); generate_list("DLL_PATH",1,@$project_settings[$T_DLL_PATH]); @@ -1622,6 +1628,7 @@ sub generate_project_files($) @{@$project_settings[$T_SOURCES_CXX]}+ @{@$project_settings[$T_SOURCES_RC]}; my $no_extra=($extra_source_count == 0); + # XXX what to do with extra src ??? if (!$no_extra) { print FILEO "### Extra source lists\n\n"; generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]); @@ -1638,121 +1645,39 @@ sub generate_project_files($) my $canon=canonize("@$target[$T_NAME]"); $canon =~ s+_so$++; - generate_list("${canon}_MODULE",1,[@$target[$T_NAME]]); - generate_list("${canon}_C_SRCS",1,@$target[$T_SOURCES_C]); - generate_list("${canon}_CXX_SRCS",1,@$target[$T_SOURCES_CXX]); - generate_list("${canon}_RC_SRCS",1,@$target[$T_SOURCES_RC]); - generate_list("${canon}_LDFLAGS",1,@$target[$T_LDFLAGS]); - generate_list("${canon}_DLL_PATH",1,@$target[$T_DLL_PATH]); - generate_list("${canon}_DLLS",1,@$target[$T_DLLS]); - generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]); - generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES]); - print FILEO "\n"; - generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(${canon}_RC_SRCS:.rc=.res)"]); - print FILEO "\n\n\n"; - } - print FILEO "### Global source lists\n\n"; - generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub - { - my $canon=canonize(@{$_[0]}[$T_NAME]); - $canon =~ s+_so$++; - return "\$(${canon}_C_SRCS)"; - }); - if (!$no_extra) { - generate_list("",1,[ "\$(EXTRA_C_SRCS)" ]); - } - generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub - { - my $canon=canonize(@{$_[0]}[$T_NAME]); - $canon =~ s+_so$++; - return "\$(${canon}_CXX_SRCS)"; - }); - if (!$no_extra) { - generate_list("",1,[ "\$(EXTRA_CXX_SRCS)" ]); - } - generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub - { - my $canon=canonize(@{$_[0]}[$T_NAME]); - $canon =~ s+_so$++; - return "\$(${canon}_RC_SRCS)"; - }); - if (!$no_extra) { - generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]); - } - } - print FILEO "\n\n"; - print FILEO "### Tools\n\n"; - print FILEO "CC = winegcc\n"; - print FILEO "CXX = wineg++\n"; - print FILEO "RC = wrc\n"; - print FILEO "\n\n"; + my $all_src=[@{@$target[$T_SOURCES_C]}, @{@$target[$T_SOURCES_CXX]}, @{@$target[$T_SOURCES_RC]}]; - print FILEO "### Generic targets\n\n"; - print FILEO "all:"; - if (@$project[$P_PATH] eq "") { - print FILEO " \$(SUBDIRS)"; - } - if (@{@$project[$P_TARGETS]} > 0) { - print FILEO " \$(DLLS:%=%.so) \$(EXES:%=%.so)"; - } - print FILEO "\n\n"; - print FILEO "### Build rules\n"; - print FILEO "\n"; - print FILEO ".PHONY: all clean dummy\n"; - print FILEO "\n"; - print FILEO "\$(SUBDIRS): dummy\n"; - print FILEO "\t\@cd \$\@ && \$(MAKE)\n"; - print FILEO "\n"; - print FILEO "# Implicit rules\n"; - print FILEO "\n"; - print FILEO ".SUFFIXES: .cpp .rc .res\n"; - print FILEO "DEFINCL = \$(INCLUDE_PATH) \$(DEFINES) \$(OPTIONS)\n"; - print FILEO "\n"; - print FILEO ".c.o:\n"; - print FILEO "\t\$(CC) -c \$(CFLAGS) \$(CEXTRA) \$(DEFINCL) -o \$\@ \$<\n"; - print FILEO "\n"; - print FILEO ".cpp.o:\n"; - print FILEO "\t\$(CXX) -c \$(CXXFLAGS) \$(CXXEXTRA) \$(DEFINCL) -o \$\@ \$<\n"; - print FILEO "\n"; - print FILEO ".cxx.o:\n"; - print FILEO "\t\$(CXX) -c \$(CXXFLAGS) \$(CXXEXTRA) \$(DEFINCL) -o \$\@ \$<\n"; - print FILEO "\n"; - print FILEO ".rc.res:\n"; - print FILEO "\t\$(RC) \$(RCFLAGS) \$(RCEXTRA) \$(DEFINCL) -fo\$@ \$<\n"; - print FILEO "\n"; - print FILEO "# Rules for cleaning\n"; - print FILEO "\n"; - print FILEO "CLEAN_FILES = y.tab.c y.tab.h lex.yy.c core *.orig *.rej \\\n"; - print FILEO " \\\\\\#*\\\\\\# *~ *% .\\\\\\#*\n"; - print FILEO "\n"; - print FILEO "clean:: \$(SUBDIRS:%=%/__clean__) \$(EXTRASUBDIRS:%=%/__clean__)\n"; - print FILEO "\t\$(RM) \$(CLEAN_FILES) \$(RC_SRCS:.rc=.res) \$(C_SRCS:.c=.o) \$(CXX_SRCS:.cpp=.o)\n"; - print FILEO "\t\$(RM) \$(DLLS:%=%.so) \$(EXES:%=%.so) \$(EXES:%.exe=%)\n"; - print FILEO "\n"; - print FILEO "\$(SUBDIRS:%=%/__clean__): dummy\n"; - print FILEO "\tcd `dirname \$\@` && \$(MAKE) clean\n"; - print FILEO "\n"; - print FILEO "\$(EXTRASUBDIRS:%=%/__clean__): dummy\n"; - print FILEO "\t-cd `dirname \$\@` && \$(RM) \$(CLEAN_FILES)\n"; - print FILEO "\n"; + # insert spec file for .dll targets + if (@$target[$T_TYPE] == $TT_DLL) { + my $basename=@$target[$T_NAME]; + $basename=~ s/\.(dll|exe)$//i; + push @$all_src, "$basename.spec"; + } - if (@{@$project[$P_TARGETS]} > 0) { - print FILEO "### Target specific build rules\n"; - print FILEO "DEFLIB = \$(LIBRARY_PATH) \$(LIBRARIES) \$(DLL_PATH)\n\n"; - foreach my $target (@{@$project[$P_TARGETS]}) { - my $canon=canonize("@$target[$T_NAME]"); - $canon =~ s/_so$//; + generate_list("${canon}_SRC",1,[@$all_src]); + print FILEO "\n"; - print FILEO "\$(${canon}_MODULE).so: \$(${canon}_OBJS)\n"; - if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) { - print FILEO "\t\$(CXX)"; - } else { - print FILEO "\t\$(CC)"; - } - print FILEO " \$(${canon}_LDFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_LIBRARY_PATH) \$(DEFLIB) \$(${canon}_DLLS:%=-l%) \$(${canon}_LIBRARIES:%=-l%)\n"; - print FILEO "\n\n"; + generate_list("@$target[$T_NAME]:\tLDFLAGS",1,@$target[$T_LDFLAGS]); + generate_list("@$target[$T_NAME]:\tDLL_PATH",1,@$target[$T_DLL_PATH]); + generate_list("@$target[$T_NAME]:\tDLLS",1,@$target[$T_DLLS]); + generate_list("@$target[$T_NAME]:\tLIBRARY_PATH",1,@$target[$T_LIBRARY_PATH]); + generate_list("@$target[$T_NAME]:\tLIBS",1,@$target[$T_LIBRARIES]); + + print FILEO "\n\n\n"; } } + print FILEO "\n\n"; + print FILEO "# Include rules\n"; + print FILEO "#\n"; + print FILEO "# if located in non-std place, set in your environment\n"; + print FILEO '# MAKEFLAGS="-I /path/to/winemake-include-dir/"',"\n"; + print FILEO "#\n"; + print FILEO "# or put Winemake.include at the root of your project.\n"; + print FILEO "# or include Winemake.include in the top-level Makefile with explicit path.\n"; + print FILEO "#\n"; + print FILEO "# NB: std-places (as stated in GNU make manual):\n"; + print FILEO "# /usr/include /usr/local/include ...\n"; + print FILEO "include Winemake.include"; close(FILEO); } -- 1.4.4.4