Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
3.6KB

  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2008 Jonathan Moore Liles
  4. # This file is licensed under version 2 of the GPL.
  5. . scripts/colors
  6. # support functions for 'configure' scripts.
  7. fatal ()
  8. {
  9. echo "$BOLD$RED$*$SGR0" > /dev/stderr
  10. exit 255
  11. }
  12. [ $# -gt 0 ] && fatal "This is not an autoconf script. Run it without any options and you will be prompted."
  13. ask ()
  14. {
  15. local A D
  16. D="`eval echo \\$$2`"
  17. D=${D:-$3}
  18. echo -n "$BLACK$BOLD::$SGR0 $1 [$BOLD${D}$SGR0] "
  19. read A
  20. A=${A:-$D}
  21. if [ "$3" = yes ] || [ "$3" = no ]
  22. then
  23. case "$A" in
  24. no | n | N) A=no ;;
  25. yes | y | Y) A=yes ;;
  26. * ) fatal "Invalid response. Must be 'yes' or 'no'" ;;
  27. esac
  28. fi
  29. append "${2}=${A:-$D}"
  30. }
  31. ok ()
  32. {
  33. echo "$BOLD${GREEN}ok${SGR0}"
  34. }
  35. failed ()
  36. {
  37. echo "$BOLD${RED}failed!${SGR0}" > /dev/stderr
  38. rm -f make.conf
  39. }
  40. using ()
  41. {
  42. [ "`eval echo \\$USE_$1`" = yes ]
  43. return $?
  44. }
  45. upcase ()
  46. {
  47. echo "$*" | tr '[[:lower:]]' '[[:upper:]]'
  48. }
  49. extract_options ()
  50. {
  51. local line name value
  52. if [ -f make.conf ]
  53. then
  54. {
  55. while read line
  56. do
  57. [ "$line" = "## options" ] && break
  58. done
  59. while read line
  60. do
  61. if [ "$line" = "## libs" ]
  62. then
  63. break
  64. else
  65. name=${line%=*}
  66. value=${line#*=}
  67. eval "$name='$value'"
  68. fi
  69. done
  70. } < make.conf
  71. fi
  72. }
  73. begin ()
  74. {
  75. echo -n "Checking sanity..."
  76. require_command pkg-config pkg-config > /dev/null
  77. ok
  78. }
  79. begin_options ()
  80. {
  81. # get the old values
  82. extract_options
  83. echo > make.conf
  84. append "# This file was automatically generated on `date`. Any changes may be lost!"
  85. append "## options"
  86. echo "--- Configuration required ---"
  87. }
  88. begin_tests ()
  89. {
  90. append "## libs"
  91. extract_options
  92. }
  93. append ()
  94. {
  95. echo "$1" >> make.conf
  96. }
  97. end ()
  98. {
  99. echo "--- Configuration complete ---"
  100. touch make.conf
  101. }
  102. require_command ()
  103. {
  104. echo -n "Checking for ${BOLD}$1${SGR0}..."
  105. if ! [ -x "`which $2`" ]
  106. then
  107. failed
  108. fatal "Command $1 not found."
  109. else
  110. ok
  111. fi
  112. }
  113. require_package ()
  114. {
  115. local name
  116. echo -n "Checking for $BOLD$1$SGR0..."
  117. if ! pkg-config --exists $3
  118. then
  119. failed
  120. fatal "Required package $1 doesn't appear to be installed."
  121. elif ! pkg-config --atleast-version $2 $3
  122. then
  123. failed
  124. fatal "The installed version of $1 (`pkg-config --mod-version $3`) is too old."
  125. fi
  126. name="`upcase \"$1\"`"
  127. append "${name}_LIBS=`pkg-config --libs $3`"
  128. append "${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
  129. ok
  130. return 0
  131. }
  132. _test_version ()
  133. {
  134. [ $1 -gt $4 ] && return 0
  135. [ $1 -eq $4 ] && [ $2 -gt $5 ] && return 0
  136. [ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -gt $6 ] && return 0
  137. [ $1 -eq $4 ] && [ $2 -eq $5 ] && [ $3 -eq $6 ] && return 0
  138. return 1
  139. }
  140. # return true if #1 is greater than or equal to $2
  141. test_version ()
  142. {
  143. local IFS
  144. IFS='.'
  145. _test_version $1 $2
  146. }
  147. version_of ()
  148. {
  149. echo `pkg-config --modversion $1`
  150. }
  151. require_FLTK ()
  152. {
  153. local use
  154. echo -n "Checking for ${BOLD}FLTK${SGR0}..."
  155. FLTK_VERSION=`fltk-config --version`
  156. if ! test_version $FLTK_VERSION $1
  157. then
  158. failed
  159. fatal "The installed FLTK version ($FLTK_VERSION) is too old."
  160. else
  161. ok
  162. fi
  163. use=
  164. while [ $# -gt 1 ]
  165. do
  166. shift 1
  167. use="$use --use-$1"
  168. done
  169. append "FLTK_LIBS=`fltk-config $use --ldflags`"
  170. append "FLTK_CFLAGS=`fltk-config $use --cflags`"
  171. }