diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-12-06 14:09:19 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-12-06 14:09:19 +0000 |
commit | 6ae6f4fd4bd96c089544885d42a50aa7e7d15abe (patch) | |
tree | e7ede51ebd53943dd9b05ce752660dcce18d5c01 | |
parent | 36147c08e9224fadc5a713ebbc16ae644a986cf7 (diff) | |
download | radius-6ae6f4fd4bd96c089544885d42a50aa7e7d15abe.tar.gz radius-6ae6f4fd4bd96c089544885d42a50aa7e7d15abe.tar.bz2 |
scripts/radius.m4: New file.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | scripts/Makefile.am | 5 | ||||
-rw-r--r-- | scripts/mktypes.c | 31 | ||||
-rw-r--r-- | scripts/radius.m4 | 85 |
4 files changed, 122 insertions, 2 deletions
@@ -1,5 +1,8 @@ 2008-12-06 Sergey Poznyakoff <gray@gnu.org.ua> + * scripts/radius.m4: New file. + * NEWS: Mention AM_GNU_RADIUS. + Namespace normalization. * include/radius/list.h: Rename struct list/iterator to grad_list/ diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 98840906..f62a8751 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,5 +1,5 @@ # This file is part of GNU Radius. -# Copyright (C) 2000,2001,2003,2004,2007 Free Software Foundation, Inc. +# Copyright (C) 2000,2001,2003,2004,2007,2008 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # @@ -28,3 +28,6 @@ EXTRA_DIST=\ update-dict.awk noinst_PROGRAMS = mktypes + +m4datadir = $(datadir)/aclocal +dist_m4data_DATA = radius.m4 diff --git a/scripts/mktypes.c b/scripts/mktypes.c index 05154673..3eb3cd01 100644 --- a/scripts/mktypes.c +++ b/scripts/mktypes.c @@ -1,6 +1,6 @@ char header_text[] = "\ /* This file is part of GNU Radius.\n\ - Copyright (C) 2004, 2007 Free Software Foundation, Inc.\n\ + Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.\n\ \n\ GNU Radius is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ @@ -22,6 +22,7 @@ char header_text[] = "\ # include <config.h> #endif #include <sys/types.h> +#include <ctype.h> #ifdef HAVE_STDINT_H # include <stdint.h> #endif @@ -33,9 +34,23 @@ char header_text[] = "\ # define DEF_ACCT_PORT 1813 #endif +char * +print_number(char *prefix, char *p) +{ + if (isdigit(*p)) { + printf("#define %s ", prefix); + for (; isdigit(*p); p++) + putchar(*p); + putchar('\n'); + } + return p; +} + int main() { + char *p; + printf("%s\n\n", header_text); printf("#ifndef _gnu_radius_types_h\n"); printf("#define _gnu_radius_types_h\n"); @@ -44,6 +59,20 @@ main() printf("#include <stdint.h>\n"); #endif printf("\n"); + printf("#define GRAD_VERSION_STRING \"%s\"\n", PACKAGE_VERSION); + p = PACKAGE_VERSION; + p = print_number("GRAD_VERSION_MAJOR", p); + if (*p == '.') { + p++; + p = print_number("GRAD_VERSION_MINOR", p); + if (*p == '.') { + p++; + p = print_number("GRAD_VERSION_PATCH", p); + } + } + if (*p) + printf("#define GRAD_VERSION_EXTRA \"%s\"\n"); + printf("typedef %s grad_uint32_t;\n", #if SIZEOF_UINT32_T == 4 "uint32_t" diff --git a/scripts/radius.m4 b/scripts/radius.m4 new file mode 100644 index 00000000..cb442bf2 --- /dev/null +++ b/scripts/radius.m4 @@ -0,0 +1,85 @@ +dnl Copyright (C) 2008 Free Software Foundation, Inc. +dnl GNU Radius is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl GNU Radius is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see <http://www.gnu.org/licenses/>. + +dnl AM_GNU_RADIUS(minversion, [act-if-found], [ac-if-not-found]) +dnl $1 $2 $3 +dnl Verify if GNU Radius is installed and if its version is `minversion' +dnl or newer. If not installed, execute `ac-if-not-found' or, if it is not +dnl given, spit out an error message. +dnl If GNU Radius is found, set: +dnl GNU_RADIUS_VERSION to the Radius version (string); +dnl GNU_RADIUS_VERSION_NUMBER to the packed numeric representation of the +dnl GNU Radius version (major * 1000 + minor * 100 + patch); +dnl GNU_RADIUS_LIBS to the list of cc(1) flags needed to link in the +dnl GNU Radius libraries +dnl +dnl Finally, if `act-if-found' is given, execute it. Otherwise, append the +dnl value of $GNU_RADIUS_LIBS to LIBS. + +AC_DEFUN([_AM_GRAD_PREPROC],[ +AC_REQUIRE_CPP()dnl +AC_LANG_CONFTEST([$1]) +$3=`$CPP conftest.$ac_ext 2>conftest.err | sed -n 's/^$2//p'` +rm -f conftest.err conftest.$ac_ext]) + +m4_define([grad_version_number],[dnl + patsubst([$1],[\([0-9]+\)\.\([0-9]+\)\(\.\([0-9]+\)\)?.*], + [m4_builtin(eval, \1*1000 + \2*100 + \40 / 10)])dnl +]) + +AC_DEFUN([AM_GNU_RADIUS], + [AC_SUBST(GNU_RADIUS_VERSION) + AC_SUBST(GNU_RADIUS_VERSION_NUMBER) + AC_SUBST(GNU_RADIUS_LIBS) + + AC_CHECK_HEADERS([radius/radius.h], + [grad_cv_radius=yes], + [grad_cv_radius=no]) + if test $grad_cv_radius = yes; then + AC_CHECK_LIB(gnuradius, grad_dict_init, + :, + [grad_cv_radius=no]) + fi + if test $grad_cv_radius = yes; then + _AM_GRAD_PREPROC([ +#include <radius/types.h> +version=GRAD_VERSION_MAJOR.GRAD_VERSION_MINOR.GRAD_VERSION_PATCH +], + [version=], + [grad_version_string]) + + GNU_RADIUS_VERSION= + for f in $grad_version_string + do + GNU_RADIUS_VERSION="${GNU_RADIUS_VERSION}$f" + done + if test -n "GNU_RADIUS_VERSION"; then + VEX=`echo $GNU_RADIUS_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'` + GNU_RADIUS_VERSION_NUMBER=`eval expr "$VEX"` + + ifelse($1,,,[ + if test $GNU_RADIUS_VERSION_NUMBER -lt grad_version_number($1); then + ifelse($3,, + [AC_MSG_ERROR([GNU Radius version too old; required is at least ]$1)], + [$3]) + fi]) + + GNU_RADIUS_LIBS="-lgnuradius" + ifelse($2,,[LIBS="$LIBS $GNU_RADIUS_LIBS"], [$2]) + fi + fi + if test $grad_cv_radius != yes; then + ifelse($3,,[AC_MSG_ERROR(cannot find GNU Radius)], [$3]) + fi]) + |