From 100570c7f91d3bfe8f90536f96c8154c78641b1d Mon Sep 17 00:00:00 2001 From: Alan Brault Date: Mon, 2 May 2011 16:35:59 -0400 Subject: Add configure checks for strchrnul() and strcasestr() and config.h entries Add __NLINUX__ and __NSOLARIS__ platform checks to configure and config.h entries --- Makefile.in | 44 +++++++++++----------- config.h.in | 92 ---------------------------------------------- configure | 31 ++++++++++++++-- configure.in | 13 ++++--- include/config.h.in | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/duser.h | 6 +-- src/Makefile.in | 4 +- src/user.c | 8 +--- 8 files changed, 168 insertions(+), 134 deletions(-) delete mode 100644 config.h.in create mode 100644 include/config.h.in diff --git a/Makefile.in b/Makefile.in index e99b3ee..8b90141 100644 --- a/Makefile.in +++ b/Makefile.in @@ -36,9 +36,10 @@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/config.h.in \ - $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - compile config.guess config.sub depcomp install-sh missing + $(srcdir)/Makefile.in $(top_srcdir)/configure \ + $(top_srcdir)/include/config.h.in AUTHORS COPYING ChangeLog \ + INSTALL NEWS compile config.guess config.sub depcomp \ + install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -46,7 +47,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = config.h +CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = @@ -201,8 +202,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src -all: config.h - $(MAKE) $(AM_MAKEFLAGS) all-recursive +all: all-recursive .SUFFIXES: am--refresh: @@ -240,22 +240,22 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): -config.h: stamp-h1 +include/config.h: include/stamp-h1 @if test ! -f $@; then \ - rm -f stamp-h1; \ - $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + rm -f include/stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) include/stamp-h1; \ else :; fi -stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.h.in: $(am__configure_deps) +include/stamp-h1: $(top_srcdir)/include/config.h.in $(top_builddir)/config.status + @rm -f include/stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status include/config.h +$(top_srcdir)/include/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 + rm -f include/stamp-h1 touch $@ distclean-hdr: - -rm -f config.h stamp-h1 + -rm -f include/config.h include/stamp-h1 # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -337,7 +337,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) mkid -fID $$unique tags: TAGS -TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ @@ -354,7 +354,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ - list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ @@ -372,9 +372,9 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ fi; \ fi ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ @@ -569,7 +569,7 @@ distcleancheck: distclean exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile config.h +all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive @@ -666,8 +666,8 @@ ps-am: uninstall-am: -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ - ctags-recursive install-am install-strip tags-recursive +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 7533f1a..0000000 --- a/config.h.in +++ /dev/null @@ -1,92 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* duser configuration path */ -#undef CFG_PATH - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strncasecmp' function. */ -#undef HAVE_STRNCASECMP - -/* Define to 1 if you have the `strstr' function. */ -#undef HAVE_STRSTR - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/configure b/configure index d3dfa6c..db66ea8 100755 --- a/configure +++ b/configure @@ -1769,6 +1769,8 @@ ac_func_list="$ac_func_list strdup" ac_func_list="$ac_func_list strerror" ac_func_list="$ac_func_list strncasecmp" ac_func_list="$ac_func_list strstr" +ac_func_list="$ac_func_list strchrnul" +ac_func_list="$ac_func_list strcasestr" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -2509,7 +2511,7 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' -ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers include/config.h" @@ -5142,6 +5144,14 @@ done + + + + + + + + @@ -5155,12 +5165,25 @@ done case "$host_os" in *linux*) CFLAGS="-O2 -Wall -Wextra -I../include" + +cat >>confdefs.h <<\_ACEOF +#define __NLINUX__ 1 +_ACEOF + ;; *solaris*) - CFLAGS="-O2 -Wall -D_NLINUX_ -I../include" + # The STSCI Build of GNU GCC has a broken -Wextra handler + CFLAGS="-O2 -Wall -I../include" + +cat >>confdefs.h <<\_ACEOF +#define __NSOLARIS__ 1 +_ACEOF + ;; *) - CFLAGS="-O2 -Wall -Wextra -I../include" + { { $as_echo "$as_me:$LINENO: error: duser does not currently support your platform" >&5 +$as_echo "$as_me: error: duser does not currently support your platform" >&2;} + { (exit 1); exit 1; }; } ;; esac @@ -5810,7 +5833,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; diff --git a/configure.in b/configure.in index 7a97a17..9705e98 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(1.11.1) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_SRCDIR([src/duser.c]) # Checks for programs. @@ -25,18 +25,21 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC -AC_CHECK_FUNCS_ONCE([memset strcasecmp strdup strerror strncasecmp strstr]) +AC_CHECK_FUNCS_ONCE([memset strcasecmp strdup strerror strncasecmp strstr strchrnul strcasestr]) # Checks for currently used operating system. case "$host_os" in *linux*) CFLAGS="-O2 -Wall -Wextra -I../include" + AC_DEFINE([__NLINUX__], 1, [host operating system is linux]) ;; - *solaris*) - CFLAGS="-O2 -Wall -D_NLINUX_ -I../include" + *solaris*) + # The STSCI Build of GNU GCC has a broken -Wextra handler + CFLAGS="-O2 -Wall -I../include" + AC_DEFINE([__NSOLARIS__], 1, [host operating system is solaris]) ;; *) - CFLAGS="-O2 -Wall -Wextra -I../include" + AC_MSG_ERROR([duser does not currently support your platform]) ;; esac diff --git a/include/config.h.in b/include/config.h.in new file mode 100644 index 0000000..022e00a --- /dev/null +++ b/include/config.h.in @@ -0,0 +1,104 @@ +/* include/config.h.in. Generated from configure.in by autoheader. */ + +/* duser configuration path */ +#undef CFG_PATH + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strcasestr' function. */ +#undef HAVE_STRCASESTR + +/* Define to 1 if you have the `strchrnul' function. */ +#undef HAVE_STRCHRNUL + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* host operating system is linux */ +#undef __NLINUX__ + +/* host operating system is solaris */ +#undef __NSOLARIS__ + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/include/duser.h b/include/duser.h index 06cdf84..5a102bb 100644 --- a/include/duser.h +++ b/include/duser.h @@ -22,13 +22,13 @@ #define DUSER_H #ifdef HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif #include #define REGEX_MAX 255 #define SELF __FUNCTION__ -#ifndef _NLINUX_ +#ifndef __NSOLARIS__ # define FMTLIST "%20s\t%5d%23s\n" #else # define FMTLIST "%20s\t%5d%16s\n" @@ -77,7 +77,7 @@ int user_cmd(const int argc, char* argv[]); int user_choice(char c); int user_add(const char* filename, const char* needle); int user_new_list(const char* fname); -#ifdef _NLINUX_ +#ifdef __NSOLARIS__ char *strcasestr(const char *s, const char *find); char *strchrnul(const char* s, int c); #endif diff --git a/src/Makefile.in b/src/Makefile.in index 6dc339b..3474743 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -43,7 +43,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" @@ -52,7 +52,7 @@ am_duser_OBJECTS = duser.$(OBJEXT) user.$(OBJEXT) util.$(OBJEXT) \ log.$(OBJEXT) cfg.$(OBJEXT) duser_OBJECTS = $(am_duser_OBJECTS) duser_LDADD = $(LDADD) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f diff --git a/src/user.c b/src/user.c index 72a7c13..f9b24a8 100644 --- a/src/user.c +++ b/src/user.c @@ -32,10 +32,6 @@ #include #include #include -#ifdef _NLINUX_ -# define HAVE_STRCHRNUL -# define HAVE_STRCASESTR -#endif #include "duser.h" extern char list_path[PATH_MAX]; @@ -320,7 +316,7 @@ int get_file_count(const char* path) while((ep = readdir(dp))) { -#ifdef _NLINUX_ +#ifdef __NSOLARIS__ char path[PATH_MAX]; struct stat st; snprintf(path, PATH_MAX, "%s%s", list_path, ep->d_name); @@ -376,7 +372,7 @@ char** get_file_list(const char* path, int count) } while((ep = readdir(dp))) { -#ifdef _NLINUX_ +#ifdef __NSOLARIS__ char path[PATH_MAX]; struct stat st; snprintf(path, PATH_MAX, "%s%s", list_path, ep->d_name); -- cgit