configure 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. --outdir=DIR output directory for binary packages [${outdir}]
  39. "
  40. }
  41. # Defaults
  42. prefix=/usr/local
  43. exec_prefix='$(prefix)'
  44. bindir='$(exec_prefix)/bin'
  45. sbindir='$(exec_prefix)/sbin'
  46. libexecdir='$(exec_prefix)/libexec'
  47. sysconfdir='$(prefix)/etc'
  48. localstatedir='$(prefix)/var'
  49. datarootdir='$(prefix)/share'
  50. infodir='$(datarootdir)/info'
  51. mandir='$(datarootdir)/man'
  52. docdir='$(datarootdir)/doc'
  53. arch="$(uname -m)"
  54. packagedir='$(prefix)/pkgs'
  55. targetdir='$(prefix)'
  56. outdir='$(localstatedir)/cache/qi/packages'
  57. return_variables()
  58. {
  59. printf '%s\n' \
  60. "prefix = $prefix" \
  61. "exec_prefix = $exec_prefix" \
  62. "bindir = $bindir" \
  63. "sbindir = $sbindir" \
  64. "libexecdir = $libexecdir" \
  65. "sysconfdir = $sysconfdir" \
  66. "localstatedir = $localstatedir" \
  67. "datarootdir = $datarootdir" \
  68. "infodir = $infodir" \
  69. "mandir = $mandir" \
  70. "docdir = $docdir" \
  71. "arch = $arch" \
  72. "packagedir = $packagedir" \
  73. "targetdir = $targetdir" \
  74. "outdir = $outdir" \
  75. ""
  76. }
  77. # Handle options
  78. while test $# -gt 0
  79. do
  80. case $1 in
  81. --prefix)
  82. prefix="$2"
  83. shift
  84. ;;
  85. --prefix=*)
  86. prefix="${1#*=}"
  87. ;;
  88. --exec-prefix)
  89. exec_prefix="$2"
  90. shift
  91. ;;
  92. --exec-prefix=*)
  93. exec_prefix="${1#*=}"
  94. ;;
  95. --bindir)
  96. bindir="$2"
  97. shift
  98. ;;
  99. --bindir=*)
  100. bindir="${1#*=}"
  101. ;;
  102. --sbindir)
  103. sbindir="$2"
  104. shift
  105. ;;
  106. --sbindir=*)
  107. sbindir="${1#*=}"
  108. ;;
  109. --libexecdir)
  110. libexecdir="$2"
  111. shift
  112. ;;
  113. --libexecdir=*)
  114. libexecdir="${1#*=}"
  115. ;;
  116. --sysconfdir)
  117. sysconfdir="$2"
  118. shift
  119. ;;
  120. --sysconfdir=*)
  121. sysconfdir="${1#*=}"
  122. ;;
  123. --localstatedir)
  124. localstatedir="$2"
  125. shift
  126. ;;
  127. --localstatedir=*)
  128. localstatedir="${1#*=}"
  129. ;;
  130. --datarootdir)
  131. datarootdir="$2"
  132. shift
  133. ;;
  134. --datarootdir=*)
  135. datarootdir="${1#*=}"
  136. ;;
  137. --infodir)
  138. infodir="$2"
  139. shift
  140. ;;
  141. --infodir=*)
  142. infodir="${1#*=}"
  143. ;;
  144. --mandir)
  145. mandir="$2"
  146. shift
  147. ;;
  148. --mandir=*)
  149. mandir="${1#*=}"
  150. ;;
  151. --docdir)
  152. docdir="$2"
  153. shift
  154. ;;
  155. --docdir=*)
  156. docdir="${1#*=}"
  157. ;;
  158. --arch)
  159. arch="$2"
  160. shift
  161. ;;
  162. --arch=*)
  163. arch="${1#*=}"
  164. ;;
  165. --packagedir)
  166. packagedir="$2"
  167. shift
  168. ;;
  169. --packagedir=*)
  170. packagedir="${1#*=}"
  171. ;;
  172. --targetdir)
  173. targetdir="$2"
  174. shift
  175. ;;
  176. --targetdir=*)
  177. targetdir="${1#*=}"
  178. ;;
  179. --outdir)
  180. outdir="$2"
  181. shift
  182. ;;
  183. --outdir=*)
  184. outdir="${1#*=}"
  185. ;;
  186. --help | --hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
  187. usage
  188. exit
  189. ;;
  190. --)
  191. shift
  192. break; # End of options.
  193. ;;
  194. -*)
  195. echo "configure: WARNING: unrecognized option '${1}'" 1>&2
  196. ;;
  197. *)
  198. break
  199. ;;
  200. esac
  201. shift
  202. done
  203. echo "Creating config.mak ..."
  204. return_variables; # Show configured variables.
  205. : > config.mak; # Clean up config.mak, first.
  206. if return_variables > config.mak
  207. then
  208. touch src/qi.in && echo "OK, now you can run \`make'"
  209. fi