Enable utf8 I/O stuff when compiling with MinGW.
authorErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 1 Apr 2013 08:57:13 +0000 (19:57 +1100)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 1 Apr 2013 08:57:13 +0000 (19:57 +1100)
15 files changed:
.gitignore
configure.ac
include/share/compat.h
include/share/win_utf8_io.h
src/Makefile.am
src/flac/iffscan.c
src/flac/main.c
src/flac/vorbiscomment.c
src/libFLAC/Makefile.am
src/metaflac/main.c
src/metaflac/operations_shorthand_vorbiscomment.c
src/share/Makefile.am
src/share/win_utf8_io/win_utf8_io.c
src/test_libFLAC/Makefile.am
src/test_streams/Makefile.am

index d277845..a24f4e4 100644 (file)
@@ -69,3 +69,4 @@ test/metaflac-test-files/out.meta
 test/metaflac.flac
 test/picture.diff
 test/picture.log
+.dirstamp
index bda568f..12e2907 100644 (file)
@@ -124,16 +124,19 @@ case "$host" in
 esac
 AM_CONDITIONAL(FLaC__CPU_PPC_SPE, test "x$abi_spe" = xtrue)
 
+os_is_windows=no
 case "$host" in
        *-*-cygwin|*mingw*|*emx*)
                # define this variable for enabling strict exports with libtool; for now, it's supported by Win32 and OS/2
                LT_NO_UNDEFINED="-no-undefined"
+               os_is_windows=yes
                ;;
        *)
                LT_NO_UNDEFINED=
                ;;
 esac
 AC_SUBST(LT_NO_UNDEFINED)
+AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes)
 
 case "$host" in
        *-pc-linux-gnu)
index 214990c..cf83bfe 100644 (file)
 #  endif
 #endif /* defined _MSC_VER */
 
-#ifdef FLAC__STRINGS_IN_UTF8 /* all char* strings are in UTF-8 format. Added to support Unicode files on Windows */
+#ifdef _WIN32
+/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */
 #include "share/win_utf8_io.h"
 
 #define flac_printf printf_utf8
index caf7cf9..598f187 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef FLAC__STRINGS_IN_UTF8
+#ifdef _WIN32
 
 #ifndef flac__win_utf8_io_h
 #define flac__win_utf8_io_h
index e833eb3..22615d7 100644 (file)
@@ -24,8 +24,8 @@ CPPLIBS_DIRS = libFLAC++ test_libFLAC++
 endif
 
 SUBDIRS = \
-       libFLAC \
        share \
+       libFLAC \
        flac \
        metaflac \
        monkeys_audio_utilities \
index cf0fb93..2a8a0ce 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
        size_t i;
        FLAC__uint32 size;
 
