aboutsummaryrefslogtreecommitdiffstats
path: root/parport.c
blob: a5ba3c2e7ed3131a8f55463c9a9fca1d4ade4a36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
/* $Id: parport.c,v 1.4 2003/08/16 07:31:35 reinelt Exp $
 *
 * generic parallel port handling
 *
 * Copyright 2003 by Michael Reinelt (reinelt@eunet.at)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: parport.c,v $
 * Revision 1.4  2003/08/16 07:31:35  reinelt
 * double buffering in all drivers
 *
 * Revision 1.3  2003/08/15 07:54:07  reinelt
 * HD44780 4 bit mode implemented
 *
 * Revision 1.2  2003/04/07 06:03:05  reinelt
 * further parallel port abstraction
 *
 * Revision 1.1  2003/04/04 06:02:03  reinelt
 * new parallel port abstraction scheme
 *
 */

/* 
 * exported functions:
 * 
 * int parport_open (void)
 *   reads 'Port' entry from config and opens
 *   the parallel port
 *   returns 0 if ok, -1 on failure
 *
 * int parport_close (void)
 *   closes parallel port
 *   returns 0 if ok, -1 on failure
 *
 * unsigned char parport_wire_ctrl (char *name, char *deflt)
 *   reads wiring for one control signal from config
 *   returns PARPORT_CONTROL_* or 255 on error
 *
 * unsigned char parport_wire_data (char *name, char *deflt)
 *   reads wiring for one data signal from config
 *   returns 1<<bitpos or 255 on error
 *
 * void parport_direction (int direction)
 *   0 - write to parport
 *   1 - read from parport
 *
 * void parport_control (unsigned char mask, unsigned char value)
 *   frobs control line and takes care of inverted signals
 *
 * void parport_toggle (unsigned char bit, int level, int delay)
 *   toggles the line <bit> to <level> for <delay> nanoseconds
 *
 * void parport_data (unsigned char value)
 *   put data bits on DB1..DB8
 *
 * unsigned char parport_read (void)
 *   reads a byte from the parallel port
 *
 * void parport_debug(void)
 *   prints status of control lines
 */


#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include <sys/ioctl.h>


#ifdef HAVE_SYS_IO_H
#include <sys/io.h>
#define WITH_OUTB
#else
#ifdef HAVE_ASM_IO_H
#include <asm/io.h>
#define WITH_OUTB
#endif
#endif

#if defined (HAVE_LINUX_PARPORT_H) && defined (HAVE_LINUX_PPDEV_H)
#define WITH_PPDEV
#include <linux/parport.h>
#include <linux/ppdev.h>
#else
#define PARPORT_CONTROL_STROBE    0x1
#define PARPORT_CONTROL_AUTOFD    0x2
#define PARPORT_CONTROL_INIT      0x4
#define PARPORT_CONTROL_SELECT    0x8
#endif

#if !defined(WITH_OUTB) && !defined(WITH_PPDEV)
#error neither outb() nor ppdev() possible
#error cannot compile parallel port driver
#endif


#include "debug.h"
#include "cfg.h"
#include "udelay.h"
#include "parport.h"


static unsigned short Port=0;
static char *PPdev=NULL;

// initial value taken from linux/parport_pc.c
static unsigned char ctr = 0xc;

#ifdef WITH_PPDEV
static int PPfd=-1;
#endif


