1#!/bin/sh 2# 3# FLTK configuration utility. 4# 5# Copyright 2000-2021 by Bill Spitzak and others. 6# Original version Copyright 2000 by James Dean Palmer 7# Adapted by Vincent Penne and Michael Sweet 8# 9# This library is free software. Distribution and use rights are outlined in 10# the file "COPYING" which should have been included with this file. If this 11# file is missing or damaged, see the license at: 12# 13# https://www.fltk.org/COPYING.php 14# 15# Please see the following page on how to report bugs and issues: 16# 17# https://www.fltk.org/bugs.php 18# 19 20MAJOR_VERSION=@FLTK_VERSION_MAJOR@ 21MINOR_VERSION=@FLTK_VERSION_MINOR@ 22PATCH_VERSION=@FLTK_VERSION_PATCH@ 23VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" 24APIVERSION="$MAJOR_VERSION.$MINOR_VERSION" 25 26### BEGIN fltk-config 27selfdir=`dirname "$0"` 28 29prefix=@prefix@ 30exec_prefix=@exec_prefix@ 31exec_prefix_set=no 32includedir=@includedir@ 33libdir=@libdir@ 34srcdir=@srcdir@ 35 36# BINARY_DIR - used only for CMake builds in local (binary) directory 37BINARY_DIR=@BINARY_DIR@ 38 39# compiler names 40CC="@CC@" 41CXX="@CXX@" 42 43# flags for C++ compiler: 44ARCHFLAGS="@ARCHFLAGS@" 45CFLAGS="@CFLAGS@ @LARGEFILE@ @PTHREAD_FLAGS@" 46CXXFLAGS="@CXXFLAGS@ @LARGEFILE@ @PTHREAD_FLAGS@" 47LDFLAGS="@LDFLAGS@" 48LDLIBS="@LIBS@" 49OPTIM="@OPTIM@" 50CAIROFLAGS="@CAIROFLAGS@" 51 52# Check for local invocation, and update paths accordingly... 53if test -f "$selfdir/FL/Fl_Window.H"; then 54 includedir="$selfdir" 55 libdir="$selfdir/lib" 56 57 if test -f "$libdir/libfltk_jpeg.a"; then 58 CFLAGS="-I$includedir/jpeg $CFLAGS" 59 CXXFLAGS="-I$includedir/jpeg $CXXFLAGS" 60 fi 61 62 if test -f "$libdir/libfltk_z.a"; then 63 CFLAGS="-I$includedir/zlib $CFLAGS" 64 CXXFLAGS="-I$includedir/zlib $CXXFLAGS" 65 fi 66 67 if test -f "$libdir/libfltk_png.a"; then 68 CFLAGS="-I$includedir/png $CFLAGS" 69 CXXFLAGS="-I$includedir/png $CXXFLAGS" 70 fi 71fi 72 73if test -d $includedir/FL/images; then 74 CFLAGS="-I$includedir/FL/images $CFLAGS" 75 CXXFLAGS="-I$includedir/FL/images $CXXFLAGS" 76fi 77 78if test -f "$libdir/libfltk_cairo.a"; then 79 CFLAGS="$CAIROFLAGS $CFLAGS" 80 CXXFLAGS="$CAIROFLAGS $CXXFLAGS" 81fi 82 83# libraries to link with: 84LIBNAME="@LIBNAME@" 85DSONAME="@DSONAME@" 86DSOLINK="@DSOLINK@" 87IMAGELIBS="@IMAGELIBS@" 88STATICIMAGELIBS="@STATICIMAGELIBS@" 89CAIROLIBS="@CAIROLIBS@" 90SHAREDSUFFIX="@SHAREDSUFFIX@" 91 92usage () 93{ 94 echo "Usage: fltk-config [OPTIONS] 95Options: 96 [--version] 97 [--api-version] 98 99Options telling what we are doing: 100 [--use-gl] use GL 101 [--use-images] use extra image formats (PNG, JPEG) 102 [--use-glut] use glut compatibility layer 103 [--use-forms] use forms compatibility layer 104 [--use-cairo] use cairo graphics lib 105 106Options telling what information we request: 107 [--cc] return C compiler used to compile FLTK 108 [--cxx] return C++ compiler used to compile FLTK 109 [--optim] return compiler optimization used to compile FLTK 110 [--cflags] return flags to compile C using FLTK 111 [--cxxflags] return flags to compile C++ using FLTK 112 [--ldflags] return flags to link against FLTK 113 [--ldstaticflags] return flags to link against static FLTK library 114 even if there are DSOs installed 115 [--libs] return FLTK libraries full path for dependencies 116 [--prefix] return FLTK install time --prefix directory 117 [--includedir] return FLTK install time include directory 118 119Options to compile and link an application: 120 [-g] compile the program with debugging information 121 [-Dname[=value]] compile the program with the given define 122 [--compile program.cxx] 123 [--post program] prepare the program for desktop use 124" 125 exit $1 126} 127 128if test $# -eq 0; then 129 usage 1 130fi 131 132no_plugins=no 133compile= 134post= 135debug= 136 137# Parse command line options 138while test $# -gt 0 139do 140 case "$1" in 141 -*=*) 142 optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` 143 ;; 144 *) 145 optarg= 146 ;; 147 esac 148 149 case $1 in 150 --version) 151 echo $VERSION 152 ;; 153 --api-version) 154 echo $APIVERSION 155 ;; 156 --cc) 157 echo $CC 158 ;; 159 --cxx) 160 echo $CXX 161 ;; 162 --optim) 163 echo_optim=yes 164 ;; 165 --use-gl | --use-glut) 166 use_gl=yes 167 ;; 168 --use-forms) 169 use_forms=yes 170 ;; 171 --use-images) 172 use_images=yes 173 ;; 174 --use-cairo) 175 use_cairo=yes 176 ;; 177 --cflags) 178 echo_cflags=yes 179 ;; 180 --cxxflags) 181 echo_cxxflags=yes 182 ;; 183 --ldflags) 184 echo_ldflags=yes 185 ;; 186 --ldstaticflags) 187 echo_ldstaticflags=yes 188 ;; 189 --libs) 190 echo_libs=yes 191 ;; 192 --prefix) 193 echo_prefix=yes 194 ;; 195 --includedir) 196 echo_includedir=yes 197 ;; 198 -g) 199 debug=-g 200 ;; 201 -D*) 202 CXXFLAGS="$CXXFLAGS $1" 203 ;; 204 --compile) 205 compile="$2" 206 shift 207 ;; 208 --post) 209 post="$2" 210 shift 211 ;; 212 *) 213 echo_help=yes 214 ;; 215 esac 216 shift 217done 218 219if test "$includedir" != /usr/include; then 220 includes=-I$includedir 221else 222 includes= 223fi 224 225if test "$BINARY_DIR" != ""; then 226 includes="-I$BINARY_DIR $includes" 227fi 228 229if test "$libdir" != /usr/lib -a "$libdir" != /usr/lib32; then 230 libs=-L$libdir 231else 232 libs= 233fi 234 235# Calculate needed libraries 236LDSTATIC="-lm $libdir/libfltk.a $LDLIBS" 237LDLIBS="-lfltk$SHAREDSUFFIX $LDLIBS" 238 239if test x$use_forms = xyes; then 240 LDLIBS="-lfltk_forms$SHAREDSUFFIX $LDLIBS" 241 LDSTATIC="$libdir/libfltk_forms.a $LDSTATIC" 242fi 243if test x$use_gl = xyes; then 244 LDLIBS="-lfltk_gl$SHAREDSUFFIX @GLLIBS@ $LDLIBS" 245 LDSTATIC="$libdir/libfltk_gl.a @GLLIBS@ $LDSTATIC" 246fi 247if test x$use_images = xyes; then 248 LDLIBS="-lfltk_images$SHAREDSUFFIX $IMAGELIBS $LDLIBS" 249 LDSTATIC="$libdir/libfltk_images.a $STATICIMAGELIBS $LDSTATIC" 250fi 251 252if test x$use_cairo = xyes; then 253 LDLIBS="-lfltk_cairo$SHAREDSUFFIX $CAIROLIBS $LDLIBS" 254 LDSTATIC="$libdir/libfltk_cairo.a $CAIROLIBS $LDSTATIC" 255fi 256 257LDLIBS="$DSOLINK $LDFLAGS $libs $LDLIBS" 258LDSTATIC="$LDFLAGS $LDSTATIC" 259 260# Answer to user requests 261if test -n "$echo_help"; then 262 usage 1 263fi 264 265if test -n "$compile"; then 266 case "$compile" in 267 *.cxx) 268 prog="`basename \"$compile\" .cxx`" 269 ;; 270 *.cpp) 271 prog="`basename \"$compile\" .cpp`" 272 ;; 273 *.cc) 274 prog="`basename \"$compile\" .cc`" 275 ;; 276 *.C) 277 prog="`basename \"$compile\" .C`" 278 ;; 279 *) 280 echo "ERROR: Unknown/bad C++ source file extension on \"$compile\"!" 281 exit 1 282 ;; 283 esac 284 285 post="$prog" 286 287 echo $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "'$prog'" "'$compile'" $LDSTATIC 288 $CXX $ARCHFLAGS $includes $CXXFLAGS $debug -o "$prog" "$compile" $LDSTATIC || exit 1 289fi 290 291if test -n "$post"; then 292 running=`uname` 293 if test "$running" = "Darwin"; then 294 # if FLTK targets MacOS+X11, apps need not be bundled 295 if test `echo $LDLIBS | fgrep -c -e " -lX11"` = 1; then 296 running="" 297 fi 298 fi 299 case $running in 300 Darwin) 301 echo Creating "'$post.app'" bundle for desktop... 302 id=`echo $post | tr ' ' '_'` 303 304 # Make the bundle directory and move the executable there 305 rm -rf "$post.app/Contents/MacOS" 306 mkdir -p "$post.app/Contents/MacOS" 307 mv "$post" "$post.app/Contents/MacOS" 308 309 # Make a shell script that runs the bundled executable 310 echo "#!/bin/sh" >"$post" 311 echo 'dir="`dirname \"$0\"`"' >>"$post" 312 echo 'exec "$dir/'"$post.app/Contents/MacOS/$post"'" "$@"' >>"$post" 313 chmod +x "$post" 314 315 # Make the simplest Info.plist needed for an application 316 cat >"$post.app/Contents/Info.plist" <<EOF 317<?xml version="1.0" encoding="UTF-8"?> 318<plist version="0.9"> 319 <dict> 320 <key>CFBundleInfoDictionaryVersion</key> 321 <string>6.0</string> 322 <key>CFBundleExecutable</key> 323 <string>$post</string> 324 <key>CFBundleIdentifier</key> 325 <string>org.fltk.$id</string> 326 <key>CFBundleName</key> 327 <string>$post</string> 328 <key>CFBundlePackageType</key> 329 <string>APPL</string> 330 <key>NSHighResolutionCapable</key> 331 <true/> 332 </dict> 333</plist> 334EOF 335 ;; 336 esac 337fi 338 339if test "$echo_cflags" = "yes"; then 340 echo $includes $CFLAGS 341fi 342 343if test "$echo_cxxflags" = "yes"; then 344 echo $includes $CXXFLAGS 345fi 346 347if test "$echo_optim" = "yes"; then 348 echo $OPTIM 349fi 350 351if test "$echo_ldflags" = "yes"; then 352 my_libs="-lm" 353 libdirs=$libs 354 355 for i in $LDLIBS ; do 356 if test $i != -L$libdir ; then 357 if test -z "$my_libs" ; then 358 my_libs="$i" 359 else 360 my_libs="$my_libs $i" 361 fi 362 fi 363 done 364 echo $libdirs $my_libs 365fi 366 367if test "$echo_ldstaticflags" = "yes"; then 368 echo $LDSTATIC 369fi 370 371if test "$echo_libs" = "yes"; then 372 USELIBS="$libdir/libfltk.a" 373 374 if test x$use_forms = xyes; then 375 USELIBS="$libdir/libfltk_forms.a $USELIBS" 376 fi 377 378 if test x$use_gl = xyes; then 379 USELIBS="$libdir/libfltk_gl.a $USELIBS" 380 fi 381 382 if test x$use_cairo = xyes; then 383 USELIBS="$libdir/libfltk_cairo.a $USELIBS" 384 fi 385 386 if test x$use_images = xyes; then 387 USELIBS="$libdir/libfltk_images.a $USELIBS" 388 389 for lib in fltk_jpeg fltk_png fltk_z; do 390 if test -f $libdir/lib$lib.a; then 391 USELIBS="$libdir/lib$lib.a $USELIBS" 392 fi 393 done 394 fi 395 396 echo $USELIBS 397fi 398 399if test "$echo_prefix" = "yes"; then 400 echo $prefix 401fi 402 403if test "$echo_includedir" = "yes"; then 404 echo $includedir 405fi 406