-#ifdef FLAC__STRINGS_IN_UTF8
+#ifdef _WIN32
        if (get_utf8_argv(&argc, &argv) != 0) {
                fprintf(stderr, "%ERROR: failed to convert command line parameters to UTF-8\n");
                return 1;
index 7bbe460..62e54a4 100644 (file)
@@ -304,7 +304,7 @@ int main(int argc, char *argv[])
        _response(&argc, &argv);
        _wildcard(&argc, &argv);
 #endif
-#ifdef FLAC__STRINGS_IN_UTF8
+#ifdef _WIN32
        if (get_utf8_argv(&argc, &argv) != 0) {
                fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n");
                return 1;
index db6d9ad..5a9f619 100644 (file)
@@ -170,7 +170,7 @@ static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcFie
        }
        else {
                FLAC__bool needs_free = false;
-#ifdef FLAC__STRINGS_IN_UTF8 /* everything in UTF-8 already. Must not alter */
+#ifdef _WIN32 /* everything in UTF-8 already. Must not alter */
                entry.entry = (FLAC__byte *)field->field;
 #else
                if(raw) {
index 7928abf..aa0b8b6 100644 (file)
@@ -82,7 +82,11 @@ endif
 endif
 endif
 
-libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
+libFLAC_la_LIBADD = $(win_utf8_lib) $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm
 
 SUBDIRS = $(ARCH_SUBDIRS) include .
 
@@ -106,6 +110,7 @@ extra_ogg_sources = \
        ogg_helper.c \
        ogg_mapping.c
 endif
+
 # see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention
 libFLAC_la_LDFLAGS = -version-info 11:0:3 $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@
 
index e85d1c2..03e42c7 100644 (file)
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
        _response(&argc, &argv);
        _wildcard(&argc, &argv);
 #endif
-#ifdef FLAC__STRINGS_IN_UTF8
+#ifdef _WIN32
        if (get_utf8_argv(&argc, &argv) != 0) {
                fprintf(stderr, "%ERROR: failed to convert command line parameters to UTF-8\n");
                return 1;
index 61537bf..3d381a5 100644 (file)
@@ -245,7 +245,7 @@ FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const
        }
        else {
                FLAC__bool needs_free = false;
-#ifdef FLAC__STRINGS_IN_UTF8 /* do not convert anything or things will break */
+#ifdef _WIN32 /* do not convert anything or things will break */
                entry.entry = (FLAC__byte *)field->field;
 #else
                if(raw) {
index 8c32588..bb66122 100644 (file)
@@ -45,10 +45,18 @@ noinst_LTLIBRARIES = \
        getopt/libgetopt.la \
        grabbag/libgrabbag.la \
        utf8/libutf8.la \
+       win_utf8_io/libwin_utf8_io.la \
        replaygain_analysis/libreplaygain_analysis.la \
        replaygain_synthesis/libreplaygain_synthesis.la
 
 
+if OS_IS_WINDOWS
+win_utf8_io_libwin_utf8_io_la_SOURCES =        win_utf8_io/win_utf8_io.c
+else
+win_utf8_io_libwin_utf8_io_la_SOURCES =
+endif
+
+
 getopt_libgetopt_la_SOURCES = getopt/getopt.c getopt/getopt1.c
 
 grabbag_libgrabbag_la_SOURCES = \
@@ -64,8 +72,7 @@ utf8_libutf8_la_SOURCES = \
        utf8/charset.c \
        utf8/charset.h \
        utf8/iconvert.c \
-       utf8/utf8.c \
-       win_utf8_io/win_utf8_io.c
+       utf8/utf8.c
 
 replaygain_analysis_libreplaygain_analysis_la_SOURCES = replaygain_analysis/replaygain_analysis.c
 
index 0699f19..12cfd97 100644 (file)
@@ -1,4 +1,3 @@
-#ifdef FLAC__STRINGS_IN_UTF8
 
 #include <stdio.h>
 #include <sys/stat.h>
@@ -12,6 +11,7 @@
 #include "share/win_utf8_io.h"
 
 /* convert WCHAR stored Unicode string to UTF-8. Caller is responsible for freeing memory */
+static
 char *utf8_from_wchar(const wchar_t *wstr)
 {
        char *utf8str;
@@ -29,6 +29,7 @@ char *utf8_from_wchar(const wchar_t *wstr)
 }
 
 /* convert UTF-8 back to WCHAR. Caller is responsible for freeing memory */
+static
 wchar_t *wchar_from_utf8(const char *str)
 {
        wchar_t *widestr;
@@ -256,5 +257,3 @@ int rename_utf8(const char *oldname, const char *newname)
 
        return ret;
 }
-
-#endif
index e6136e7..cd75472 100644 (file)
@@ -22,12 +22,17 @@ EXTRA_DIST = \
 AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include
 
 noinst_PROGRAMS = test_libFLAC
+
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 test_libFLAC_LDADD = \
        $(top_builddir)/src/share/grabbag/libgrabbag.la \
        $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
        $(top_builddir)/src/test_libs_common/libtest_libs_common.la \
        $(top_builddir)/src/libFLAC/libFLAC-static.la \
-       @OGG_LIBS@ \
+       $(win_utf8_lib) @OGG_LIBS@ \
        -lm
 
 test_libFLAC_SOURCES = \
index de0d693..7942dc5 100644 (file)
@@ -24,6 +24,10 @@ noinst_PROGRAMS = test_streams
 test_streams_SOURCES = \
        main.c
 
-test_streams_LDADD =  $(top_builddir)/src/share/grabbag/libgrabbag.la -lm
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
+test_streams_LDADD = $(win_utf8_lib) $(top_builddir)/src/share/grabbag/libgrabbag.la -lm
 
 CLEANFILES = test_streams.exe