From 62d773170327ede527d77c36deaf9f0b88192197 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 24 Apr 2008 07:28:00 +0000 Subject: [PATCH] Patch from Peter Hartley to allow Cross-compiling to mingw32: - MinGW doesn't have struct timespec, so udf_time.c doesn't compile (changes lib/udf/udf_time.c, configure.ac, config.h.in) - The configure test for bitfield ordering uses AC_TRY_RUN and thus doesn't work when cross-compiling; use sneakiness to try and determine it at compile time, falling back to the existing runtime check if the sneakiness doesn't work (changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32 which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0) - The configure test for "extern long timezone" needlessly uses AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and that latter works when cross-compiling (changes configure.ac) - MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK or S_IFSOCK, nor S_ISUID etc (changes lib/udf/udf.c and lib/iso9660/xa.c) - MinGW doesn't have , so even the header-inclusion bit of the Linux driver doesn't compile unless it's moved inside the "ifdef HAVE_LINUX_CDROM" (changes lib/driver/gnu_linux.c) - Because the man pages cd-info.1 etc depend on the binaries themselves (for help2man reasons), the configure options --without-cd-info etc don't actually stop them being compiled. Fixed by only depending on man pages for programs that are actually built, which also stops the installation of man pages of programs which aren't themselves installed (changes src/Makefile.am) --- NEWS | 8 +++--- THANKS | 3 +++ configure.ac | 57 ++++++++++++++++++++++++++++++++++++++++-- lib/driver/gnu_linux.c | 6 ++--- lib/iso9660/xa.c | 10 +++++++- lib/udf/udf.c | 12 ++++++++- lib/udf/udf_time.c | 5 ++-- src/Makefile.am | 25 ++++++++++-------- 8 files changed, 104 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index 4e800432..b2cc936e 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -$Id: NEWS,v 1.121 2008/03/27 10:45:24 edsdead Exp $ +$Id: NEWS,v 1.122 2008/04/24 07:28:00 rocky Exp $ version 0.81cvs @@ -14,6 +14,8 @@ version 0.81cvs - Allow reading pregap of a track via get_track_pregap_lsn(). Add Section on "CD-DA pregap" in libcdio manual +- Allow cross-compiling to mingw32. Patch from Peter Hartley. + version 0.80 2008-03-15 @@ -42,7 +44,7 @@ version 0.79 by Eric Shattow. Fix erroneous #defines when DO_NO_WANT_PARANOIA_COMPATIBILITY is set - reported by David Stockwell. -- Support for multisession CD-Extra Discs - via of Patrick Guimond +- Support for multisession CD-Extra Discs. Patch from Patrick Guimond - Add iso9660_fs_find_lsn_with_path and iso9660_ifs_find_lsn_with_path to report the full filename path of lsn. @@ -417,4 +419,4 @@ version 0.1 Routines split off from VCDImager. -$Id: NEWS,v 1.121 2008/03/27 10:45:24 edsdead Exp $ +$Id: NEWS,v 1.122 2008/04/24 07:28:00 rocky Exp $ diff --git a/THANKS b/THANKS index 87b9dfb6..74cd82c8 100644 --- a/THANKS +++ b/THANKS @@ -36,6 +36,9 @@ Nicolas Boullis Patrick Guimond CD-Extra audio data boundaries +Peter Hartley + Cross-compiling to mingw32 + Peter J. Creath removal of libpopt, paranoia documentation, some bug fixes to cd-* programs and the paranoia lib diff --git a/configure.ac b/configure.ac index fbdf3867..01a48d47 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ define(RELEASE_NUM, 81) define(CDIO_VERSION_STR, 0.$1cvs) AC_PREREQ(2.52) -AC_REVISION([$Id: configure.ac,v 1.224 2008/03/27 17:40:50 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.225 2008/04/24 07:28:00 rocky Exp $])dnl AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM)) AC_CONFIG_SRCDIR(src/cd-info.c) @@ -247,6 +247,15 @@ int main(int argc, char **argv) { [AC_MSG_RESULT(no); ac_have_issock=no], [AC_MSG_RESULT(no); ac_have_issock=no]) +AC_MSG_CHECKING([for struct timespec]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#ifdef HAVE_SYS_TIME_H +#include +#endif +],[struct timespec ts;])], +[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TIMESPEC, [], [Define this if you have struct timespec]) ], +[ AC_MSG_RESULT(no) ]) + dnl empty_array_size AC_MSG_CHECKING([how to create empty arrays]) @@ -272,6 +281,49 @@ dnl empty_array_size dnl bitfield order AC_MSG_CHECKING(bitfield ordering in structs) +dnl First see whether we can work out ordering without running a program -- +dnl for instance, when cross-compiling +boring_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -O2" +AC_LINK_IFELSE([ +int conftest_undefined_reference_(); +int main() { + union { + unsigned int x; + struct { + unsigned int x0: 1; + unsigned int x1: 31; + } s; + } u; + + u.x = 0; + u.s.x0 = 1; + if (u.x == 1) + return conftest_undefined_reference_(); + return 0; +} +], [bf_lsbf=0]) +AC_LINK_IFELSE([ +int conftest_undefined_reference_(); +int main() { + union { + unsigned int x; + struct { + unsigned int x0: 1; + unsigned int x1: 31; + } s; + } u; + + u.x = 0; + u.s.x0 = 1; + if (u.x == 0x80000000) + return conftest_undefined_reference_(); + return 0; +} +], [bf_lsbf=1]) +CFLAGS="$boring_CFLAGS" +dnl If we haven't found out for certain yet, try the runtime test +if test "x$bf_lsbf" = "x"; then AC_TRY_RUN([ int main() { @@ -293,6 +345,7 @@ main() { if (sizeof (bf) != 1) return 1; return *((unsigned char*) &bf) != 0xa5; } ], bf_lsbf=0, AC_MSG_ERROR([unsupported bitfield ordering]))) +fi if test "x$bf_lsbf" = "x1"; then AC_MSG_RESULT(LSBF) AC_DEFINE(BITFIELD_LSBF, [], [compiler does least-significant bit first in struct bitfields]) @@ -474,7 +527,7 @@ int has_timeout=sizeof(test.timeout);], esac AC_MSG_CHECKING(extern long timezone variable) -AC_TRY_RUN([ +AC_LINK_IFELSE([ #ifdef NEED_TIMEZONEVAR #define timezonevar 1 #endif diff --git a/lib/driver/gnu_linux.c b/lib/driver/gnu_linux.c index 5006bd5e..b2fe2fc0 100644 --- a/lib/driver/gnu_linux.c +++ b/lib/driver/gnu_linux.c @@ -1,5 +1,5 @@ /* - $Id: gnu_linux.c,v 1.30 2008/04/22 15:29:12 karl Exp $ + $Id: gnu_linux.c,v 1.31 2008/04/24 07:28:00 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: gnu_linux.c,v 1.30 2008/04/22 15:29:12 karl Exp $"; +static const char _rcsid[] = "$Id: gnu_linux.c,v 1.31 2008/04/24 07:28:00 rocky Exp $"; #ifdef HAVE_STRING_H #include @@ -45,9 +45,9 @@ static const char _rcsid[] = "$Id: gnu_linux.c,v 1.30 2008/04/22 15:29:12 karl E #ifdef HAVE_LINUX_CDROM -#include #include #include +#include #if defined(HAVE_LINUX_VERSION_H) # include diff --git a/lib/iso9660/xa.c b/lib/iso9660/xa.c index b9493ffd..cdc0d5e6 100644 --- a/lib/iso9660/xa.c +++ b/lib/iso9660/xa.c @@ -1,5 +1,5 @@ /* - $Id: xa.c,v 1.7 2008/04/18 16:02:10 karl Exp $ + $Id: xa.c,v 1.8 2008/04/24 07:28:00 rocky Exp $ Copyright (C) 2003, 2005, 2008 Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel @@ -162,11 +162,19 @@ iso9660_get_posix_filemode_from_xa(uint16_t i_perms) if (i_perms & XA_PERM_RUSR) mode |= S_IRUSR; if (i_perms & XA_PERM_XUSR) mode |= S_IXUSR; +#ifdef S_IRGRP if (i_perms & XA_PERM_RGRP) mode |= S_IRGRP; +#endif +#ifdef S_IXGRP if (i_perms & XA_PERM_XGRP) mode |= S_IXGRP; +#endif +#ifdef S_IROTH if (i_perms & XA_PERM_ROTH) mode |= S_IROTH; +#endif +#ifdef S_IXOTH if (i_perms & XA_PERM_XOTH) mode |= S_IXOTH; +#endif if (i_perms & XA_ATTR_DIRECTORY) mode |= S_IFDIR; diff --git a/lib/udf/udf.c b/lib/udf/udf.c index 9de137bb..b4cb00b4 100644 --- a/lib/udf/udf.c +++ b/lib/udf/udf.c @@ -1,5 +1,5 @@ /* - $Id: udf.c,v 1.12 2008/04/18 16:02:10 karl Exp $ + $Id: udf.c,v 1.13 2008/04/24 07:28:00 rocky Exp $ Copyright (C) 2005, 2008 Rocky Bernstein @@ -63,13 +63,17 @@ udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent) if (i_perms & FE_PERM_U_WRITE) mode |= S_IWUSR; if (i_perms & FE_PERM_U_EXEC) mode |= S_IXUSR; +#ifdef S_IRGRP if (i_perms & FE_PERM_G_READ) mode |= S_IRGRP; if (i_perms & FE_PERM_G_WRITE) mode |= S_IWGRP; if (i_perms & FE_PERM_G_EXEC) mode |= S_IXGRP; +#endif +#ifdef S_IROTH if (i_perms & FE_PERM_O_READ) mode |= S_IROTH; if (i_perms & FE_PERM_O_WRITE) mode |= S_IWOTH; if (i_perms & FE_PERM_O_EXEC) mode |= S_IXOTH; +#endif switch (udf_fe.icb_tag.file_type) { case ICBTAG_FILE_TYPE_DIRECTORY: @@ -78,24 +82,30 @@ udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent) case ICBTAG_FILE_TYPE_REGULAR: mode |= S_IFREG; break; +#ifdef S_IFLNK case ICBTAG_FILE_TYPE_SYMLINK: mode |= S_IFLNK; break; +#endif case ICBTAG_FILE_TYPE_CHAR: mode |= S_IFCHR; break; +#ifdef S_IFSOCK case ICBTAG_FILE_TYPE_SOCKET: mode |= S_IFSOCK; break; +#endif case ICBTAG_FILE_TYPE_BLOCK: mode |= S_IFBLK; break; default: ; }; +#ifdef S_ISUID if (i_flags & ICBTAG_FLAG_SETUID) mode |= S_ISUID; if (i_flags & ICBTAG_FLAG_SETGID) mode |= S_ISGID; if (i_flags & ICBTAG_FLAG_STICKY) mode |= S_ISVTX; +#endif } return mode; diff --git a/lib/udf/udf_time.c b/lib/udf/udf_time.c index 6ee98474..0a7dbc3a 100644 --- a/lib/udf/udf_time.c +++ b/lib/udf/udf_time.c @@ -1,5 +1,5 @@ /* - $Id: udf_time.c,v 1.9 2008/04/18 16:02:10 karl Exp $ + $Id: udf_time.c,v 1.10 2008/04/24 07:28:00 rocky Exp $ Copyright (C) 2005, 2008 Rocky Bernstein Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. @@ -148,7 +148,7 @@ udf_stamp_to_time(time_t *dest, long int *dest_usec, return dest; } - +#ifdef HAVE_STRUCT_TIMESPEC /*! Convert a UDF timestamp to a time_t. If microseconds are desired, use dest_usec. The return value is the same as dest. */ @@ -206,6 +206,7 @@ udf_timespec_to_stamp(const struct timespec ts, udf_timestamp_t *dest) - (dest->hundreds_of_microseconds * 100) ); return dest; } +#endif /*! Return the modification time of the file. diff --git a/src/Makefile.am b/src/Makefile.am index 7796c643..9421c8b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.45 2008/03/20 19:02:38 karl Exp $ +# $Id: Makefile.am,v 1.46 2008/04/24 07:28:00 rocky Exp $ # # Copyright (C) 2003, 2004, 2006, 2008 Rocky Bernstein # @@ -17,11 +17,6 @@ GETOPT_C = getopt.c getopt1.c -man_MANS = cd-drive.1 cd-info.1 cd-read.1 iso-read.1 iso-info.1 -EXTRA_DIST = cd-drive.help2man cd-info.help2man cd-read.help2man \ - iso-info.help2man iso-read.help2man $(GETOPT_C) getopt.h \ - $(man_MANS) - noinst_HEADERS = cddb.h getopt.h util.h #################################################### @@ -35,10 +30,6 @@ endif CDDB_LIBS=@CDDB_LIBS@ CDDA_PLAYER_LIBS=@CDDA_PLAYER_LIBS@ -$(man_MANS): %.1: % %.help2man - -$(HELP2MAN) --opt-include=$<.help2man --no-info --output=$@ ./$< -MOSTLYCLEANFILES = $(man_MANS) - if BUILD_CDDA_PLAYER cdda_player_SOURCES = cdda-player.c cddb.c cddb.h $(GETOPT_C) cdda_player_LDADD = $(LIBCDIO_LIBS) $(CDDB_LIBS) $(CDDA_PLAYER_LIBS) @@ -49,12 +40,14 @@ if BUILD_CD_DRIVE cd_drive_SOURCES = cd-drive.c util.c util.h $(GETOPT_C) cd_drive_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV) bin_cd_drive = cd-drive +man_cd_drive = cd-drive.1 endif if BUILD_CDINFO cd_info_SOURCES = cd-info.c cddb.c cddb.h util.c util.h $(GETOPT_C) cd_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(CDDB_LIBS) $(VCDINFO_LIBS) $(LIBICONV) bin_cd_info = cd-info +man_cd_info = cd-info.1 endif if BUILD_CDINFO_LINUX @@ -67,18 +60,21 @@ if BUILD_CD_READ cd_read_SOURCES = cd-read.c util.c util.h $(GETOPT_C) cd_read_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV) bin_cd_read = cd-read +man_cd_read = cd-read.1 endif if BUILD_ISO_INFO iso_info_SOURCES = iso-info.c util.c util.h $(GETOPT_C) iso_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV) bin_iso_info = iso-info +man_iso_info = iso-info.1 endif if BUILD_ISO_READ iso_read_SOURCES = iso-read.c util.c util.h $(GETOPT_C) iso_read_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV) bin_iso_read = iso-read +man_iso_read = iso-read.1 endif mmc_tool_SOURCES = mmc-tool.c util.c util.h $(GETOPT_C) @@ -88,3 +84,12 @@ bin_mmc_tool = mmc-tool bin_PROGRAMS = $(bin_cd_drive) $(bin_cd_info) $(bin_cdinfo_linux) $(bin_cd_read) $(bin_iso_info) $(bin_iso_read) $(bin_cdda_player) $(bin_mmc_tool) INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(VCDINFO_CFLAGS) $(CDDB_CFLAGS) + +man_MANS = $(man_cd_drive) $(man_cd_info) $(man_cd_read) $(man_iso_read) $(man_iso_info) +EXTRA_DIST = cd-drive.help2man cd-info.help2man cd-read.help2man \ + iso-info.help2man iso-read.help2man $(GETOPT_C) getopt.h \ + $(man_MANS) + +$(man_MANS): %.1: % %.help2man + -$(HELP2MAN) --opt-include=$<.help2man --no-info --output=$@ ./$< +MOSTLYCLEANFILES = $(man_MANS)