updated on Wed Jan 11 12:00:27 UTC 2012
[aur-mirror.git] / kencc-svn / configure
blob0442b3ddd34532b0270435bf6a4b87bd1a29e53a
1 #!/bin/bash
4 if ROOT=$(pwd) && HOST_SYSTEM="Linux" && HOST_ARCH="386"
5 then
8 # Rewrite uname values to a pair from these sets
10 # HOST_SYSTEM := { MacOSX, Linux, Nt, Solaris, FreeBSD, NetBSD, Irix, Plan9 }
12 # HOST_ARCH := { 386, mips, power, sparc }
14 case ${HOST_SYSTEM} in
15 Windows*|CYGWIN*|MINGW*)
16 HOST_SYSTEM="Nt"
18 Darwin)
19 HOST_SYSTEM="MacOSX"
21 SunOS)
22 HOST_SYSTEM="Solaris"
24 IRIX64)
25 HOST_SYSTEM="Irix"
27 esac
29 if [ "unknown" = "${HOST_ARCH}" ]
30 then
31 HOST_ARCH=$(uname -m)
34 case ${HOST_ARCH} in
35 ppc|powerpc)
36 HOST_ARCH="power"
38 x86|x86_32|i386|i586|i686|486|586|686)
39 HOST_ARCH="386"
41 esac
44 # Initialize configuration
46 SYSHOST=${HOST_SYSTEM}
47 SYSTARG=${HOST_SYSTEM}
48 OBJTYPE=${HOST_ARCH}
51 # Optionally modify configuration
53 while [ -n "${1}" ]
55 case $1 in
56 *clean)
57 rm -f mkconfig env bin
58 #1>&2 echo ok
59 exit 0
61 --host)
62 shift
63 HOST_SYSTEM=$1
64 shift
65 SYSHOST=${HOST_SYSTEM}
66 SYSTARG=${HOST_SYSTEM}
68 --target)
69 shift
70 SYSTARG=$1
71 shift
73 --object)
74 shift
75 OBJTYPE=$1
76 shift
78 --help|-help|-h|-?)
79 cat<<EOF>&2
81 Configuration options (in order)
83 --host <Host system type> (eg, MacOSX, Linux, Nt, Solaris, FreeBSD, NetBSD, Irix, Plan9)
85 --target <Target system type> (eg, MacOSX, Linux, Nt, Solaris, FreeBSD, NetBSD, Irix, Plan9)
87 --object <Target object type> (eg, 386, mips, power, sparc)
89 Usage
91 Configuration options must be employed in the order shown above.
93 Running with no arguments should produce a valid result.
95 Please contribute to this project by ensuring that any found bugs
96 have been reported via
98 http://code.google.com/p/ken-cc/issues/list
100 for your configuration
102 HOST_SYSTEM=${HOST_SYSTEM}
103 HOST_ARCH=${HOST_ARCH}
105 Cleaning (or unconfiguring)
107 Run
108 ./configure clean
110 ./configure --clean
112 to remove the products of this script.
115 exit 1
117 esac
118 done
120 # Host bin
122 BINDIR=${HOST_SYSTEM}/${HOST_ARCH}
124 # Target bin
126 OBJDIR=${SYSTARG}/${OBJTYPE}
128 # Sanity testing...
130 if [ -z "${SYSHOST}" ]||[ -z "${SYSTARG}" ]||[ -z "${OBJTYPE}" ]
131 then
132 cat<<EOF>&2
133 Input error
135 exit 1
137 elif [ ! -d "${BINDIR}" ]
138 then
139 cat<<EOF>&2
140 Host type selection error in one or both of
141 HOST_SYSTEM '${HOST_SYSTEM}'
142 HOST_ARCH '${HOST_ARCH}'
144 exit 1
146 elif [ ! -d "${OBJDIR}" ]
147 then
148 cat<<EOF>&2
149 Target type selection error in one or both of
150 TARGET '${SYSTARG}'
151 OBJECT '${OBJTYPE}'
153 exit 1
155 else
157 # Generate configuration
159 cat<<EOF>mkconfig
161 # Set the following 4 variables. The host system is the system where
162 # the software will be built; the target system is where it will run.
163 # They are almost always the same.
165 # On Nt systems, the ROOT path MUST be of the form 'drive:/path'
166 ROOT=${ROOT}
168 # build system OS type
169 SYSHOST=${SYSHOST}
171 # target system OS type
172 SYSTARG=${SYSTARG}
174 # target system object type
175 OBJTYPE=${OBJTYPE}
178 # no changes required beyond this point
180 OBJDIR=\$SYSTARG/\$OBJTYPE
182 <\$ROOT/mkfiles/mkhost-\$SYSHOST # variables appropriate for host system
183 <\$ROOT/mkfiles/mkfile-\$SYSTARG-\$OBJTYPE # variables used to build target object type
189 # Report product
191 cat<<EOF
192 Successfully configured and wrote 'mkconfig'
196 # Configure host binaries into 'env' path
198 if [ -e bin ]
199 then
200 rm -f bin
202 if ln -s ${BINDIR}/bin bin
203 then
204 cat<<EOF
205 Successfully configured host path '$(pwd)/bin'
207 else
208 cat<<EOF>&2
209 Error linking host path 'ln -s ${BINDIR}/bin bin'
211 exit 1
214 # Configure 'env' script
216 ewd=$(pwd)
217 ebp=${ewd}/bin
218 cat<<EOF>env
220 # Generated by ${ewd}/configure. See ./configure --help.
222 # Usage
223 # Run
224 # . ./env
225 # or
226 # source ./env
228 # in this directory
229 # to initialize this development environment
231 PATH=${ebp}:\$(echo \${PATH} | sed 's%${ebp}:%%g; s%:${ebp}%%g')
233 # Convenience for running commands outside 'mk'...
235 ROOT=${ROOT}
237 # Conveniences for sourcing and targeting commands as in 'mk'...
239 SYSTARG=${SYSTARG}
240 OBJTYPE=${OBJTYPE}
241 OBJDIR=\${SYSTARG}/\${OBJTYPE}
245 cat<<EOF>&2
247 Employ command ". ./env" in this directory to initialize usage,
248 or PREPEND "$(pwd)/bin" to your PATH.
251 exit 0
252 else
253 cat<<EOF>&2
255 Error running commands 'pwd' or 'uname'.
256 Unable to configure.
259 exit 1