Fixed building of Debian-native packages without any 'orig-*' archive.
[macros.git] / glade-w.m4
1 dnl $Id$
2 dnl autoconf plugin for 'glade-2 --write-source' detection
3 dnl Copyright (C) 2000,2003 Jan Kratochvil <project-macros@jankratochvil.net>
4 dnl 
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; exactly version 2 of June 1991 is required
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19 dnl
20 dnl GLADE_W_INIT (glade-generated-files, user-option, add-on)
21 dnl
22 dnl glade-generated-files: All files that glade-w.sh.in would be able to
23 dnl                        generate. Depends on *.glade file options.
24 dnl user-option:           User wish for the client (yes/no/[* for auto])
25 dnl add-on:                Some additional requirements, set "glade_addon=yes"
26 dnl Use AC_SUBST(GNOMEUI_CFLAGS)
27 dnl     AC_SUBST(GNOMEUI_LIBS)
28 dnl afterwards.
29 dnl
30
31 AC_DEFUN([GLADE_W_INIT],
32 [
33         if test "$2" != "no"
34         then
35                 dnl Gnome is optional.
36                 PKG_CHECK_MODULES(GNOMEUI,libgnomeui-2.0,[
37                         AC_DEFINE(HAVE_GNOMEUI,,[Have libgnomeui-2.0 include files and libraries.])
38                         have_gnome=true 
39                         ],[ have_gnome=false ])
40
41                 AC_PATH_PROG(PATH_GLADE,glade-2,)
42
43 dnl FIXME: Gnome-enabled glade-2 will complain on $DISPLAY even if --invalid-option!
44 dnl Do we need to provide Xvnc $DISPLAY to it to check it for Gnome support?
45 dnl Currently we assume it is Gnome-enabled.
46 dnl             if test "x$PATH_GLADE" != "x"
47 dnl             then
48 dnl                     AC_CACHE_CHECK([whether glade found has Gnome extensions],glade_cv_has_gnome,
49 dnl                             [
50 dnl                             save_DISPLAY="$DISPLAY"
51 dnl                             unset DISPLAY
52 dnl                             gladeun="`$PATH_GLADE --disable-crash-dialog --invalid-option 2>&1|grep -- '--invalid-option:'`"
53 dnl                             export DISPLAY="$save_DISPLAY"
54 dnl                             if test "x$gladeun" != "x"
55 dnl                             then
56 dnl                                     glade_cv_has_gnome=yes
57 dnl                             else
58 dnl                                     glade_cv_has_gnome=no
59 dnl                             fi
60 dnl                             ])
61 dnl                     if test "x$glade_cv_has_gnome" = "xno"
62 dnl                     then
63 dnl                             unset PATH_GLADE
64 dnl                             AC_MSG_WARN([GTK+/Gnome: Glade builder was found but it has no Gnome support, only GTK+,
65 dnl     please install Gnome packages and then recompile your Glade.])
66 dnl                     fi
67 dnl             fi
68
69                 if test "x$PATH_GLADE" != "x"
70                 then
71                         AC_CACHE_CHECK([whether glade found is capable of write-source-ing],glade_cv_writesource,
72                                 [
73                                 save_DISPLAY="$DISPLAY"
74                                 unset DISPLAY
75                                 gladeun="`$PATH_GLADE --disable-crash-dialog --write-source /dev/null 2>&1|grep -- '-w:'`"
76                                 export DISPLAY="$save_DISPLAY"
77                                 if test "x$gladeun" = "x"
78                                 then
79                                         glade_cv_writesource=yes
80                                 else
81                                         glade_cv_writesource=no
82                                 fi
83                                 ])
84                         if test "x$glade_cv_writesource" = "xno"
85                         then
86                                 unset PATH_GLADE
87                                 AC_MSG_WARN([GTK+/Gnome: Glade builder was found but it is not capable of batch source builds,
88         please upgrade to Glade version 0.5.8 or higher.])
89                         fi
90                 fi
91
92                 if test "x$PATH_GLADE" != "x"
93                 then
94                         AC_PATH_PROG(PATH_XVNC,Xvnc,)
95                         AC_PATH_PROG(PATH_BC,bc,)
96                         AC_CACHE_CHECK([whether it is possible to access any X server for Glade],glade_cv_can_xserver,
97                                 [
98                                 export PATH_XVNC
99                                 export PATH_BC
100                                 gladeun="`sh ./macros/glade-w.sh.in /dev/null 2>&1|grep -- 'Document is empty'`"
101                                 if test "x$gladeun" != "x"
102                                 then
103                                         glade_cv_can_xserver=yes
104                                 else
105                                         glade_cv_can_xserver=no
106                                 fi
107                                 ])
108                         if test "x$glade_cv_can_xserver" = "xno"
109                         then
110                                 unset PATH_GLADE
111                                 if test "x$PATH_XVNC" = "x"
112                                 then
113                                         AC_MSG_WARN([GTK+/Gnome: Unable to access any valid X server, give DISPLAY or install Xvnc(1) (vnc-server package).])
114                                 else
115                                         AC_MSG_WARN([GTK+/Gnome: Unable to access any valid X server, DISPLAY and Xvnc(1) tried.])
116                                 fi
117                         fi
118                 fi
119
120                 AC_MSG_CHECKING(whether I need write-source-ing and runnable Glade for GTK+/Gnome client)
121                 NEED_GLADE=no
122                 if test "x$1" = "x"
123                 then
124                         gnofis="./src/interface.c ./src/interface.h ./src/support.c ./src/support.h"
125                 else
126                         gnofis="$1"
127                 fi
128                 for gnofi in $gnofis
129                 do
130                         if test '!' -f "$gnofi"
131                         then
132                                 NEED_GLADE=yes
133                         fi
134                 done
135                 AC_MSG_RESULT($NEED_GLADE)
136
137                 glade_addon=no
138                 ifelse([$3], ,glade_addon=yes,[$3])
139         fi
140
141         if test "x$2" != "xno" -a "xtrue" = "x$have_gnome" -a '(' "x$NEED_GLADE" = "xno" -o "x$PATH_GLADE" != "x" ')' -a "x$glade_addon" = "xyes"
142         then
143                 BUILD_GLADESRC=yes
144         else
145                 BUILD_GLADESRC=no
146                 if test "x$2" = "xyes"
147                 then
148                         AC_MSG_ERROR([GTK+/Gnome: Requested client compilation impossible, see errors above.])
149                 elif test "x$2" != "xno"
150                 then
151                         AC_MSG_WARN([GTK+/Gnome: Interface will not be build, see errors above for reason(s).])
152                 fi
153         fi
154         AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
155         AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
156 ])