aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2011-05-02 18:14:53 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2011-05-02 18:14:53 -0400
commit2fb05c7c4516d1ae3f0ad46df50043bbaa17ccb7 (patch)
treee4cd1c7e8587dac35ed805f1daa2bcc9804308a4
parentb568ec9b26ae378880409f2413da8d4b62fa4788 (diff)
parent817b384592e730f4f832bfbe92a948970840ee33 (diff)
downloadduser-2fb05c7c4516d1ae3f0ad46df50043bbaa17ccb7.tar.gz
Merge pull request #3 from extrarius/master.
Platform sanity checks
-rw-r--r--Makefile.in44
-rwxr-xr-xconfigure31
-rw-r--r--configure.in13
-rw-r--r--include/config.h.in (renamed from config.h.in)14
-rw-r--r--include/duser.h6
-rw-r--r--src/Makefile.am3
-rw-r--r--src/Makefile.in12
-rw-r--r--src/user.c8
8 files changed, 84 insertions, 47 deletions
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/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"
@@ -5151,16 +5153,37 @@ done
+
+
+
+
+
+
+
+
# Checks for currently used operating system.
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/config.h.in b/include/config.h.in
index 7533f1a..022e00a 100644
--- a/config.h.in
+++ b/include/config.h.in
@@ -1,4 +1,4 @@
-/* config.h.in. Generated from configure.in by autoheader. */
+/* include/config.h.in. Generated from configure.in by autoheader. */
/* duser configuration path */
#undef CFG_PATH
@@ -31,6 +31,12 @@
/* 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
@@ -85,6 +91,12 @@
/* 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
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 <limits.h>
#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.am b/src/Makefile.am
index 45d46ef..ba9d267 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,7 @@
sbin_PROGRAMS= duser
-duser_SOURCES= duser.c \
+duser_SOURCES= compat.c \
+ duser.c \
user.c \
util.c \
log.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 6dc339b..9ffffcc 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -43,16 +43,16 @@ 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)"
PROGRAMS = $(sbin_PROGRAMS)
-am_duser_OBJECTS = duser.$(OBJEXT) user.$(OBJEXT) util.$(OBJEXT) \
- log.$(OBJEXT) cfg.$(OBJEXT)
+am_duser_OBJECTS = compat.$(OBJEXT) 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
@@ -163,7 +163,8 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-duser_SOURCES = duser.c \
+duser_SOURCES = compat.c \
+ duser.c \
user.c \
util.c \
log.c \
@@ -251,6 +252,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/duser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@
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 <time.h>
#include <fcntl.h>
#include <libgen.h>
-#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);