From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <38faa65577e2dff08685b44f53d39a63.comp-unix-tru64@archive.invalid> X-Google-Thread: e63b27eb52,817f0adc82d68c3a,start X-Google-Attributes: gide63b27eb52,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 03 Oct 2009 21:24:01 +0100 From: Dave User-Agent: Thunderbird 2.0.0.19 (X11/20090218) MIME-Version: 1.0 Newsgroups: comp.sys.hp.hpux,comp.unix.aix,comp.unix.tru64 Subject: Count someone test this script which determines compiler please? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 213.78.42.15 Message-ID: <4ac7b2e2@212.67.96.135> X-Trace: 3 Oct 2009 21:24:02 GMT, 213.78.42.15 Path: g2news2.google.com!news1.google.com!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!newsfeed.news2me.com!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!212.67.96.135!213.78.42.15 Xref: g2news2.google.com comp.sys.hp.hpux:1230 comp.unix.aix:3621 comp.unix.tru64:101 I have two scripts, one of which is supposed to determine if the environment variable CC points to a IBM, Sun, GNU, HP ... etc C compiler. The other does the same for the C++ compiler, if CXX is defined. I've tested these with Sun's compiler and gcc on Solaris, but I don't have any machines running HP-UX, AIX or tru64 easily available. Could someone try setting the variables CC and CXX to various compilers, and let me know what these two scripts report. I've put a bit of a gap between then. I'm not sure how well newsgroups handle attachments, so I'm not using that. First the C one: drkirkby@swan:[~] $ cat testcc #!/usr/bin/sh # Determine the type of C compiler, which can later # be used to determine the flags the compiler # will want. Do this by defining pre-processing a bit # of C++ code, and checking what are defined. # The Sun and GNU compilers have been tested. # The HP and GNU compilers have not been tested, but # use information gained from the documentation. # HP-UX C and C++ compiler. # http://docs.hp.com/en/7730/newhelp0610/preprocess.htm # IBM Compiler Reference - XL C/C++ for AIX, V10.1 # http://www-01.ibm.com/support/docview.wss?uid=swg27012860&aid=1 # Using HP C++ for Tru64 UNIX and Linux Alpha # http://h30097.www3.hp.com/cplus/ugu_impl.html#implem_chap # First, make sure the enviroment variable CC is defined. if [ -z "$CC" ]; then echo "Sorry, you should define the enivronment variable CC" exit 1 fi # Create a test file. It does not need to be a complete # C++ file, as it is only pre-processed. So there is no # need for a 'main' TESTFILE=/tmp/test.$$.c # The flags for the GNU compilers do not change with # operating system, so there is no need to worry too # much about what system this is on. echo "#ifdef __GNUC__" > $TESTFILE echo "it_is_the_GNU_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __SUNPRO_C" >> $TESTFILE echo "it_is_the_Sun_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE # Not found any offical documention to suggest __DECC # would be defined, but __DECCC is defined for C++, # and a Google on __DECC shows many hits. echo "#ifdef __digital__" >> $TESTFILE echo "#ifdef __DECC" >> $TESTFILE echo "it_is_the_HP_Tru64_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __linux__" >> $TESTFILE echo "#ifdef __DECCC" >> $TESTFILE echo "it_is_the_HP_Alpha_Linux_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __HP_aCC" >> $TESTFILE echo "it_is_the_HP_HPUX_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __xlC__" >> $TESTFILE echo "it_is_the_IBM_AIX_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE ${CC} -E $TESTFILE | grep it_is_the_GNU_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo GNU rm $TESTFILE exit 0 fi ${CC} -E $TESTFILE | grep it_is_the_Sun_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo Sun_on_Solaris rm $TESTFILE exit 0 fi # HP make compilers for linux, HP-UX and tru64, which complicates matters. ${CC} -E $TESTFILE | grep it_is_the_HP_Tru64_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_Tru64 rm $TESTFILE exit 0 fi ${CC} -E $TESTFILE | grep it_is_the_HP_Alpha_Linux_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_Alpha_Linux rm $TESTFILE exit 0 fi ${CC} -E $TESTFILE | grep it_is_the_HP_HPUX_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_HPUX rm $TESTFILE exit 0 fi ${CC} -E $TESTFILE | grep it_is_the_IBM_AIX_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo IBM_on_AIX rm $TESTFILE exit 0 fi # Exit saying 'Unknown' if the type of the compiler could not be found. echo Unknown rm $TESTFILE exit 0 Now the C++ one drkirkby@swan:[~] $ cat testcxx #!/usr/bin/sh # Determine the type of C++ compiler, which can later # be used to determine the flags the compiler # will want. Do this by defining pre-processing a bit # of C++ code, and checking what are defined. # The Sun and GNU compilers have been tested. # The HP and GNU compilers have not been tested, but # use information gained from the documentation. # HP-UX C and C++ compiler. # http://docs.hp.com/en/7730/newhelp0610/preprocess.htm # IBM Compiler Reference - XL C/C++ for AIX, V10.1 # http://www-01.ibm.com/support/docview.wss?uid=swg27012860&aid=1 # Using HP C++ for Tru64 UNIX and Linux Alpha # http://h30097.www3.hp.com/cplus/ugu_impl.html#implem_chap # First, make sure the enviroment variable CXX is defined. if [ -z "$CXX" ]; then echo "Sorry, you should define the enivronment variable CXX" exit 1 fi # Create a test file. It does not need to be a complete # C++ file, as it is only pre-processed. So there is no # need for a 'main' TESTFILE=/tmp/test.$$.cpp # The flags for the GNU compilers do not change with # operating system, so there is no need to worry too # much about what system this is on. echo "#ifdef __GNUC__" > $TESTFILE echo "it_is_the_GNU_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __SUNPRO_CC" >> $TESTFILE echo "it_is_the_Sun_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __digital__" >> $TESTFILE echo "#ifdef __DECCXX" >> $TESTFILE echo "it_is_the_HP_Tru64_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __linux__" >> $TESTFILE echo "#ifdef __DECCXX" >> $TESTFILE echo "it_is_the_HP_Alpha_Linux_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __HP_aCC" >> $TESTFILE echo "it_is_the_HP_HPUX_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE echo "#ifdef __xlC__" >> $TESTFILE echo "it_is_the_IBM_AIX_compiler" >> $TESTFILE echo "#endif" >> $TESTFILE ${CXX} -E $TESTFILE | grep it_is_the_GNU_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo GNU rm $TESTFILE exit 0 fi ${CXX} -E $TESTFILE | grep it_is_the_Sun_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo Sun_on_Solaris rm $TESTFILE exit 0 fi # HP make compilers for linux, HP-UX and tru64, which complicates matters. ${CXX} -E $TESTFILE | grep it_is_the_HP_Tru64_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_Tru64 rm $TESTFILE exit 0 fi ${CXX} -E $TESTFILE | grep it_is_the_HP_Alpha_Linux_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_Alpha_Linux rm $TESTFILE exit 0 fi ${CXX} -E $TESTFILE | grep it_is_the_HP_HPUX_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo HP_on_HPUX rm $TESTFILE exit 0 fi ${CXX} -E $TESTFILE | grep it_is_the_IBM_AIX_compiler >/dev/null 2>&1 if [ $? = 0 ]; then echo IBM_on_AIX rm $TESTFILE exit 0 fi # Exit saying 'Unknown' if the type of the compiler could not be found. echo Unknown rm $TESTFILE exit 0 -- I respectfully request that this message is not archived by companies as unscrupulous as 'Experts Exchange' . In case you are unaware, 'Experts Exchange' take questions posted on the web and try to find idiots stupid enough to pay for the answers, which were posted freely by others. They are leeches.