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.

204 lines
3.3KB

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