config 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. #!/bin/sh
  2. #
  3. # config - this is a merge of minarch and GuessOS from the Apache Group
  4. # which then automatically runs Configure from SSLeay after
  5. # mapping the Apache names for OSs into SSLeay names
  6. #
  7. # 29-May-97 eay Added no-asm option
  8. # 27-May-97 eay Alpha linux mods
  9. # ??-May-97 eay IRIX mods
  10. # 16-Sep-97 tjh first cut of merged version
  11. #
  12. # Tim Hudson
  13. # tjh@cryptsoft.com
  14. #
  15. # Original Apache Group comments on GuessOS
  16. # Simple OS/Platform guesser. Similar to config.guess but
  17. # much, much smaller. Since it was developed for use with
  18. # Apache, it follows under Apache's regular licensing
  19. # with one specific addition: Any changes or additions
  20. # to this script should be Emailed to the Apache
  21. # group (apache@apache.org) in general and to
  22. # Jim Jagielski (jim@jaguNET.com) in specific.
  23. #
  24. # Be as similar to the output of config.guess/config.sub
  25. # as possible.
  26. # First get uname entries that we use below
  27. MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
  28. RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
  29. SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
  30. VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
  31. # Now test for ISC and SCO, since it is has a braindamaged uname.
  32. #
  33. # We need to work around FreeBSD 1.1.5.1
  34. (
  35. XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
  36. if [ "x$XREL" != "x" ]; then
  37. if [ -f /etc/kconfig ]; then
  38. case "$XREL" in
  39. 4.0|4.1)
  40. echo "${MACHINE}-whatever-isc4"; exit 0
  41. ;;
  42. esac
  43. else
  44. case "$XREL" in
  45. 3.2v4.2)
  46. echo "whatever-whatever-sco3"; exit 0
  47. ;;
  48. 3.2v5.0*)
  49. echo "whatever-whatever-sco5"; exit 0
  50. ;;
  51. 4.2MP)
  52. if [ "x$VERSION" = "x2.1.1" ]; then
  53. echo "${MACHINE}-whatever-unixware211"; exit 0
  54. else
  55. echo "${MACHINE}-whatever-unixware2"; exit 0
  56. fi
  57. ;;
  58. 4.2)
  59. echo "whatever-whatever-unixware1"; exit 0
  60. ;;
  61. esac
  62. fi
  63. fi
  64. # Now we simply scan though... In most cases, the SYSTEM info is enough
  65. #
  66. case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
  67. A/UX:*)
  68. echo "m68k-apple-aux3"; exit 0
  69. ;;
  70. AIX:*)
  71. echo "${MACHINE}-ibm-aix"; exit 0
  72. ;;
  73. dgux:*)
  74. echo "${MACHINE}-dg-dgux"; exit 0
  75. ;;
  76. HI-UX:*)
  77. echo "${MACHINE}-hi-hiux"; exit 0
  78. ;;
  79. HP-UX:*)
  80. HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
  81. case "$HPUXVER" in
  82. 10.*)
  83. echo "${MACHINE}-hp-hpux10."; exit 0
  84. ;;
  85. *)
  86. echo "${MACHINE}-hp-hpux"; exit 0
  87. ;;
  88. esac
  89. ;;
  90. IRIX:*)
  91. echo "${MACHINE}-sgi-irix"; exit 0
  92. ;;
  93. IRIX64:*)
  94. echo "${MACHINE}-sgi-irix64"; exit 0
  95. ;;
  96. Linux:[2-9].*)
  97. echo "${MACHINE}-whatever-linux2"; exit 0
  98. ;;
  99. Linux:1.*)
  100. echo "${MACHINE}-whatever-linux1"; exit 0
  101. ;;
  102. LynxOS:*)
  103. echo "${MACHINE}-lynx-lynxos"; exit 0
  104. ;;
  105. BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
  106. echo "i486-whatever-bsdi"; exit 0
  107. ;;
  108. BSD/386:*|BSD/OS:*)
  109. echo "${MACHINE}-whatever-bsdi"; exit 0
  110. ;;
  111. FreeBSD:*:*:*486*)
  112. echo "i486-whatever-freebsd"; exit 0
  113. ;;
  114. FreeBSD:*)
  115. echo "${MACHINE}-whatever-freebsd"; exit 0
  116. ;;
  117. NetBSD:*:*:*486*)
  118. echo "i486-whatever-netbsd"; exit 0
  119. ;;
  120. NetBSD:*)
  121. echo "${MACHINE}-whatever-netbsd"; exit 0
  122. ;;
  123. OpenBSD:*)
  124. echo "${MACHINE}-whatever-openbsd"; exit 0
  125. ;;
  126. OSF1:*:*:*alpha*)
  127. echo "${MACHINE}-dec-osf"; exit 0
  128. ;;
  129. QNX:*)
  130. case "$VERSION" in
  131. 423)
  132. echo "${MACHINE}-qssl-qnx32"
  133. ;;
  134. *)
  135. echo "${MACHINE}-qssl-qnx"
  136. ;;
  137. esac
  138. exit 0
  139. ;;
  140. Paragon*:*:*:*)
  141. echo "i860-intel-osf1"; exit 0
  142. ;;
  143. SunOS:5.*)
  144. echo "${MACHINE}-sun-solaris2"; exit 0
  145. ;;
  146. SunOS:*)
  147. echo "${MACHINE}-sun-sunos4"; exit 0
  148. ;;
  149. UNIX_System_V:4.*:*)
  150. echo "${MACHINE}-whatever-sysv4"; exit 0
  151. ;;
  152. *:4*:R4*:m88k)
  153. echo "${MACHINE}-whatever-sysv4"; exit 0
  154. ;;
  155. DYNIX/ptx:4*:*)
  156. echo "${MACHINE}-whatever-sysv4"; exit 0
  157. ;;
  158. *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
  159. echo "i486-ncr-sysv4"; exit 0
  160. ;;
  161. ULTRIX:*)
  162. echo "${MACHINE}-unknown-ultrix"; exit 0
  163. ;;
  164. SINIX*)
  165. echo "${MACHINE}-sni-sysv4"; exit 0
  166. ;;
  167. machten:*)
  168. echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
  169. ;;
  170. library:*)
  171. echo "${MACHINE}-ncr-sysv4"; exit 0
  172. ;;
  173. ConvexOS:*:11.0:*)
  174. echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
  175. ;;
  176. esac
  177. #
  178. # Ugg. These are all we can determine by what we know about
  179. # the output of uname. Be more creative:
  180. #
  181. # Do the Apollo stuff first. Here, we just simply assume
  182. # that the existance of the /usr/apollo directory is proof
  183. # enough
  184. if [ -d /usr/apollo ]; then
  185. echo "whatever-apollo-whatever"
  186. exit 0
  187. fi
  188. # Now NeXT
  189. ISNEXT=`hostinfo 2>/dev/null`
  190. case "$ISNEXT" in
  191. *NeXT*)
  192. echo "whatever-next-nextstep"; exit 0
  193. ;;
  194. esac
  195. # At this point we gone through all the one's
  196. # we know of: Punt
  197. echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}"
  198. exit 0
  199. ) 2>/dev/null | (
  200. # ---------------------------------------------------------------------------
  201. # this is where the translation occurs into SSLeay terms
  202. # ---------------------------------------------------------------------------
  203. PREFIX=""
  204. SUFFIX=""
  205. VERBOSE="false"
  206. TEST="false"
  207. # pick up any command line args to config
  208. for i
  209. do
  210. case "$i" in
  211. -d*) PREFIX="debug-";;
  212. -v*) VERBOSE="true";;
  213. -t*) TEST="true";;
  214. -h*) cat <<EOF
  215. usage: config [options]
  216. -d Add a debug- prefix to machine choice.
  217. -v Verbose mode.
  218. -t Test mode, do not run the Configure perl script.
  219. -h This help.
  220. Any other text will be passed to ther Configure perl script.
  221. Usefull options include
  222. no-asm Build with no assember code.
  223. -Dxxx Add xxx define to compilation.
  224. -Lxxx Add xxx library include path to build.
  225. -lxxx Add xxx library to build.
  226. eg, to build using RSAref, without assember, building to allow anon-DH
  227. ciphers and null encryption ciphers,
  228. config no-asm -DRSAref -DSSL_ALLOW_ADH -DSSL_ALLOW_ENULL -lrsaref
  229. EOF
  230. ;;
  231. *) options=$options" $i" ;;
  232. esac
  233. done
  234. # figure out if gcc is available and if so we use it otherwise
  235. # we fallback to whatever cc does on the system
  236. GCCVER=`gcc -v 2>&1`
  237. if [ $? = "0" ]; then
  238. CC=gcc
  239. else
  240. CC=cc
  241. fi
  242. # read the output of the embedded GuessOS
  243. read GUESSOS
  244. if [ "$VERBOSE" = "true" ]; then
  245. echo GUESSOS $GUESSOS
  246. fi
  247. # now map the output into SSLeay terms ... really should hack into the
  248. # script above so we end up with values in vars but that would take
  249. # more time that I want to waste at the moment
  250. case "$GUESSOS" in
  251. alpha-*-linux2) OUT="alpha-gcc" ;;
  252. *-*-linux2) OUT="linux-elf" ;;
  253. *-*-linux) OUT="linux-aout" ;;
  254. sun4*-sun-solaris2) OUT="solaris-sparc-$CC" ;;
  255. *86*-sun-solaris2) OUT="solaris-x86-$CC" ;;
  256. *-*-sunos4) OUT="sunos-$CC" ;;
  257. *-freebsd) OUT="FreeBSD" ;;
  258. *86*-*-netbsd) OUT="NetBSD-x86" ;;
  259. sun3*-*-netbsd) OUT="NetBSD-m68" ;;
  260. *-*-netbsd) OUT="NetBSD-sparc" ;;
  261. *86*-*-openbsd) OUT="OpenBSD-x86" ;;
  262. alpha*-*-openbsd) OUT="OpenBSD-alpha" ;;
  263. pmax*-*-openbsd) OUT="OpenBSD-mips" ;;
  264. *-*-openbsd) OUT="OpenBSD" ;;
  265. *-*-osf) OUT="alpha-cc" ;;
  266. *-*-unixware*) OUT="unixware-2.0" ;;
  267. *-sni-sysv4) OUT="SINIX" ;;
  268. *-hpux*) OUT="hpux-$CC" ;;
  269. # these are all covered by the catchall below
  270. # *-aix) OUT="aix-$CC" ;;
  271. # *-dgux) OUT="dgux" ;;
  272. *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
  273. esac
  274. if [ -z "$OUT" ]; then
  275. OUT="$CC"
  276. fi
  277. # run Configure to check to see if we need to specify the
  278. # compiler for the platform ... in which case we add it on
  279. # the end ... otherwise we leave it off
  280. perl ./Configure 2>&1 | grep "$OUT-$CC" > /dev/null
  281. if [ $? = "0" ]; then
  282. OUT="$OUT-$CC"
  283. fi
  284. OUT="$PREFIX$OUT"
  285. # at this point we have the answer ... which we could check again
  286. # and then fallback to a vanilla SSLeay build but then this script
  287. # wouldn't get updated
  288. echo Configuring for $OUT
  289. if [ "$TEST" = "true" ]; then
  290. echo ./Configure $OUT $options
  291. else
  292. perl ./Configure $OUT $options
  293. fi
  294. )