Subversion Repositories tendra.SVN

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 7u83 1
# $Id$
2
# ex:filetype=sh
3
 
4
# Wrap normal command utilities with env.
5
AWK="/usr/bin/env awk"
6
CUT="/usr/bin/env cut"
7
SED="/usr/bin/env sed"
8
 
9
 
10
# Check if the CC environment variable is set.
11
check_cc()
12
{
13
	if [ -z $CC ]; then
14
		CC="cc";
15
	elif [ "$CC" = "CC" ]; then
16
		CC="cc";
17
		echo "NOTICE: CC is often the C++ compiler, we just need a normal C compiler,";
18
		echo "        setting CC to \"cc\"."
19
		echo;
20
	elif [ "$CC" = "xlc_r" -o "$CC" = "xlc_r4" -o "$CC" = "xlc_r7"\
21
		-o "$CC" = "cc_r" -o "$CC" = "cc_r4" -o "$CC" = "cc_r7" ]; then
22
		# We are on AIX, and since we focus on ANSI as a compiler, use
23
		# the right bootstrapping compiler: xlc (which implies ansi).
24
		CC="xlc";
25
		CCTYPE="AIX";
26
		echo "NOTICE: Using xlc_r or cc_r creates POSIX threaded applications.  We do";
27
		echo "        not need that.  Setting CC to \"xlc\"."
28
		echo
29
	fi
30
 
31
	check_cc_ver ${CC}
32
}
33
 
34
# Check to see if we can lift the version string from the cc call.
35
check_cc_ver()
36
{
37
	CC=$1
38
 
39
	case "${CC}" in
40
		cc*)
41
		VERSIONSTRING=`${CC} --version`
42
		if [ $? -eq 0 ]; then
43
			CCVER=`echo ${VERSIONSTRING} | ${AWK} '{ where = match($0, /[[:digit:]][[:digit:]]?\.?[[:digit:]]?[[:digit:]]?\.[[:digit:]][[:digit:]]?/); if (where != 0) print substr($0, RSTART, RLENGTH); else print where }'`
44
		fi
45
		;;
46
		[gi]cc*)
47
		VERSIONSTRING=`${CC} --version`
48
		if [ $? -eq 0 ]; then
49
			CCVER=`echo ${VERSIONSTRING} | ${AWK} '{ where = match($0, /[[:digit:]][[:digit:]]?\.?[[:digit:]]?[[:digit:]]?\.[[:digit:]][[:digit:]]?/); if (where != 0) print substr($0, RSTART, RLENGTH); else print where }'`
50
		fi
51
		;;
52
		*)
53
			CCVER=0
54
		;;
55
	esac
56
 
57
	CCVER_MAJOR=`echo ${CCVER} | ${CUT} -d . -f 1`
58
	CCVER_MINOR=`echo ${CCVER} | ${CUT} -d . -f 2`
59
	CCVER_TINY=`echo ${CCVER} | ${CUT} -d . -f 3`
60
	if [ -z ${CCVER_TINY} ]; then
61
		CCVER_TINY=0
62
	fi
63
}
64
 
65
# Check to see which architecture the host is running on.
66
check_hostarch()
67
{
68
	case "$HOSTARCH" in
69
		alpha)
70
		# DEC, nay, Compaq, nay HP Alpha
71
		BLDARCH="alpha"
72
		BLDARCHBITS="64"
73
		;;
74
		amd64)
75
		# AMD64
76
		BLDARCH="amd64"
77
		BLDARCHBITS="64"
78
		;;
79
		i386)
80
		# Intel 80386
81
		BLDARCH="80x86"
82
		BLDARCHBITS="32"
83
		;;
84
		i486)
85
		# Intel 80486
86
		BLDARCHBITS="32"
87
		;;
88
		i586)
89
		# Intel 80586 (Pentium, Pentium MMX)
90
		BLDARCH="80x86"
91
		BLDARCHBITS="32"
92
		;;
93
		i686)
94
		# Intel 80686 (Pentium Pro, Pentium II,
95
		# Pentium III, Pentium 4, AMD Athlon)
96
		BLDARCH="80x86"
97
		BLDARCHBITS="32"
98
		;;
99
		sparc)
100
		# SPARC 32 bit
101
		BLDARCH="sparc"
102
		BLDARCHBITS="32"
103
		;;
104
		sparc64)
105
		# SPARC 64 bit
106
		BLDARCH="sparc"
107
		BLDARCHBITS="64"
108
		;;
109
		*)
110
		echo "Unknown architecture \"${HOSTARCH}\""
111
		echo "Please report the following to the developers:"
112
		echo
113
		echo "uname -m:	${HOSTARCH}"
114
		echo
115
		;;
116
	esac
117
}
118
 
119
usage()
120
{
121
	echo "makedefs"
122
	echo "usage: [OPTIONS] ./makedefs [-h]"
123
	echo
124
	echo "Configuration definition generator of the TenDRA Project"
125
	echo
126
	echo "Available OPTIONS (OPTION=value):"
127
	echo "PREFIX		installation prefix"
128
	echo "CC		C compiler command name"
129
	echo "CFLAGS		C compiler flags"
130
	echo "EXECFORMAT	desired default executable format (aout, elf)"
131
}