~ubuntu-branches/ubuntu/precise/pcb/precise

« back to all changes in this revision

Viewing changes to acinclude.m4

  • Committer: Bazaar Package Importer
  • Author(s): Hamish Moffatt
  • Date: 2005-02-20 13:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050220131400-pfz66g5vhx0azl8f
Tags: 1.99j+20050127-2
* Improved package description: (closes: #295405)
* Fixed dependency: tk84 -> tk8.4 (closes: #295404)
* Updated README.debian (closes: #269578)
* Applied patch to src/djopt.c to allow compilation with gcc-4.0
  (closes: #294319), thanks to Andreas Jochens for the patch.
* Prevent example files from being compressed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl $Id: acinclude.m4,v 1.3 2004/10/21 22:02:25 danmc Exp $
 
2
dnl
 
3
dnl the FC_* macros were copied from the freeciv program.  The use here
 
4
dnl is to figure out if we need -DNARROWPROTO and the correct setting
 
5
dnl for FUNCPROTO.  Without these set right, it has been observed that
 
6
dnl the sliders don't work right on some systems.
 
7
 
 
8
 
 
9
dnl
 
10
dnl FC_CHECK_X_PROTO_DEFINE(DEFINED-VARIABLE)
 
11
dnl
 
12
dnl This macro determines the value of the given defined
 
13
dnl variable needed by Xfuncproto.h in order to compile correctly.
 
14
dnl
 
15
dnl Typical DEFINED-VARIABLEs are:
 
16
dnl   FUNCPROTO
 
17
dnl   NARROWPROTO
 
18
dnl
 
19
dnl The following variables are output:
 
20
dnl   fc_x_proto_value          -- contains the value to which
 
21
dnl                             the DEFINED-VARIABLE is set,
 
22
dnl                             or "" if it has no known value.
 
23
dnl
 
24
dnl Example use:
 
25
dnl   FC_CHECK_X_PROTO_DEFINE(FUNCPROTO)
 
26
dnl   if test -n "$fc_x_proto_value"; then
 
27
dnl     AC_DEFINE_UNQUOTED(FUNCPROTO, $fc_x_proto_value)
 
28
dnl   fi
 
29
dnl
 
30
AC_DEFUN([FC_CHECK_X_PROTO_DEFINE],
 
31
[AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])dnl
 
32
AC_MSG_CHECKING(for Xfuncproto control definition $1)
 
33
# Search for the requested defined variable; return it's value:
 
34
fc_x_proto_value=
 
35
for fc_x_define in $fc_x_proto_defines; do
 
36
  fc_x_val=1
 
37
  eval `echo $fc_x_define | sed -e 's/=/ ; fc_x_val=/' | sed -e 's/^/fc_x_var=/'`
 
38
  if test "x$fc_x_var" = "x$1"; then
 
39
    fc_x_proto_value=$fc_x_val
 
40
    break
 
41
  fi
 
42
done
 
43
if test -n "$fc_x_proto_value"; then
 
44
  AC_MSG_RESULT([yes: $fc_x_proto_value])
 
45
else
 
46
  AC_MSG_RESULT([no])
 
47
fi
 
48
])
 
49
 
 
50
dnl FC_CHECK_X_PROTO_FETCH
 
51
dnl
 
52
dnl This macro fetches the Xfuncproto control definitions.
 
53
dnl (Intended to be called once from FC_CHECK_X_PROTO_DEFINE.)
 
54
dnl
 
55
dnl The following variables are output:
 
56
dnl   fc_x_proto_defines        -- contains the list of defines of
 
57
dnl                             Xfuncproto control definitions
 
58
dnl                             (defines may or may not include
 
59
dnl                             the -D prefix, or an =VAL part).
 
60
dnl
 
61
dnl Example use:
 
62
dnl   AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])
 
63
dnl
 
