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.

407 lines
9.1KB

  1. #!/bin/sh
  2. #
  3. # "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $"
  4. #
  5. # FLTK configuration utility.
  6. #
  7. # Copyright 2000-2010 by Bill Spitzak and others.
  8. # Original version Copyright 2000 by James Dean Palmer
  9. # Adapted by Vincent Penne and Michael Sweet
  10. #
  11. # This library is free software; you can redistribute it and/or
  12. # modify it under the terms of the GNU Library General Public
  13. # License as published by the Free Software Foundation; either
  14. # version 2 of the License, or (at your option) any later version.
  15. #
  16. # This library is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. # Library General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU Library General Public
  22. # License along with this library; if not, write to the Free Software
  23. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  24. # USA.
  25. #
  26. # Please report all bugs and problems on the following page:
  27. #
  28. # http://www.fltk.org/str.php
  29. #
  30. MAJOR_VERSION=@FLTK_VERSION_MAJOR@
  31. MINOR_VERSION=@FLTK_VERSION_MINOR@
  32. PATCH_VERSION=@FLTK_VERSION_PATCH@
  33. VERSION=@FLTK_VERSION_FULL@
  34. APIVERSION=@FLTK_VERSION@
  35. ### BEGIN fltk-config
  36. selfdir=`dirname "$0"`
  37. prefix=@CMAKE_INSTALL_PREFIX@
  38. exec_prefix=${prefix}
  39. exec_prefix_set=no
  40. bindir=@PREFIX_BIN@
  41. includedir=@PREFIX_INCLUDE@
  42. libdir=@PREFIX_LIB@
  43. srcdir=.
  44. # compiler names
  45. CC="@CC@"
  46. CXX="@CXX@"
  47. # flags for C++ compiler:
  48. ARCHFLAGS="@OPTION_ARCHFLAGS@"
  49. CFLAGS="@C_FLAGS@"
  50. CXXFLAGS="@CAIROFLAGS@@C_FLAGS@"
  51. LDFLAGS="@LDFLAGS@"
  52. LDLIBS="@LD_LIBS@"
  53. OPTIM="@OPTION_OPTIM@"
  54. CAIROFLAGS="@CAIROFLAGS@"
  55. # Check for local invocation, and update paths accordingly...
  56. if test -f "$selfdir/bin/UseFLTK.cmake"; then
  57. bindir="$selfdir/bin/fluid"
  58. includedir="@FLTK_SOURCE_DIR@"
  59. libdir="$selfdir/lib"
  60. if test -f "$libdir/libntk_jpeg.a"; then
  61. CFLAGS="-I$includedir/jpeg $CFLAGS"
  62. CXXFLAGS="-I$includedir/jpeg $CXXFLAGS"
  63. fi
  64. if test -f "$libdir/libfltk_z.a"; then
  65. CFLAGS="-I$includedir/zlib $CFLAGS"
  66. CXXFLAGS="-I$includedir/zlib $CXXFLAGS"
  67. fi
  68. if test -f "$libdir/libntk_png.a"; then
  69. CFLAGS="-I$includedir/png $CFLAGS"
  70. CXXFLAGS="-I$includedir/png $CXXFLAGS"
  71. fi
  72. fi
  73. if test -d $includedir/FL/images; then
  74. CFLAGS="-I$includedir/FL/images $CFLAGS"
  75. CXXFLAGS="-I$includedir/FL/images $CXXFLAGS"
  76. fi
  77. if test -f "$libdir/libfltk_cairo.a"; then
  78. CFLAGS="$CAIROFLAGS $CFLAGS"
  79. CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
  80. fi
  81. # libraries to link with:
  82. LIBNAME="@LIBNAME@"
  83. DSONAME="@DSONAME@"
  84. DSOLINK="@DSOLINK@"
  85. IMAGELIBS="@IMAGELIBS@"
  86. STATICIMAGELIBS="@STATICIMAGELIBS@"
  87. CAIROLIBS="@CAIROLIBS@"
  88. SHAREDSUFFIX="@SHAREDSUFFIX@"
  89. usage ()
  90. {
  91. echo "Usage: fltk-config [OPTIONS]
  92. Options:
  93. [--version]
  94. [--api-version]
  95. Options telling what we are doing:
  96. [--use-gl] use GL
  97. [--use-images] use extra image formats (PNG, JPEG)
  98. [--use-glut] use glut compatibility layer
  99. [--use-forms] use forms compatibility layer
  100. [--use-cairo] use cairo graphics lib
  101. Options telling what information we request:
  102. [--cc] return C compiler used to compile FLTK
  103. [--cxx] return C++ compiler used to compile FLTK
  104. [--optim] return compiler optimization used to compile FLTK
  105. [--cflags] return flags to compile C using FLTK
  106. [--cxxflags] return flags to compile C++ using FLTK
  107. [--ldflags] return flags to link against FLTK
  108. [--ldstaticflags] return flags to link against static FLTK library
  109. even if there are DSOs installed
  110. [--libs] return FLTK libraries full path for dependencies
  111. [--prefix] return FLTK install time --prefix directory
  112. [--includedir] return FLTK install time include directory
  113. Options to compile and link an application:
  114. [-g] compile the program with debugging information
  115. [-Dname[=value]] compile the program with the given define
  116. [--compile program.cxx]
  117. [--post program] prepare the program for desktop use
  118. "
  119. exit $1
  120. }
  121. if test $# -eq 0; then
  122. usage 1
  123. fi
  124. no_plugins=no
  125. compile=
  126. post=
  127. debug=
  128. # Parse command line options
  129. while test $# -gt 0
  130. do
  131. case "$1" in
  132. -*=*)
  133. optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
  134. ;;
  135. *)
  136. optarg=
  137. ;;
  138. esac
  139. case $1 in
  140. --version)
  141. echo $VERSION
  142. ;;
  143. --api-version)
  144. echo $APIVERSION
  145. ;;
  146. --cc)
  147. echo $CC
  148. ;;
  149. --cxx)
  150. echo $CXX
  151. ;;
  152. --optim)
  153. echo_optim=yes
  154. ;;
  155. --use-gl | --use-glut)
  156. use_gl=yes
  157. ;;
  158. --use-forms)
  159. use_forms=yes
  160. ;;
  161. --use-images)
  162. use_images=yes
  163. ;;
  164. --use-cairo)
  165. use_cairo=yes
  166. ;;
  167. --cflags)
  168. echo_cflags=yes
  169. ;;
  170. --cxxflags)
  171. echo_cxxflags=yes
  172. ;;
  173. --ldflags)
  174. echo_ldflags=yes
  175. ;;
  176. --ldstaticflags)
  177. echo_ldstaticflags=yes
  178. ;;
  179. --libs)
  180. echo_libs=yes
  181. ;;
  182. --prefix)
  183. echo_prefix=yes
  184. ;;
  185. --includedir)
  186. echo_includedir=yes
  187. ;;
  188. -g)
  189. debug=-g
  190. ;;
  191. -D*)
  192. CXXFLAGS="$CXXFLAGS $1"
  193. ;;
  194. --compile)
  195. compile="$2"
  196. shift
  197. ;;
  198. --post)
  199. post="$2"
  200. shift
  201. ;;
  202. *)
  203. echo_help=yes
  204. ;;
  205. esac
  206. shift
  207. done
  208. if test "$includedir" != /usr/include; then
  209. includes=-I$includedir
  210. else
  211. includes=
  212. fi
  213. if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then
  214. libs=-L$libdir
  215. else
  216. libs=
  217. fi
  218. # Calculate needed libraries
  219. LDSTATIC="$libdir/libfltk.a $LDLIBS"
  220. LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS"
  221. if test x$use_forms = xyes; then
  222. LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS"
  223. LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC"
  224. fi
  225. if test x$use_gl = xyes; then
  226. LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIB@ $LDLIBS"
  227. LDSTATIC="$libdir/libfltk_gl.a @GLLIB@ $LDSTATIC"
  228. fi
  229. if test x$use_images = xyes; then
  230. LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS"
  231. LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC"
  232. fi
  233. if test x$use_cairo = xyes; then
  234. LDLIBS="-lfltk_cairo$SHAREDSUFFIX $CAIROLIBS $LDLIBS"
  235. LDSTATIC="$libdir/libfltk_cairo.a $CAIROLIBS $LDSTATIC"
  236. fi
  237. LDLIBS="$DSOLINK $LDFLAGS $libs $LDLIBS"
  238. LDSTATIC="$LDFLAGS $LDSTATIC"
  239. # Answer to user requests
  240. if test -n "$echo_help"; then
  241. usage 1
  242. fi
  243. if test -n "$compile"; then
  244. case "$compile" in
  245. *.cxx)
  246. prog="`basename \"$compile\" .cxx`"
  247. ;;
  248. *.cpp)
  249. prog="`basename \"$compile\" .cpp`"
  250. ;;
  251. *.cc)
  252. prog="`basename \"$compile\" .cc`"
  253. ;;
  254. *.C)
  255. prog="`basename \"$compile\" .C`"
  256. ;;
  257. *)
  258. echo "ERROR: Unknown/bad C++ source file extension on \"$compile\"!"
  259. exit 1
  260. ;;
  261. esac
  262. post="$prog"
  263. echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "'$prog'" "'$compile'" $LDSTATIC
  264. $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "$prog" "$compile" $LDSTATIC || exit 1
  265. fi
  266. if test -n "$post"; then
  267. case "`uname`" in
  268. Darwin)
  269. echo Creating "'$post.app'" bundle for desktop...
  270. id=`echo $post | tr ' ' '_'`
  271. # Make the bundle directory and move the executable there
  272. rm -rf "$post.app/Contents/MacOS"
  273. mkdir -p "$post.app/Contents/MacOS"
  274. mv "$post" "$post.app/Contents/MacOS"
  275. # Make a shell script that runs the bundled executable
  276. echo "#!/bin/sh" >"$post"
  277. echo 'dir="`dirname '"'"'$0'"'"'`"' >>"$post"
  278. echo 'exec "$dir/'"$post.app/Contents/MacOS/$post"'" "$@"' >>"$post"
  279. chmod +x "$post"
  280. # Make the simplest Info.plist needed for an application
  281. cat >"$post.app/Contents/Info.plist" <<EOF
  282. <?xml version="1.0" encoding="UTF-8"?>
  283. <plist version="0.9">
  284. <dict>
  285. <key>CFBundleInfoDictionaryVersion</key>
  286. <string>6.0</string>
  287. <key>CFBundleExecutable</key>
  288. <string>$post</string>
  289. <key>CFBundleIdentifier</key>
  290. <string>org.fltk.$id</string>
  291. <key>CFBundleName</key>
  292. <string>$post</string>
  293. <key>CFBundlePackageType</key>
  294. <string>APPL</string>
  295. </dict>
  296. </plist>
  297. EOF
  298. ;;
  299. esac
  300. fi
  301. if test "$echo_cflags" = "yes"; then
  302. echo $includes $CFLAGS
  303. fi
  304. if test "$echo_cxxflags" = "yes"; then
  305. echo $includes $CXXFLAGS
  306. fi
  307. if test "$echo_optim" = "yes"; then
  308. echo $OPTIM
  309. fi
  310. if test "$echo_ldflags" = "yes"; then
  311. my_libs=
  312. libdirs=$libs
  313. for i in $LDLIBS ; do
  314. if test $i != -L$libdir ; then
  315. if test -z "$my_libs" ; then
  316. my_libs="$i"
  317. else
  318. my_libs="$my_libs $i"
  319. fi
  320. fi
  321. done
  322. echo $libdirs $my_libs
  323. fi
  324. if test "$echo_ldstaticflags" = "yes"; then
  325. echo $LDSTATIC
  326. fi
  327. if test "$echo_libs" = "yes"; then
  328. USELIBS="$libdir/libfltk.a"
  329. if test x$use_forms = xyes; then
  330. USELIBS="$libdir/libfltk_forms.a $USELIBS"
  331. fi
  332. if test x$use_gl = xyes; then
  333. USELIBS="$libdir/libfltk_gl.a $USELIBS"
  334. fi
  335. if test x$use_cairo = xyes; then
  336. USELIBS="$libdir/libfltk_cairo.a $USELIBS"
  337. fi
  338. if test x$use_images = xyes; then
  339. USELIBS="$libdir/libfltk_images.a $USELIBS"
  340. for lib in ntk_jpeg ntk_png fltk_z; do
  341. if test -f $libdir/lib$lib.a; then
  342. USELIBS="$libdir/lib$lib.a $USELIBS"
  343. fi
  344. done
  345. fi
  346. echo $USELIBS
  347. fi
  348. if test "$echo_prefix" = "yes"; then
  349. echo $prefix
  350. fi
  351. if test "$echo_includedir" = "yes"; then
  352. echo $includedir
  353. fi
  354. #
  355. # End of "$Id: fltk-config.in 6614 2009-01-01 16:11:32Z matt $".
  356. #