xref: /titanic_51/usr/src/cmd/sgs/tools/proto.sh (revision f6485eec0b33b15e863ae352c5279913ed8e6d29)
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, and 5.9.
34#
35
36if [ "X$CODEMGR_WS" = "X" -o "X$MACH" = "X" ] ; then
37	echo "usage: CODEMGR_WS and MACH environment variables must be set"
38	exit 1
39fi
40
41RELEASE=$1
42
43if [ "X$RELEASE" = "X" ] ; then
44	echo "usage: proto release"
45	exit 1;
46fi
47
48IS_THIS_UNIFIED=1
49
50case $RELEASE in
51	"5.11") break;;
52	"5.10") break;;
53	"5.9") IS_THIS_UNIFIED=0;  break;;
54	*)
55	echo "usage: unsupported release $RELEASE specified"
56	exit 1;;
57esac
58
59dirs="	$CODEMGR_WS/proto \
60	$CODEMGR_WS/proto/root_$MACH \
61	$CODEMGR_WS/proto/root_$MACH/lib \
62	$CODEMGR_WS/proto/root_$MACH/usr \
63	$CODEMGR_WS/proto/root_$MACH/usr/demo \
64	$CODEMGR_WS/proto/root_$MACH/usr/lib \
65	$CODEMGR_WS/proto/root_$MACH/usr/lib/abi \
66	$CODEMGR_WS/proto/root_$MACH/usr/lib/link_audit \
67	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb \
68	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb/proc \
69	$CODEMGR_WS/proto/root_$MACH/usr/lib/pics \
70	$CODEMGR_WS/proto/root_$MACH/usr/4lib \
71	$CODEMGR_WS/proto/root_$MACH/usr/bin \
72	$CODEMGR_WS/proto/root_$MACH/usr/ccs \
73	$CODEMGR_WS/proto/root_$MACH/usr/ccs/bin \
74	$CODEMGR_WS/proto/root_$MACH/usr/include \
75	$CODEMGR_WS/proto/root_$MACH/usr/include/sys \
76	$CODEMGR_WS/proto/root_$MACH/usr/xpg4 \
77	$CODEMGR_WS/proto/root_$MACH/usr/xpg4/bin \
78	$CODEMGR_WS/proto/root_$MACH/etc \
79	$CODEMGR_WS/proto/root_$MACH/etc/lib \
80	$CODEMGR_WS/proto/root_$MACH/opt \
81	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld \
82	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/bin \
83	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/doc \
84	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/lib \
85	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man \
86	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man1 \
87	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man1l \
88	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3t \
89	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3l \
90	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/man/man3x"
91
92#
93# Add 64bit directories
94#
95MACH64=""
96if [ $MACH = "sparc" ]; then
97    MACH64="sparcv9";
98fi
99if [ $MACH = "i386" ]; then
100    MACH64="amd64";
101fi
102if [ "${MACH64}x" != x ]; then
103
104	dirs="$dirs \
105	$CODEMGR_WS/proto/root_$MACH/lib/$MACH64 \
106	$CODEMGR_WS/proto/root_$MACH/usr/bin/$MACH64 \
107	$CODEMGR_WS/proto/root_$MACH/usr/ccs/bin/$MACH64 \
108	$CODEMGR_WS/proto/root_$MACH/usr/lib/$MACH64 \
109	$CODEMGR_WS/proto/root_$MACH/usr/lib/abi/$MACH64 \
110	$CODEMGR_WS/proto/root_$MACH/usr/lib/link_audit/$MACH64 \
111	$CODEMGR_WS/proto/root_$MACH/usr/lib/mdb/proc/$MACH64 \
112	$CODEMGR_WS/proto/root_$MACH/usr/lib/pics/$MACH64 \
113	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/bin/$MACH64 \
114	$CODEMGR_WS/proto/root_$MACH/opt/SUNWonld/lib/$MACH64 \
115	"
116fi
117
118for dir in `echo $dirs`
119do
120	if [ ! -d $dir ] ; then
121		echo $dir
122		mkdir $dir
123		chmod 777 $dir
124	fi
125done
126
127# We need a local copy of libc_pic.a (we should get this from the parent
128# workspace, but as we can't be sure how the proto area is constructed there
129# simply take it from a stashed copy on the linkers server. If
130# LINKERS_EXPORT is defined, we use it. Failing that, we fall over
131#  to linkers.central.
132if [ "$LINKERS_EXPORT" = "" ]; then
133    LINKERS_EXPORT=/net/linkers.central/export
134fi
135
136if [ $MACH = "sparc" ]; then
137	PLATS="sparc sparcv9"
138elif [ $MACH = "i386" ]; then
139	PLATS="i386 amd64"
140else
141	echo "Unknown Mach: $MACH - no libc_pic.a provided!"
142	PLATS=""
143fi
144
145for p in $PLATS
146do
147	SRCLIBCDIR=${SRC}/lib/libc/$p
148	if [ ! -d $SRCLIBCDIR ]; then
149		mkdir -p $SRCLIBCDIR
150	fi
151	if [ ! -f $SRCLIBCDIR/libc_pic.a ]; then
152		cp $LINKERS_EXPORT/big/libc_pic/$RELEASE/$p/libc_pic.a \
153			$SRCLIBCDIR
154	fi
155done
156
157SYSLIB=$CODEMGR_WS/proto/root_$MACH/lib
158USRLIB=$CODEMGR_WS/proto/root_$MACH/usr/lib
159
160if [ ! -h $USRLIB/ld.so.1 ]; then
161	rm -f $USRLIB/ld.so.1
162	ln -s ../../lib/ld.so.1 $USRLIB/ld.so.1
163	echo "$USRLIB/ld.so.1 -> ../../lib/ld.so.1"
164fi
165
166#
167# In addition create some 64 symlinks so that dependencies referenced
168# from our test environment will map back to the appropriate libraries.
169#
170if [ ! -h $SYSLIB/64 ] ; then
171	rm -f $SYSLIB/64
172	ln -s $MACH64 $SYSLIB/64
173	echo "$SYSLIB/64 -> $SYSLIB/$MACH64"
174fi
175if [ ! -h $USRLIB/64 ] ; then
176	rm -f $USRLIB/64
177	ln -s $MACH64 $USRLIB/64
178	echo "$USRLIB/64 -> $USRLIB/$MACH64"
179fi
180if [ ! -h $USRLIB/link_audit/64 ] ; then
181	rm -f $USRLIB/link_audit/64
182	ln -s $MACH64 $USRLIB/link_audit/64
183	echo "$USRLIB/link_audit/64 -> $USRLIB/link_audit/$MACH64"
184fi
185if [ ! -h $USRLIB/64/ld.so.1 ]; then
186	rm -f $USRLIB/64/ld.so.1
187	ln -s ../../../lib/64/ld.so.1 $USRLIB/64/ld.so.1
188	echo "$USRLIB/64/ld.so.1 -> ../../../lib/64/ld.so.1"
189fi
190
191#
192#
193#
194if [ $IS_THIS_UNIFIED = 0 ] ; then
195	rm -fr $CODEMGR_WS/proto/root_$MACH/lib
196	ln -s $CODEMGR_WS/proto/root_$MACH/usr/lib $CODEMGR_WS/proto/root_$MACH/lib
197fi
198