1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: create.pl,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 $solarversion = $ENV{SOLARVERSION
};
33 $solarversion =~ s![^0-9A-Za-z]!\\$&!g;
34 $in = <> || die 'no input';
36 if ($ENV{OS
} eq 'LINUX') {
37 1 while $in =~ s!\s+-I\s*[^/]\S*\s*! !g; # discard relative includes
38 $in =~ s!(\s+-I\s*)$solarversion(\S*)!$1\${SOLARVERSION}$2!og;
39 # macrofy includes to solver
40 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
41 $in =~ s!\S+/testhxx.cxx!-x c++ /proc/self/fd/0!
42 || die 'bad input: no source file';
43 print STDOUT
'#!/bin/bash', "\n";
45 ' <<<"#include \\"`echo $(if [ ${1%/*} != $1 ];then cd ${1%/*};fi;',
46 '/bin/pwd)/${1##*/}`\\""', "\n";
47 } elsif ($ENV{OS
} eq 'SOLARIS') {
48 1 while $in =~ s!\s+-I\s*[^/]\S*\s*! !g; # discard relative includes
49 $in =~ s!(\s+-I\s*)$solarversion(\S*)!$1\${SOLARVERSION}$2!og;
50 # macrofy includes to solver
51 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
52 $in =~ s!\S+/testhxx.cxx!\${my_tmp}!
53 || die 'bad input: no source file';
54 print STDOUT
'#!/bin/sh', "\n";
56 'my_tmp=${TMPDIR:-/tmp}/`/usr/xpg4/bin/id -u`_$$_include.cc', "\n";
57 print STDOUT
'my_pat=`dirname $1`', "\n";
58 print STDOUT
'my_fil=`basename $1`', "\n";
59 print STDOUT
'my_org=${PWD}', "\n";
60 print STDOUT
'cd $my_pat || exit 1', "\n";
61 print STDOUT
'my_pat=`pwd`', "\n";
62 print STDOUT
'cd $my_org || exit 1', "\n";
64 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
65 print STDOUT
$in, ' > ${my_tmp}.out 2>&1', "\n";
66 print STDOUT
'my_ret=$?', "\n";
68 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
70 print STDOUT
'unlink ${my_tmp} || exit 1', "\n";
71 print STDOUT
'unlink ${my_tmp}.out || exit 1', "\n";
72 print STDOUT
'exit ${my_ret}', "\n";
73 } elsif ($ENV{OS
} eq 'WNT' and $ENV{USE_SHELL
} eq '4nt') {
74 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
75 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1%SOLARVERSION%$2!og;
76 # macrofy includes to solver
77 $in =~ s!\s+-Fo\s*\S+! -Fo%my_tmp%.obj! || die 'bad input: no -Fo';
79 $in =~ s!\s+-Fd\s*\S+!!;
80 $in =~ s!\S+\\testhxx.cxx!%my_tmp%!
81 || die 'bad input: no source file';
82 print STDOUT
'@ECHO OFF', "\n";
83 print STDOUT
'SET my_tmp=%TMP%\%_PID%_include.cc', "\n";
84 print STDOUT
'ECHO #include "%@REPLACE[\\,/,%@FULL[%1]]" > %my_tmp%', "\n";
85 print STDOUT
$in, ' > %my_tmp%.out', "\n";
86 print STDOUT
'SET my_ret=%ERRORLEVEL%', "\n";
87 print STDOUT
'IF %my_ret% != 0',
88 ' sed -e s!%@FILENAME[%my_tmp%]!%@REPLACE[\\,\\\\,%1]! %my_tmp%.out',
90 print STDOUT
'DEL /EQ %my_tmp% %my_tmp%.obj %my_tmp%.pdb %my_tmp%.out',
92 print STDOUT
'QUIT %my_ret%', "\n";
93 } elsif ($ENV{OS
} eq 'WNT' and $ENV{USE_SHELL
} ne '4nt') {
94 if ($ENV{COM
} eq 'GCC') {
95 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
96 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1\${SOLARVERSION}$2!og;
97 # macrofy includes to solver
98 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
99 $in =~ s!\S+/testhxx.cxx!\${my_tmp}!
100 || die 'bad input: no source file';
101 print STDOUT
'#!/bin/sh', "\n";
103 'my_tmp=${TMPDIR:-/tmp}/`id -u`_$$_include.cc', "\n";
104 print STDOUT
'my_pat=`dirname $1`', "\n";
105 print STDOUT
'my_fil=`basename $1`', "\n";
106 print STDOUT
'my_org=${PWD}', "\n";
107 print STDOUT
'cd $my_pat || exit 1', "\n";
108 print STDOUT
'my_pat=`cygpath -m \`pwd\``', "\n";
109 print STDOUT
'cd $my_org || exit 1', "\n";
111 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
112 print STDOUT
$in, ' > ${my_tmp}.out 2>&1', "\n";
113 print STDOUT
'my_ret=$?', "\n";
115 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
117 print STDOUT
'unlink ${my_tmp} || exit 1', "\n";
118 print STDOUT
'unlink ${my_tmp}.out || exit 1', "\n";
119 print STDOUT
'exit ${my_ret}', "\n";
121 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
122 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1\${SOLARVERSION}$2!og;
123 # macrofy includes to solver
124 $in =~ s!\s+-Fo\s*\S+! -Fo$[my_tmp}obj! || die 'bad input: no -Fo';
125 $in =~ s!\s+-Zi\s! !;
126 $in =~ s!\s+-Fd\s*\S+!!;
127 print STDOUT
'#!/bin/sh', "\n";
129 'my_tmp=${TMPDIR:-/tmp}/`id -u`_$$_include.cc', "\n";
130 print STDOUT
'my_pat=`dirname $1`', "\n";
131 print STDOUT
'my_fil=`basename $1`', "\n";
132 print STDOUT
'my_org=${PWD}', "\n";
133 print STDOUT
'cd $my_pat || exit 1', "\n";
134 print STDOUT
'my_pat=`pwd`', "\n";
135 print STDOUT
'cd $my_org || exit 1', "\n";
137 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
138 print STDOUT
$in, ' > ${my_tmp}.out 2>&1', "\n";
139 print STDOUT
'my_ret=$?', "\n";
141 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
143 print STDOUT
'unlink ${my_tmp} || exit 1', "\n";
144 print STDOUT
'unlink ${my_tmp}.out || exit 1', "\n";
145 print STDOUT
'exit ${my_ret}', "\n";
148 print STDOUT
'echo \'no testhxx on this platform\'', "\n";