int parport_open (void)
{
  char *s, *e;

#ifdef USE_OLD_UDELAY
  s=cfg_get ("Delay",NULL);
  if (s==NULL || *s=='\0') {
    error ("parport: no 'Delay' entry in %s", cfg_file());
    return -1;
  }
  if ((loops_per_usec=strtol(s, &e, 0))==0 || *e!='\0') {
    error ("parport: bad delay '%s' in %s", s, cfg_file());
    return -1;
  }    
#else
  udelay_init();
#endif
  
  s=cfg_get ("Port",NULL);
  if (s==NULL || *s=='\0') {
    error ("parport: no 'Port' entry in %s", cfg_file());
    return -1;
  }
  PPdev=NULL;
  if ((Port=strtol(s, &e, 0))==0 || *e!='\0') {
#ifdef WITH_PPDEV
    Port=0;
    PPdev=s;
#else
    error ("parport: bad Port '%s' in %s", s, cfg_file());
    return -1;
#endif
  }
  
  
#ifdef WITH_PPDEV
  
  if (PPdev) {
    debug ("using ppdev %s", PPdev);
    PPfd=open(PPdev, O_RDWR);
    if (PPfd==-1) {
      error ("parport: open(%s) failed: %s", PPdev, strerror(errno));
      return -1;
    }
    
#if 0
    // Fixme
    if (ioctl(PPfd, PPEXCL)) {
      debug ("ioctl(%s, PPEXCL) failed: %s", PPdev, strerror(errno));
    } else {
      debug ("ioctl(%s, PPEXCL) succeded.");
    }
#endif
    
    if (ioctl(PPfd, PPCLAIM)) {
      error ("parport: ioctl(%s, PPCLAIM) failed: %d %s", PPdev, errno, strerror(errno));
      return -1;
    }
  } else
    
#endif
    
    {
      debug ("using raw port 0x%x", Port);
      if ((Port+3)<=0x3ff) {
	if (ioperm(Port, 3, 1)!=0) {
	  error ("parport: ioperm(0x%x) failed: %s", Port, strerror(errno));
	  return -1;
	}
      } else {
	if (iopl(3)!=0) {
	  error ("parport: iopl(1) failed: %s", strerror(errno));
	  return -1;
	}
      }
    }
  return 0;
}


int parport_close (void)
{
#ifdef WITH_PPDEV
  if (PPdev) {
    debug ("closing ppdev %s", PPdev);
    if (ioctl(PPfd, PPRELEASE)) {
      error ("parport: ioctl(%s, PPRELEASE) failed: %s", PPdev, strerror(errno));
    }
    if (close(PPfd)==-1) {
      error ("parport: close(%s) failed: %s", PPdev, strerror(errno));
      return -1;
    }
  } else 
#endif    
    {
      debug ("closing raw port 0x%x", Port);
      if ((Port+3)<=0x3ff) {
	if (ioperm(Port, 3, 0)!=0) {
	  error ("parport: ioperm(0x%x) failed: %s", Port, strerror(errno));
	  return -1;
	} 
      } else {
	if (iopl(0)!=0) {
	  error ("parport: iopl(0) failed: %s", strerror(errno));
	  return -1;
	}
      }
    }
  return 0;
}


unsigned char parport_wire_ctrl (char *name, unsigned char *deflt)
{
  unsigned char w;
  char wire[256];
  char *s;
  
  snprintf (wire, sizeof(wire), "Wire.%s", name);
  s=cfg_get (wire,deflt);
  if (strcasecmp(s,"STROBE")==0) {
    w=PARPORT_CONTROL_STROBE;
  } else if(strcasecmp(s,"AUTOFD")==0) {
    w=PARPORT_CONTROL_AUTOFD;
  } else if(strcasecmp(s,"INIT")==0) {
    w=PARPORT_CONTROL_INIT;
  } else if(strcasecmp(s,"SELECT")==0) {
    w=PARPORT_CONTROL_SELECT;
  } else if(strcasecmp(s,"GND")==0) {
    w=0;
  } else {
    error ("parport: unknown signal <%s> for wire <%s>", s, name);
    error ("         should be STROBE, AUTOFD, INIT, SELECT or GND");
    return 0xff;
  }

  if (w&PARPORT_CONTROL_STROBE) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:STROBE]", name);
  }
  if (w&PARPORT_CONTROL_AUTOFD) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:AUTOFD]", name);
  }
  if (w&PARPORT_CONTROL_INIT) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:INIT]", name);
  }
  if (w&PARPORT_CONTROL_SELECT) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:SELECT]", name);
  }
  if (w==0) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:GND]", name);
  }
  
  return w;
}


unsigned char parport_wire_data (char *name, unsigned char *deflt)
{
  unsigned char w;
  char wire[256];
  char *s;
  
  snprintf (wire, sizeof(wire), "Wire.%s", name);
  s=cfg_get (wire,deflt);
  if(strlen(s)==3 && strncasecmp(s,"DB",2)==0 && s[2]>='0' && s[2]<='7') {
    w=s[2]-'0';
  } else if(strcasecmp(s,"GND")==0) {
    w=0;
  } else {
    error ("parport: unknown signal <%s> for wire <%s>", s, name);
    error ("         should be DB..7 or GND");
    return 0xff;
  }
  
  if (w==0) {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:GND]", name);
  } else {
    info ("wiring: [DISPLAY:%s]<==>[PARPORT:DB%d]", name, w);
  }
  
  w=1<<w;

  return w;
}


