xref: /AOO41X/main/icu/createmak.pl (revision 7ccb0d530a82b7ad7d024d7230ef1f4a7f5faac3)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir    if 0;
47e90fac2SAndrew Rist#**************************************************************
5cdf0e10cSrcweir#
67e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
77e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
87e90fac2SAndrew Rist#  distributed with this work for additional information
97e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
107e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
117e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
127e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
13cdf0e10cSrcweir#
147e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
15cdf0e10cSrcweir#
167e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
177e90fac2SAndrew Rist#  software distributed under the License is distributed on an
187e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
197e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
207e90fac2SAndrew Rist#  specific language governing permissions and limitations
217e90fac2SAndrew Rist#  under the License.
22cdf0e10cSrcweir#
237e90fac2SAndrew Rist#**************************************************************
247e90fac2SAndrew Rist
257e90fac2SAndrew Rist
26cdf0e10cSrcweir#
27cdf0e10cSrcweiruse XML::Parser;
28cdf0e10cSrcweir# ------------------------------------------------------------------------
29cdf0e10cSrcweir# Other global stuff
30cdf0e10cSrcweir$is_debug=0;
31cdf0e10cSrcweirmy $path = $ENV{'INPATH'} . "/";
32cdf0e10cSrcweirmy $quot = '"';
33cdf0e10cSrcweirmy %template_hash=();
34*7ccb0d53SArrigo Marchiorimy $architecture = "x86";
35cdf0e10cSrcweirmy %vcproj_hash=();
36cdf0e10cSrcweir# ------------------------------------------------------------------------
37cdf0e10cSrcweir# Global stuff for parsing the *.vcproj files (XML::Parser)
38cdf0e10cSrcweir#
39cdf0e10cSrcweirmy $ConfigurationGlobal = 1; # Release = 1, Debug=0
40cdf0e10cSrcweirmy $Configuration = undef;
41cdf0e10cSrcweirmy %configelements = ();
42cdf0e10cSrcweirmy %files = ();
43cdf0e10cSrcweirmy %files2copy = ();
44cdf0e10cSrcweirmy %files_special = ();
45cdf0e10cSrcweirmy $Release = 1;
46cdf0e10cSrcweir     # Release = 1, Debug = 0, undef = 2
47cdf0e10cSrcweirmy $file_tmp = "";      # temporary storage for file name
48cdf0e10cSrcweirmy $CustomSection = 0;
49cdf0e10cSrcweir# ------------------------------------------------------------------------
50cdf0e10cSrcweir# ------------------------------------------------------------------------
51cdf0e10cSrcweir# e.g. %object_hash with Key = blabla.cpp
52cdf0e10cSrcweir# contains a Hash:
53cdf0e10cSrcweir# Header: "..\\common\\unicode\\utypes.h ..\\common\\unicode\\uset.h"
54cdf0e10cSrcweir# CFlags: Common (set in templates file) or special sequence
55cdf0e10cSrcweir# CDefs:  Common (set in templates file) or special sequence
56cdf0e10cSrcweir# ------------------------------------------------------------------------
57cdf0e10cSrcweirmy $configfile = shift;
58cdf0e10cSrcweirmy $sourcePath = shift;
59cdf0e10cSrcweirif ( !$configfile ) {
60cdf0e10cSrcweir    $configfile = "createmak.cfg";
61cdf0e10cSrcweir}
62cdf0e10cSrcweirif ( !$sourcePath ) {
63cdf0e10cSrcweir    $inpath = $ENV{"INPATH"};
64cdf0e10cSrcweir    $sourcePath = $inpath . "\\misc\\build\\icu\\source";
65cdf0e10cSrcweir}
66cdf0e10cSrcweir$dir = "";
67cdf0e10cSrcweir$header = "";
68cdf0e10cSrcweir$sep = "\\\\";
69cdf0e10cSrcweir
70cdf0e10cSrcweir%project_by_id =();
71cdf0e10cSrcweir%project_by_name = ();
72cdf0e10cSrcweir%project_dependencies = ();
73cdf0e10cSrcweirmy @builddeps = prepare_allinone_all_mak(\%project_by_id,\%project_by_name,\%project_dependencies,$sourcePath);
74cdf0e10cSrcweir
75cdf0e10cSrcweirfillTemplateHash($configfile);
76*7ccb0d53SArrigo Marchiori# The architecture is indicated in the configuration file
77*7ccb0d53SArrigo Marchiori$architecture=${$template_hash{"Architecture"}}[0];
78*7ccb0d53SArrigo Marchiorichomp $architecture;
79*7ccb0d53SArrigo Marchioriprint "Architecture: $architecture\n" if ($is_debug);
80cdf0e10cSrcweir
81cdf0e10cSrcweircreate_allinone_all_mak(\@builddeps,\%project_by_id,$sourcePath);
82cdf0e10cSrcweirmy @dirs = ();
83cdf0e10cSrcweirforeach $projectname(keys %project_by_name)
84cdf0e10cSrcweir{
85cdf0e10cSrcweir    my $dir = $project_by_name{$projectname}[1];
86cdf0e10cSrcweir    $dir =~ /\.\.\\(.+)\\(.+)\.vcproj/;
87cdf0e10cSrcweir    my $dir1 = $1;
88cdf0e10cSrcweir    my $dir2 = $2;
89cdf0e10cSrcweir    if ( $dir1 !~ /$dir2$/ ) {
90cdf0e10cSrcweir        $dir1 .= "\.$dir2";
91cdf0e10cSrcweir    }
92cdf0e10cSrcweir    print "$dir1 - $dir2\n" if ($is_debug);
93cdf0e10cSrcweir    push @dirs, $dir1;
94cdf0e10cSrcweir}
95cdf0e10cSrcweir
96cdf0e10cSrcweir# set nonpro switch (linking against debug runtime if nonpro=1)
97cdf0e10cSrcweirmy $nonpro = ($ENV{"PROEXT"} ne ".pro");
98cdf0e10cSrcweirprint "Non Product Build" if ($nonpro);
99cdf0e10cSrcweir
100cdf0e10cSrcweirforeach $dir(@dirs)
101cdf0e10cSrcweir{
102cdf0e10cSrcweir    next if ($dir eq "data.makedata"); # very special don't overwrite this file
103cdf0e10cSrcweir    # ------------------------------------------------------------------------
104cdf0e10cSrcweir    # Reset global stuff for parsing the *.vcproj files (XML::Parser)
105cdf0e10cSrcweir    #
106cdf0e10cSrcweir    $Configuration = $ConfigurationGlobal; # Release = 1, Debug=0
107cdf0e10cSrcweir    %configelements = ();
108cdf0e10cSrcweir    %files = ();
109cdf0e10cSrcweir       # contains all relevant *.c,*.cpp,*.h,*.rc files
110cdf0e10cSrcweir    %files2copy = ();
111cdf0e10cSrcweir    %files_special = ();
112cdf0e10cSrcweir    $Release = 2;
113cdf0e10cSrcweir     # Release = 1, Debug = 0, undef = 2
114cdf0e10cSrcweir    $file_tmp = "";      # temporary storage for file name
115cdf0e10cSrcweir    $CustomSection = 0;
116cdf0e10cSrcweir    # ------------------------------------------------------------------------
117cdf0e10cSrcweir
118cdf0e10cSrcweir    my $extra_mak = "";
119cdf0e10cSrcweir    ($dir, $extra_mak) = handle_extra_mak_files($dir); # handle e.g. tools/genrb.derb entires
120cdf0e10cSrcweir
121cdf0e10cSrcweir    my @mak=(); # Array for make file *.mak
122cdf0e10cSrcweir    my %deps=();
123cdf0e10cSrcweir    my %object_hash=();
124cdf0e10cSrcweir    my %collected_header=();
125cdf0e10cSrcweir    my %collect_header_target_hash=();
126cdf0e10cSrcweir    my %collect_object_target_hash=();
127cdf0e10cSrcweir    my $vcproj_file = "";
128cdf0e10cSrcweir    my $resource_file = "";
129cdf0e10cSrcweir
130cdf0e10cSrcweir    # $dir : common,i18n,...
131cdf0e10cSrcweir    chomp $dir;
132cdf0e10cSrcweir    next if ( $dir eq "" );
133cdf0e10cSrcweir    my $fullpath = $sourcePath . "\\" . $dir;
134cdf0e10cSrcweir    if ( $extra_mak eq "" ) {
135cdf0e10cSrcweir        if ($dir =~ /(.+)+\\(.+)$/)
136cdf0e10cSrcweir        {
137cdf0e10cSrcweir            $vcproj_file = $fullpath ."\\$2.vcproj";
138cdf0e10cSrcweir        } else
139cdf0e10cSrcweir        {
140cdf0e10cSrcweir            $vcproj_file = $fullpath ."\\$dir.vcproj";
141cdf0e10cSrcweir        }
142cdf0e10cSrcweir    } else
143cdf0e10cSrcweir    {
144cdf0e10cSrcweir        $vcproj_file = $fullpath . "\\" . $extra_mak . ".vcproj";
145cdf0e10cSrcweir    }
146cdf0e10cSrcweir
147cdf0e10cSrcweir
148cdf0e10cSrcweir    # Parse the *.vcproj file
149cdf0e10cSrcweir    my $parser = new XML::Parser(ErrorContext => 2);
150cdf0e10cSrcweir    $parser->setHandlers(Start => \&start_handler,
151cdf0e10cSrcweir                 Char  => \&char_handler);
152cdf0e10cSrcweir    $parser->parsefile($vcproj_file);
153cdf0e10cSrcweir    if ( $file_tmp ) {
154cdf0e10cSrcweir        # save a file which hasn't been saved yet
155cdf0e10cSrcweir        $files{ $file_tmp } = 1;        # save it now
156cdf0e10cSrcweir        $file_tmp = "";                 # has been saved now reset it
157cdf0e10cSrcweir    }
158cdf0e10cSrcweir
159cdf0e10cSrcweir    # is there a resource file?
160cdf0e10cSrcweir    foreach $i (keys %files)
161cdf0e10cSrcweir    {
162cdf0e10cSrcweir        if ($i =~ /\.rc/)
163cdf0e10cSrcweir        {
164cdf0e10cSrcweir            $resource_file = $i;
165cdf0e10cSrcweir        }
166cdf0e10cSrcweir    }
167cdf0e10cSrcweir    # Fill hash %deps for dependencies for all files in directory ($testdir)
168cdf0e10cSrcweir    # %files contains all relevant files from *.vcproj
169cdf0e10cSrcweir
170cdf0e10cSrcweir    getAllFilesDeps($fullpath,\%deps,\%files);
171cdf0e10cSrcweir    my $includedir = $configelements{"Release"}{"OutputDirectory"};     # e.g. OutputDirectory = ..\..\lib
172cdf0e10cSrcweir    $includedir =~ s/lib/include/;
173cdf0e10cSrcweir    foreach $file( sort keys %deps)
174cdf0e10cSrcweir    {
175cdf0e10cSrcweir        $file =~ /(.+)\.(.+)/;
176cdf0e10cSrcweir        my $name = $1;
177cdf0e10cSrcweir        my $ext  = $2;
178cdf0e10cSrcweir        next if (!defined $name);
179cdf0e10cSrcweir        $object = "\$(INTDIR)\\" . "$name.obj";
180cdf0e10cSrcweir        $collect_object_target_hash{$object}=1;
181cdf0e10cSrcweir
182cdf0e10cSrcweir        createMakDepSection($dir,$name,$ext,$deps{$file},\@mak,\%files_special);
183cdf0e10cSrcweir    }
184cdf0e10cSrcweir    my %all_target_hash=();
185cdf0e10cSrcweir    foreach $header(sort keys %files2copy)
186cdf0e10cSrcweir    {
187cdf0e10cSrcweir        my $dir;
188cdf0e10cSrcweir        my $file;
189cdf0e10cSrcweir        #$pathdepth = "..\\..";
190cdf0e10cSrcweir        $file = $header;
191cdf0e10cSrcweir        $header =~ s/^\.\\//;
192cdf0e10cSrcweir        $inputpath = $file;
193cdf0e10cSrcweir        $target = $includedir . "\\" . $header;
194cdf0e10cSrcweir        $target =~ /.+\\(.+)\\.+$/;
195cdf0e10cSrcweir        $targetpath = $configelements{"Release"}{"CommandLine"};
196cdf0e10cSrcweir        chomp $targetpath;
197cdf0e10cSrcweir        # set %all_target_hash and @mak
198cdf0e10cSrcweir        createCopySection($file,$inputpath,$target,$targetpath,\@mak,\%all_target_hash);
199cdf0e10cSrcweir        $collect_header_target_hash{$target}=1;
200cdf0e10cSrcweir    }
201cdf0e10cSrcweir    my $test = $configelements{"Release"}{"OutputFile"};
202cdf0e10cSrcweir    $all_target_hash{$test}=1;
203cdf0e10cSrcweir
204cdf0e10cSrcweir    # set name of the *.mak file
205cdf0e10cSrcweir    my $mak_file="";
206cdf0e10cSrcweir    if ( $extra_mak eq "" ) {
207cdf0e10cSrcweir        $mak_file = $vcproj_file;
208cdf0e10cSrcweir        $mak_file =~ s/vcproj/mak/;
209cdf0e10cSrcweir    } else
210cdf0e10cSrcweir    {
211cdf0e10cSrcweir        # extra_mak eg. derb, stringperf
212cdf0e10cSrcweir        $mak_file = $fullpath . "\\$extra_mak" . "\.mak";
213cdf0e10cSrcweir    }
214cdf0e10cSrcweir
215cdf0e10cSrcweir    # generate the content of the *.mak file
216cdf0e10cSrcweir    # in @mak array
217cdf0e10cSrcweir    print "extra_mak=$extra_mak\n" if ($is_debug);
218cdf0e10cSrcweir    print "mak_file=$mak_file\n" if ($is_debug);
219cdf0e10cSrcweir    open(MAKFILE, ">$mak_file") || die "Can't open $mak_file\n";
220cdf0e10cSrcweir    print_all_target($fullpath, \%all_target_hash);
221cdf0e10cSrcweir
222cdf0e10cSrcweir    # $extra_mak handles further *.mak files in a directory
223cdf0e10cSrcweir    print_flags($dir,$extra_mak,'CFlags',$nonpro);    # depends on directory
224cdf0e10cSrcweir    print_simple_flag("Rules");
225cdf0e10cSrcweir    print_simple_flag("Link");
226cdf0e10cSrcweir    print_common_linkflags();
227cdf0e10cSrcweir#    print_flags($fullpath,$extra_mak,'LinkFlags'); # depends on directory
228cdf0e10cSrcweir#    print_lib32_objs($fullpath,$extra_mak,\%collect_object_target_hash,$resource_file);
229cdf0e10cSrcweir    print_flags($dir,$extra_mak,'LinkFlags'); # depends on directory
230cdf0e10cSrcweir    print_lib32_objs($dir,$extra_mak,\%collect_object_target_hash,$resource_file);
231cdf0e10cSrcweir
232cdf0e10cSrcweir    # write @mak array into the *.mak file
233cdf0e10cSrcweir    foreach $line(@mak)
234cdf0e10cSrcweir    {
235cdf0e10cSrcweir        print MAKFILE $line;
236cdf0e10cSrcweir    }
237cdf0e10cSrcweir	$|=1;
238cdf0e10cSrcweir    print "."; # user entertainment
239cdf0e10cSrcweir	$|=0;
240cdf0e10cSrcweir}
241cdf0e10cSrcweirprint "\ndone\n";
242cdf0e10cSrcweirexit;
243cdf0e10cSrcweir
244cdf0e10cSrcweir############################################################################
245cdf0e10cSrcweirsub getKey		#01.04.2008 09:46
246cdf0e10cSrcweir############################################################################
247cdf0e10cSrcweir {
248cdf0e10cSrcweir	my $line = shift;
249cdf0e10cSrcweir	$line =~ /\[(.+)\]/;
250cdf0e10cSrcweir	return $1;
251cdf0e10cSrcweir}	##getKey
252cdf0e10cSrcweir
253cdf0e10cSrcweir############################################################################
254cdf0e10cSrcweirsub fillTemplateHash		#01.04.2008 10:48
255cdf0e10cSrcweir############################################################################
256cdf0e10cSrcweir {
257cdf0e10cSrcweir	my $file = shift;
258cdf0e10cSrcweir	open (TEMPLATE, "< $file") || die "Can't open template file $file\n";
259cdf0e10cSrcweir    my $key = "";
260cdf0e10cSrcweir	while ( $line=<TEMPLATE> ) {
261cdf0e10cSrcweir		if ( $line =~ /\[.+\]/ ) {
262cdf0e10cSrcweir            print $line if ($is_debug);
263cdf0e10cSrcweir			if ( $key ne "" ) {
264cdf0e10cSrcweir				$template_hash{$key}=[@cmdlines];
265cdf0e10cSrcweir				@cmdlines="";
266cdf0e10cSrcweir				$key="";
267cdf0e10cSrcweir			}
268cdf0e10cSrcweir			$key = getKey( $line );
269cdf0e10cSrcweir		} else
270cdf0e10cSrcweir		{
271cdf0e10cSrcweir			push @cmdlines, $line;
272cdf0e10cSrcweir		}
273cdf0e10cSrcweir	} # while
274cdf0e10cSrcweir}	##fillTemplateHash
275cdf0e10cSrcweir
276cdf0e10cSrcweir############################################################################
277cdf0e10cSrcweirsub createCopySection		#01.04.2008 11:37
278cdf0e10cSrcweir############################################################################
279cdf0e10cSrcweir {
280cdf0e10cSrcweir	my $header	   = shift;
281cdf0e10cSrcweir	my $inputpath  = shift;
282cdf0e10cSrcweir	my $target	   = shift;
283cdf0e10cSrcweir	my $targetpath = shift;
284cdf0e10cSrcweir	my $ref_make_file = shift; # Array written later to make file *.mak
285cdf0e10cSrcweir    my $ref_all_target_hash = shift;  # reference to fill all_target_hash;
286cdf0e10cSrcweir    if ( $target !~ /\\include/ && $target !~ /\\bin/) {
287cdf0e10cSrcweir        return; # $target contains nonsense
288cdf0e10cSrcweir    }
289cdf0e10cSrcweir    if ( !$targetpath ) {
290cdf0e10cSrcweir        # $targetpath is empty! (Due to missing entry in *.vcproj file)
291cdf0e10cSrcweir        # Generate $targetpath here from $target
292cdf0e10cSrcweir        my $t = $target;
293cdf0e10cSrcweir        $t =~ /(.+)\\(.+)$/;
294cdf0e10cSrcweir        $targetpath = "copy \"\$(InputPath)\" " . $1;
295cdf0e10cSrcweir        chomp $targetpath;
296cdf0e10cSrcweir    }
297cdf0e10cSrcweir    $targetpath =~ s/\r$//; # remove x0A from EOL if the is one
298cdf0e10cSrcweir	my @template = @{$template_hash{"Copy"}};
299cdf0e10cSrcweir	my $line = "";
300cdf0e10cSrcweir	foreach $line(@template)
301cdf0e10cSrcweir	{
302cdf0e10cSrcweir		$line =~ s/<HEADER>/$header/g;
303cdf0e10cSrcweir		$line =~ s/<INPUTPATH>/$inputpath/g;
304cdf0e10cSrcweir		$line =~ s/<TARGET>/$target/g;
305cdf0e10cSrcweir        $line =~ s/<TARGETPATH>/$targetpath/;
306cdf0e10cSrcweir        push @{$ref_make_file}, $line;           # from template
307cdf0e10cSrcweir        $$ref_all_target_hash{$target} = 1;       # "\"$target\" ";
308cdf0e10cSrcweir     # save for target ALL:
309cdf0e10cSrcweir	}
310cdf0e10cSrcweir}	##createCopySection
311cdf0e10cSrcweir
312cdf0e10cSrcweir############################################################################
313cdf0e10cSrcweirsub createMakDepSection		#01.04.2008 13:36
314cdf0e10cSrcweir############################################################################
315cdf0e10cSrcweir {
316cdf0e10cSrcweir	# creates the dependency section in the make file
317cdf0e10cSrcweir    my $dir         = shift;
318cdf0e10cSrcweir	my $source 		= shift;
319cdf0e10cSrcweir	my $extension	= shift;
320cdf0e10cSrcweir	my $ref_header_list	= shift;
321cdf0e10cSrcweir	my $ref_make_file = shift; # Array written later to make file *.mak
322cdf0e10cSrcweir    my $ref_special_file = shift; # hash for special files (compiler flags, include paths)
323cdf0e10cSrcweir	my $header_list = "";
324cdf0e10cSrcweir    my $special_flag = 0;
325cdf0e10cSrcweir
326cdf0e10cSrcweir    return if ( !defined $source );
327cdf0e10cSrcweir	foreach $header(@{$ref_header_list})
328cdf0e10cSrcweir	{
329cdf0e10cSrcweir        if ( ($header =~ /^\.\.\\.+/) && (-e $header )) {
330cdf0e10cSrcweir			$header_list = $header_list . " " . $header; # this header is located in an other directory
331cdf0e10cSrcweir		} else
332cdf0e10cSrcweir		{
333cdf0e10cSrcweir			$header_list = $header_list . " .\\" . $header;
334cdf0e10cSrcweir		}
335cdf0e10cSrcweir	}
336cdf0e10cSrcweir
337cdf0e10cSrcweir    #special handling
338cdf0e10cSrcweir    # compile this file with other compiler switches
339cdf0e10cSrcweir    my $file = $source . "\." . $extension;
340cdf0e10cSrcweir    $dir =~ s/\\/_/;
341cdf0e10cSrcweir    my @template = @{$template_hash{"CFlags_$dir"}};
342cdf0e10cSrcweir    if ( defined $$ref_special_file{"AdditionalIncludeDirectories"}{$file} ) {
343cdf0e10cSrcweir        $special_flag = 1;
344cdf0e10cSrcweir        my $includepath = $$ref_special_file{"AdditionalIncludeDirectories"}{$file};
345cdf0e10cSrcweir        $includepath =~ s/\;/\/I /g;                   # subst ; with /I for multiple paths
346cdf0e10cSrcweir        $line = "CPP_SWITCH_INCLUDE=/I  $includepath\n";
347cdf0e10cSrcweir		push @{$ref_make_file}, $line;
348cdf0e10cSrcweir        foreach $line(@template)
349cdf0e10cSrcweir        {
350cdf0e10cSrcweir            if ( $line =~ /CPP_PROJ/)
351cdf0e10cSrcweir            {
352cdf0e10cSrcweir                $line =~ s/CPP_PROJ=/CPPX_PROJ=/;
353cdf0e10cSrcweir                $line =~ s/\$\(CDEFS\)/\$\(CDEFS\) \$\(CPP_SWITCH_INCLUDE\)/; # include $(CPP_SWITCH_INCLUDE)
354cdf0e10cSrcweir                push @{$ref_make_file}, $line;
355cdf0e10cSrcweir            }
356cdf0e10cSrcweir        }
357cdf0e10cSrcweir    }
358cdf0e10cSrcweir    if ( $$ref_special_file{"DisableLanguageExtensions"}{$file} )
359cdf0e10cSrcweir    {
360cdf0e10cSrcweir        # FALSE = /Ze
361cdf0e10cSrcweir        $special_flag = 1;
362cdf0e10cSrcweir        foreach $line(@template)
363cdf0e10cSrcweir        {
364cdf0e10cSrcweir            if ( $line =~ /CPP_PROJ/)
365cdf0e10cSrcweir            {
366cdf0e10cSrcweir                $line =~ s/CPP_PROJ=/CPPX_PROJ=/;
367cdf0e10cSrcweir                $line =~ s/-Za/-Ze/;
368cdf0e10cSrcweir                if ( $nonpro )
369cdf0e10cSrcweir                {
370cdf0e10cSrcweir                    # if non product link against debug libraries
371cdf0e10cSrcweir                    $line =~ s/-MD/-MDd/;
372cdf0e10cSrcweir                    $line =~ s/-MT/-MTd/;
373cdf0e10cSrcweir                }
374cdf0e10cSrcweir                push @{$ref_make_file}, $line;
375cdf0e10cSrcweir            }
376cdf0e10cSrcweir        }
377cdf0e10cSrcweir    }
378cdf0e10cSrcweir
379cdf0e10cSrcweir    @template = @{$template_hash{"Deps"}};
380cdf0e10cSrcweir	my $line = "";
381cdf0e10cSrcweir	foreach $line(@template)
382cdf0e10cSrcweir	{
383cdf0e10cSrcweir		$line =~ s/<SOURCEFILE>/$source/g;
384cdf0e10cSrcweir		$line =~ s/<EXT>/$extension/g;
385cdf0e10cSrcweir        $line =~ s/<HEADER_LIST>/$header_list/g;
386cdf0e10cSrcweir		push @{$ref_make_file}, $line;
387cdf0e10cSrcweir	}
388cdf0e10cSrcweir
389cdf0e10cSrcweir    if ( $special_flag )
390cdf0e10cSrcweir    {
391cdf0e10cSrcweir        pop @{$ref_make_file}; # remove empty line
392cdf0e10cSrcweir        push @{$ref_make_file},"\t\$(CPP) @<<\n";
393cdf0e10cSrcweir        push @{$ref_make_file},"\t\$(CPPX_PROJ) \$(SOURCE)\n";
394cdf0e10cSrcweir        push @{$ref_make_file},"<<\n\n";
395cdf0e10cSrcweir        $special_flag = 0;
396cdf0e10cSrcweir    }
397cdf0e10cSrcweir
398cdf0e10cSrcweir}	##createMakDepSection
399cdf0e10cSrcweir
400cdf0e10cSrcweir
401cdf0e10cSrcweir############################################################################
402cdf0e10cSrcweirsub getFilenameFromPath		#10.04.2008 13:03
403cdf0e10cSrcweir############################################################################
404cdf0e10cSrcweir{
405cdf0e10cSrcweir	my $path = shift;
406cdf0e10cSrcweir	$path =~ /.+\\(.+)$/;
407cdf0e10cSrcweir	return $1;
408cdf0e10cSrcweir}	##getFilenameFromPath
409cdf0e10cSrcweir
410cdf0e10cSrcweir############################################################################
411cdf0e10cSrcweirsub getAllFilesDeps		#08.04.2008 09:39
412cdf0e10cSrcweir############################################################################
413cdf0e10cSrcweir{
414cdf0e10cSrcweir	my $path = shift;
415cdf0e10cSrcweir	my $ref_deps = shift;
416cdf0e10cSrcweir    my $ref_allfiles = shift;       # contains all relevant files from *.vcproj
417cdf0e10cSrcweir    my %local_header_hash=();       # contains all local header
418cdf0e10cSrcweir
419cdf0e10cSrcweir    my @all_files = keys %{$ref_allfiles};
420cdf0e10cSrcweir
421cdf0e10cSrcweir    # collect lokal header names in %header_hash
422cdf0e10cSrcweir    foreach $file(@all_files)
423cdf0e10cSrcweir    {
424cdf0e10cSrcweir        if ( $file =~ /.+\.h/ ) {
425cdf0e10cSrcweir            chomp $file;
426cdf0e10cSrcweir            $local_header_hash{$file} = 1;
427cdf0e10cSrcweir        }
428cdf0e10cSrcweir    }
429cdf0e10cSrcweir
430cdf0e10cSrcweir	foreach $file(@all_files)
431cdf0e10cSrcweir	{
432cdf0e10cSrcweir        my @header_deps=();
433cdf0e10cSrcweir        my $skip = 0;
434cdf0e10cSrcweir
435cdf0e10cSrcweir        $file =~ s/^\.\\//; # remove leading .\
436cdf0e10cSrcweir
437cdf0e10cSrcweir		# exclude sub directories and several file extensions
438cdf0e10cSrcweir        # *.dep,*.h,*.in,*.mak,*.pl,*.txt,*.vcproj.*.rc and origs of patch files (*.*~) and
439cdf0e10cSrcweir        # .cvsignore (files beginning with .)
440cdf0e10cSrcweir        next if ( (-d "$path$sep$file") || ($file =~ /.+(_|\~|dep|h|in|mak|pl|txt|vcproj|rc)$/) || ($file =~ /^\.+./));
441cdf0e10cSrcweir        parse_header_deps($path,$file,\@header_deps,\%local_header_hash);
442cdf0e10cSrcweir		handle_dep_to_other_directory($path,$file,\@header_deps,$$ref_vcproj{$file}) if ($$ref_vcproj{$file});
443cdf0e10cSrcweir		$$ref_deps{$file}=[@header_deps];
444cdf0e10cSrcweir    }
445cdf0e10cSrcweir}	##getAllFilesDeps
446cdf0e10cSrcweir
447cdf0e10cSrcweir ############################################################################
448cdf0e10cSrcweir sub parse_header_deps		#14.06.2006 18:04
449cdf0e10cSrcweir ############################################################################
450cdf0e10cSrcweir  {
451cdf0e10cSrcweir	# get includes from c/cpp file
452cdf0e10cSrcweir	# call create_deps(path,file,\$link_obj)
453cdf0e10cSrcweir	#
454cdf0e10cSrcweir	my $path = shift;
455cdf0e10cSrcweir	my $cfile = shift;
456cdf0e10cSrcweir	my $ref_header_deps = shift;
457cdf0e10cSrcweir    my $ref_local_header_hash = shift;
458cdf0e10cSrcweir
459cdf0e10cSrcweir	my $fullpath = $path . $sep . $cfile;
460cdf0e10cSrcweir	my $unicodedep="";
461cdf0e10cSrcweir   	open(IN, "<$fullpath") || die "can't open $fullpath\n";
462cdf0e10cSrcweir	while ( $line = <IN> ) {
463cdf0e10cSrcweir		next if ($line !~ /^.?\#include.+/); # handle include lines only
464cdf0e10cSrcweir		if ($line =~ /.+?\s(.+)/)
465cdf0e10cSrcweir		{
466cdf0e10cSrcweir			$header = $1;
467cdf0e10cSrcweir			if ( ($header !~ /^<.+/) && ($header !~ /.+\.c.+$/) ) {
468cdf0e10cSrcweir				# no <stdio> etc. header
469cdf0e10cSrcweir				$header =~ s/\s+\/\*.+\*\///; # delete <blanks>/* ... */
470cdf0e10cSrcweir				$header =~ s/\s+\/\/.+//;	   # delete <blanks>//......
471cdf0e10cSrcweir				$header =~ s/\//\\/;		   # subst. / with \
472cdf0e10cSrcweir				$header =~ s/^\"/\".\\/;
473cdf0e10cSrcweir				$header =~ s/\"//g;
474cdf0e10cSrcweir				$header =~ s/\.\\//;
475cdf0e10cSrcweir                my $test = $$ref_local_header_hash{$header};
476cdf0e10cSrcweir                    my $header_fullpath = $path . "\\" . $header;
477cdf0e10cSrcweir                if ( $test || (($header =~ /\\/) && (-e $header_fullpath))) {
478cdf0e10cSrcweir                    push @{$ref_header_deps}, $header;
479cdf0e10cSrcweir                }
480cdf0e10cSrcweir			}
481cdf0e10cSrcweir		}
482cdf0e10cSrcweir	}
483cdf0e10cSrcweir }	##parse_header_deps
484cdf0e10cSrcweir
485cdf0e10cSrcweir############################################################################
486cdf0e10cSrcweirsub handle_dep_to_other_directory		#16.04.2008 15:11
487cdf0e10cSrcweir############################################################################
488cdf0e10cSrcweir{
489cdf0e10cSrcweir	# there has been an additional include directoy detected
490cdf0e10cSrcweir	# now try to find out which header (parsed from c/cpp-file)
491cdf0e10cSrcweir	# comes from this directory by checking: does it exist there?
492cdf0e10cSrcweir	my $path = shift;
493cdf0e10cSrcweir	my $file = shift;
494cdf0e10cSrcweir	my $ref_header_deps = shift;
495cdf0e10cSrcweir	my $path_additional = shift;
496cdf0e10cSrcweir	my $search_path = $path . "\\" . $path_additional;
497cdf0e10cSrcweir	my $counter = 0;
498cdf0e10cSrcweir	foreach $header(@{$ref_header_deps})
499cdf0e10cSrcweir	{
500cdf0e10cSrcweir		my $full_path = $search_path . "\\" . $header;
501cdf0e10cSrcweir		if ( -e "$full_path" )
502cdf0e10cSrcweir		{
503cdf0e10cSrcweir			$$ref_header_deps[$counter] = $path_additional . "\\" .	$header;
504cdf0e10cSrcweir		}
505cdf0e10cSrcweir		$counter++
506cdf0e10cSrcweir	}
507cdf0e10cSrcweir} 	##handle_dep_to_other_directory
508cdf0e10cSrcweir
509cdf0e10cSrcweir############################################################################
510cdf0e10cSrcweirsub print_lib32_objs		#18.04.2008 12:54
511cdf0e10cSrcweir############################################################################
512cdf0e10cSrcweir {
513cdf0e10cSrcweir    # generate Link section
514cdf0e10cSrcweir	my $path = shift;
515cdf0e10cSrcweir    my $extra_mak = shift;
516cdf0e10cSrcweir	my $ref_objecthash = shift;
517cdf0e10cSrcweir    my $resource_file = shift;
518cdf0e10cSrcweir	# output link objects
519cdf0e10cSrcweir	print MAKFILE "LINK32_OBJS= \\\n";
520cdf0e10cSrcweir    # print objects
521cdf0e10cSrcweir	foreach $object(sort keys %{$ref_objecthash})
522cdf0e10cSrcweir	{
523cdf0e10cSrcweir		print MAKFILE "\t$object \\\n";
524cdf0e10cSrcweir	}
525cdf0e10cSrcweir
526cdf0e10cSrcweir    # print *.res if *.rc exists
527cdf0e10cSrcweir    if ( $resource_file ne "" ) {
528cdf0e10cSrcweir        my $res_file = $resource_file;
529cdf0e10cSrcweir        $res_file =~ s/\.rc/\.res/;
530cdf0e10cSrcweir        $res_file =~ /(.+)\\(.+)$/;
531cdf0e10cSrcweir        $res_file = $2;
532cdf0e10cSrcweir        print MAKFILE "\t\$(INTDIR)\\$res_file \\\n";
533cdf0e10cSrcweir    }
534cdf0e10cSrcweir
535cdf0e10cSrcweir    # add import libs and res files
536cdf0e10cSrcweir    print_flags($path,$extra_mak,"AdditionalLinkObjects");
537cdf0e10cSrcweir    my $outfile = $configelements{"Release"}{"OutputFile"};
538cdf0e10cSrcweir
539cdf0e10cSrcweir    # section for linking
540cdf0e10cSrcweir    print_link_template($path,$outfile);
541cdf0e10cSrcweir
542cdf0e10cSrcweir    # section for creating res files
543cdf0e10cSrcweir    # setting for rsc, res target etc.
544cdf0e10cSrcweir    print "resource_file=$resource_file\n" if ($is_debug);
545cdf0e10cSrcweir    print_rsc_template($resource_file) if ($resource_file);
546cdf0e10cSrcweir    print_simple_flag("Special_extra_uconv") if ($outfile =~ /uconv/);
547cdf0e10cSrcweir}	##print_lib32_objs
548cdf0e10cSrcweir
549cdf0e10cSrcweir############################################################################
550cdf0e10cSrcweirsub print_all_target        #26.06.2008 13:27
551cdf0e10cSrcweir############################################################################
552cdf0e10cSrcweir {
553cdf0e10cSrcweir    my $path = shift;
554cdf0e10cSrcweir    my $ref_all_target_hash = shift;
555cdf0e10cSrcweir    my $filename = getFilenameFromPath($path);
556cdf0e10cSrcweir    my $outdir = $configelements{"Release"}{"OutputDirectory"};
557cdf0e10cSrcweir    print MAKFILE "NULL=\n";
558cdf0e10cSrcweir    print MAKFILE "OUTDIR=$outdir\n";
559cdf0e10cSrcweir    print MAKFILE "OutDir=$outdir\n";
560cdf0e10cSrcweir    print MAKFILE "INTDIR=.\\Release\n\n";
561cdf0e10cSrcweir    print MAKFILE "ALL: ";
562cdf0e10cSrcweir    foreach $target(sort keys %{$ref_all_target_hash})
563cdf0e10cSrcweir    {
564cdf0e10cSrcweir        if ( $target =~ /\.exe/ ) {
565cdf0e10cSrcweir            my $out = $target;
566*7ccb0d53SArrigo Marchiori            $out =~ s/\.\\((x64|x86)\\)?Release/\.\.\\\.\.\\\.\.\\$1bin/;
567cdf0e10cSrcweir            $out =~ s/\$\(OutDir\)/\.\.\\\.\.\\\.\.\\bin/;
568cdf0e10cSrcweir            $out =~ s/\//\\/; # convert / to \
569cdf0e10cSrcweir            $target = $out;
570cdf0e10cSrcweir        }
571cdf0e10cSrcweir        print MAKFILE "\"$target\" ";
572cdf0e10cSrcweir    }
573cdf0e10cSrcweir
574cdf0e10cSrcweir    # Append [Target_<dir>] item e.g. ../../icuxy36.dll
575cdf0e10cSrcweir    my $targetkey = "Target_" . $filename;
576cdf0e10cSrcweir    my @target = ();
577cdf0e10cSrcweir    if ( exists $template_hash{$targetkey}  ) {
578cdf0e10cSrcweir        @target = @{$template_hash{$targetkey}};
579cdf0e10cSrcweir    }
580cdf0e10cSrcweir    my $additional_target="";
581cdf0e10cSrcweir    foreach $additional_target(@target)
582cdf0e10cSrcweir    {
583cdf0e10cSrcweir        print MAKFILE $additional_target if ($additional_target ne "");
584cdf0e10cSrcweir    }
585cdf0e10cSrcweir    print MAKFILE "\n\n";
586cdf0e10cSrcweir    print MAKFILE "\"\$(OUTDIR)\" : \n";
587cdf0e10cSrcweir    print MAKFILE "\tif not exist \"\$(OUTDIR)/\$(NULL)\" mkdir \"\$(OUTDIR)\"\n\n";
588cdf0e10cSrcweir    print MAKFILE "!IF \"\$(OUTDIR)\" != \"\$(INTDIR)\"\n";
589cdf0e10cSrcweir    print MAKFILE "\"\$(INTDIR)\" : \n";
590cdf0e10cSrcweir    print MAKFILE "\tif not exist \"\$(INTDIR)/\$(NULL)\" mkdir \"\$(INTDIR)\"\n";
591cdf0e10cSrcweir    print MAKFILE "!ENDIF\n";
592cdf0e10cSrcweir    print MAKFILE "\n\n";
593cdf0e10cSrcweir}   ##print_all_target
594cdf0e10cSrcweir
595cdf0e10cSrcweir############################################################################
596cdf0e10cSrcweirsub print_simple_flag		#18.04.2008 13:39
597cdf0e10cSrcweir############################################################################
598cdf0e10cSrcweir{
599cdf0e10cSrcweir	my $simple_flag = shift;
600cdf0e10cSrcweir	my @template = @{$template_hash{$simple_flag}};
601cdf0e10cSrcweir	foreach $line(@template)
602cdf0e10cSrcweir	{
603cdf0e10cSrcweir		print MAKFILE $line;
604cdf0e10cSrcweir	}
605cdf0e10cSrcweir}	##print_rules
606cdf0e10cSrcweir
607cdf0e10cSrcweir############################################################################
608cdf0e10cSrcweirsub print_link_template       #18.04.2008 13:39
609cdf0e10cSrcweir############################################################################
610cdf0e10cSrcweir{
611cdf0e10cSrcweir    my $dir = shift;
612cdf0e10cSrcweir    my $outfile = shift;
613cdf0e10cSrcweir    my $manifest;
614cdf0e10cSrcweir    # set resource id for manifest file
615cdf0e10cSrcweir    if ( $outfile =~ /\.exe/ ) {
616cdf0e10cSrcweir        $manifest = 1;
617cdf0e10cSrcweir    } else
618cdf0e10cSrcweir    {
619cdf0e10cSrcweir        $manifest = 2;
620cdf0e10cSrcweir    }
621cdf0e10cSrcweir    my @template = ();
622cdf0e10cSrcweir    if ($dir =~ /stubdata/ ) {
623cdf0e10cSrcweir        @template = @{$template_hash{"Special_stubdata"}};
624cdf0e10cSrcweir    } else
625cdf0e10cSrcweir    {
626cdf0e10cSrcweir        @template = @{$template_hash{"LinkTemplate"}};
627cdf0e10cSrcweir    }
628cdf0e10cSrcweir
629cdf0e10cSrcweir    print MAKFILE "\n"; # insert blank line
630cdf0e10cSrcweir	foreach $line(@template)
631cdf0e10cSrcweir	{
632cdf0e10cSrcweir        $line =~ s/<OUTFILE>/$outfile/;
633cdf0e10cSrcweir        $line =~ s/<MANIFEST>/$manifest/;
634cdf0e10cSrcweir		print MAKFILE $line;
635cdf0e10cSrcweir	}
636cdf0e10cSrcweir
637cdf0e10cSrcweir    # insert special stuff for
638cdf0e10cSrcweir    # extras/uconv/uconv.mak
639cdf0e10cSrcweir    if ( $dir =~ /uconv/ ) {
640cdf0e10cSrcweir        print_flags($dir,"","Special");
641cdf0e10cSrcweir    }
642cdf0e10cSrcweir
643cdf0e10cSrcweir    # for *.exe files an additional
644cdf0e10cSrcweir    # copy section is required to get
645*7ccb0d53SArrigo Marchiori    # the stuff into the per-arch bin directory
646cdf0e10cSrcweir    my %dummy = ();
647cdf0e10cSrcweir    my @mak = ();
648*7ccb0d53SArrigo Marchiori    my $arch = "";
649*7ccb0d53SArrigo Marchiori    if ( $out =~ /x64/ ) {
650*7ccb0d53SArrigo Marchiori	$arch = "x64\\";
651*7ccb0d53SArrigo Marchiori    } elsif ( $out =~ /x86/ ) {
652*7ccb0d53SArrigo Marchiori	$arch = "x86\\";
653*7ccb0d53SArrigo Marchiori    }
654cdf0e10cSrcweir    if( $manifest ==1 )
655cdf0e10cSrcweir    {
656cdf0e10cSrcweir        # source,inputpath,target,action
657cdf0e10cSrcweir        my $out = $outfile;
658*7ccb0d53SArrigo Marchiori        $out =~ s/\.\\((x64|x86)\\)?Release/\.\.\\\.\.\\\.\.\\$1bin/;
659cdf0e10cSrcweir        $out =~ s/\$\(OutDir\)/\.\.\\\.\.\\\.\.\\bin/;
660cdf0e10cSrcweir        $out =~ s/\//\\/;       # subst / with \
661cdf0e10cSrcweir        $outfile =~ s/\//\\/;   # subst / with \
662*7ccb0d53SArrigo Marchiori        createCopySection($outfile,$outfile,$out,"copy \"\$(InputPath)\" .\\..\\..\\..\\${arch}bin",\@mak,\%dummy);
663cdf0e10cSrcweir        foreach $line(@mak)
664cdf0e10cSrcweir        {
665cdf0e10cSrcweir            print MAKFILE $line;
666cdf0e10cSrcweir        }
667cdf0e10cSrcweir    }
668cdf0e10cSrcweir}	##print_rules
669cdf0e10cSrcweir
670cdf0e10cSrcweir############################################################################
671cdf0e10cSrcweirsub print_rsc_template      #04.11.2008 14:48
672cdf0e10cSrcweir############################################################################
673cdf0e10cSrcweir {
674cdf0e10cSrcweir    # print resource compiler setting + resource target
675cdf0e10cSrcweir    my $resourcefile = shift;
676cdf0e10cSrcweir    # skip this if no res file required
677cdf0e10cSrcweir
678cdf0e10cSrcweir    return if (!$resourcefile);
679cdf0e10cSrcweir    $resfile = $resourcefile;
680cdf0e10cSrcweir    #remove file extension (.res)
681cdf0e10cSrcweir    $resfile =~ /(.+)\\(.+)\.(.+)/;
682cdf0e10cSrcweir    $resfile = $2;
683cdf0e10cSrcweir
684cdf0e10cSrcweir    my @template = @{$template_hash{"RSC_Template"}};
685cdf0e10cSrcweir    print MAKFILE "\n"; # insert blank line
686cdf0e10cSrcweir	foreach $line(@template)
687cdf0e10cSrcweir	{
688cdf0e10cSrcweir        $line =~ s/<FILE>/$resourcefile/;
689cdf0e10cSrcweir        $line =~ s/<FILEOUT>/$resfile/;
690cdf0e10cSrcweir		print MAKFILE $line;
691cdf0e10cSrcweir	}
692cdf0e10cSrcweir}   ##print_rsc_template
693cdf0e10cSrcweir
694cdf0e10cSrcweir############################################################################
695cdf0e10cSrcweirsub print_flags		#18.04.2008 14:19
696cdf0e10cSrcweir############################################################################
697cdf0e10cSrcweir{
698cdf0e10cSrcweir    # CFlags, LinkFlags
699cdf0e10cSrcweir    my $dir = shift;
700cdf0e10cSrcweir    my $extra_mak = shift; # eg. derb.mak, stringperf.mak
701cdf0e10cSrcweir	my $flag = shift;
702cdf0e10cSrcweir    my $nonpro = shift;
703cdf0e10cSrcweir	my @template = ();
704cdf0e10cSrcweir    my $switch = "";
705cdf0e10cSrcweir    $dir =~ s/\\/_/g if ($dir);            # change \ to _
706cdf0e10cSrcweir    $switch = "$flag" . "_" . "$dir" if ($dir);
707cdf0e10cSrcweir    handle_CFlags() if ($flag eq "CFlags");  # get and print Preprocessor defines
708cdf0e10cSrcweir    $switch .= "\." . $extra_mak if ( $extra_mak ne "" ) ;
709cdf0e10cSrcweir    if ( exists $template_hash{$switch} ) {
710cdf0e10cSrcweir        @template = @{$template_hash{$switch}};
711cdf0e10cSrcweir        foreach $line(@template)
712cdf0e10cSrcweir        {
713cdf0e10cSrcweir            if ( $nonpro )
714cdf0e10cSrcweir            {
715cdf0e10cSrcweir                # if non product link against debug libraries
716cdf0e10cSrcweir                $line =~ s/-MD/-MDd/;
717cdf0e10cSrcweir                $line =~ s/-MT/-MTd/;
718cdf0e10cSrcweir            }
719cdf0e10cSrcweir            print MAKFILE $line;
720cdf0e10cSrcweir        }
721cdf0e10cSrcweir    }
722cdf0e10cSrcweir}	##print_flags
723cdf0e10cSrcweir
724cdf0e10cSrcweir############################################################################
725cdf0e10cSrcweirsub handle_CFlags       #28.01.2009 11:20
726cdf0e10cSrcweir############################################################################
727cdf0e10cSrcweir {
728cdf0e10cSrcweir
729cdf0e10cSrcweir    my $ppdefs = $configelements{"Release"}{"PreprocessorDefinitions"};
730cdf0e10cSrcweir    my $ppinc  = $configelements{"Release"}{"AdditionalIncludeDirectories"};
731cdf0e10cSrcweir    my @template = @{$template_hash{"General_CFlags"}};
732cdf0e10cSrcweir    $ppdefs =~ s/;/ -D/g; # subst ; with -D switch
733cdf0e10cSrcweir    $ppdefs = "-D" . $ppdefs;
734cdf0e10cSrcweir    $ppinc =~ s/(;|,)/ -I/g; # subst ; with -I switch
735cdf0e10cSrcweir    $ppinc = "-I" . $ppinc;
736cdf0e10cSrcweir    print "ppdefs=$ppdefs\n" if ($is_debug);
737cdf0e10cSrcweir    print "ppinc =$ppinc\n" if ($is_debug);
738cdf0e10cSrcweir	foreach $line(@template)
739cdf0e10cSrcweir	{
740cdf0e10cSrcweir        $line =~ s/<AddIncDirs>/$ppinc/;
741cdf0e10cSrcweir        $line =~ s/<PreProcDefs>/$ppdefs/;
742cdf0e10cSrcweir		print MAKFILE $line;
743cdf0e10cSrcweir	}
744cdf0e10cSrcweir}   ##handle_CFlags
745cdf0e10cSrcweir
746cdf0e10cSrcweir############################################################################
747cdf0e10cSrcweirsub print_common_linkflags      #21.11.2008 11:47
748cdf0e10cSrcweir############################################################################
749cdf0e10cSrcweir {
750cdf0e10cSrcweir    my @template = @{$template_hash{"CommonLinkFlags"}};
751cdf0e10cSrcweir    my $outfile = $configelements{"Release"}{"OutputFile"};
752cdf0e10cSrcweir    my $pdbfile = $configelements{"Release"}{"ProgramDatabaseFile"};
753cdf0e10cSrcweir    $pdbfile =~ s/\//\\/;   # subst / with \
754cdf0e10cSrcweir    $outfile =~ s/\//\\/;   # subst / with \
755cdf0e10cSrcweir    print "PATH=$path OUTFILE=$outfile\n" if ($is_debug);
756cdf0e10cSrcweir	foreach $line(@template)
757cdf0e10cSrcweir	{
758cdf0e10cSrcweir        $line =~ s/<OUTFILE>/$outfile/;
759cdf0e10cSrcweir        $line =~ s/<PDBFILE>/$pdbfile/;
760cdf0e10cSrcweir		print MAKFILE $line;
761cdf0e10cSrcweir	}
762cdf0e10cSrcweir}   ##print_common_linkflags
763cdf0e10cSrcweir
764cdf0e10cSrcweir############################################################################
765cdf0e10cSrcweirsub handle_extra_mak_files      #25.08.2008 14:32
766cdf0e10cSrcweir############################################################################
767cdf0e10cSrcweir{
768cdf0e10cSrcweir    # extract extra filename for *.mak file
769cdf0e10cSrcweir    # e.g input: tools\genrb.derb
770cdf0e10cSrcweir    #    output: derb
771cdf0e10cSrcweir    my $direntry = shift;
772cdf0e10cSrcweir    my $out = "";
773cdf0e10cSrcweir    my $dir = "";
774cdf0e10cSrcweir    if ( $direntry =~ /(.+)\.(.+)$/ ) {
775cdf0e10cSrcweir        $dir = $1;
776cdf0e10cSrcweir        $out = $2;
777cdf0e10cSrcweir    } else
778cdf0e10cSrcweir    {
779cdf0e10cSrcweir        $dir = $direntry;
780cdf0e10cSrcweir    }
781cdf0e10cSrcweir    return ($dir,$out);
782cdf0e10cSrcweir}   ##handle_extra_mak_files
783cdf0e10cSrcweir
784cdf0e10cSrcweir############################################################################
785cdf0e10cSrcweirsub prepare_allinone_all_mak
786cdf0e10cSrcweir############################################################################
787cdf0e10cSrcweir{
788cdf0e10cSrcweir    # Read in allinone.sln
789cdf0e10cSrcweir    # Fills hashes and returns an array with build order
790cdf0e10cSrcweir    # uses topographical sorting
791cdf0e10cSrcweir
792cdf0e10cSrcweir    my $href_project_by_id = shift;
793cdf0e10cSrcweir    my $href_project_by_name = shift;
794cdf0e10cSrcweir    my $href_project_dependencies = shift;
795cdf0e10cSrcweir    my $sourcePath = shift;
796cdf0e10cSrcweir
797cdf0e10cSrcweir    my $allslnfile = $sourcePath . "\\allinone\\allinone.sln";
798cdf0e10cSrcweir    my @projectdeps;
799cdf0e10cSrcweir    my $projectname;
800cdf0e10cSrcweir    my $projectpath;
801cdf0e10cSrcweir    my $projectid;
802cdf0e10cSrcweir
803cdf0e10cSrcweir    # fill hash tables
804cdf0e10cSrcweir    open (SLN, "< $allslnfile") || die "Can't open $allslnfile\n";
805cdf0e10cSrcweir    while ($line = <SLN>)
806cdf0e10cSrcweir    {
807cdf0e10cSrcweir        my @project = ();
808cdf0e10cSrcweir        if ( $line =~ /^Project\(/ ) {
809cdf0e10cSrcweir            @project = split( /,/, $line);
810cdf0e10cSrcweir            if ( $#project ) {
811cdf0e10cSrcweir                $projectname = "";
812cdf0e10cSrcweir                $projectpath = "";
813cdf0e10cSrcweir                $projectid = "";
814cdf0e10cSrcweir                @projectdeps = ();
815cdf0e10cSrcweir                my @subarray = ();
816cdf0e10cSrcweir                @subarray = split( /=/, $project[0]);
817cdf0e10cSrcweir                $projectname = $subarray[1];
818cdf0e10cSrcweir                $projectname =~ s/\"//g;      # remove "
819cdf0e10cSrcweir                $projectpath = $project[1];
820cdf0e10cSrcweir                $projectid = $project[2];
821cdf0e10cSrcweir                $projectid =~ s/\"//g;        # remove "
822cdf0e10cSrcweir                $projectid =~ s/.+\{//g;      # remove til {
823cdf0e10cSrcweir                $projectid =~ s/\}\n//g;      # remove }<CR>
824cdf0e10cSrcweir                my @pnp = ($projectname,$projectpath);
825cdf0e10cSrcweir                my @pip = ($projectid,$projectpath);
826cdf0e10cSrcweir                $$href_project_by_id{$projectid}=[@pnp];
827cdf0e10cSrcweir                $$href_project_by_name{$projectname} =[@pip];
828cdf0e10cSrcweir            }
829cdf0e10cSrcweir        } # $line =~ /^Project\(/
830cdf0e10cSrcweir        if ( $line =~ /ProjectSection\(/ ) {
831cdf0e10cSrcweir            $psect = 1;
832cdf0e10cSrcweir            next;
833cdf0e10cSrcweir        }
834cdf0e10cSrcweir        if ( $line =~ /EndProjectSection/ ) {
835cdf0e10cSrcweir            $psect = 0;
836cdf0e10cSrcweir            $$href_project_dependencies{$projectid}=[@projectdeps];
837cdf0e10cSrcweir            next;
838cdf0e10cSrcweir        }
839cdf0e10cSrcweir        if ( $psect ) {
840cdf0e10cSrcweir            my @tarray = split(/=/, $line);
841cdf0e10cSrcweir            $depends_on_id = $tarray[0];
842cdf0e10cSrcweir            $depends_on_id =~ s/.+\{//g;
843cdf0e10cSrcweir            $depends_on_id =~ s/\}.+//g;
844cdf0e10cSrcweir             print "+$depends_on_id-\n" if ($is_debug);
845cdf0e10cSrcweir
846cdf0e10cSrcweir            push @projectdeps, $depends_on_id;
847cdf0e10cSrcweir        }
848cdf0e10cSrcweir    }
849cdf0e10cSrcweir    ########################################
850cdf0e10cSrcweir    # sort here and generate build order
851cdf0e10cSrcweir    ########################################
852cdf0e10cSrcweir    $objektzahl=0;
853cdf0e10cSrcweir    %hashindex=();
854cdf0e10cSrcweir
855cdf0e10cSrcweir    foreach $projectid(keys %{$href_project_by_id})
856cdf0e10cSrcweir    {
857cdf0e10cSrcweir        if ( $$href_project_dependencies{$projectid} )
858cdf0e10cSrcweir        {
859cdf0e10cSrcweir            @deps = @{$$href_project_dependencies{$projectid}};
860cdf0e10cSrcweir        } else
861cdf0e10cSrcweir        {
862cdf0e10cSrcweir            @deps = ();
863cdf0e10cSrcweir        }
864cdf0e10cSrcweir        for  $counter(0..$#deps)
865cdf0e10cSrcweir        {
866cdf0e10cSrcweir            $v = find_or_create_element($deps[$counter]);
867cdf0e10cSrcweir            $n = find_or_create_element($projectid);
868cdf0e10cSrcweir            push @{$nachfolgerliste[$v]},$n;
869cdf0e10cSrcweir        }
870cdf0e10cSrcweir    }
871cdf0e10cSrcweir
872cdf0e10cSrcweir    for $n (0..$objektzahl-1)
873cdf0e10cSrcweir    {
874cdf0e10cSrcweir            $vorgaengerzahl[$n]=0;
875cdf0e10cSrcweir    }
876cdf0e10cSrcweir    for $v (0..$objektzahl-1)
877cdf0e10cSrcweir    {
878cdf0e10cSrcweir            for $n (@{$nachfolgerliste[$v]})
879cdf0e10cSrcweir            {
880cdf0e10cSrcweir                    ++$vorgaengerzahl[$n];
881cdf0e10cSrcweir            }
882cdf0e10cSrcweir    }
883cdf0e10cSrcweir
884cdf0e10cSrcweir    @hilfsliste=();
885cdf0e10cSrcweir    for $n (0..$objektzahl-1)
886cdf0e10cSrcweir    {
887cdf0e10cSrcweir        push(@hilfsliste,$n) if ($vorgaengerzahl[$n]==0)
888cdf0e10cSrcweir    }
889cdf0e10cSrcweir
890cdf0e10cSrcweir    $ausgabe=0;
891cdf0e10cSrcweir    @builddep =();
892cdf0e10cSrcweir    while (defined($v=pop(@hilfsliste)))
893cdf0e10cSrcweir    {
894cdf0e10cSrcweir        push @builddep, $name[$v];                           # save build order by project_id;
895cdf0e10cSrcweir        ++$ausgabe;
896cdf0e10cSrcweir        for $n (@{$nachfolgerliste[$v]})
897cdf0e10cSrcweir        {
898cdf0e10cSrcweir                --$vorgaengerzahl[$n];
899cdf0e10cSrcweir                push(@hilfsliste,$n) if ($vorgaengerzahl[$n]==0);
900cdf0e10cSrcweir        }
901cdf0e10cSrcweir    } # while
902cdf0e10cSrcweir    die "Cyclic dependencies found! Stopping now.\n" if $ausgabe<$objektzahl;
903cdf0e10cSrcweir    ##############################################################
904cdf0e10cSrcweir    # End of sorting stuff
905cdf0e10cSrcweir    ##############################################################
906cdf0e10cSrcweir
907cdf0e10cSrcweir    return @builddep;
908cdf0e10cSrcweir    ###############################################################
909cdf0e10cSrcweir    ###########################
910cdf0e10cSrcweir    # sub for sorting only
911cdf0e10cSrcweir    ###########################
912cdf0e10cSrcweir    sub find_or_create_element
913cdf0e10cSrcweir    {
914cdf0e10cSrcweir        my ($str)=@_;
915cdf0e10cSrcweir        my ($idx)=$hashindex{$str};
916cdf0e10cSrcweir        if (!defined($idx)) {               # new element ...
917cdf0e10cSrcweir                $idx=$objektzahl++;
918cdf0e10cSrcweir                $hashindex{$str}=$idx;
919cdf0e10cSrcweir                $name[$idx]=$str;
920cdf0e10cSrcweir            @{$nachfolgerliste[$idx]}=();
921cdf0e10cSrcweir        }
922cdf0e10cSrcweir        return $idx;
923cdf0e10cSrcweir    } # find_or_create_element
924cdf0e10cSrcweir}  # prepare_allinone_all_mak
925cdf0e10cSrcweir
926cdf0e10cSrcweir############################################################################
927cdf0e10cSrcweirsub create_allinone_all_mak     #09.02.2009 09:22
928cdf0e10cSrcweir############################################################################
929cdf0e10cSrcweir{
930cdf0e10cSrcweir    my $ref_buildorder = shift;
931cdf0e10cSrcweir    my $href_project_by_id = shift;
932cdf0e10cSrcweir    my $sourcePath = shift;
933cdf0e10cSrcweir    my $allmakfile = $sourcePath . "\\allinone\\all.mak";
934cdf0e10cSrcweir    open (ALLMAK, ">$allmakfile") || die "Can't write to $allmakfile \n";
935cdf0e10cSrcweir    print ALLMAK "ALL: ";
936cdf0e10cSrcweir    foreach $proj(@{$ref_buildorder})
937cdf0e10cSrcweir    {
938cdf0e10cSrcweir        print ALLMAK $$href_project_by_id{$proj}[0];
939cdf0e10cSrcweir    }
940cdf0e10cSrcweir    print ALLMAK "\n\n";
941cdf0e10cSrcweir
942cdf0e10cSrcweir    foreach $proj( @{$ref_buildorder} )
943cdf0e10cSrcweir    {
944cdf0e10cSrcweir        print "$proj $$href_project_by_id{$proj}[0] $$href_project_by_id{$proj}[1]\n";
945cdf0e10cSrcweir        my $prjdir = $$href_project_by_id{$proj}[1];
946cdf0e10cSrcweir        $prjdir =~ /(.+)\\(.+)$/;
947cdf0e10cSrcweir        $prjdir = $1;
948cdf0e10cSrcweir        $prjname = $2;
949cdf0e10cSrcweir        $prjdir =~ s/^.+\"//;
950cdf0e10cSrcweir        $prjname =~ s/\"$//;
951cdf0e10cSrcweir        $prjname =~ s/vcproj/mak/;
952cdf0e10cSrcweir        $allinonehelpstring = $prjdir;
953cdf0e10cSrcweir        $allinonehelpstring =~ s/^\.+\\//; # remove ..\
954cdf0e10cSrcweir        my $backcount = "";
955cdf0e10cSrcweir        while ($allinonehelpstring=~ /.+\\/g) # counts the occuring \
956cdf0e10cSrcweir        {
957cdf0e10cSrcweir            $backcount .= "..\\";
958cdf0e10cSrcweir        }
959cdf0e10cSrcweir        $allinonedir = $backcount . "..\\allinone";
960cdf0e10cSrcweir
961cdf0e10cSrcweir        # write all.mak
962cdf0e10cSrcweir        $$href_project_by_id{$proj}[0] =~ s/^\s+//;
963cdf0e10cSrcweir        if ( $$href_project_by_id{$proj}[0] ne "makedata" )
964cdf0e10cSrcweir        {
965cdf0e10cSrcweir            my @template = @{$template_hash{"AllInOnePrj"}};
966cdf0e10cSrcweir            foreach $line(@template)
967cdf0e10cSrcweir            {
968cdf0e10cSrcweir                $line =~ s/<PRJ>/$$href_project_by_id{$proj}[0]/;
969cdf0e10cSrcweir                $line =~ s/<PRJDIR>/$prjdir/;
970cdf0e10cSrcweir                $line =~ s/<PRJMAK>/$prjname/;
971cdf0e10cSrcweir                $line =~ s/<ALLINONEDIR>/$allinonedir/;
972cdf0e10cSrcweir                print ALLMAK $line;
973cdf0e10cSrcweir            }
974cdf0e10cSrcweir        } else
975cdf0e10cSrcweir        {
976cdf0e10cSrcweir            #special code snippet
977cdf0e10cSrcweir            print ALLMAK "makedata : \n";
978cdf0e10cSrcweir            print ALLMAK "     cd \"..\\data\"\n";
979*7ccb0d53SArrigo Marchiori            print ALLMAK "     nmake /f makedata.mak icumake=\$(MAKEDIR)\\..\\data cfg=$architecture/Release\n";
980cdf0e10cSrcweir            print ALLMAK "     cd \"..\\allinone\"\n\n";
981cdf0e10cSrcweir        }
982cdf0e10cSrcweir    }
983cdf0e10cSrcweir    close ALLMAK;
984cdf0e10cSrcweir}   ##create_allinone_all_mak
985cdf0e10cSrcweir
986cdf0e10cSrcweir############################################################################
987cdf0e10cSrcweir
988cdf0e10cSrcweir# ------------------------------------------------------------------------
989cdf0e10cSrcweir# XML parser handling
990cdf0e10cSrcweir# ------------------------------------------------------------------------
991cdf0e10cSrcweir
992cdf0e10cSrcweir############################################################################
993cdf0e10cSrcweirsub start_handler
994cdf0e10cSrcweir############################################################################
995cdf0e10cSrcweir{
996cdf0e10cSrcweir    my $p = shift;           # pointer to parser
997cdf0e10cSrcweir    my $el = shift;          # element
998cdf0e10cSrcweir
999cdf0e10cSrcweir    # Deal with attributes
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir    my $CompilerSection = 0;
1002cdf0e10cSrcweir    my $LinkerSection = 0;
1003cdf0e10cSrcweir    my $ConfigSection = ($el eq "Configuration");
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir    while (@_)
1006cdf0e10cSrcweir    {
1007cdf0e10cSrcweir #       shift if ( $el eq "FileConfiguration" );
1008cdf0e10cSrcweir        my $att = shift;
1009cdf0e10cSrcweir        my $val = shift;
1010cdf0e10cSrcweir        $CustomSection = 0;
1011cdf0e10cSrcweir        if ($special_file && defined $att & $att ne "Name")
1012cdf0e10cSrcweir        {
1013cdf0e10cSrcweir            print "$special_file - $att - $val\n";
1014cdf0e10cSrcweir            my @param = ($att,$val);
1015cdf0e10cSrcweir            $files_special{ $special_file } = [@param]; # files with special compiler switch
1016cdf0e10cSrcweir            @test = @{$files_special{ $special_file }};
1017cdf0e10cSrcweir            print "test=@test\n";
1018cdf0e10cSrcweir            $special_file="";
1019cdf0e10cSrcweir        }
1020cdf0e10cSrcweir        if ( $ConfigSection && $att eq "Name" && $val eq "Release|Win32" ) {
1021*7ccb0d53SArrigo Marchiori	    if ( $architecture eq "x86" ) {
1022cdf0e10cSrcweir		$Release = 1;
1023cdf0e10cSrcweir		$config = "Release";                                                             # Release
1024*7ccb0d53SArrigo Marchiori	    } else {
1025*7ccb0d53SArrigo Marchiori		print "Ignoring Configuration $val\n" if ($is_debug);
1026*7ccb0d53SArrigo Marchiori		$Release = 2;
1027*7ccb0d53SArrigo Marchiori		$config = "Ignored";
1028*7ccb0d53SArrigo Marchiori	    }
1029cdf0e10cSrcweir        }
1030cdf0e10cSrcweir        if ( $ConfigSection && $att eq "Name" && $val eq "Debug|Win32" ) {
1031*7ccb0d53SArrigo Marchiori	    if ( $architecture eq "x86" ) {
1032cdf0e10cSrcweir		$Release = 0;                                                                    # Debug
1033cdf0e10cSrcweir		$config = "Debug";
1034*7ccb0d53SArrigo Marchiori	    } else {
1035*7ccb0d53SArrigo Marchiori                print "Ignoring Configuration $val\n" if ($is_debug);
1036*7ccb0d53SArrigo Marchiori		$Release = 2;
1037*7ccb0d53SArrigo Marchiori		$config = "Ignored";
1038*7ccb0d53SArrigo Marchiori	    }
1039*7ccb0d53SArrigo Marchiori        }
1040*7ccb0d53SArrigo Marchiori        if ( $ConfigSection && $att eq "Name" && $val eq "Release|x64" ) {
1041*7ccb0d53SArrigo Marchiori	    if ( $architecture eq "x64" ) {
1042*7ccb0d53SArrigo Marchiori		$Release = 1;
1043*7ccb0d53SArrigo Marchiori		$config = "Release";                                                             # Release
1044*7ccb0d53SArrigo Marchiori	    } else {
1045*7ccb0d53SArrigo Marchiori                print "Ignoring Configuration $val\n" if ($is_debug);
1046*7ccb0d53SArrigo Marchiori		$Release = 2;
1047*7ccb0d53SArrigo Marchiori		$config = "Ignored";
1048*7ccb0d53SArrigo Marchiori	    }
1049*7ccb0d53SArrigo Marchiori        }
1050*7ccb0d53SArrigo Marchiori        if ( $ConfigSection && $att eq "Name" && $val eq "Debug|x64" ) {
1051*7ccb0d53SArrigo Marchiori	    if ( $architecture eq "x64" ) {
1052*7ccb0d53SArrigo Marchiori		$Release = 0;                                                             # Debug
1053*7ccb0d53SArrigo Marchiori		$config = "Debug";
1054*7ccb0d53SArrigo Marchiori	    } else {
1055*7ccb0d53SArrigo Marchiori                print "Ignoring Configuration $val\n" if ($is_debug);
1056*7ccb0d53SArrigo Marchiori		$Release = 2;
1057*7ccb0d53SArrigo Marchiori		$config = "Ignored";
1058*7ccb0d53SArrigo Marchiori	    }
1059cdf0e10cSrcweir        }
1060cdf0e10cSrcweir        if ( $att eq "Name" && $val eq "VCCLCompilerTool" ) {
1061cdf0e10cSrcweir            $CompilerSection = 1;
1062cdf0e10cSrcweir        }
1063cdf0e10cSrcweir        if ( $att eq "Name" && $val eq "VCLinkerTool" ) {
1064cdf0e10cSrcweir            $LinkerSection = 1;
1065cdf0e10cSrcweir        }
1066cdf0e10cSrcweir        if ( $att eq "Name" && $val eq "VCCustomBuildTool" ) {
1067cdf0e10cSrcweir            $CustomSection = 1;
1068cdf0e10cSrcweir        }
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir        # For Configuration Infos like compiler defines etc.
1071cdf0e10cSrcweir        if ( $att eq "PreprocessorDefinitions" && $CompilerSection ) {
1072cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1073cdf0e10cSrcweir        }
1074cdf0e10cSrcweir        if ( $att eq "AdditionalIncludeDirectories" && $CompilerSection ) {
1075cdf0e10cSrcweir           #$configelements{$config}{$att} = $val;
1076cdf0e10cSrcweir            if ( ($file_tmp ne "") && ($val ne "") ) {
1077cdf0e10cSrcweir                $files{ $file_tmp } = 1;        # save it now
1078cdf0e10cSrcweir                $file_tmp =~ s/^\.\\//;         # remove leading .\
1079cdf0e10cSrcweir                $files_special{"AdditionalIncludeDirectories"}{$file_tmp} = $val;
1080cdf0e10cSrcweir                print "Include $val: $file_tmp\n" if ($is_debug);
1081cdf0e10cSrcweir                $file_tmp = "";                 # has been saved now reset it
1082cdf0e10cSrcweir            } else
1083cdf0e10cSrcweir            {
1084cdf0e10cSrcweir               $configelements{$config}{$att} = $val;
1085cdf0e10cSrcweir            }
1086cdf0e10cSrcweir        }
1087cdf0e10cSrcweir        if ( ($att eq "DisableLanguageExtensions") && $CompilerSection ) {
1088cdf0e10cSrcweir           #$configelements{$config}{$att} = $val;
1089cdf0e10cSrcweir            if ( ($file_tmp ne "") && ($val ne "")) {
1090cdf0e10cSrcweir                $files{ $file_tmp } = 1;        # save it now
1091cdf0e10cSrcweir                $file_tmp =~ s/^\.\\//;         # remove leading .\
1092cdf0e10cSrcweir                $files_special{"DisableLanguageExtensions"}{$file_tmp} = $val;
1093cdf0e10cSrcweir                print "-Ze: $file_tmp\n" if ($is_debug);
1094cdf0e10cSrcweir                $file_tmp = "";                 # has been saved now reset it
1095cdf0e10cSrcweir            }
1096cdf0e10cSrcweir        }
1097cdf0e10cSrcweir        if ( $att eq "OutputDirectory" ) {
1098cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1099cdf0e10cSrcweir        }
1100cdf0e10cSrcweir        if ( $att eq "OutputFile" && $LinkerSection ) {
1101*7ccb0d53SArrigo Marchiori           if ($architecture eq "x64") {
1102*7ccb0d53SArrigo Marchiori              # We want the /bin/ subdirectory on all architectures
1103*7ccb0d53SArrigo Marchiori              $val =~ s/\\bin64\\/\\bin\\/;
1104*7ccb0d53SArrigo Marchiori           }
1105cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1106cdf0e10cSrcweir        }
1107cdf0e10cSrcweir        if ( $att eq "ProgramDatabaseFile" ) {
1108cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1109cdf0e10cSrcweir        }
1110cdf0e10cSrcweir        if ( $att eq "ImportLibrary" && $LinkerSection ) {
1111cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1112cdf0e10cSrcweir        }
1113cdf0e10cSrcweir        if ($att eq "CommandLine") {
1114cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1115cdf0e10cSrcweir        }
1116cdf0e10cSrcweir        if (($att eq "PreprocessorDefinitions") && $ConfigSection) {
1117cdf0e10cSrcweir           $configelements{$config}{$att} = $val;
1118cdf0e10cSrcweir        }
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir        # Is the file in the step before a header
1121cdf0e10cSrcweir        # which has to be copied into the global
1122cdf0e10cSrcweir        # include path?
1123cdf0e10cSrcweir        if ( $file_tmp ne "" )
1124cdf0e10cSrcweir        {
1125cdf0e10cSrcweir            $config = "Release";
1126cdf0e10cSrcweir            if ( ($att eq "CommandLine") && ($el eq "Tool") )
1127cdf0e10cSrcweir            {
1128cdf0e10cSrcweir                if ( $file_tmp =~ /.+\.h$/ ) {
1129cdf0e10cSrcweir                    $files2copy{ $file_tmp } = $val; # unicode + layout header to copy
1130cdf0e10cSrcweir                    $file_tmp = "";                 # has been saved now reset it
1131cdf0e10cSrcweir                }
1132cdf0e10cSrcweir            }
1133cdf0e10cSrcweir        } # if $file_tmp
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir        # For files
1136cdf0e10cSrcweir        if ( $att eq "RelativePath" ) {
1137cdf0e10cSrcweir            if ( $file_tmp ) {
1138cdf0e10cSrcweir                # no special file (include dir / compiler switch)
1139cdf0e10cSrcweir                $files{ $file_tmp } = 1;        # save it now
1140cdf0e10cSrcweir                $file_tmp = "";                 # has been saved now reset it
1141cdf0e10cSrcweir            }
1142cdf0e10cSrcweir            # store temporary the file name
1143cdf0e10cSrcweir            $file_tmp = $val if ($val !~ /\.mk$/);  # no *.mk files
1144cdf0e10cSrcweir        }
1145cdf0e10cSrcweir    } # while @_
1146cdf0e10cSrcweir}  # End start_handler
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir############################################################################
1149cdf0e10cSrcweirsub char_handler
1150cdf0e10cSrcweir############################################################################
1151cdf0e10cSrcweir{
1152cdf0e10cSrcweir}  # End char_handler
1153