Home | History | Annotate | Download | only in cc
      1 #!/usr/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #
     24 # Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 
     28 #	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
     29 #	  All Rights Reserved
     30 
     31 #
     32 # University Copyright- Copyright (c) 1982, 1986, 1988
     33 # The Regents of the University of California
     34 # All Rights Reserved
     35 #
     36 # University Acknowledgment- Portions of this document are derived from
     37 # software developed by the University of California, Berkeley, and its
     38 # contributors.
     39 #
     40 
     41 #ident	"%Z%%M%	%I%	%E% SMI"
     42 
     43 # cc command for BSD compatibility package:
     44 #
     45 #	BSD compatibility package header files (/usr/ucbinclude)
     46 #	are included before SVr4 default (/usr/include) files but 
     47 #       after any directories specified on the command line via 
     48 #	the -I option.  Thus, the BSD header files are included
     49 #	next to last, and SVr4 header files are searched last.
     50 #	
     51 #	BSD compatibility package libraries (/usr/ucblib) are
     52 #	searched next to third to last.  SVr4 default libraries 
     53 #	(/usr/ccs/lib and /usr/lib) are searched next to last
     54 #
     55 #	Because the BSD compatibility package C library does not 
     56 #	contain all the C library routines of /usr/ccs/lib/libc.a, 
     57 #	the BSD package C library is named /usr/ucblib/libucb.a
     58 #	and is passed explicitly to cc.  This ensures that libucb.a 
     59 #	will be searched first for routines and that 
     60 #	/usr/ccs/lib/libc.a will be searched afterwards for routines 
     61 #	not found in /usr/ucblib/libucb.a.  Also because sockets is    
     62 #       provided in libc under BSD, /usr/lib/libsocket and /usr/lib/nsl
     63 #       are also included as default libraries.
     64 #
     65 #	NOTE: the -Y L, and -Y U, options of cc are not valid 
     66 
     67 if [ -f /usr/ccs/bin/ucbcc ]
     68 then
     69 
     70 	if [ $# -eq 0 ]
     71 	then
     72 		# use this to get the usage message from /usr/ccs/bin/ucbcc
     73 		/usr/ccs/bin/ucbcc
     74 		ret=$?
     75 		exit $ret
     76 	fi
     77 
     78 
     79 	UCB_LIB_DIR=/usr/ucblib
     80 	CCS_LIB_DIR=/usr/ccs/lib
     81 	USR_LIB=/usr/lib
     82 	TYPE=
     83 	dopt=
     84 	cgdir=
     85 
     86 	for i in $*
     87 	do
     88 		case $i in
     89 			-cg*)
     90 				cgdir=`echo $i | sed -n 's/-//p'`
     91 				;;
     92 			-Bstatic|-Bdynamic)
     93 				dopt=$i
     94 				;;
     95 			-xarch=v9)
     96 				TYPE=/sparcv9
     97 				;;
     98 		esac
     99 	done
    100 
    101 	if [ x$LD_RUN_PATH = x ]
    102 	then
    103 		LD_RUN_PATH=$UCB_LIB_DIR$TYPE
    104 	else
    105 		LD_RUN_PATH=$LD_RUN_PATH:$UCB_LIB_DIR$TYPE
    106 	fi
    107 	export LD_RUN_PATH
    108 
    109 	if [ "$dopt" = "-Bstatic" ]
    110 	then
    111 		LIBS="-lucb -lsocket -lnsl -lelf"
    112 	else
    113 		LIBS="-lucb -lsocket -lnsl -lelf -laio"
    114 	fi
    115 
    116 	# get the directory where ucbcc points to and set the LD_LIBRARY_PATH
    117 	# to that directory so as to get the necessary libraries.
    118 	cclink=`/usr/bin/ls -ln /usr/ccs/bin/ucbcc | awk '{print $11}'`
    119 	ccdir=`/usr/bin/dirname $cclink`
    120 	if [ "$cgdir" != "" ]
    121 	then
    122 		# can not have cgdir set and compile in 64bit mode, so
    123 		# reset variables back to 32bit mode
    124 		TYPE=
    125 		nccdir="$ccdir/../lib/$cgdir:$ccdir/../lib:$ccdir/$cgdir:$ccdir"
    126 	else
    127 		nccdir="$ccdir/../lib$TYPE:$ccdir$TYPE"
    128 	fi
    129 
    130 	LD_LIBRARY_PATH=$UCB_LIB_DIR$TYPE:$CCS_LIB_DIR$TYPE:$USR_LIB$TYPE
    131 	export LD_LIBRARY_PATH
    132 
    133 	/usr/ccs/bin/ucbcc -Xs \
    134 	-YP,:$UCB_LIB_DIR$TYPE:$nccdir:$CCS_LIB_DIR$TYPE:$USR_LIB$TYPE \
    135 	"$@" -I/usr/ucbinclude $LIBS
    136 	ret=$?
    137 	exit $ret
    138 else
    139 	echo "/usr/ucb/cc:  language optional software package not installed"
    140 	exit 1
    141 fi
    142