configure 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. #! /bin/sh -
  2. #
  3. # Simple "configure" script for Qi.
  4. #
  5. # Copyright (c) 2016-2018, 2020-2022 Matias Fonzo, <selk@dragora.org>.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. set -e
  19. usage() {
  20. printf '%s' \
  21. "Usage: configure [options]
  22. Defaults for the options are specified in brackets.
  23. Options:
  24. --prefix=DIR install files in DIR [${prefix}]
  25. --exec-prefix=DIR base DIR for arch-dependent files [${exec_prefix}]
  26. --bindir=DIR user executables [${bindir}]
  27. --sbindir=DIR system admin executables [${sbindir}]
  28. --libexecdir=DIR program executables [${libexecdir}]
  29. --sysconfdir=DIR read-only single-machine data [${sysconfdir}]
  30. --localstatedir=DIR modifiable single-machine data [${localstatedir}]
  31. --datarootdir=DIR read-only arch-independent data root [${datarootdir}]
  32. --infodir=DIR info documentation [${infodir}]
  33. --mandir=DIR man documentation [${mandir}]
  34. --docdir=DIR documentation root [${docdir}]
  35. --arch=NAME architecture name to build packages [${arch}]
  36. --packagedir=DIR directory for package installations [${packagedir}]
  37. --targetdir=DIR target directory for symbolic links [${targetdir}]
  38. --cachedir=DIR output directory for cache files [${cachedir}]
  39. --outdir=DIR output directory for binary packages [${outdir}]
  40. "
  41. }
  42. # Defaults
  43. prefix=/usr/local
  44. exec_prefix='$(prefix)'
  45. bindir='$(exec_prefix)/bin'
  46. sbindir='$(exec_prefix)/sbin'
  47. libexecdir='$(exec_prefix)/libexec'
  48. sysconfdir='$(prefix)/etc'
  49. localstatedir='$(prefix)/var'
  50. datarootdir='$(prefix)/share'
  51. infodir='$(datarootdir)/info'
  52. mandir='$(datarootdir)/man'
  53. docdir='$(datarootdir)/doc'
  54. arch="$(uname -m)"
  55. packagedir='$(prefix)/pkgs'
  56. targetdir='$(prefix)'
  57. cachedir='$(localstatedir)/cache/qi'
  58. outdir='$(cachedir)/packages'
  59. return_variables()
  60. {
  61. printf '%s\n' \
  62. "prefix = $prefix" \
  63. "exec_prefix = $exec_prefix" \
  64. "bindir = $bindir" \
  65. "sbindir = $sbindir" \
  66. "libexecdir = $libexecdir" \
  67. "sysconfdir = $sysconfdir" \
  68. "localstatedir = $localstatedir" \
  69. "datarootdir = $datarootdir" \
  70. "infodir = $infodir" \
  71. "mandir = $mandir" \
  72. "docdir = $docdir" \
  73. "arch = $arch" \
  74. "packagedir = $packagedir" \
  75. "targetdir = $targetdir" \
  76. "cachedir = $cachedir" \
  77. "outdir = $outdir" \
  78. ""
  79. }
  80. # Handle options
  81. while test $# -gt 0
  82. do
  83. case $1 in
  84. --prefix)
  85. prefix="$2"
  86. shift
  87. ;;
  88. --prefix=*)
  89. prefix="${1#*=}"
  90. ;;
  91. --exec-prefix)
  92. exec_prefix="$2"
  93. shift
  94. ;;
  95. --exec-prefix=*)
  96. exec_prefix="${1#*=}"
  97. ;;
  98. --bindir)
  99. bindir="$2"
  100. shift
  101. ;;
  102. --bindir=*)
  103. bindir="${1#*=}"
  104. ;;
  105. --sbindir)
  106. sbindir="$2"
  107. shift
  108. ;;
  109. --sbindir=*)
  110. sbindir="${1#*=}"
  111. ;;
  112. --libexecdir)
  113. libexecdir="$2"
  114. shift
  115. ;;
  116. --libexecdir=*)
  117. libexecdir="${1#*=}"
  118. ;;
  119. --sysconfdir)
  120. sysconfdir="$2"
  121. shift
  122. ;;
  123. --sysconfdir=*)
  124. sysconfdir="${1#*=}"
  125. ;;
  126. --localstatedir)
  127. localstatedir="$2"
  128. shift
  129. ;;
  130. --localstatedir=*)
  131. localstatedir="${1#*=}"
  132. ;;
  133. --datarootdir)
  134. datarootdir="$2"
  135. shift
  136. ;;
  137. --datarootdir=*)
  138. datarootdir="${1#*=}"
  139. ;;
  140. --infodir)
  141. infodir="$2"
  142. shift
  143. ;;
  144. --infodir=*)
  145. infodir="${1#*=}"
  146. ;;
  147. --mandir)
  148. mandir="$2"
  149. shift
  150. ;;
  151. --mandir=*)
  152. mandir="${1#*=}"
  153. ;;
  154. --docdir)
  155. docdir="$2"
  156. shift
  157. ;;
  158. --docdir=*)
  159. docdir="${1#*=}"
  160. ;;
  161. --arch)
  162. arch="$2"
  163. shift
  164. ;;
  165. --arch=*)
  166. arch="${1#*=}"
  167. ;;
  168. --packagedir)
  169. packagedir="$2"
  170. shift
  171. ;;
  172. --packagedir=*)
  173. packagedir="${1#*=}"
  174. ;;
  175. --targetdir)
  176. targetdir="$2"
  177. shift
  178. ;;
  179. --targetdir=*)
  180. targetdir="${1#*=}"
  181. ;;
  182. --outdir)
  183. outdir="$2"
  184. shift
  185. ;;
  186. --outdir=*)
  187. outdir="${1#*=}"
  188. ;;
  189. --cachedir)
  190. cachedir="$2"
  191. shift
  192. ;;
  193. --cachedir=*)
  194. cachedir="${1#*=}"
  195. ;;
  196. --help | --hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
  197. usage
  198. exit
  199. ;;
  200. --)
  201. shift
  202. break; # End of options.
  203. ;;
  204. -*)
  205. echo "configure: WARNING: unrecognized option '${1}'" 1>&2
  206. ;;
  207. *)
  208. break
  209. ;;
  210. esac
  211. shift
  212. done
  213. echo "Creating config.mak ..."
  214. return_variables; # Show configured variables.
  215. : > config.mak; # Clean up config.mak, first.
  216. if return_variables > config.mak
  217. then
  218. touch src/qi.in && echo "OK, now you can run \`make'"
  219. fi