File: oarch.sh

package info (click to toggle)
star 1.5a67-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,600 kB
  • ctags: 4,715
  • sloc: ansic: 37,601; sh: 3,198; makefile: 200
file content (171 lines) | stat: -rwxr-xr-x 3,792 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
# @(#)oarch.sh  1.9 05/07/28 Copyright 2005 J. Schilling
###########################################################################
# Written 2005 by J. Schilling
###########################################################################
# A simulation of $(OARCH) from the Schily Makefile system
###########################################################################
# Copyright J�rg Schilling. All rights reserved.
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only.
# See the file CDDL.Schily.txt in this distribution or
# http://opensource.org/licenses/cddl1.php for details.
###########################################################################

cflag=FALSE
oflag=FALSE
pflag=FALSE
if [ .$1 = .-c ]; then
	cflag=TRUE
fi
if [ .$1 = .-o ]; then
	oflag=TRUE
fi
if [ .$1 = .-p ]; then
	pflag=TRUE
fi

MACHCMD="((mach || uname -p || true)		2> /dev/null)"
ARCHCMD="((arch || /usr/ucb/arch || true)	2> /dev/null)"

XP_ARCH=`eval ${MACHCMD} | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',\-'`
XK_ARCH=`uname -m    | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',\-'`
XM_ARCH=`eval ${ARCHCMD} | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',\-'`

#echo XP_ARCH $XP_ARCH
#echo XK_ARCH $XK_ARCH
#echo XM_ARCH $XM_ARCH

P_ARCH="${XP_ARCH}"
K_ARCH="${XK_ARCH}"
M_ARCH="${XM_ARCH}"

if [ ."$XP_ARCH" = .unknown ]; then
	P_ARCH="${K_ARCH}"
fi
if [ ."$XP_ARCH" = . ]; then
	P_ARCH="${K_ARCH}"
fi

if [ ."${XM_ARCH}" = . ]; then
	M_ARCH="${K_ARCH}"
fi

OSNAME=`uname -s | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',\-'`
OSREL=`uname -r | tr '[A-Z]' '[a-z]' | tr ', /\\()"' ',//////' | tr ',/' ',\-'`

O_ARCH="$OSNAME"

case "$OSREL" in
	cygwin*) O_ARCH=cygwin32_nt;;
esac
if [ ."$OSNAME" = .bsd-os ]; then
	case "$OSREL" in
		3.*)	O_ARCH=bsd-os3;;
		4.*)	O_ARCH=bsd-os;;
	esac
fi
if [ ."$OSNAME" = .bsd-os ]; then
	case "$OSREL" in
		3.*)	O_ARCH=bsd-os3;;
		4.*)	O_ARCH=bsd-os;;
	esac
fi
if [ ."$OSNAME" = .dgux ]; then
	case "$OSREL" in
		r4.*)	O_ARCH=dgux4;;
		5.4r3*)	O_ARCH=dgux3;;
	esac
fi
if [ ."$OSNAME" = .irix64 ]; then
	O_ARCH=irix
fi
if [ ."$OSNAME" = .mac-os ]; then
	case "$OSREL" in
		9.*)	O_ARCH=mac-os9;;
		10.*)	O_ARCH=mac-os10;;
	esac
fi
case "$OSREL" in
	mingw*) O_ARCH= mingw32_nt;;
esac
if [ ."$OSNAME" = .newsos ]; then
	case "$OSREL" in
		5.*)	O_ARCH=newsos5;;
		6.*)	O_ARCH=newsos6;;
	esac
fi
if [ ."$OSNAME" = .openunix ]; then
	O_ARCH=unixware
fi
if [ ."$OSNAME" = .os-2 ]; then
	O_ARCH=os2
fi
if [ ."$OSNAME" = .sco_sv ]; then
	O_ARCH=openserver
fi
if [ ."$OSNAME" = .sunos ]; then
	case "$OSREL" in
		4.*)	O_ARCH=sunos4;;
		5.*)	O_ARCH=sunos5;;
	esac
fi
if [ ."$OSNAME" = .unix_sv ]; then
	O_ARCH=unixware
fi

MARCH="$M_ARCH"
if [ ."$ARCH" != . ]; then
	MARCH="$ARCH"
fi

PARCH="$P_ARCH"
if [ ."$ARCH" != . ]; then
	PARCH="$ARCH"
fi

confdir=
if [ -z "$confdir" ]; then
	#
	# Try the directory containing this script.
	#
	prog=$0 
	confdir=`echo $prog|sed 's,/[^/][^/]*$,,'` 
	test ".$confdir" = ".$prog" && confdir=. 
	confdir=$confdir
fi 

CC="`grep '^DEFCCOM' $confdir/../incs/Dcc.${PARCH}-${O_ARCH} 2>/dev/null | sed -e 's,^DEFCCOM=[      ]*,,'`"
if [ ".$CC" = . ]; then
	CC="`grep '^DEFCCOM' $confdir/../DEFAULTS/Defaults.${O_ARCH} 2>/dev/null | sed -e 's,^DEFCCOM=[ 	]*,,'`"
fi
if [ ".$CC" = . ]; then
	CC=cc
fi

C_ARCH="`sh $confdir/../conf/cc-config.sh -echo $CC ${O_ARCH}`"

OARCH="${PARCH}-${O_ARCH}-${C_ARCH}"

#echo
#echo P_ARCH $P_ARCH
#echo K_ARCH $K_ARCH
#echo M_ARCH $M_ARCH
#echo OSNAME $OSNAME
#echo OSREL  $OSREL
#echo OARCH  "$OARCH"

if [ $cflag = TRUE ]; then
	echo "${C_ARCH}"
	exit
fi
if [ $oflag = TRUE ]; then
	echo "${O_ARCH}"
	exit
fi
if [ $pflag = TRUE ]; then
	echo "${PARCH}"
	exit
fi
echo "$OARCH"