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