64
AC_DEFUN([FC_CHECK_X_PROTO_FETCH],
 
65
[AC_REQUIRE([AC_PATH_X])dnl
 
66
AC_MSG_CHECKING(whether Xfuncproto was supplied)
 
67
dnl May override determined defines with explicit argument:
 
68
AC_ARG_WITH(x-funcproto,
 
69
    [  --with-x-funcproto=DEFS Xfuncproto control definitions are DEFS
 
70
                          (e.g.: --with-x-funcproto='FUNCPROTO=15 NARROWPROTO']dnl
 
71
)
 
72
if test "x$with_x_funcproto" = "x"; then
 
73
  fc_x_proto_defines=
 
74
  rm -fr conftestdir
 
75
  if mkdir conftestdir; then
 
76
    cd conftestdir
 
77
    # Make sure to not put "make" in the Imakefile rules, since we grep it out.
 
78
    cat > Imakefile <<'EOF'
 
79
fcfindpd:
 
80
        @echo 'fc_x_proto_defines=" ${PROTO_DEFINES}"'
 
81
EOF
 
82
    if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
 
83
      # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 
84
      eval `${MAKE-make} fcfindpd 2>/dev/null | grep -v make | sed -e 's/ -D/ /g'`
 
85
      AC_MSG_RESULT([no, found: $fc_x_proto_defines])
 
86
      cd ..
 
87
      rm -fr conftestdir
 
88
    else
 
89
      dnl Oops -- no/bad xmkmf... Time to go a-guessing...
 
90
      AC_MSG_RESULT([no])
 
91
      cd ..
 
92
      rm -fr conftestdir
 
93
      dnl First, guess something for FUNCPROTO:
 
94
      AC_MSG_CHECKING([for compilable FUNCPROTO definition])
 
95
      dnl Try in order of preference...
 
96
      for fc_x_value in 15 11 3 1 ""; do
 
97
        FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value)
 
98
        if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
 
99
          break
 
100
        fi
 
101
      done
 
102
      if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
 
103
        fc_x_proto_defines="$fc_x_proto_defines FUNCPROTO=$fc_x_proto_FUNCPROTO"
 
104
        AC_MSG_RESULT([yes, determined: $fc_x_proto_FUNCPROTO])
 
105
      else
 
106
        AC_MSG_RESULT([no, cannot determine])
 
107
      fi
 
108
      dnl Second, guess something for NARROWPROTO:
 
109
      AC_MSG_CHECKING([for workable NARROWPROTO definition])
 
110
      dnl Try in order of preference...
 
111
      for fc_x_value in 1 ""; do
 
112
        FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value)
 
113
        if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
 
114
          break
 
115
        fi
 
116
      done
 
117
      if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
 
118
        fc_x_proto_defines="$fc_x_proto_defines NARROWPROTO=$fc_x_proto_NARROWPROTO"
 
119
        AC_MSG_RESULT([yes, determined: $fc_x_proto_NARROWPROTO])
 
120
      else
 
121
        AC_MSG_RESULT([no, cannot determine])
 
122
      fi
 
123
      AC_MSG_CHECKING(whether Xfuncproto was determined)
 
124
      if test -n "$fc_x_proto_defines"; then
 
125
        AC_MSG_RESULT([yes: $fc_x_proto_defines])
 
126
      else
 
127
        AC_MSG_RESULT([no])
 
128
      fi
 
129
    fi
 
130
  else
 
131
    AC_MSG_RESULT([no, examination failed])
 
132
  fi
 
133
else
 
134
  fc_x_proto_defines=$with_x_funcproto
 
135
  AC_MSG_RESULT([yes, given: $fc_x_proto_defines])
 
136
fi
 
137
])
 
138
 
 
139
dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE(FUNCPROTO-VALUE)
 
140
dnl
 
141
dnl This macro determines whether or not Xfuncproto.h will
 
142
dnl compile given a value to use for the FUNCPROTO definition.
 
143
dnl
 
144
dnl Typical FUNCPROTO-VALUEs are:
 
145
dnl   15, 11, 3, 1, ""
 
146
dnl
 
147
dnl The following variables are output:
 
148
dnl   fc_x_proto_FUNCPROTO      -- contains the passed-in
 
149
dnl                             FUNCPROTO-VALUE if Xfuncproto.h
 
150
dnl                             compiled, or "no" if it did not.
 
151
dnl
 
152
dnl Example use:
 
153
dnl   FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value)
 
154
dnl   if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
 
155
dnl     echo Compile using FUNCPROTO=$fc_x_proto_FUNCPROTO
 
156
dnl   fi
 
157
dnl
 
158
AC_DEFUN([FC_CHECK_X_PROTO_FUNCPROTO_COMPILE],
 
159
[AC_REQUIRE([AC_PATH_XTRA])dnl
 
160
AC_LANG_SAVE
 
161
AC_LANG_C
 
162
fc_x_proto_FUNCPROTO=no
 
163
if test "x$1" = "x"; then
 
164
  fc_x_compile="#undef FUNCPROTO"
 
165
else
 
166
  fc_x_compile="#define FUNCPROTO $1"
 
167
fi
 
168
fc_x_save_CFLAGS="$CFLAGS"
 
169
CFLAGS="$CFLAGS $X_CFLAGS"
 
170
AC_TRY_COMPILE([
 
171
$fc_x_compile
 
172
#include <X11/Xfuncproto.h>
 
173
  ],[
 
174
exit (0)
 
175
  ],
 
176
  [fc_x_proto_FUNCPROTO=$1])
 
177
CFLAGS="$fc_x_save_CFLAGS"
 
178
AC_LANG_RESTORE
 
179
])
 