void parport_direction (int direction)
{
#ifdef WITH_PPDEV
  if (PPdev) {
    ioctl (PPfd, PPDATADIR, &direction);
  } else
#endif
    {
      // code stolen from linux/parport_pc.h
      ctr = (ctr & ~0x20) ^ (direction?0x20:0x00);
      outb (ctr, Port+2);
    }
}


void parport_control (unsigned char mask, unsigned char value)
{
  // any signal affected?
  // Note: this may happen in case a signal is hardwired to GND
  if (mask==0) return;

  // Strobe, Select and AutoFeed are inverted!
  value = mask & (value ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD));
  // value ^= PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD;

#ifdef WITH_PPDEV
  if (PPdev) {
    struct ppdev_frob_struct frob;
    frob.mask=mask;
    frob.val=value;
    ioctl (PPfd, PPFCONTROL, &frob);
  } else
#endif
    {
      // code stolen from linux/parport_pc.h
      ctr = (ctr & ~mask) ^ value;
      outb (ctr, Port+2);
    }
}


void parport_toggle (unsigned char bit, int level, int delay)
{

  // any signal affected?
  // Note: this may happen in case a signal is hardwired to GND
  if (bit==0) return;

  // Strobe, Select and AutoFeed are inverted!
  if (bit & (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD)) {
    level=!level;
  }
 
#ifdef WITH_PPDEV
  if (PPdev) {
    struct ppdev_frob_struct frob;
    frob.mask=bit;
    
    // rise
    frob.val=level?bit:0;
    ioctl (PPfd, PPFCONTROL, &frob);
    
    // pulse width
    ndelay(delay);      
    
    // lower
    frob.val=level?0:bit;
    ioctl (PPfd, PPFCONTROL, &frob);
  } else
#endif
    {
      // rise
      ctr = (ctr & ~bit) ^ (level?bit:0);
      outb (ctr, Port+2);

      // pulse width
      ndelay(delay);      
      
      // lower
      ctr = (ctr & ~bit) ^ (level?0:bit);
      outb (ctr, Port+2);
    }
}


void parport_data (unsigned char data)
{
#ifdef WITH_PPDEV
  if (PPdev) {
    ioctl(PPfd, PPWDATA, &data);
  } else
#endif
    {
      outb (data, Port);
    }
}

unsigned char parport_read (void)
{
  unsigned char data;
  
#ifdef WITH_PPDEV
  if (PPdev) {
    ioctl (PPfd, PPRDATA, &data);
  } else
#endif
    {
      data=inb (Port);
    }
  return data;
}


void parport_debug(void)
{
  unsigned char control;
  
  ioctl (PPfd, PPRCONTROL, &control);
  
  debug ("%cSTROBE %cAUTOFD %cINIT %cSELECT", 
	 control & PARPORT_CONTROL_STROBE ? '-':'+',
	 control & PARPORT_CONTROL_AUTOFD ? '-':'+',
	 control & PARPORT_CONTROL_INIT   ? '+':'-',
	 control & PARPORT_CONTROL_SELECT ? '-':'+');
  
}
haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" done dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) # lib-ld.m4 serial 3 (gettext-0.13) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 </dev/null` in *GNU* | *'with BFD'*) acl_cv_prog_gnu_ld=yes ;; *) acl_cv_prog_gnu_ld=no ;; esac]) with_gnu_ld=$acl_cv_prog_gnu_ld ]) dnl From libtool-1.4. Sets the variable LD. AC_DEFUN([AC_LIB_PROG_LD], [AC_ARG_WITH(gnu-ld, [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # Copyright 2002 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"]) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.4-p6])]) # # Check to make sure that the build environment is sane. # AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN([AM_MISSING_PROG], [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN([AM_CONFIG_HEADER], [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <<am_indx=1 for am_file in <<$1>>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) # serial 1 AC_DEFUN([AM_WITH_DMALLOC], [AC_MSG_CHECKING(if malloc debugging is wanted) AC_ARG_WITH(dmalloc, [ --with-dmalloc use dmalloc, as in ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz], [if test "$withval" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(WITH_DMALLOC,1, [Define if using the dmalloc debugging malloc package]) LIBS="$LIBS -ldmalloc" LDFLAGS="$LDFLAGS -g" else AC_MSG_RESULT(no) fi], [AC_MSG_RESULT(no)]) ])