comparison configure.rc @ 0:3e629dc19168

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:24:28 +0100
parents
children ed19b429a152
comparison
equal deleted inserted replaced
-1:000000000000 0:3e629dc19168
1 #!/bin/rc
2 #//////////////////////////////////////////////////////////////////////////////
3 #
4 # Copyright (c) 2007-2010 Daniel Adler <dadler@uni-goettingen.de>,
5 # Tassilo Philipp <tphilipp@potion-studios.com>
6 #
7 # Permission to use, copy, modify, and distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10 #
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #
19 #//////////////////////////////////////////////////////////////////////////////
20
21 # --- configure settings ------------------------------------------------------
22
23 PACKAGE=dyncall
24 CONFIG_PREFIX=/usr/local #@@@
25
26 # --- output error message ----------------------------------------------------
27 fn error {
28 echo error: $*
29 exit 1
30 }
31
32 # --- output warning message --------------------------------------------------
33
34 fn warning {
35 echo warning: $*
36 }
37
38 # --- output info message -----------------------------------------------------
39
40 fn info {
41 echo $*
42 }
43
44 # --- print usage -------------------------------------------------------------
45
46 fn usage {
47 echo $PACKAGE' configuration shell-script'
48 echo 'Usage:'
49 echo ' configure [ options ]'
50 echo
51 echo 'Options:'
52 echo ' --help'
53 echo ' -h print this page'
54 #echo
55 #echo ' --target-x86 build for x86 architecture platform'
56 #echo ' --target-x64 build for x64 architecture platform'
57 #echo ' --target-ppc32 build for ppc32 architecture platform'
58 #echo ' --target-arm-arm build for ARM architecture platform (ARM mode)'
59 #echo ' --target-arm-thumb build for ARM architecture platform (THUMB mode)'
60 #echo
61 #echo ' --tool-pcc use Portable C Compiler'
62 #echo
63 #echo ' --asm-xa use Plan9 Assemblers (0a, 1a, 2a, etc.)'
64 #echo
65 #echo ' --config-release build release version (default)'
66 #echo ' --config-debug build debug version'
67 echo
68 exit 0
69 }
70
71 # --- guess operating system -------------------------------------------------
72
73 CONFIG_OS=()
74 fn guess_os {
75 CONFIG_OS='plan9'
76 info 'guess os '$CONFIG_OS
77 }
78
79 # --- guess architecture -----------------------------------------------------
80
81 CONFIG_ARCH=()
82 fn guess_arch {
83 CONFIG_ARCH='x86'
84 switch($cputype) {
85 case 386
86 CONFIG_ARCH='x86'
87 case amd64
88 CONFIG_ARCH='x64'
89 case arm
90 CONFIG_ARCH='arm32_arm'
91 case power
92 CONFIG_ARCH='ppc32'
93 case mips
94 CONFIG_ARCH='mips32'
95 case *
96 warning 'unknown architecture '$cputype' - using default (x86)'
97 }
98 info 'guess arch '$CONFIG_ARCH
99 }
100
101 # --- guess tool chain -------------------------------------------------------
102
103 CONFIG_TOOL=()
104 fn guess_tool {
105 #CONFIG_TOOL=`{grep CC /$objtype/mkfile | sed s/CC.//}
106 CONFIG_TOOL='pcc'
107 info 'guess tool '$CONFIG_TOOL
108 }
109
110 # --- guess assembler --------------------------------------------------------
111
112 CONFIG_ASM=()
113 fn guess_asm {
114 CONFIG_ASM=`{grep AS /$objtype/mkfile | sed s/AS.//}
115 info 'guess assembler '$CONFIG_ASM
116 }
117
118 # --- process arguments ------------------------------------------------------
119
120 fn args {
121 while(! ~ $#* 0 && ~ $1 -*) {
122 OPT=$1
123 shift
124
125 switch($OPT) {
126 case --help -h
127 usage
128 #case --target-x86
129 #CONFIG_ARCH='x86'
130 #case --target-x64
131 #CONFIG_ARCH='x64'
132 #case --target-ppc32
133 #CONFIG_ARCH='ppc32'
134 #case --target-arm-arm
135 #CONFIG_ARCH='arm32_arm'
136 #case --target-arm-thumb
137 #CONFIG_ARCH='arm32_thumb'
138 #case --tool-pcc
139 #CONFIG_TOOL=pcc
140 #CONFIG_ASM=2a
141 #case --tool-xa
142 #CONFIG_ASM=2a
143 #case --config-release
144 #CONFIG_CONFIG=release
145 #case --config-debug
146 #CONFIG_CONFIG=debug
147 case *
148 warning 'unknown option '$OPT
149 }
150 }
151 }
152
153 # --- guess variables --------------------------------------------------------
154
155 fn guess {
156 if(~ $#CONFIG_OS 0) {
157 guess_os
158 if(~ $#CONFIG_OS 0) {
159 error 'unsupported operating system '$OS
160 }
161 }
162
163 if(~ $#CONFIG_ARCH 0) {
164 guess_arch
165 if(~ $#CONFIG_ARCH 0) {
166 error 'unsupported architecture '$ARCH
167 }
168 }
169
170 if(~ $#CONFIG_TOOL 0) {
171 guess_tool
172 if(~ $#CONFIG_TOOL 0) {
173 error 'no tool'
174 }
175 }
176
177 if(~ $#CONFIG_ASM 0) {
178 guess_asm
179 if(~ $#CONFIG_ASM 0) {
180 error 'no assembler tool'
181 }
182 }
183
184 if(~ $#CONFIG_CONFIG 0) {
185 CONFIG_CONFIG=release
186 }
187 }
188
189 # --- set default variables --------------------------------------------------
190
191 fn set_defaults {
192 CONFIG_HOST=$CONFIG_OS
193 }
194
195 # --- derive variables -------------------------------------------------------
196
197 fn derive_vars {
198 BUILD_HOST=$CONFIG_HOST
199 if(! ~ $CONFIG_HOST $CONFIG_OS) {
200 BUILD_HOST=$CONFIG_HOST'_'$CONFIG_OS
201 }
202 }
203
204 # --- write ConfigVars files ------------------------------------------------
205
206 fn output {
207 echo '#auto-generated by '$PACKAGE'/configure' >$1
208 echo 'CONFIG_PACKAGE='$PACKAGE >>$1
209 echo 'CONFIG_HOST='$CONFIG_HOST >>$1
210 echo 'CONFIG_OS='$CONFIG_OS >>$1
211 echo 'CONFIG_ARCH='$CONFIG_ARCH >>$1
212 echo 'CONFIG_TOOL='$CONFIG_TOOL >>$1
213 echo 'CONFIG_ASM='$CONFIG_ASM >>$1
214 echo 'CONFIG_CONFIG='$CONFIG_CONFIG >>$1
215 echo 'CONFIG_PREFIX='$CONFIG_PREFIX >>$1
216 if(! ~ $#CONFIG_BUILDPREFIX 0) {
217 echo 'CONFIG_BUILDPREFIX='$CONFIG_BUILDPREFIX >>$1
218 }
219 echo '' >>$1
220 }
221
222 # --- main -------------------------------------------------------------------
223
224 fn main {
225 args $*
226 info '* configure package '$PACKAGE
227 guess
228 set_defaults
229 derive_vars
230 output ConfigVars
231 }
232
233 main $*
234