From 2b48ecd0976216be47f977bcad3a92982f266330 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 6 May 2002 14:34:53 +0000 Subject: [PATCH] 2002-05-05 Robert Collins * Makefile.am (inlint_SOURCES): Add conditional objects to inilint depending on platform. Add file:// support. * configure.in: Set conditional MINGWTARGET if compiling against mingw libraries. * Makefile.in: Regenerate. * configure: Ditto. * io_stream_file.cc: Only use win32 calls when building for mingw. --- ChangeLog | 11 +++++++++++ Makefile.am | 14 +++++++++++++- Makefile.in | 19 ++++++++++++++++--- configure | 45 ++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 10 ++++++++++ configure.in | 10 ++++++++++ io_stream_file.cc | 42 ++++++++++++++++++++++++++++++++++++------ 7 files changed, 140 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49b26d7b..a825fde0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-05-05 Robert Collins + + * Makefile.am (inlint_SOURCES): Add conditional objects to inilint + depending on platform. + Add file:// support. + * configure.in: Set conditional MINGWTARGET if compiling against mingw + libraries. + * Makefile.in: Regenerate. + * configure: Ditto. + * io_stream_file.cc: Only use win32 calls when building for mingw. + 2002-05-05 Robert Collins * Makefile.am (noinst_PROGRAMS): Make inilint configurable. diff --git a/Makefile.am b/Makefile.am index 703efb45..8e996613 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,15 @@ BUILT_SOURCES = setup_version.c \ inilex.cc \ iniparse.cc +if MINGWTARGET + inilint_extras = \ + autoload.c \ + mklink2.cc\ + mklink2.cc +else + inilint_extras = +endif + inilint_LDADD = libgetopt++/libgetopt++.la -lstdc++ -luser32 -lkernel32 inilint_SOURCES = \ filemanip.cc \ @@ -72,12 +81,15 @@ inilint_SOURCES = \ iniparse.h \ io_stream.h \ io_stream.cc \ + io_stream_file.h \ + io_stream_file.cc \ IOStreamProvider.h \ PackageTrust.h \ rfc1738.cc \ rfc1738.h \ String++.cc \ - String++.h + String++.h \ + $(inilint_extras) setup_LDADD = res.o zlib/libzcygw.a bz2lib/libbz2.a libgetopt++/libgetopt++.la \ -lstdc++ -luser32 -lkernel32 \ diff --git a/Makefile.in b/Makefile.in index 20b93e0b..361d6a1e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -155,6 +155,13 @@ BUILT_SOURCES = setup_version.c \ iniparse.cc +@MINGWTARGET_TRUE@inilint_extras = \ +@MINGWTARGET_TRUE@ autoload.c \ +@MINGWTARGET_TRUE@ mklink2.cc\ +@MINGWTARGET_TRUE@ mklink2.cc + +@MINGWTARGET_FALSE@inilint_extras = + inilint_LDADD = libgetopt++/libgetopt++.la -lstdc++ -luser32 -lkernel32 inilint_SOURCES = \ filemanip.cc \ @@ -169,12 +176,15 @@ inilint_SOURCES = \ iniparse.h \ io_stream.h \ io_stream.cc \ + io_stream_file.h \ + io_stream_file.cc \ IOStreamProvider.h \ PackageTrust.h \ rfc1738.cc \ rfc1738.h \ String++.cc \ - String++.h + String++.h \ + $(inilint_extras) setup_LDADD = res.o zlib/libzcygw.a bz2lib/libbz2.a libgetopt++/libgetopt++.la \ @@ -338,10 +348,13 @@ EXTRA_PROGRAMS = inilint$(EXEEXT) noinst_PROGRAMS = setup$(EXEEXT) @INILINT@ PROGRAMS = $(noinst_PROGRAMS) +@MINGWTARGET_TRUE@am__objects_1 = autoload.$(OBJEXT) mklink2.$(OBJEXT) \ +@MINGWTARGET_TRUE@ mklink2.$(OBJEXT) +@MINGWTARGET_FALSE@am__objects_1 = am_inilint_OBJECTS = filemanip.$(OBJEXT) LogSingleton.$(OBJEXT) \ IniDBBuilder.$(OBJEXT) inilex.$(OBJEXT) inilintmain.$(OBJEXT) \ - iniparse.$(OBJEXT) io_stream.$(OBJEXT) rfc1738.$(OBJEXT) \ - String++.$(OBJEXT) + iniparse.$(OBJEXT) io_stream.$(OBJEXT) io_stream_file.$(OBJEXT) \ + rfc1738.$(OBJEXT) String++.$(OBJEXT) $(am__objects_1) inilint_OBJECTS = $(am_inilint_OBJECTS) inilint_DEPENDENCIES = libgetopt++/libgetopt++.la inilint_LDFLAGS = diff --git a/configure b/configure index 3cd84b78..39de72bc 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 2.8 . +# From configure.in Revision: 2.9 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. # @@ -15100,6 +15100,33 @@ subdirs="$subdirs bz2lib" subdirs="$subdirs libgetopt++" +case "$host_os" in +mingw32) + + +if true; then + MINGWTARGET_TRUE= + MINGWTARGET_FALSE='#' +else + MINGWTARGET_TRUE='#' + MINGWTARGET_FALSE= +fi + + ;; +*) + + +if false; then + MINGWTARGET_TRUE= + MINGWTARGET_FALSE='#' +else + MINGWTARGET_TRUE='#' + MINGWTARGET_FALSE= +fi + + ;; +esac + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -15223,6 +15250,20 @@ echo "$as_me: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${MINGWTARGET_TRUE}" && test -z "${MINGWTARGET_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"MINGWTARGET\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"MINGWTARGET\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${MINGWTARGET_TRUE}" && test -z "${MINGWTARGET_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"MINGWTARGET\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"MINGWTARGET\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files @@ -15767,6 +15808,8 @@ s,@LIBTOOL@,$LIBTOOL,;t t s,@WINDRES@,$WINDRES,;t t s,@ac_ct_WINDRES@,$ac_ct_WINDRES,;t t s,@subdirs@,$subdirs,;t t +s,@MINGWTARGET_TRUE@,$MINGWTARGET_TRUE,;t t +s,@MINGWTARGET_FALSE@,$MINGWTARGET_FALSE,;t t CEOF _ACEOF diff --git a/configure.ac b/configure.ac index c937f1ab..ddea32fe 100644 --- a/configure.ac +++ b/configure.ac @@ -74,5 +74,15 @@ AC_CONFIG_SUBDIRS(zlib) AC_CONFIG_SUBDIRS(bz2lib) AC_CONFIG_SUBDIRS(libgetopt++) +dnl add portability sources to inilint +case "$host_os" in +mingw32) + AM_CONDITIONAL(MINGWTARGET, true) + ;; +*) + AM_CONDITIONAL(MINGWTARGET, false) + ;; +esac + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/configure.in b/configure.in index c937f1ab..ddea32fe 100644 --- a/configure.in +++ b/configure.in @@ -74,5 +74,15 @@ AC_CONFIG_SUBDIRS(zlib) AC_CONFIG_SUBDIRS(bz2lib) AC_CONFIG_SUBDIRS(libgetopt++) +dnl add portability sources to inilint +case "$host_os" in +mingw32) + AM_CONDITIONAL(MINGWTARGET, true) + ;; +*) + AM_CONDITIONAL(MINGWTARGET, false) + ;; +esac + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/io_stream_file.cc b/io_stream_file.cc index f9018e38..ad4359cd 100644 --- a/io_stream_file.cc +++ b/io_stream_file.cc @@ -18,16 +18,18 @@ static const char *cvsid = "\n%%% $Id$\n"; #endif +#if defined(WIN32) && !defined (_CYGWIN_) #include "win32.h" +#include "port.h" +#include "mkdir.h" +#include "mklink2.h" +#endif + #include #include #include #include -#include "port.h" -#include "mkdir.h" -#include "mklink2.h" -#include "io_stream.h" #include "io_stream_file.h" #include "IOStreamProvider.h" @@ -86,7 +88,11 @@ io_stream_file::~io_stream_file () int io_stream_file::exists (String const &path) { +#if defined(WIN32) && !defined (_CYGWIN_) if (_access (path.cstr_oneuse(), 0) == 0) +#else + if (access (path.cstr_oneuse(), F_OK) == 0) +#endif return 1; return 0; } @@ -96,7 +102,7 @@ io_stream_file::remove (String const &path) { if (!path.size()) return 1; - +#if defined(WIN32) && !defined (_CYGWIN_) unsigned long w = GetFileAttributes (path.cstr_oneuse()); if (w != 0xffffffff && w & FILE_ATTRIBUTE_DIRECTORY) { @@ -114,7 +120,10 @@ io_stream_file::remove (String const &path) delete[] tmp; } return !DeleteFileA (path.cstr_oneuse()); - +#else + // FIXME: try rmdir if unlink fails - remove the dir + return unlink (path.cstr_oneuse()); +#endif } int @@ -123,6 +132,7 @@ io_stream_file::mklink (String const &from, String const &to, { if (!from.size() || !to.size()) return 1; +#if defined(WIN32) && !defined (_CYGWIN_) switch (linktype) { case IO_STREAM_SYMLINK: @@ -130,6 +140,15 @@ io_stream_file::mklink (String const &from, String const &to, case IO_STREAM_HARDLINK: return 1; } +#else + switch (linktype) + { + case IO_STREAM_SYMLINK: + return symlink (to.cstr_oneuse(), from.cstr_oneuse()); + case IO_STREAM_HARDLINK: + return link (to.cstr_oneuse(), from.cstr_oneuse()); + } +#endif return 1; } @@ -201,6 +220,7 @@ io_stream_file::set_mtime (int mtime) return 1; if (fp) fclose (fp); +#if defined(WIN32) && !defined (_CYGWIN_) long long ftimev = mtime * NSPERSEC + FACTOR; FILETIME ftime; ftime.dwHighDateTime = ftimev >> 32; @@ -215,6 +235,9 @@ io_stream_file::set_mtime (int mtime) CloseHandle (h); return 0; } +#else + throw new runtime_error ("set_mtime not supported on posix yet."); +#endif return 1; } @@ -231,6 +254,7 @@ io_stream_file::get_size () { if (!fname.size()) return 0; +#if defined(WIN32) && !defined (_CYGWIN_) HANDLE h; WIN32_FIND_DATA buf; DWORD ret = 0; @@ -243,4 +267,10 @@ io_stream_file::get_size () FindClose (h); } return ret; +#else + struct stat buf; + if (stat(fname.cstr_oneuse(), &buf)) + throw new runtime_error ("Failed to stat file - has it been deleted?"); + return buf.st_size; +#endif } -- 2.43.5