180
 
 
181
dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS(NARROWPROTO-VALUE)
 
182
dnl
 
183
dnl This macro determines whether or not NARROWPROTO is required
 
184
dnl to get a typical X function (XawScrollbarSetThumb) to work.
 
185
dnl
 
186
dnl Typical NARROWPROTO-VALUEs are:
 
187
dnl   1, ""
 
188
dnl
 
189
dnl The following variables are required for input:
 
190
dnl   fc_x_proto_FUNCPROTO      -- the value to use for FUNCPROTO.
 
191
dnl
 
192
dnl The following variables are output:
 
193
dnl   fc_x_proto_NARROWPROTO    -- contains the passed-in
 
194
dnl                             NARROWPROTO-VALUE if the test
 
195
dnl                             worked, or "no" if it did not.
 
196
dnl
 
197
dnl Example use:
 
198
dnl   FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value)
 
199
dnl   if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
 
200
dnl     echo Compile using NARROWPROTO=$fc_x_proto_NARROWPROTO
 
201
dnl   fi
 
202
dnl
 
203
AC_DEFUN([FC_CHECK_X_PROTO_NARROWPROTO_WORKS],
 
204
[AC_REQUIRE([AC_PATH_XTRA])dnl
 
205
AC_LANG_SAVE
 
206
AC_LANG_C
 
207
fc_x_proto_NARROWPROTO=no
 
208
if test "x$1" = "x"; then
 
209
  fc_x_works="#undef NARROWPROTO"
 
210
else
 
211
  fc_x_works="#define NARROWPROTO $1"
 
212
fi
 
213
if test "x$fc_x_proto_FUNCPROTO" = "x"; then
 
214
  fc_x_compile="#define FUNCPROTO 1"
 
215
else
 
216
  fc_x_compile="#define FUNCPROTO $fc_x_proto_FUNCPROTO"
 
217
fi
 
218
fc_x_save_CFLAGS="$CFLAGS"
 
219
CFLAGS="$CFLAGS $X_CFLAGS $X_LIBS $X_PRE_LIBS -l$LIBXAW -lXt -lX11 $X_EXTRA_LIBS"
 
220
AC_TRY_RUN([
 
221
$fc_x_works
 
222
$fc_x_compile
 
223
#include <X11/Xfuncproto.h>
 
224
#include <X11/Intrinsic.h>
 
225
#include <X11/StringDefs.h>
 
226
#include <X11/$XAWINC/Scrollbar.h>
 
227
#define TOP_VAL 0.125
 
228
#define SHOWN_VAL 0.25
 
229
int main (int argc, char ** argv)
 
230
{
 
231
  Widget toplevel;
 
232
  XtAppContext appcon;
 
233
  Widget scrollbar;
 
234
  double topbuf;
 
235
  double shownbuf;
 
236
  float * top = (float *)(&topbuf);
 
237
  float * shown = (float *)(&shownbuf);
 
238
  toplevel =
 
239
    XtAppInitialize
 
240
    (
 
241
     &appcon,
 
242
     "FcXTest",
 
243
     NULL, 0,
 
244
     &argc, argv,
 
245
     NULL,
 
246
     NULL, 0
 
247
    );
 
248
  scrollbar =
 
249
    XtVaCreateManagedWidget
 
250
    (
 
251
     "my_scrollbar",
 
252
     scrollbarWidgetClass,
 
253
     toplevel,
 
254
     NULL
 
255
    );
 
256
  XawScrollbarSetThumb (scrollbar, TOP_VAL, SHOWN_VAL);
 
257
  XtVaGetValues
 
258
  (
 
259
   scrollbar,
 
260
   XtNtopOfThumb, top,
 
261
   XtNshown, shown,
 
262
   NULL
 
263
  );
 
264
  if ((*top == TOP_VAL) && (*shown == SHOWN_VAL))
 
265
    {
 
266
      exit (0);
 
267
    }
 
268
  else
 
269
    {
 
270
      exit (1);
 
271
    }
 
272
  return (0);
 
273
}
 
274
  ],
 
275
  [fc_x_proto_NARROWPROTO=$1])
 
276
CFLAGS="$fc_x_save_CFLAGS"
 
277
AC_LANG_RESTORE
 
278
])
 
279