config 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. #!/bin/sh
  2. # Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. # OpenSSL config: determine the operating system and run ./Configure
  9. # Derived from minarch and GuessOS from Apache.
  10. #
  11. # Do "config -h" for usage information.
  12. SUFFIX=""
  13. DRYRUN="false"
  14. VERBOSE="false"
  15. EXE=""
  16. THERE=`dirname $0`
  17. # pick up any command line args to config
  18. for i
  19. do
  20. case "$i" in
  21. -d*) options=$options" --debug";;
  22. -t*) DRYRUN="true" VERBOSE="true";;
  23. -v*) VERBOSE="true";;
  24. -h*) DRYRUN="true"; cat <<EOF
  25. Usage: config [options]
  26. -d Build with debugging when possible.
  27. -t Test mode, do not run the Configure perl script.
  28. -v Verbose mode, show the exact Configure call that is being made.
  29. -h This help.
  30. Any other text will be passed to the Configure perl script.
  31. See INSTALL for instructions.
  32. EOF
  33. ;;
  34. *) i=`echo "$i" | sed -e "s|'|'\\\\\\''|g"`
  35. options="$options '$i'" ;;
  36. esac
  37. done
  38. # Environment that's being passed to Configure
  39. __CNF_CPPDEFINES=
  40. __CNF_CPPINCLUDES=
  41. __CNF_CPPFLAGS=
  42. __CNF_CFLAGS=
  43. __CNF_CXXFLAGS=
  44. __CNF_LDFLAGS=
  45. __CNF_LDLIBS=
  46. # First get uname entries that we use below
  47. [ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
  48. [ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown"
  49. [ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown"
  50. [ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown"
  51. # Now test for ISC and SCO, since it is has a braindamaged uname.
  52. #
  53. # We need to work around FreeBSD 1.1.5.1
  54. (
  55. XREL=`uname -X 2>/dev/null | grep "^Release" | awk '{print $3}'`
  56. if [ "x$XREL" != "x" ]; then
  57. if [ -f /etc/kconfig ]; then
  58. case "$XREL" in
  59. 4.0|4.1)
  60. echo "${MACHINE}-whatever-isc4"; exit 0
  61. ;;
  62. esac
  63. else
  64. case "$XREL" in
  65. 3.2v4.2)
  66. echo "whatever-whatever-sco3"; exit 0
  67. ;;
  68. 3.2v5.0*)
  69. echo "whatever-whatever-sco5"; exit 0
  70. ;;
  71. 4.2MP)
  72. case "x${VERSION}" in
  73. x2.0*) echo "whatever-whatever-unixware20"; exit 0 ;;
  74. x2.1*) echo "whatever-whatever-unixware21"; exit 0 ;;
  75. x2*) echo "whatever-whatever-unixware2"; exit 0 ;;
  76. esac
  77. ;;
  78. 4.2)
  79. echo "whatever-whatever-unixware1"; exit 0
  80. ;;
  81. 5*)
  82. case "x${VERSION}" in
  83. # We hardcode i586 in place of ${MACHINE} for the
  84. # following reason. The catch is that even though Pentium
  85. # is minimum requirement for platforms in question,
  86. # ${MACHINE} gets always assigned to i386. Now, problem
  87. # with i386 is that it makes ./config pass 386 to
  88. # ./Configure, which in turn makes make generate
  89. # inefficient SHA-1 (for this moment) code.
  90. x[678]*) echo "i586-sco-unixware7"; exit 0 ;;
  91. esac
  92. ;;
  93. esac
  94. fi
  95. fi
  96. # Now we simply scan though... In most cases, the SYSTEM info is enough
  97. #
  98. case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
  99. A/UX:*)
  100. echo "m68k-apple-aux3"; exit 0
  101. ;;
  102. AIX:[3-9]:4:*)
  103. echo "${MACHINE}-ibm-aix"; exit 0
  104. ;;
  105. AIX:*:[5-9]:*)
  106. echo "${MACHINE}-ibm-aix"; exit 0
  107. ;;
  108. AIX:*)
  109. echo "${MACHINE}-ibm-aix3"; exit 0
  110. ;;
  111. HI-UX:*)
  112. echo "${MACHINE}-hi-hiux"; exit 0
  113. ;;
  114. HP-UX:*)
  115. HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
  116. case "$HPUXVER" in
  117. 1[0-9].*) # HPUX 10 and 11 targets are unified
  118. echo "${MACHINE}-hp-hpux1x"; exit 0
  119. ;;
  120. *)
  121. echo "${MACHINE}-hp-hpux"; exit 0
  122. ;;
  123. esac
  124. ;;
  125. IRIX:6.*)
  126. echo "mips3-sgi-irix"; exit 0
  127. ;;
  128. IRIX64:*)
  129. echo "mips4-sgi-irix64"; exit 0
  130. ;;
  131. Linux:[2-9].*)
  132. echo "${MACHINE}-whatever-linux2"; exit 0
  133. ;;
  134. Linux:1.*)
  135. echo "${MACHINE}-whatever-linux1"; exit 0
  136. ;;
  137. GNU*)
  138. echo "hurd-x86"; exit 0;
  139. ;;
  140. LynxOS:*)
  141. echo "${MACHINE}-lynx-lynxos"; exit 0
  142. ;;
  143. BSD/OS:4.*) # BSD/OS always says 386
  144. echo "i486-whatever-bsdi4"; exit 0
  145. ;;
  146. BSD/386:*:*:*486*|BSD/OS:*:*:*:*486*)
  147. case `/sbin/sysctl -n hw.model` in
  148. Pentium*)
  149. echo "i586-whatever-bsdi"; exit 0
  150. ;;
  151. *)
  152. echo "i386-whatever-bsdi"; exit 0
  153. ;;
  154. esac;
  155. ;;
  156. BSD/386:*|BSD/OS:*)
  157. echo "${MACHINE}-whatever-bsdi"; exit 0
  158. ;;
  159. FreeBSD:*:*:*386*)
  160. VERS=`echo ${RELEASE} | sed -e 's/[-(].*//'`
  161. MACH=`sysctl -n hw.model`
  162. ARCH='whatever'
  163. case ${MACH} in
  164. *386* ) MACH="i386" ;;
  165. *486* ) MACH="i486" ;;
  166. Pentium\ II*) MACH="i686" ;;
  167. Pentium* ) MACH="i586" ;;
  168. * ) MACH="$MACHINE" ;;
  169. esac
  170. case ${MACH} in
  171. i[0-9]86 ) ARCH="pc" ;;
  172. esac
  173. echo "${MACH}-${ARCH}-freebsd${VERS}"; exit 0
  174. ;;
  175. DragonFly:*)
  176. echo "${MACHINE}-whatever-dragonfly"; exit 0
  177. ;;
  178. FreeBSD:*)
  179. echo "${MACHINE}-whatever-freebsd"; exit 0
  180. ;;
  181. Haiku:*)
  182. echo "${MACHINE}-whatever-haiku"; exit 0
  183. ;;
  184. NetBSD:*:*:*386*)
  185. echo "`(/usr/sbin/sysctl -n hw.model || /sbin/sysctl -n hw.model) | sed 's,.*\(.\)86-class.*,i\186,'`-whatever-netbsd"; exit 0
  186. ;;
  187. NetBSD:*)
  188. echo "${MACHINE}-whatever-netbsd"; exit 0
  189. ;;
  190. OpenBSD:*)
  191. echo "${MACHINE}-whatever-openbsd"; exit 0
  192. ;;
  193. OpenUNIX:*)
  194. echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
  195. ;;
  196. OSF1:*:*:*alpha*)
  197. OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
  198. case "$OSFMAJOR" in
  199. 4|5)
  200. echo "${MACHINE}-dec-tru64"; exit 0
  201. ;;
  202. 1|2|3)
  203. echo "${MACHINE}-dec-osf"; exit 0
  204. ;;
  205. *)
  206. echo "${MACHINE}-dec-osf"; exit 0
  207. ;;
  208. esac
  209. ;;
  210. Paragon*:*:*:*)
  211. echo "i860-intel-osf1"; exit 0
  212. ;;
  213. Rhapsody:*)
  214. echo "ppc-apple-rhapsody"; exit 0
  215. ;;
  216. Darwin:*)
  217. case "$MACHINE" in
  218. Power*)
  219. echo "ppc-apple-darwin${VERSION}"
  220. ;;
  221. x86_64)
  222. echo "x86_64-apple-darwin${VERSION}"
  223. ;;
  224. *)
  225. echo "i686-apple-darwin${VERSION}"
  226. ;;
  227. esac
  228. exit 0
  229. ;;
  230. SunOS:5.*)
  231. echo "${MACHINE}-whatever-solaris2"; exit 0
  232. ;;
  233. SunOS:*)
  234. echo "${MACHINE}-sun-sunos4"; exit 0
  235. ;;
  236. UNIX_System_V:4.*:*)
  237. echo "${MACHINE}-whatever-sysv4"; exit 0
  238. ;;
  239. VOS:*:*:i786)
  240. echo "i386-stratus-vos"; exit 0
  241. ;;
  242. VOS:*:*:*)
  243. echo "hppa1.1-stratus-vos"; exit 0
  244. ;;
  245. *:4*:R4*:m88k)
  246. echo "${MACHINE}-whatever-sysv4"; exit 0
  247. ;;
  248. DYNIX/ptx:4*:*)
  249. echo "${MACHINE}-whatever-sysv4"; exit 0
  250. ;;
  251. *:4.0:3.0:3[34]?? | *:4.0:3.0:3[34]??,*)
  252. echo "i486-ncr-sysv4"; exit 0
  253. ;;
  254. ULTRIX:*)
  255. echo "${MACHINE}-unknown-ultrix"; exit 0
  256. ;;
  257. POSIX-BC*)
  258. echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
  259. ;;
  260. machten:*)
  261. echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
  262. ;;
  263. library:*)
  264. echo "${MACHINE}-ncr-sysv4"; exit 0
  265. ;;
  266. ConvexOS:*:11.0:*)
  267. echo "${MACHINE}-v11-${SYSTEM}"; exit 0;
  268. ;;
  269. # The following combinations are supported
  270. # MINGW64* on x86_64 => mingw64
  271. # MINGW32* on x86_64 => mingw
  272. # MINGW32* on i?86 => mingw
  273. #
  274. # MINGW64* on i?86 isn't expected to work...
  275. MINGW64*:*:*:x86_64)
  276. echo "${MACHINE}-whatever-mingw64"; exit 0;
  277. ;;
  278. MINGW*)
  279. echo "${MACHINE}-whatever-mingw"; exit 0;
  280. ;;
  281. CYGWIN*)
  282. echo "${MACHINE}-pc-cygwin"; exit 0
  283. ;;
  284. vxworks*)
  285. echo "${MACHINE}-whatever-vxworks"; exit 0;
  286. ;;
  287. esac
  288. #
  289. # Ugg. These are all we can determine by what we know about
  290. # the output of uname. Be more creative:
  291. #
  292. # Do the Apollo stuff first. Here, we just simply assume
  293. # that the existence of the /usr/apollo directory is proof
  294. # enough
  295. if [ -d /usr/apollo ]; then
  296. echo "whatever-apollo-whatever"
  297. exit 0
  298. fi
  299. # Now NeXT
  300. ISNEXT=`hostinfo 2>/dev/null`
  301. case "$ISNEXT" in
  302. *'NeXT Mach 3.3'*)
  303. echo "whatever-next-nextstep3.3"; exit 0
  304. ;;
  305. *NeXT*)
  306. echo "whatever-next-nextstep"; exit 0
  307. ;;
  308. esac
  309. # At this point we gone through all the one's
  310. # we know of: Punt
  311. echo "${MACHINE}-whatever-${SYSTEM}"
  312. exit 0
  313. ) 2>/dev/null | (
  314. # ---------------------------------------------------------------------------
  315. # this is where the translation occurs into SSLeay terms
  316. # ---------------------------------------------------------------------------
  317. # Only set CC if not supplied already
  318. if [ -z "$CROSS_COMPILE$CC" ]; then
  319. GCCVER=`sh -c "gcc -dumpversion" 2>/dev/null`
  320. if [ "$GCCVER" != "" ]; then
  321. # then strip off whatever prefix egcs prepends the number with...
  322. # Hopefully, this will work for any future prefixes as well.
  323. GCCVER=`echo $GCCVER | LC_ALL=C sed 's/^[a-zA-Z]*\-//'`
  324. # Since gcc 3.1 gcc --version behaviour has changed. gcc -dumpversion
  325. # does give us what we want though, so we use that. We just just the
  326. # major and minor version numbers.
  327. # peak single digit before and after first dot, e.g. 2.95.1 gives 29
  328. GCCVER=`echo $GCCVER | sed 's/\([0-9]\)\.\([0-9]\).*/\1\2/'`
  329. CC=gcc
  330. else
  331. CC=cc
  332. fi
  333. fi
  334. GCCVER=${GCCVER:-0}
  335. if [ "$SYSTEM" = "HP-UX" ];then
  336. # By default gcc is a ILP32 compiler (with long long == 64).
  337. GCC_BITS="32"
  338. if [ $GCCVER -ge 30 ]; then
  339. # PA64 support only came in with gcc 3.0.x.
  340. # We check if the preprocessor symbol __LP64__ is defined...
  341. if echo "__LP64__" | gcc -v -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null; then
  342. : # __LP64__ has slipped through, it therefore is not defined
  343. else
  344. GCC_BITS="64"
  345. fi
  346. fi
  347. fi
  348. if [ "$SYSTEM" = "SunOS" ]; then
  349. if [ $GCCVER -ge 30 ]; then
  350. # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
  351. # to be working, at the very least 'make test' passes...
  352. if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
  353. GCC_ARCH="-m64"
  354. else
  355. GCC_ARCH="-m32"
  356. fi
  357. fi
  358. # check for WorkShop C, expected output is "cc: blah-blah C x.x"
  359. CCVER=`(cc -V 2>&1) 2>/dev/null | \
  360. egrep -e '^cc: .* C [0-9]\.[0-9]' | \
  361. sed 's/.* C \([0-9]\)\.\([0-9]\).*/\1\2/'`
  362. CCVER=${CCVER:-0}
  363. if [ $MACHINE != i86pc -a $CCVER -gt 40 ]; then
  364. CC=cc # overrides gcc!!!
  365. if [ $CCVER -eq 50 ]; then
  366. echo "WARNING! Detected WorkShop C 5.0. Do make sure you have"
  367. echo " patch #107357-01 or later applied."
  368. sleep 5
  369. fi
  370. fi
  371. fi
  372. if [ "${SYSTEM}" = "AIX" ]; then # favor vendor cc over gcc
  373. (cc) 2>&1 | grep -iv "not found" > /dev/null && CC=cc
  374. fi
  375. CCVER=${CCVER:-0}
  376. # read the output of the embedded GuessOS
  377. read GUESSOS
  378. echo Operating system: $GUESSOS
  379. # now map the output into SSLeay terms ... really should hack into the
  380. # script above so we end up with values in vars but that would take
  381. # more time that I want to waste at the moment
  382. case "$GUESSOS" in
  383. uClinux*64*)
  384. OUT=uClinux-dist64
  385. ;;
  386. uClinux*)
  387. OUT=uClinux-dist
  388. ;;
  389. mips3-sgi-irix)
  390. OUT="irix-mips3-$CC"
  391. ;;
  392. mips4-sgi-irix64)
  393. echo "WARNING! If you wish to build 64-bit library, then you have to"
  394. echo " invoke '$THERE/Configure irix64-mips4-$CC' *manually*."
  395. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  396. echo " You have about 5 seconds to press Ctrl-C to abort."
  397. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  398. fi
  399. OUT="irix-mips3-$CC"
  400. ;;
  401. ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
  402. ppc-apple-darwin*)
  403. ISA64=`(sysctl -n hw.optional.64bitops) 2>/dev/null`
  404. if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
  405. echo "WARNING! If you wish to build 64-bit library, then you have to"
  406. echo " invoke '$THERE/Configure darwin64-ppc-cc' *manually*."
  407. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  408. echo " You have about 5 seconds to press Ctrl-C to abort."
  409. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  410. fi
  411. fi
  412. if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
  413. OUT="darwin64-ppc-cc"
  414. else
  415. OUT="darwin-ppc-cc"
  416. fi ;;
  417. i?86-apple-darwin*)
  418. ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null`
  419. if [ "$ISA64" = "1" -a -z "$KERNEL_BITS" ]; then
  420. echo "WARNING! If you wish to build 64-bit library, then you have to"
  421. echo " invoke 'KERNEL_BITS=64 $THERE/config $options'."
  422. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  423. echo " You have about 5 seconds to press Ctrl-C to abort."
  424. (trap "stty `stty -g`; exit 1" 2; stty -icanon min 0 time 50; read waste; exit 0) <&1 || exit
  425. fi
  426. fi
  427. if [ "$ISA64" = "1" -a "$KERNEL_BITS" = "64" ]; then
  428. OUT="darwin64-x86_64-cc"
  429. else
  430. OUT="darwin-i386-cc"
  431. fi ;;
  432. x86_64-apple-darwin*)
  433. if [ "$KERNEL_BITS" = "32" ]; then
  434. OUT="darwin-i386-cc"
  435. else
  436. OUT="darwin64-x86_64-cc"
  437. fi ;;
  438. armv6+7-*-iphoneos)
  439. __CNF_CFLAGS="$__CNF_CFLAGS -arch%20armv6 -arch%20armv7"
  440. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch%20armv6 -arch%20armv7"
  441. OUT="iphoneos-cross" ;;
  442. *-*-iphoneos)
  443. __CNF_CFLAGS="$__CNF_CFLAGS -arch%20${MACHINE}"
  444. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch%20${MACHINE}"
  445. OUT="iphoneos-cross" ;;
  446. arm64-*-iphoneos|*-*-ios64)
  447. OUT="ios64-cross" ;;
  448. alpha-*-linux2)
  449. ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo`
  450. case ${ISA:-generic} in
  451. *[678]) OUT="linux-alpha+bwx-$CC" ;;
  452. *) OUT="linux-alpha-$CC" ;;
  453. esac
  454. if [ "$CC" = "gcc" ]; then
  455. case ${ISA:-generic} in
  456. EV5|EV45) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev5"
  457. __CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=ev5";;
  458. EV56|PCA56) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev56"
  459. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev56";;
  460. *) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=ev6"
  461. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mcpu=ev6";;
  462. esac
  463. fi
  464. ;;
  465. ppc64-*-linux2)
  466. if [ -z "$KERNEL_BITS" ]; then
  467. echo "WARNING! If you wish to build 64-bit library, then you have to"
  468. echo " invoke '$THERE/Configure linux-ppc64' *manually*."
  469. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  470. echo " You have about 5 seconds to press Ctrl-C to abort."
  471. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  472. fi
  473. fi
  474. if [ "$KERNEL_BITS" = "64" ]; then
  475. OUT="linux-ppc64"
  476. else
  477. OUT="linux-ppc"
  478. if (echo "__LP64__" | gcc -E -x c - 2>/dev/null | grep "^__LP64__" 2>&1 > /dev/null); then
  479. :;
  480. else
  481. __CNF_CFLAGS="$__CNF_CFLAGS -m32"
  482. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -m32"
  483. fi
  484. fi
  485. ;;
  486. ppc64le-*-linux2) OUT="linux-ppc64le" ;;
  487. ppc-*-linux2) OUT="linux-ppc" ;;
  488. mips64*-*-linux2)
  489. echo "WARNING! If you wish to build 64-bit library, then you have to"
  490. echo " invoke '$THERE/Configure linux64-mips64' *manually*."
  491. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  492. echo " You have about 5 seconds to press Ctrl-C to abort."
  493. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  494. fi
  495. OUT="linux-mips64"
  496. ;;
  497. mips*-*-linux2) OUT="linux-mips32" ;;
  498. ppc60x-*-vxworks*) OUT="vxworks-ppc60x" ;;
  499. ppcgen-*-vxworks*) OUT="vxworks-ppcgen" ;;
  500. pentium-*-vxworks*) OUT="vxworks-pentium" ;;
  501. simlinux-*-vxworks*) OUT="vxworks-simlinux" ;;
  502. mips-*-vxworks*) OUT="vxworks-mips";;
  503. ia64-*-linux?) OUT="linux-ia64" ;;
  504. sparc64-*-linux2)
  505. echo "WARNING! If you *know* that your GNU C supports 64-bit/V9 ABI"
  506. echo " and wish to build 64-bit library, then you have to"
  507. echo " invoke '$THERE/Configure linux64-sparcv9' *manually*."
  508. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  509. echo " You have about 5 seconds to press Ctrl-C to abort."
  510. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  511. fi
  512. OUT="linux-sparcv9" ;;
  513. sparc-*-linux2)
  514. KARCH=`awk '/^type/{print$3;exit(0);}' /proc/cpuinfo`
  515. case ${KARCH:-sun4} in
  516. sun4u*) OUT="linux-sparcv9" ;;
  517. sun4m) OUT="linux-sparcv8" ;;
  518. sun4d) OUT="linux-sparcv8" ;;
  519. *) OUT="linux-generic32";
  520. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
  521. esac ;;
  522. parisc*-*-linux2)
  523. # 64-bit builds under parisc64 linux are not supported and
  524. # compiler is expected to generate 32-bit objects...
  525. CPUARCH=`awk '/cpu family/{print substr($5,1,3); exit(0);}' /proc/cpuinfo`
  526. CPUSCHEDULE=`awk '/^cpu.[ ]*: PA/{print substr($3,3); exit(0);}' /proc/cpuinfo`
  527. # ??TODO ?? Model transformations
  528. # 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
  529. # assuming no further arch. identification will ever be used by GCC.
  530. # 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
  531. # 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
  532. # for these chips in the future.
  533. # PA7300LC -> 7100LC (1.1)
  534. # PA8200 -> 8000 (2.0)
  535. # PA8500 -> 8000 (2.0)
  536. # PA8600 -> 8000 (2.0)
  537. CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8.00/8000/'`
  538. # Finish Model transformations
  539. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN"
  540. __CNF_CFLAGS="$__CNF_CFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
  541. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -mschedule=$CPUSCHEDULE -march=$CPUARCH"
  542. OUT="linux-generic32" ;;
  543. armv[1-3]*-*-linux2) OUT="linux-generic32" ;;
  544. armv[7-9]*-*-linux2) OUT="linux-armv4"
  545. __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
  546. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a"
  547. ;;
  548. arm*-*-linux2) OUT="linux-armv4" ;;
  549. aarch64-*-linux2) OUT="linux-aarch64" ;;
  550. sh*b-*-linux2) OUT="linux-generic32";
  551. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
  552. sh*-*-linux2) OUT="linux-generic32";
  553. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
  554. m68k*-*-linux2) OUT="linux-generic32";
  555. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
  556. s390-*-linux2) OUT="linux-generic32";
  557. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
  558. s390x-*-linux2)
  559. # To be uncommented when glibc bug is fixed, see Configure...
  560. #if egrep -e '^features.* highgprs' /proc/cpuinfo >/dev/null ; then
  561. # echo "WARNING! If you wish to build \"highgprs\" 32-bit library, then you"
  562. # echo " have to invoke './Configure linux32-s390x' *manually*."
  563. # if [ "$DRYRUN" = "false" -a -t -1 ]; then
  564. # echo " You have about 5 seconds to press Ctrl-C to abort."
  565. # (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  566. # fi
  567. #fi
  568. OUT="linux64-s390x"
  569. ;;
  570. x86_64-*-linux?)
  571. if $CC -dM -E -x c /dev/null 2>&1 | grep -q ILP32 > /dev/null; then
  572. OUT="linux-x32"
  573. else
  574. OUT="linux-x86_64"
  575. fi ;;
  576. *86-*-linux2)
  577. # On machines where the compiler understands -m32, prefer a
  578. # config target that uses it
  579. if $CC -m32 -E -x c /dev/null > /dev/null 2>&1; then
  580. OUT="linux-x86"
  581. else
  582. OUT="linux-elf"
  583. fi ;;
  584. *86-*-linux1) OUT="linux-aout" ;;
  585. *-*-linux?) OUT="linux-generic32" ;;
  586. sun4[uv]*-*-solaris2)
  587. OUT="solaris-sparcv9-$CC"
  588. ISA64=`(isainfo) 2>/dev/null | grep sparcv9`
  589. if [ "$ISA64" != "" -a "$KERNEL_BITS" = "" ]; then
  590. if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
  591. echo "WARNING! If you wish to build 64-bit library, then you have to"
  592. echo " invoke '$THERE/Configure solaris64-sparcv9-cc' *manually*."
  593. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  594. echo " You have about 5 seconds to press Ctrl-C to abort."
  595. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  596. fi
  597. elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
  598. # $GCC_ARCH denotes default ABI chosen by compiler driver
  599. # (first one found on the $PATH). I assume that user
  600. # expects certain consistency with the rest of his builds
  601. # and therefore switch over to 64-bit. <appro>
  602. OUT="solaris64-sparcv9-gcc"
  603. echo "WARNING! If you wish to build 32-bit library, then you have to"
  604. echo " invoke '$THERE/Configure solaris-sparcv9-gcc' *manually*."
  605. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  606. echo " You have about 5 seconds to press Ctrl-C to abort."
  607. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  608. fi
  609. elif [ "$GCC_ARCH" = "-m32" ]; then
  610. echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
  611. echo " and wish to build 64-bit library, then you have to"
  612. echo " invoke '$THERE/Configure solaris64-sparcv9-gcc' *manually*."
  613. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  614. echo " You have about 5 seconds to press Ctrl-C to abort."
  615. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  616. fi
  617. fi
  618. fi
  619. if [ "$ISA64" != "" -a "$KERNEL_BITS" = "64" ]; then
  620. OUT="solaris64-sparcv9-$CC"
  621. fi
  622. ;;
  623. sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
  624. sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
  625. sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
  626. *86*-*-solaris2)
  627. ISA64=`(isainfo) 2>/dev/null | grep amd64`
  628. if [ "$ISA64" != "" -a ${KERNEL_BITS:-64} -eq 64 ]; then
  629. OUT="solaris64-x86_64-$CC"
  630. else
  631. OUT="solaris-x86-$CC"
  632. if [ `uname -r | sed -e 's/5\.//'` -lt 10 ]; then
  633. options="$options no-sse2"
  634. fi
  635. fi
  636. ;;
  637. *-*-sunos4) OUT="sunos-$CC" ;;
  638. *86*-*-bsdi4) OUT="BSD-x86-elf"; options="$options no-sse2";
  639. __CNF_LDFLAGS="$__CNF_LDFLAGS -ldl" ;;
  640. alpha*-*-*bsd*) OUT="BSD-generic64";
  641. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DL_ENDIAN" ;;
  642. powerpc64-*-*bsd*) OUT="BSD-generic64";
  643. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DB_ENDIAN" ;;
  644. sparc64-*-*bsd*) OUT="BSD-sparc64" ;;
  645. ia64-*-*bsd*) OUT="BSD-ia64" ;;
  646. x86_64-*-dragonfly*) OUT="BSD-x86_64" ;;
  647. amd64-*-*bsd*) OUT="BSD-x86_64" ;;
  648. *86*-*-*bsd*) # mimic ld behaviour when it's looking for libc...
  649. if [ -L /usr/lib/libc.so ]; then # [Free|Net]BSD
  650. libc=/usr/lib/libc.so
  651. else # OpenBSD
  652. # ld searches for highest libc.so.* and so do we
  653. libc=`(ls /usr/lib/libc.so.* /lib/libc.so.* | tail -1) 2>/dev/null`
  654. fi
  655. case "`(file -L $libc) 2>/dev/null`" in
  656. *ELF*) OUT="BSD-x86-elf" ;;
  657. *) OUT="BSD-x86"; options="$options no-sse2" ;;
  658. esac ;;
  659. *-*-*bsd*) OUT="BSD-generic32" ;;
  660. x86_64-*-haiku) OUT="haiku-x86_64" ;;
  661. *-*-haiku) OUT="haiku-x86" ;;
  662. *-*-osf) OUT="osf1-alpha-cc" ;;
  663. *-*-tru64) OUT="tru64-alpha-cc" ;;
  664. *-*-[Uu]nix[Ww]are7)
  665. if [ "$CC" = "gcc" ]; then
  666. OUT="unixware-7-gcc" ; options="$options no-sse2"
  667. else
  668. OUT="unixware-7" ; options="$options no-sse2"
  669. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D__i386__"
  670. fi
  671. ;;
  672. *-*-[Uu]nix[Ww]are20*) OUT="unixware-2.0"; options="$options no-sse2 no-sha512" ;;
  673. *-*-[Uu]nix[Ww]are21*) OUT="unixware-2.1"; options="$options no-sse2 no-sha512" ;;
  674. *-*-vos)
  675. options="$options no-threads no-shared no-asm no-dso"
  676. EXE=".pm"
  677. OUT="vos-$CC" ;;
  678. BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
  679. *-hpux1*)
  680. if [ $CC = "gcc" -a $GCC_BITS = "64" ]; then
  681. OUT="hpux64-parisc2-gcc"
  682. fi
  683. [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
  684. KERNEL_BITS=${KERNEL_BITS:-32}
  685. CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
  686. CPU_VERSION=${CPU_VERSION:-0}
  687. # See <sys/unistd.h> for further info on CPU_VERSION.
  688. if [ $CPU_VERSION -ge 768 ]; then # IA-64 CPU
  689. if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
  690. OUT="hpux64-ia64-cc"
  691. else
  692. OUT="hpux-ia64-cc"
  693. fi
  694. elif [ $CPU_VERSION -ge 532 ]; then # PA-RISC 2.x CPU
  695. # PA-RISC 2.0 is no longer supported as separate 32-bit
  696. # target. This is compensated for by run-time detection
  697. # in most critical assembly modules and taking advantage
  698. # of 2.0 architecture in PA-RISC 1.1 build.
  699. OUT=${OUT:-"hpux-parisc1_1-${CC}"}
  700. if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
  701. echo "WARNING! If you wish to build 64-bit library then you have to"
  702. echo " invoke '$THERE/Configure hpux64-parisc2-cc' *manually*."
  703. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  704. echo " You have about 5 seconds to press Ctrl-C to abort."
  705. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  706. fi
  707. fi
  708. elif [ $CPU_VERSION -ge 528 ]; then # PA-RISC 1.1+ CPU
  709. OUT="hpux-parisc1_1-${CC}"
  710. elif [ $CPU_VERSION -ge 523 ]; then # PA-RISC 1.0 CPU
  711. OUT="hpux-parisc-${CC}"
  712. else # Motorola(?) CPU
  713. OUT="hpux-$CC"
  714. fi
  715. __CNF_CPPFLAGS="$__CNF_CPPFLAGS -D_REENTRANT" ;;
  716. *-hpux) OUT="hpux-parisc-$CC" ;;
  717. *-aix)
  718. [ "$KERNEL_BITS" ] || KERNEL_BITS=`(getconf KERNEL_BITMODE) 2>/dev/null`
  719. KERNEL_BITS=${KERNEL_BITS:-32}
  720. OBJECT_MODE=${OBJECT_MODE:-32}
  721. if [ "$CC" = "gcc" ]; then
  722. OUT="aix-gcc"
  723. if [ $OBJECT_MODE -eq 64 ]; then
  724. echo 'Your $OBJECT_MODE was found to be set to 64'
  725. OUT="aix64-gcc"
  726. fi
  727. elif [ $OBJECT_MODE -eq 64 ]; then
  728. echo 'Your $OBJECT_MODE was found to be set to 64'
  729. OUT="aix64-cc"
  730. else
  731. OUT="aix-cc"
  732. if [ $KERNEL_BITS -eq 64 ]; then
  733. echo "WARNING! If you wish to build 64-bit kit, then you have to"
  734. echo " invoke '$THERE/Configure aix64-cc' *manually*."
  735. if [ "$DRYRUN" = "false" -a -t 1 ]; then
  736. echo " You have ~5 seconds to press Ctrl-C to abort."
  737. (trap "stty `stty -g`; exit 0" 2 0; stty -icanon min 0 time 50; read waste) <&1
  738. fi
  739. fi
  740. fi
  741. if (lsattr -E -O -l `lsdev -c processor|awk '{print$1;exit}'` | grep -i powerpc) >/dev/null 2>&1; then
  742. : # this applies even to Power3 and later, as they return PowerPC_POWER[345]
  743. else
  744. options="$options no-asm"
  745. fi
  746. ;;
  747. # these are all covered by the catchall below
  748. i[3456]86-*-cygwin) OUT="Cygwin-x86" ;;
  749. *-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
  750. x86-*-android|i?86-*-android) OUT="android-x86" ;;
  751. armv[7-9]*-*-android)
  752. OUT="android-armeabi"
  753. __CNF_CFLAGS="$__CNF_CFLAGS -march=armv7-a"
  754. __CNF_CXXFLAGS="$__CNF_CXXFLAGS -march=armv7-a";;
  755. arm*-*-android) OUT="android-armeabi" ;;
  756. *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
  757. esac
  758. # NB: This atalla support has been superseded by the ENGINE support
  759. # That contains its own header and definitions anyway. Support can
  760. # be enabled or disabled on any supported platform without external
  761. # headers, eg. by adding the "hw-atalla" switch to ./config or
  762. # perl Configure
  763. #
  764. # See whether we can compile Atalla support
  765. #if [ -f /usr/include/atasi.h ]
  766. #then
  767. # __CNF_CPPFLAGS="$__CNF_CPPFLAGS -DATALLA"
  768. #fi
  769. if [ -n "$CONFIG_OPTIONS" ]; then
  770. options="$options $CONFIG_OPTIONS"
  771. fi
  772. # gcc < 2.8 does not support -march=ultrasparc
  773. if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
  774. then
  775. echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
  776. echo " Upgrade to gcc-2.8 or later."
  777. sleep 5
  778. OUT=solaris-sparcv8-gcc
  779. fi
  780. if [ "$OUT" = "linux-sparcv9" -a $GCCVER -lt 28 ]
  781. then
  782. echo "WARNING! Falling down to 'linux-sparcv8'."
  783. echo " Upgrade to gcc-2.8 or later."
  784. sleep 5
  785. OUT=linux-sparcv8
  786. fi
  787. case "$GUESSOS" in
  788. i386-*) options="$options 386" ;;
  789. esac
  790. for i in aes aria bf camellia cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa seed sha sm2 sm3 sm4
  791. do
  792. if [ ! -d $THERE/crypto/$i ]
  793. then
  794. options="$options no-$i"
  795. fi
  796. done
  797. if [ -z "$OUT" ]; then
  798. OUT="$CC"
  799. fi
  800. if [ ".$PERL" = . ] ; then
  801. for i in . `echo $PATH | sed 's/:/ /g'`; do
  802. if [ -f "$i/perl5$EXE" ] ; then
  803. PERL="$i/perl5$EXE"
  804. break;
  805. fi;
  806. done
  807. fi
  808. if [ ".$PERL" = . ] ; then
  809. for i in . `echo $PATH | sed 's/:/ /g'`; do
  810. if [ -f "$i/perl$EXE" ] ; then
  811. if "$i/perl$EXE" -e 'exit($]<5.0)'; then
  812. PERL="$i/perl$EXE"
  813. break;
  814. fi;
  815. fi;
  816. done
  817. fi
  818. if [ ".$PERL" = . ] ; then
  819. echo "You need Perl 5."
  820. exit 1
  821. fi
  822. # run Configure to check to see if we need to specify the
  823. # compiler for the platform ... in which case we add it on
  824. # the end ... otherwise we leave it off
  825. $PERL $THERE/Configure LIST | grep "$OUT-$CC" > /dev/null
  826. if [ $? = "0" ]; then
  827. OUT="$OUT-$CC"
  828. fi
  829. OUT="$OUT"
  830. $PERL $THERE/Configure LIST | grep "$OUT" > /dev/null
  831. if [ $? = "0" ]; then
  832. if [ "$VERBOSE" = "true" ]; then
  833. echo /usr/bin/env \
  834. __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
  835. __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
  836. __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
  837. __CNF_CFLAGS="'$__CNF_CFLAGS'" \
  838. __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
  839. __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
  840. __CNF_LDLIBS="'$__CNF_LDLIBS'" \
  841. $PERL $THERE/Configure $OUT $options
  842. fi
  843. if [ "$DRYRUN" = "false" ]; then
  844. # eval to make sure quoted options, possibly with spaces inside,
  845. # are treated right
  846. eval /usr/bin/env \
  847. __CNF_CPPDEFINES="'$__CNF_CPPDEFINES'" \
  848. __CNF_CPPINCLUDES="'$__CNF_CPPINCLUDES'" \
  849. __CNF_CPPFLAGS="'$__CNF_CPPFLAGS'" \
  850. __CNF_CFLAGS="'$__CNF_CFLAGS'" \
  851. __CNF_CXXFLAGS="'$__CNF_CXXFLAGS'" \
  852. __CNF_LDFLAGS="'$__CNF_LDFLAGS'" \
  853. __CNF_LDLIBS="'$__CNF_LDLIBS'" \
  854. $PERL $THERE/Configure $OUT $options
  855. fi
  856. else
  857. echo "This system ($OUT) is not supported. See file INSTALL for details."
  858. exit 1
  859. fi
  860. if [ "$OUT" = "darwin64-x86_64-cc" ]; then
  861. echo "WARNING! If you wish to build 32-bit libraries, then you have to"
  862. echo " invoke 'KERNEL_BITS=32 $THERE/config $options'."
  863. fi
  864. )