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.

206 lines
3.4KB

  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. extract_options ()
  46. {
  47. local line name value
  48. if [ -f make.conf ]
  49. then
  50. {
  51. while read line
  52. do
  53. [ "$line" = "## options" ] && break
  54. done
  55. while read line
  56. do
  57. if [ "$line" = "## libs" ]
  58. then
  59. break
  60. else
  61. name=${line%=*}
  62. value=${line#*=}
  63. eval "$name='$value'"
  64. fi
  65. done
  66. } < make.conf
  67. fi
  68. }
  69. begin ()
  70. {
  71. echo -n "Checking sanity..."
  72. require_command pkg-config pkg-config > /dev/null
  73. ok
  74. }
  75. begin_options ()
  76. {
  77. # get the old values
  78. extract_options
  79. echo > make.conf
  80. append "# This file was automatically generated on `date`. Any changes may be lost!"
  81. append "## options"
  82. echo "--- Configuration required ---"
  83. }
  84. begin_tests ()
  85. {
  86. append "## libs"
  87. extract_options
  88. }
  89. append ()
  90. {
  91. echo "$1" >> make.conf
  92. }
  93. end ()
  94. {
  95. echo "--- Configuration complete ---"
  96. touch make.conf
  97. }
  98. require_command ()
  99. {
  100. echo -n "Checking for ${BOLD}$1${SGR0}..."
  101. if ! [ -x "`which $2`" ]
  102. then
  103. failed
  104. fatal "Command $1 not found."
  105. else
  106. ok
  107. fi
  108. }
  109. require_package ()
  110. {
  111. echo -n "Checking for $BOLD$1$SGR0..."
  112. if ! pkg-config --exists $3
  113. then
  114. failed
  115. fatal "Required package $1 doesn't appear to be installed."
  116. elif ! pkg-config --atleast-version $2 $3
  117. then
  118. failed
  119. fatal "The installed version of $1 (`pkg-config --mod-version $3`) is too old."
  120. fi
  121. append "${1}_LIBS=`pkg-config --libs $3`"
  122. append "${1}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
  123. ok
  124. return 0
  125. }
  126. _test_version ()
  127. {
  128. [ $1 $4 $5 ] && [ $2 $4 $6 ] && [ $3 $4 $7 ]
  129. }
  130. test_version ()
  131. {
  132. local IFS
  133. IFS='.'
  134. if [ $2 != -ge ] && [ $2 != -le ]
  135. then
  136. fatal "Syntax error"
  137. fi
  138. _test_version $1 $2 $3
  139. }
  140. version_of ()
  141. {
  142. echo `pkg-config --modversion $1`
  143. }
  144. require_FLTK ()
  145. {
  146. local use
  147. echo -n "Checking for ${BOLD}FLTK${SGR0}..."
  148. FLTK_VERSION=`fltk-config --version`
  149. if ! test_version $FLTK_VERSION -ge $1
  150. then
  151. failed
  152. fatal "The installed FLTK version ($FLTK_VERSION) is too old."
  153. else
  154. ok
  155. fi
  156. use=
  157. while [ $# -gt 1 ]
  158. do
  159. shift 1
  160. use="$use --use-$1"
  161. done
  162. append "FLTK_LIBS=`fltk-config $use --ldflags`"
  163. append "FLTK_CFLAGS=`fltk-config $use --cflags`"
  164. }