xref: /titanic_52/usr/src/cmd/sgs/tools/proto.sh (revision adb91f4744062c28f7f3d0e8bf4704d2a8127b89)
1#!/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 (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"%Z%%M%	%I%	%E% SMI"
28#
29# Generate a proto area suitable for the current architecture ($(MACH))
30# sufficient to support the sgs build.
31#
32# Currently, the following releases are supported:
33#	5.11, 5.10, 5.9 and 5.8
34#
35
36if [ "X$CODEMGR_WS" = "X" -o "X$MACH" = "X" ] ; then
37	echo "CODEMGR_WS and MACH environment variables must be set"
38	exit 1
39fi
40
41dirs="	$CODEMGR_WS/proto \
42	$CODEMGR_WS/proto/root_$MACH \
43	$CODEMGR_WS/proto/root_$MACH/lib \
44	$CODEMGR_WS/proto/root_$MACH/usr \
45	$CODEMGR_WS/proto/root_$MACH/usr/demo \
46	$CODEMGR_WS/proto/root_$MACH/usr/lib \
47	$CODEMGR_WS/proto/root_$MACH/usr/lib/abi \
48	$CODEMGR_WS/proto/root_$MACH/usr/lib/link_audit \
49	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb \
50	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb/proc \
51	$CODEMGR_WS/proto/root_$MACH/usr/lib/pics \
52	$CODEMGR_WS/proto/root_$MACH/usr/4lib \
53	$CODEMGR_WS/proto/root_$MACH/usr/bin \
54	$CODEMGR_WS/proto/root_$MACH/usr/ccs \
55	$CODEMGR_WS/proto/root_$MACH/usr/ccs/bin \
56	$CODEMGR_WS/proto/root_$MACH/usr/include \
57	$CODEMGR_WS/proto/root_$MACH/usr/include/sys \
58	$CODEMGR_WS/proto/root_$MACH/usr/xpg4 \
59	$CODEMGR_WS/proto/root_$MACH/usr/xpg4/bin \
60	$CODEMGR_WS/proto/root_$MACH/etc \
61	$CODEMGR_WS/proto/root_$MACH/etc/lib \
62	$CODEMGR_WS/proto/root_$MACH/opt \
63	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld \
64	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/bin \
65	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/doc \
66	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/lib \
67	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man \
68	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man1 \
69	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man1l \
70	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3t \
71	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3l \
72	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3x"
73
74#
75# Add 64bit directories
76#
77MACH64=""
78if [ $MACH = "sparc" ]; then
79    MACH64="sparcv9";
80fi
81if [ $MACH = "i386" ]; then
82    MACH64="amd64";
83fi
84if [ "${MACH64}x" != x ]; then
85
86	dirs="$dirs \
87	$CODEMGR_WS/proto/root_$MACH/lib/$MACH64 \
88	$CODEMGR_WS/proto/root_$MACH/usr/bin/$MACH64 \
89	$CODEMGR_WS/proto/root_$MACH/usr/ccs/bin/$MACH64 \
90	$CODEMGR_WS/proto/root_$MACH/usr/lib/$MACH64 \
91	$CODEMGR_WS/proto/root_$MACH/usr/lib/abi/$MACH64 \
92	$CODEMGR_WS/proto/root_$MACH/usr/lib/link_audit/$MACH64 \
93	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb/proc/$MACH64 \
94	$CODEMGR_WS/proto/root_$MACH/usr/lib/pics/$MACH64 \
95	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/bin/$MACH64 \
96	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/lib/$MACH64 \
97	"
98fi
99
100for dir in `echo $dirs`
101do
102	if [ ! -d $dir ] ; then
103		echo $dir
104		mkdir $dir
105		chmod 777 $dir
106	fi
107done
108
109#
110# Get the target release from ${SRC}/Makefile.master
111#
112RELEASE=`grep "^[ 	]*RELEASE=" ${SRC}/Makefile.master |\
113	sed -e "s/^[ 	]*RELEASE=[ 	]*//"`
114
115IS_THIS_UNIFIED=1
116case $RELEASE in
117	"5.11") break;;
118	"5.10") break;;
119	"5.9") IS_THIS_UNIFIED=0;  break;;
120	"5.8") IS_THIS_UNIFIED=0;  break;;
121	"5.7") IS_THIS_UNIFIED=0;  break;;
122	*)
123	echo "Unsupported release $RELEASE specified in ${SRC}/Makefile.master"
124	exit 1;;
125esac
126
127
128# We need a local copy of libc_pic.a (we should get this from the parent
129# workspace, but as we can't be sure how the proto area is constructed there
130# simply take it from a stashed copy on linkers.central or linkers.eng.)
131#
132# We try for the linkers server in the current domain. Failing that,
133# we fall over to linkers.central.
134LIBC_PICDIR=/net/linkers/export/big/libc_pic/$RELEASE
135if [ ! -d $LIBC_PICDIR ]; then
136    LIBC_PICDIR=/net/linkers.central/export/big/libc_pic/$RELEASE
137fi
138
139
140if [ $MACH = "sparc" ]; then
141	PLATS="sparc sparcv9"
142elif [ $MACH = "i386" ]; then
143	PLATS="i386 amd64"
144else
145	echo "Unknown Mach: $MACH - no libc_pic.a provided!"
146	PLATS=""
147fi
148
149for p in $PLATS
150do
151	SRCLIBCDIR=${SRC}/lib/libc/$p
152	if [ ! -d $SRCLIBCDIR ]; then
153		mkdir -p $SRCLIBCDIR
154	fi
155	if [ ! -f $SRCLIBCDIR/libc_pic.a ]; then
156		cp $LIBC_PICDIR/$p/libc_pic.a $SRCLIBCDIR
157	fi
158done
159
160SYSLIB=$CODEMGR_WS/proto/root_$MACH/lib
161USRLIB=$CODEMGR_WS/proto/root_$MACH/usr/lib
162
163if [ ! -h $USRLIB/ld.so.1 ]; then
164	rm -f $USRLIB/ld.so.1
165	ln -s ../../lib/ld.so.1 $USRLIB/ld.so.1
166	echo "$USRLIB/ld.so.1 -> ../../lib/ld.so.1"
167fi
168
169#
170# In addition create some 64 symlinks so that dependencies referenced
171# from our test environment will map back to the appropriate libraries.
172#
173if [ ! -h $SYSLIB/64 ] ; then
174	rm -f $SYSLIB/64
175	ln -s $MACH64 $SYSLIB/64
176	echo "$SYSLIB/64 -> $SYSLIB/$MACH64"
177fi
178if [ ! -h $USRLIB/64 ] ; then
179	rm -f $USRLIB/64
180	ln -s $MACH64 $USRLIB/64
181	echo "$USRLIB/64 -> $USRLIB/$MACH64"
182fi
183if [ ! -h $USRLIB/link_audit/64 ] ; then
184	rm -f $USRLIB/link_audit/64
185	ln -s $MACH64 $USRLIB/link_audit/64
186	echo "$USRLIB/link_audit/64 -> $USRLIB/link_audit/$MACH64"
187fi
188if [ ! -h $USRLIB/64/ld.so.1 ]; then
189	rm -f $USRLIB/64/ld.so.1
190	ln -s ../../../lib/64/ld.so.1 $USRLIB/64/ld.so.1
191	echo "$USRLIB/64/ld.so.1 -> ../../../lib/64/ld.so.1"
192fi
193
194#
195#
196#
197if [ $IS_THIS_UNIFIED = 0 ] ; then
198	rm -fr $CODEMGR_WS/proto/root_$MACH/lib
199	ln -s $CODEMGR_WS/proto/root_$MACH/usr/lib $CODEMGR_WS/proto/root_$MACH/lib
200fi
201