Makefile.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 8876 60edb019f0fe
child 9769 4716db508b0d
permissions -rw-r--r--
Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead

Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
     1 # Makefile to build and install the SDL library
     2 
     3 top_builddir = .
     4 srcdir  = @srcdir@
     5 objects = build
     6 prefix = @prefix@
     7 exec_prefix = @exec_prefix@
     8 bindir	= @bindir@
     9 libdir  = @libdir@
    10 includedir = @includedir@
    11 datarootdir = @datarootdir@
    12 datadir	= @datadir@
    13 auxdir	= @ac_aux_dir@
    14 distpath = $(srcdir)/..
    15 distdir = SDL2-@SDL_VERSION@
    16 distfile = $(distdir).tar.gz
    17 
    18 @SET_MAKE@
    19 SHELL	= @SHELL@
    20 CC      = @CC@
    21 INCLUDE = @INCLUDE@
    22 CFLAGS  = @BUILD_CFLAGS@
    23 EXTRA_CFLAGS = @EXTRA_CFLAGS@
    24 LDFLAGS = @BUILD_LDFLAGS@
    25 EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
    26 LIBTOOL = @LIBTOOL@
    27 INSTALL = @INSTALL@
    28 AR	= @AR@
    29 RANLIB	= @RANLIB@
    30 WINDRES	= @WINDRES@
    31 
    32 TARGET  = libSDL2.la
    33 OBJECTS = @OBJECTS@
    34 VERSION_OBJECTS = @VERSION_OBJECTS@
    35 
    36 SDLMAIN_TARGET = libSDL2main.a
    37 SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
    38 
    39 SDLTEST_TARGET = libSDL2_test.a
    40 SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
    41 
    42 SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake configure configure.in debian include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC Xcode Xcode-iOS
    43 GEN_DIST = SDL2.spec
    44 
    45 ifneq ($V,1)
    46 RUN_CMD_AR     = @echo "  AR    " $@;
    47 RUN_CMD_CC     = @echo "  CC    " $@;
    48 RUN_CMD_CXX    = @echo "  CXX   " $@;
    49 RUN_CMD_LTLINK = @echo "  LTLINK" $@;
    50 RUN_CMD_RANLIB = @echo "  RANLIB" $@;
    51 LIBTOOL += --quiet
    52 endif
    53 
    54 HDRS = \
    55 	SDL.h \
    56 	SDL_assert.h \
    57 	SDL_atomic.h \
    58 	SDL_audio.h \
    59 	SDL_bits.h \
    60 	SDL_blendmode.h \
    61 	SDL_clipboard.h \
    62 	SDL_cpuinfo.h \
    63 	SDL_egl.h \
    64 	SDL_endian.h \
    65 	SDL_error.h \
    66 	SDL_events.h \
    67 	SDL_filesystem.h \
    68 	SDL_gamecontroller.h \
    69 	SDL_gesture.h \
    70 	SDL_haptic.h \
    71 	SDL_hints.h \
    72 	SDL_joystick.h \
    73 	SDL_keyboard.h \
    74 	SDL_keycode.h \
    75 	SDL_loadso.h \
    76 	SDL_log.h \
    77 	SDL_main.h \
    78 	SDL_messagebox.h \
    79 	SDL_mouse.h \
    80 	SDL_mutex.h \
    81 	SDL_name.h \
    82 	SDL_opengl.h \
    83 	SDL_opengl_glext.h \
    84 	SDL_opengles.h \
    85 	SDL_opengles2_gl2ext.h \
    86 	SDL_opengles2_gl2.h \
    87 	SDL_opengles2_gl2platform.h \
    88 	SDL_opengles2.h \
    89 	SDL_opengles2_khrplatform.h \
    90 	SDL_pixels.h \
    91 	SDL_platform.h \
    92 	SDL_power.h \
    93 	SDL_quit.h \
    94 	SDL_rect.h \
    95 	SDL_render.h \
    96 	SDL_rwops.h \
    97 	SDL_scancode.h \
    98 	SDL_shape.h \
    99 	SDL_stdinc.h \
   100 	SDL_surface.h \
   101 	SDL_system.h \
   102 	SDL_syswm.h \
   103 	SDL_thread.h \
   104 	SDL_timer.h \
   105 	SDL_touch.h \
   106 	SDL_types.h \
   107 	SDL_version.h \
   108 	SDL_video.h \
   109 	begin_code.h \
   110 	close_code.h
   111 
   112 SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test)
   113 
   114 LT_AGE      = @LT_AGE@
   115 LT_CURRENT  = @LT_CURRENT@
   116 LT_RELEASE  = @LT_RELEASE@
   117 LT_REVISION = @LT_REVISION@
   118 LT_LDFLAGS  = -no-undefined -rpath $(DESTDIR)$(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
   119 
   120 all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
   121 
   122 $(srcdir)/configure: $(srcdir)/configure.in
   123 	@echo "Warning, configure.in is out of date"
   124 	#(cd $(srcdir) && sh autogen.sh && sh configure)
   125 	@sleep 3
   126 
   127 Makefile: $(srcdir)/Makefile.in
   128 	$(SHELL) config.status $@
   129 
   130 Makefile.in:;
   131 
   132 $(objects):
   133 	$(SHELL) $(auxdir)/mkinstalldirs $@
   134 
   135 update-revision:
   136 	$(SHELL) $(auxdir)/updaterev.sh
   137 
   138 .PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d)
   139 
   140 $(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
   141 	$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
   142 
   143 $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
   144 	$(RUN_CMD_AR)$(AR) cru $@ $(SDLMAIN_OBJECTS)
   145 	$(RUN_CMD_RANLIB)$(RANLIB) $@
   146 
   147 $(objects)/$(SDLTEST_TARGET): $(SDLTEST_OBJECTS)
   148 	$(RUN_CMD_AR)$(AR) cru $@ $(SDLTEST_OBJECTS)
   149 	$(RUN_CMD_RANLIB)$(RANLIB) $@
   150 
   151 install: all install-bin install-hdrs install-lib install-data
   152 install-bin:
   153 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir)
   154 	$(INSTALL) -m 755 sdl2-config $(DESTDIR)$(bindir)/sdl2-config
   155 install-hdrs: update-revision
   156 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL2
   157 	for file in $(HDRS) $(SDLTEST_HDRS); do \
   158 	    $(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL2/$$file; \
   159 	done
   160 	$(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL2/SDL_config.h
   161 	if test -f include/SDL_revision.h; then \
   162 	    $(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
   163 	else \
   164 	    $(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
   165 	fi
   166 
   167 install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
   168 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
   169 	$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
   170 	$(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   171 	$(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   172 	$(INSTALL) -m 644 $(objects)/$(SDLTEST_TARGET) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   173 	$(RANLIB) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   174 install-data:
   175 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
   176 	$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
   177 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
   178 	$(INSTALL) -m 644 sdl2.pc $(DESTDIR)$(libdir)/pkgconfig
   179 
   180 uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
   181 uninstall-bin:
   182 	rm -f $(DESTDIR)$(bindir)/sdl2-config
   183 uninstall-hdrs:
   184 	for file in $(HDRS) $(SDLTEST_HDRS); do \
   185 	    rm -f $(DESTDIR)$(includedir)/SDL2/$$file; \
   186 	done
   187 	rm -f $(DESTDIR)$(includedir)/SDL2/SDL_config.h
   188 	rm -f $(DESTDIR)$(includedir)/SDL2/SDL_revision.h
   189 	-rmdir $(DESTDIR)$(includedir)/SDL2
   190 uninstall-lib:
   191 	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
   192 	rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
   193 	rm -f $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
   194 uninstall-data:
   195 	rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
   196 	rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc
   197 
   198 clean:
   199 	rm -rf $(objects)
   200 	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
   201 
   202 distclean: clean
   203 	rm -f Makefile Makefile.rules sdl2-config
   204 	rm -f config.status config.cache config.log libtool
   205 	rm -rf $(srcdir)/autom4te*
   206 	find $(srcdir) \( \
   207 	    -name '*~' -o \
   208 	    -name '*.bak' -o \
   209 	    -name '*.old' -o \
   210 	    -name '*.rej' -o \
   211 	    -name '*.orig' -o \
   212 	    -name '.#*' \) \
   213 	    -exec rm -f {} \;
   214 	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
   215 
   216 dist $(distfile):
   217 	$(SHELL) $(auxdir)/mkinstalldirs $(distdir)
   218 	(cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -)
   219 	tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -)
   220 	find $(distdir) \( \
   221 	    -name '*~' -o \
   222 	    -name '*.bak' -o \
   223 	    -name '*.old' -o \
   224 	    -name '*.rej' -o \
   225 	    -name '*.orig' -o \
   226 	    -name '.#*' \) \
   227 	    -exec rm -f {} \;
   228 	if test -f $(distdir)/test/Makefile; then (cd $(distdir)/test && make distclean); fi
   229 	(cd $(distdir); build-scripts/updaterev.sh)
   230 	tar cvf - $(distdir) | gzip --best >$(distfile)
   231 	rm -rf $(distdir)
   232 
   233 rpm: $(distfile)
   234 	rpmbuild -ta $?