diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-11-29 17:29:04 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-11-29 17:29:04 +0000 |
commit | 4f7c64e3e2bbafd378277f1648de28573c263878 (patch) | |
tree | c3a4ee8ff19a6c3f83a2761c77b62f3956198100 | |
parent | 77c4cc40647f91852ccf2225d178ad77286ac376 (diff) |
moved configuration from compiler-arguments into zexyconf.h
only build regex if there is a regex.h in the system
svn path=/trunk/externals/zexy/; revision=4080
-rw-r--r-- | src/Make.config | 2 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/configure.ac | 14 | ||||
-rw-r--r-- | src/lpt.c | 16 | ||||
-rw-r--r-- | src/regex.c | 30 | ||||
-rw-r--r-- | src/zexy.h | 2 | ||||
-rw-r--r-- | src/zexyconf.h.in | 14 |
7 files changed, 55 insertions, 25 deletions
diff --git a/src/Make.config b/src/Make.config index 05f8cb3..6927985 100644 --- a/src/Make.config +++ b/src/Make.config @@ -6,7 +6,7 @@ INSTALL_BIN=$(PREFIX)/extra INSTALL_DOC=$(PREFIX)/extra/help-$(LIBNAME) EXT = pd_linux -DEFS = -DZEXY_LIBRARY -DZ_WANT_LPT -DHAVE_PPDEV +DEFS = -DZEXY_LIBRARY IFLAGS = -I. CC = gcc diff --git a/src/Makefile b/src/Makefile index 8344c47..86e0a23 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,6 +9,8 @@ SOURCES=$(sort $(filter %.c, $(wildcard *.c))) Make.config: Make.config.in configure ./configure +zexyconf.h: zexyconf.h.in configure + ./configure configure: configure.ac autoconf diff --git a/src/configure.ac b/src/configure.ac index aa36af9..586c0b2 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -1,5 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(zexy.c) +AC_INIT([zexy.h]) +AC_CONFIG_HEADER([zexyconf.h]) LIBNAME=zexy @@ -22,8 +23,6 @@ AC_SUBST(INCLUDES) AC_SUBST(SOURCES) AC_SUBST(LIBNAME) - - AC_ARG_WITH(pdversion, [ --with-pdversion=<ver> enforce a certain pd-version (e.g. 0.37)]) AC_ARG_WITH(version, [ --with-version=<ver> enforce a certain zexy-version (e.g. 2.0)]) AC_ARG_WITH(extension, [ --with-extension=<ext> enforce a certain extension for the dynamic library (e.g. dll)]) @@ -92,7 +91,7 @@ AC_CHECK_LIB(pd, nullfn) dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(stdlib.h stdio.h string.h math.h time.h sys/time.h) +AC_CHECK_HEADERS(stdlib.h stdio.h string.h math.h time.h sys/time.h regex.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_HEADER_TIME @@ -372,7 +371,7 @@ then EXT=$with_extension fi -AC_CHECK_HEADER(linux/ppdev.h, [ have_ppdev="yes" ], [ have_ppdev="no" ]) +AC_CHECK_HEADERS(linux/ppdev.h, [ have_ppdev="yes" ], [ have_ppdev="no" ]) dnl check for LPT AC_MSG_CHECKING("parallel-port") @@ -380,7 +379,7 @@ if test "$enable_lpt" != "no" then if test "$enable_lpt" = "yes" then - DFLAGS="$DFLAGS -DZ_WANT_LPT" + AC_DEFINE([Z_WANT_LPT]) echo "yes (forced)" else @@ -396,10 +395,9 @@ EOF if $CC $INCLUDES -o conftest.o conftest.c > /dev/null 2>&1 then - DFLAGS="$DFLAGS -DZ_WANT_LPT" + AC_DEFINE([Z_WANT_LPT]) if test "x$have_ppdev" = "xyes" then - DFLAGS="$DFLAGS -DHAVE_PPDEV" echo "yes (with device-support)" else echo "yes" @@ -46,12 +46,12 @@ # include <stdlib.h> # include <errno.h> -# ifdef HAVE_PPDEV +# ifdef HAVE_LINUX_PPDEV_H # include <sys/ioctl.h> # include <linux/ppdev.h> # include <linux/parport.h> # include <fcntl.h> -# endif /* HAVE_PPDEV */ +# endif /* HAVE_LINUX_PPDEV_H */ # ifdef __WIN32__ @@ -112,7 +112,7 @@ static void lpt_float(t_lpt *x, t_floatarg f) { unsigned char b = f; #ifdef Z_WANT_LPT -# ifdef HAVE_PPDEV +# ifdef HAVE_LINUX_PPDEV_H if (x->device>0){ ioctl (x->device, PPWDATA, &b); } else @@ -126,7 +126,7 @@ static void lpt_float(t_lpt *x, t_floatarg f) static void lpt_control(t_lpt *x, t_floatarg f) { unsigned char b = f; -# ifdef HAVE_PPDEV +# ifdef HAVE_LINUX_PPDEV_H if (x->device>0){ ioctl (x->device, PPWCONTROL, &b); } else @@ -140,7 +140,7 @@ static void lpt_control(t_lpt *x, t_floatarg f) static void lpt_bang(t_lpt *x) { -# ifdef HAVE_PPDEV +# ifdef HAVE_LINUX_PPDEV_H if (x->device>0){ unsigned char b=0; ioctl (x->device, PPRCONTROL, &b); @@ -196,7 +196,7 @@ static void *lpt_new(t_symbol *s, int argc, t_atom *argv) x->device=-1; x->port=strtol(devname, 0, 16); if(0==x->port){ -#ifdef HAVE_PPDEV +#ifdef HAVE_LINUX_PPDEV_H x->device = open(devname, O_RDWR); if(x->device<=0){ error("lpt: bad device %s", devname); @@ -208,7 +208,7 @@ static void *lpt_new(t_symbol *s, int argc, t_atom *argv) x->device=-1; } } -#endif /* HAVE_PPDEV */ +#endif /* HAVE_LINUX_PPDEV_H */ } } @@ -260,7 +260,7 @@ static void *lpt_new(t_symbol *s, int argc, t_atom *argv) static void lpt_free(t_lpt *x) { #ifdef Z_WANT_LPT -# ifdef HAVE_PPDEV +# ifdef HAVE_LINUX_PPDEV_H if (x->device>0){ ioctl (x->device, PPRELEASE); close(x->device); diff --git a/src/regex.c b/src/regex.c index 2bb907d..4d819c8 100644 --- a/src/regex.c +++ b/src/regex.c @@ -16,11 +16,13 @@ #include "zexy.h" -#include <sys/types.h> -#include <regex.h> -#include <string.h> +#ifdef HAVE_REGEX_H +# include <sys/types.h> +# include <regex.h> +# include <string.h> +#endif -#define NUM_REGMATCHES 10 +# define NUM_REGMATCHES 10 /* * regex : see whether a regular expression matches the given symbol @@ -35,11 +37,13 @@ static t_class *regex_class; typedef struct _regex { t_object x_obj; - +#ifdef HAVE_REGEX_H regex_t *x_regexp; int x_matchnum; +#endif } t_regex; +#ifdef HAVE_REGEX_H static char*regex_l2s(int *reslen, t_symbol*s, int argc, t_atom*argv) { char *result = 0; @@ -105,9 +109,11 @@ static char*regex_l2s(int *reslen, t_symbol*s, int argc, t_atom*argv) if(reslen)*reslen=length; return result; } +#endif static void regex_regex(t_regex *x, t_symbol*s, int argc, t_atom*argv) { +#ifdef HAVE_REGEX_H char*result=0; int length=0; t_atom*ap=argv; @@ -137,9 +143,11 @@ static void regex_regex(t_regex *x, t_symbol*s, int argc, t_atom*argv) } if(result)freebytes(result, length); +#endif } static void regex_symbol(t_regex *x, t_symbol *s, int argc, t_atom*argv) { +#ifdef HAVE_REGEX_H char*teststring=0; int length=0; @@ -192,30 +200,36 @@ static void regex_symbol(t_regex *x, t_symbol *s, int argc, t_atom*argv) outlet_list(x->x_obj.ob_outlet, gensym("list"), ap_length, ap); freebytes(ap, sizeof(t_atom)*(1+2*num_matches)); } +#endif } static void *regex_new(t_symbol *s, int argc, t_atom*argv) { t_regex *x = (t_regex *)pd_new(regex_class); - x->x_regexp=0; - x->x_matchnum=NUM_REGMATCHES; - outlet_new(&x->x_obj, 0); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("symbol"), gensym("regex")); +#ifdef HAVE_REGEX_H + x->x_regexp=0; + x->x_matchnum=NUM_REGMATCHES; if(argc)regex_regex(x, gensym(""), argc, argv); +#else + error("[regex] non-functional: compiled without regex-support!"); +#endif return (x); } static void regex_free(t_regex *x) { +#ifdef HAVE_REGEX_H if(x->x_regexp) { regfree(x->x_regexp); freebytes(x->x_regexp, sizeof(t_regex)); x->x_regexp=0; } +#endif } @@ -39,6 +39,8 @@ # endif #endif +#include "zexyconf.h" + #include "m_pd.h" #include <math.h> diff --git a/src/zexyconf.h.in b/src/zexyconf.h.in new file mode 100644 index 0000000..3b54b63 --- /dev/null +++ b/src/zexyconf.h.in @@ -0,0 +1,14 @@ + +/* Define if you have the <regex.h> header file. */ +#undef HAVE_REGEX_H + +/* define if you want parallelport-support (direct access to the port address) */ +#undef Z_WANT_LPT + +/* define if you have the <linux/ppdev.h> header file. + * (for parport _device_ support) + * you need Z_WANT_LPT for this to have an effect ! + */ +#undef HAVE_LINUX_PPDEV_H + + |