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