configure 4.9 KB

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