?RCS: $Id: gtkconfig.U 12212 2006-11-04 01:43:46Z cbiere $ ?RCS: ?RCS: @COPYRIGHT@ ?RCS: ?MAKE:gtkconfig gtkcflags gtkldflags d_gtk: gtkversion gtkpackage awk \ glibcflags glibldflags Warn d_headless cat rm cc ccflags ldflags ?MAKE: -pick add $@ %< ?S:gtkconfig: ?S: This variable holds the command to use to grab information about GTK. ?S: Typically something like "pkg-config gtk+" or "gtk-config". ?S:. ?S:gtkcflags: ?S: This variable holds the compiler flags required to compile with GTK. ?S:. ?S:gtkldflags: ?S: This variable holds the linker flags required to link against GTK. ?S:. ?S:d_gtk: ?S: This variable is if compiling against Gtk+ works. ?S:. ?T:modver version vint flag missing allok : how can we find information about GTK? d_gtk="$undef" case "$d_headless" in "$define") ?X: Since there is no GUI, simply include the glib flags gtkcflags="$glibcflags" gtkldflags="$glibldflags" ;; *) ?X: Indentation wrong on purpose echo " " echo "Checking how we can gather information about GTK+..." >&4 if pkg-config $gtkpackage --cflags >/dev/null 2>&1; then gtkconfig="pkg-config $gtkpackage" modver=--modversion elif gtk-config --cflags >/dev/null 2>&1; then gtkconfig='gtk-config' modver=--version else echo "You've got problems! Do you have GTK+ installed?" >&4 gtkconfig='false' modver='' fi echo "(I'll use '$gtkconfig' to gather that information.)" ?X: check that we've got the version they asked for version=`$gtkconfig $modver` case "$gtkversion" in 1) case "$version" in 1.*) vint=`echo $version | $awk -F. '{print $1 * 10000 + $2 * 100 + $3;}'` if test 0$vint -lt 10210; then echo "Sorry, you have GTK+ $version, I need at least 1.2.10." >&4 exit 1; else echo "OK, you have GTK+ $version" fi ;; *) ./warn "you asked for GTK+ $gtkversion, I found $version";; esac ;; 2) case "$version" in 2.*) vint=`echo $version | $awk -F. '{print $1 * 10000 + $2 * 100 + $3;}'` if test 0$vint -lt 20201; then echo "Sorry, you have GTK+ $version, I need at least 2.2.1." >&4 exit 1; else echo "OK, you have GTK+ $version" fi ;; *) ./warn "you asked for GTK+ $gtkversion, I found $version";; esac ;; *) echo "Sorry, I don't know anything about GTK+ $version." >&4 exit 1 ;; esac gtkcflags=`$gtkconfig --cflags` gtkldflags=`$gtkconfig --libs` ?X: ?X: Make sure all the glib C flags are included, append all if any missing. ?X: missing=false allok=true for flag in "$glibcflags"; do case "$gtkcflags" in *"$flag"*) ;; *) missing=true; break;; esac done if $missing; then echo "(Some glib C flags are missing from GTK+ flags, adding all of them.)" gtkcflags="$gtkcflags $glibcflags" allok=false fi ?X: Make sure all the glib ld flags are included, append all if any missing. missing=false for flag in "$glibldflags"; do case "$gtkldflags" in *"$flag"*) ;; *) missing=true; break;; esac done if $missing; then echo "(Some glib ld flags are missing from GTK+ flags, adding all of them.)" gtkldflags="$gtkldflags $glibldflags" allok=false fi if $allok; then echo "Good, all the cc and ld flags from glib are included in GTK+ flags." fi ?X: Remember, indentation wrong on purpose ;; esac case "$d_headless" in "$undef") echo "Checking whether Gtk+ can be compiled against..." $cat >try.c < #include #include int main(void) { GtkWidget *window; gpointer p; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (!window) return 1; p = g_malloc(23); if (!p) return 1; return 0; } EOC if $cc -o try try.c $ccflags $ldflags $gtkcflags $gtkldflags >/dev/null 2>&1; then d_gtk="$define" echo "We'll be using Gtk+ version $version." else ./warn "Cannot compile against Gtk+ version '$version'" fi $rm -f try try.c ;; esac