Commits

rmtew committed 8ecd86b

Mingw SDL2 fixes.

  • Participants
  • Parent commits 4a5b46f

Comments (0)

Files changed (2)

makefiles/makefile-mingw-sdl2

 SDL_LIBS=-L $(SDL_DIR)/lib/mingw -lSDL2 -lm -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid
 
 # ZLIB
-ZLIB_DIR=dependencies/zlib-1.2.3
-ZLIB_FLAGS=-I $(ZLIB_DIR)/include
-ZLIB_LIBS=$(ZLIB_DIR)/lib/mingw/libz.a
+ZLIB_FLAGS=-I src/zlib
+ZLIB_LIBS=lib/libz.a
 
 # OPENGL
 OPENGL_LIB=-lopengl32
 
 CFLAGS=$(FLAGS) -I$(INCDIR) -I$(INCDIR)/gui $(SDL_FLAGS) $(ZLIB_FLAGS) -Wall -fno-strict-aliasing -DTCOD_SDL2 -DNO_OPENGL
-# -ansi
+MINGW_FLAGS=-static-libgcc -static-libstdc++
 CC=mingw32-gcc
 CPP=mingw32-g++
 UPX=dependencies/upx/win/upx.exe
 .SUFFIXES: .dll .a .o .h .c .hpp .cpp
 
+#compilation rules
+$(TEMP)/libtcod/debug/gui/%.o : $(SRCDIR)/gui/%.cpp
+	@echo Compiling debug $(basename $<).cpp
+	@$(CPP) $(CFLAGS) -g -DLIBTCOD_GUI_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/debug/%.o : $(SRCDIR)/%.cpp
+	@echo Compiling debug $(basename $<).cpp
+	@$(CPP) $(CFLAGS) -g -DLIBTCOD_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/debug/%.o : $(SRCDIR)/%.c
+	@ echo Compiling debug $(basename $<).c
+	@$(CC) $(CFLAGS) -g -DLIBTCOD_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/release/gui/%.o : $(SRCDIR)/gui/%.cpp
+	@ echo Compiling release $(basename $<).cpp
+	@$(CPP) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_GUI_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/release/%.o : $(SRCDIR)/%.cpp
+	@ echo Compiling release $(basename $<).cpp
+	@$(CPP) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/release/%.o : $(SRCDIR)/%.c
+	@ echo Compiling release $(basename $<).c
+	@$(CC) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_EXPORTS -o $@ -c $< 
+$(TEMP)/libtcod/zlib/%.o : $(SRCDIR)/zlib/%.c
+	@ echo Compiling zlib $(basename $<).c
+	@$(CC) $(CFLAGS) -DNDEBUG -O2 -s -o $@ -c $< 
 
-$(TEMP)/libtcod/debug/gui/%.o : $(SRCDIR)/gui/%.cpp
-	$(CPP) $(CFLAGS) -g -DLIBTCOD_GUI_EXPORTS -o $@ -c $< 
-$(TEMP)/libtcod/debug/%.o : $(SRCDIR)/%.cpp
-	$(CPP) $(CFLAGS) -g -DLIBTCOD_EXPORTS -o $@ -c $< 
-$(TEMP)/libtcod/debug/%.o : $(SRCDIR)/%.c
-	$(CC) $(CFLAGS) -g -DLIBTCOD_EXPORTS -o $@ -c $< 
-$(TEMP)/libtcod/release/gui/%.o : $(SRCDIR)/gui/%.cpp
-	$(CPP) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_GUI_EXPORTS -o $@ -c $< 
-$(TEMP)/libtcod/release/%.o : $(SRCDIR)/%.cpp
-	$(CPP) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_EXPORTS -o $@ -c $< 
-$(TEMP)/libtcod/release/%.o : $(SRCDIR)/%.c
-	$(CC) $(CFLAGS) -DNDEBUG -O2 -s -DLIBTCOD_EXPORTS -o $@ -c $< 
+ZLIBOBJS=$(addprefix $(TEMP)/libtcod/zlib/, \
+	adler32.o \
+	crc32.o \
+	deflate.o \
+	infback.o \
+	inffast.o \
+	inflate.o \
+	inftrees.o \
+	trees.o \
+	zutil.o \
+	compress.o \
+	uncompr.o \
+	gzclose.o \
+	gzlib.o \
+	gzread.o \
+	gzwrite.o )
 
-LIBOBJS_DEBUG= \
-	$(TEMP)/libtcod/debug/bresenham_c.o \
-	$(TEMP)/libtcod/debug/bsp_c.o \
-	$(TEMP)/libtcod/debug/color_c.o \
-	$(TEMP)/libtcod/debug/console_c.o \
-	$(TEMP)/libtcod/debug/fov_c.o \
-	$(TEMP)/libtcod/debug/fov_circular_raycasting.o \
-	$(TEMP)/libtcod/debug/fov_diamond_raycasting.o \
-	$(TEMP)/libtcod/debug/fov_recursive_shadowcasting.o \
-	$(TEMP)/libtcod/debug/fov_permissive2.o \
-	$(TEMP)/libtcod/debug/fov_restrictive.o \
-	$(TEMP)/libtcod/debug/heightmap_c.o \
-	$(TEMP)/libtcod/debug/image_c.o \
-	$(TEMP)/libtcod/debug/lex_c.o \
-	$(TEMP)/libtcod/debug/list_c.o \
-	$(TEMP)/libtcod/debug/mersenne_c.o \
-	$(TEMP)/libtcod/debug/noise_c.o \
-	$(TEMP)/libtcod/debug/parser_c.o \
-	$(TEMP)/libtcod/debug/path_c.o \
-	$(TEMP)/libtcod/debug/sys_c.o \
-	$(TEMP)/libtcod/debug/sys_sdl_c.o \
-	$(TEMP)/libtcod/debug/sys_sdl_img_bmp.o \
-	$(TEMP)/libtcod/debug/sys_sdl_img_png.o \
-	$(TEMP)/libtcod/debug/tree_c.o \
-	$(TEMP)/libtcod/debug/txtfield_c.o \
-	$(TEMP)/libtcod/debug/wrappers.o \
-	$(TEMP)/libtcod/debug/zip_c.o \
-	$(TEMP)/libtcod/debug/namegen_c.o \
-	$(TEMP)/libtcod/debug/bresenham.o \
-	$(TEMP)/libtcod/debug/bsp.o \
-	$(TEMP)/libtcod/debug/color.o \
-	$(TEMP)/libtcod/debug/console.o \
-	$(TEMP)/libtcod/debug/fov.o \
-	$(TEMP)/libtcod/debug/heightmap.o \
-	$(TEMP)/libtcod/debug/image.o \
-	$(TEMP)/libtcod/debug/lex.o \
-	$(TEMP)/libtcod/debug/mersenne.o \
-	$(TEMP)/libtcod/debug/mouse.o \
-	$(TEMP)/libtcod/debug/noise.o \
-	$(TEMP)/libtcod/debug/parser.o \
-	$(TEMP)/libtcod/debug/path.o \
-	$(TEMP)/libtcod/debug/sys.o \
-	$(TEMP)/libtcod/debug/sys_opengl_c.o \
-	$(TEMP)/libtcod/debug/txtfield.o \
-	$(TEMP)/libtcod/debug/zip.o \
-	$(TEMP)/libtcod/debug/namegen.o \
-	$(TEMP)/libtcod/debug/png/lodepng.o
+LIBOBJS= \
+	bresenham_c.o \
+	bsp_c.o \
+	color_c.o \
+	console_c.o \
+	fov_c.o \
+	fov_circular_raycasting.o \
+	fov_diamond_raycasting.o \
+	fov_recursive_shadowcasting.o \
+	fov_permissive2.o \
+	fov_restrictive.o \
+	heightmap_c.o \
+	image_c.o \
+	lex_c.o \
+	list_c.o \
+	mersenne_c.o \
+	noise_c.o \
+	parser_c.o \
+	path_c.o \
+	sys_c.o \
+	sys_sdl_c.o \
+	sys_sdl_img_bmp.o \
+	sys_sdl_img_png.o \
+	tree_c.o \
+	txtfield_c.o \
+	wrappers.o \
+	zip_c.o \
+	namegen_c.o \
+	bresenham.o \
+	bsp.o \
+	color.o \
+	console.o \
+	fov.o \
+	heightmap.o \
+	image.o \
+	lex.o \
+	mersenne.o \
+	mouse.o \
+	noise.o \
+	parser.o \
+	path.o \
+	sys.o \
+	sys_opengl_c.o \
+	txtfield.o \
+	zip.o \
+	namegen.o \
+	png/lodepng.o
 
-GUIOBJS_DEBUG= \
-	$(TEMP)/libtcod/debug/gui/button.o \
-	$(TEMP)/libtcod/debug/gui/container.o \
-	$(TEMP)/libtcod/debug/gui/flatlist.o \
-	$(TEMP)/libtcod/debug/gui/hbox.o \
-	$(TEMP)/libtcod/debug/gui/image.o \
-	$(TEMP)/libtcod/debug/gui/label.o \
-	$(TEMP)/libtcod/debug/gui/radiobutton.o \
-	$(TEMP)/libtcod/debug/gui/slider.o \
-	$(TEMP)/libtcod/debug/gui/statusbar.o \
-	$(TEMP)/libtcod/debug/gui/textbox.o \
-	$(TEMP)/libtcod/debug/gui/togglebutton.o \
-	$(TEMP)/libtcod/debug/gui/toolbar.o \
-	$(TEMP)/libtcod/debug/gui/vbox.o \
-	$(TEMP)/libtcod/debug/gui/widget.o
+GUIOBJS= \
+	gui/button.o \
+	gui/container.o \
+	gui/flatlist.o \
+	gui/hbox.o \
+	gui/image.o \
+	gui/label.o \
+	gui/radiobutton.o \
+	gui/slider.o \
+	gui/statusbar.o \
+	gui/textbox.o \
+	gui/togglebutton.o \
+	gui/toolbar.o \
+	gui/vbox.o \
+	gui/widget.o
 
-LIBOBJS_RELEASE= \
-	$(TEMP)/libtcod/release/bresenham_c.o \
-	$(TEMP)/libtcod/release/bsp_c.o \
-	$(TEMP)/libtcod/release/color_c.o \
-	$(TEMP)/libtcod/release/console_c.o \
-	$(TEMP)/libtcod/release/fov_c.o \
-	$(TEMP)/libtcod/release/fov_circular_raycasting.o \
-	$(TEMP)/libtcod/release/fov_diamond_raycasting.o \
-	$(TEMP)/libtcod/release/fov_recursive_shadowcasting.o \
-	$(TEMP)/libtcod/release/fov_permissive2.o \
-	$(TEMP)/libtcod/release/fov_restrictive.o \
-	$(TEMP)/libtcod/release/heightmap_c.o \
-	$(TEMP)/libtcod/release/image_c.o \
-	$(TEMP)/libtcod/release/lex_c.o \
-	$(TEMP)/libtcod/release/list_c.o \
-	$(TEMP)/libtcod/release/mersenne_c.o \
-	$(TEMP)/libtcod/release/noise_c.o \
-	$(TEMP)/libtcod/release/parser_c.o \
-	$(TEMP)/libtcod/release/path_c.o \
-	$(TEMP)/libtcod/release/sys_c.o \
-	$(TEMP)/libtcod/release/sys_sdl_c.o \
-	$(TEMP)/libtcod/release/sys_sdl_img_bmp.o \
-	$(TEMP)/libtcod/release/sys_sdl_img_png.o \
-	$(TEMP)/libtcod/release/tree_c.o \
-	$(TEMP)/libtcod/release/txtfield_c.o \
-	$(TEMP)/libtcod/release/wrappers.o \
-	$(TEMP)/libtcod/release/zip_c.o \
-	$(TEMP)/libtcod/release/namegen_c.o \
-	$(TEMP)/libtcod/release/bresenham.o \
-	$(TEMP)/libtcod/release/bsp.o \
-	$(TEMP)/libtcod/release/color.o \
-	$(TEMP)/libtcod/release/console.o \
-	$(TEMP)/libtcod/release/fov.o \
-	$(TEMP)/libtcod/release/heightmap.o \
-	$(TEMP)/libtcod/release/image.o \
-	$(TEMP)/libtcod/release/lex.o \
-	$(TEMP)/libtcod/release/mersenne.o \
-	$(TEMP)/libtcod/release/mouse.o \
-	$(TEMP)/libtcod/release/noise.o \
-	$(TEMP)/libtcod/release/parser.o \
-	$(TEMP)/libtcod/release/path.o \
-	$(TEMP)/libtcod/release/sys.o \
-	$(TEMP)/libtcod/release/sys_opengl_c.o \
-	$(TEMP)/libtcod/release/txtfield.o \
-	$(TEMP)/libtcod/release/zip.o \
-	$(TEMP)/libtcod/release/namegen.o \
-	$(TEMP)/libtcod/release/png/lodepng.o
 
-GUIOBJS_RELEASE= \
-	$(TEMP)/libtcod/release/gui/button.o \
-	$(TEMP)/libtcod/release/gui/container.o \
-	$(TEMP)/libtcod/release/gui/flatlist.o \
-	$(TEMP)/libtcod/release/gui/hbox.o \
-	$(TEMP)/libtcod/release/gui/image.o \
-	$(TEMP)/libtcod/release/gui/label.o \
-	$(TEMP)/libtcod/release/gui/radiobutton.o \
-	$(TEMP)/libtcod/release/gui/slider.o \
-	$(TEMP)/libtcod/release/gui/statusbar.o \
-	$(TEMP)/libtcod/release/gui/textbox.o \
-	$(TEMP)/libtcod/release/gui/togglebutton.o \
-	$(TEMP)/libtcod/release/gui/toolbar.o \
-	$(TEMP)/libtcod/release/gui/vbox.o \
-	$(TEMP)/libtcod/release/gui/widget.o
+LIBOBJS_DEBUG=$(addprefix $(TEMP)/libtcod/debug/, $(LIBOBJS) )
+GUIOBJS_DEBUG=$(addprefix $(TEMP)/libtcod/debug/, $(GUIOBJS) )
+LIBOBJS_RELEASE=$(addprefix $(TEMP)/libtcod/release/, $(LIBOBJS) )
+GUIOBJS_RELEASE=$(addprefix $(TEMP)/libtcod/release/, $(GUIOBJS) )
 	
 all : debug release
 
 debug : libtcod-mingw-debug.dll libtcod-gui-mingw-debug.dll
 
 $(TEMP)/libtcod/debug/png :
-	mkdir -p $@
+	@mkdir -p $@
 
 $(TEMP)/libtcod/debug/gui :
-	mkdir -p $@
+	@mkdir -p $@
 
 $(TEMP)/libtcod/release/png :
-	mkdir -p $@
+	@mkdir -p $@
 
 $(TEMP)/libtcod/release/gui :
-	mkdir -p $@
+	@mkdir -p $@
+
+$(TEMP)/libtcod/zlib :
+	@mkdir -p $@
 
 lib/ :
-	mkdir -p $@
+	@mkdir -p $@
 
 libtcod-mingw.a : $(LIBOBJS_DEBUG)
-	ar r $@ $(LIBOBJS_DEBUG)
+	@ar r $@ $(LIBOBJS_DEBUG)
+
+lib/libz.a : $(TEMP)/libtcod/zlib $(ZLIBOBJS)
+	@ar r $@ $(ZLIBOBJS)
 	
-libtcod-mingw.dll : lib/ $(TEMP)/libtcod/release/png $(LIBOBJS_RELEASE)
-	$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-mingw.a $(LIBOBJS_RELEASE) $(ZLIB_LIBS) $(SDL_LIBS) $(OPENGL_LIB) -static-libgcc -static-libstdc++
+libtcod-mingw.dll : lib/ $(TEMP)/libtcod/release/png $(LIBOBJS_RELEASE) lib/libz.a
+	@echo Linking $@
+	@$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-mingw.a $(LIBOBJS_RELEASE) $(ZLIB_LIBS) $(SDL_LIBS) $(OPENGL_LIB) $(MINGW_FLAGS)
 
-libtcod-gui-mingw.dll : $(TEMP)/libtcod/release/gui $(GUIOBJS_RELEASE)
-	$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-gui-mingw.a $(GUIOBJS_RELEASE) -Llib -ltcod-mingw -static-libgcc -static-libstdc++
+libtcod-gui-mingw.dll : lib/ $(TEMP)/libtcod/release/gui $(GUIOBJS_RELEASE) lib/libz.a
+	@echo Linking $@
+	@$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-gui-mingw.a $(GUIOBJS_RELEASE) -Llib -ltcod-mingw $(MINGW_FLAGS)
 
-libtcod-mingw-debug.dll : lib/ $(TEMP)/libtcod/debug/png $(LIBOBJS_DEBUG)
-	$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-mingw-debug.a $(LIBOBJS_DEBUG) $(ZLIB_LIBS) $(SDL_LIBS) $(OPENGL_LIB) -static-libgcc -static-libstdc++
+libtcod-mingw-debug.dll : lib/ $(TEMP)/libtcod/debug/png $(LIBOBJS_DEBUG) lib/libz.a
+	@echo Linking $@
+	@$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-mingw-debug.a $(LIBOBJS_DEBUG) $(ZLIB_LIBS) $(SDL_LIBS) $(OPENGL_LIB) $(MINGW_FLAGS)
 
-libtcod-gui-mingw-debug.dll : $(TEMP)/libtcod/debug/gui $(GUIOBJS_DEBUG)
-	$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-gui-mingw-debug.a $(GUIOBJS_DEBUG) -Llib -ltcod-mingw-debug -static-libgcc -static-libstdc++
+libtcod-gui-mingw-debug.dll : lib/ $(TEMP)/libtcod/debug/gui $(GUIOBJS_DEBUG) lib/libz.a
+	@echo Linking $@
+	@$(CPP) -mwindows -o $@ -shared -Wl,--out-implib,lib/libtcod-gui-mingw-debug.a $(GUIOBJS_DEBUG) -Llib -ltcod-mingw-debug $(MINGW_FLAGS)
 
 upx :
-	$(UPX) libtcod-mingw.dll libtcod-gui-mingw.dll
+	@echo Compressing...
+	@$(UPX) libtcod-mingw.dll libtcod-gui-mingw.dll
 
 clean :
-	rm -f $(LIBOBJS_RELEASE) $(GUIOBJS_RELEASE) libtcod-mingw.dll lib/libtcod-mingw.a libtcod-gui-mingw.dll lib/libtcod-gui-mingw.a libtcodpy.pyc $(LIBOBJS_DEBUG) $(GUIOBJS_DEBUG) libtcod-mingw-debug.dll lib/libtcod-mingw-debug.a libtcod-gui-mingw-debug.dll lib/libtcod-gui-mingw-debug.a 
+	@rm -f $(LIBOBJS_RELEASE) $(GUIOBJS_RELEASE) libtcod-mingw.dll lib/libtcod-mingw.a libtcod-gui-mingw.dll lib/libtcod-gui-mingw.a libtcodpy.pyc $(LIBOBJS_DEBUG) $(GUIOBJS_DEBUG) libtcod-mingw-debug.dll lib/libtcod-mingw-debug.a libtcod-gui-mingw-debug.dll lib/libtcod-gui-mingw-debug.a 
 
+cleanall : clean
+	@rm -f $(ZLIBOBJS)
 			}
 		}
 		break;
+#if !SDL_VERSION_ATLEAST(2,0,0)	
 		case SDL_ACTIVEEVENT : 
 			switch(ev->active.state) {
 				case SDL_APPMOUSEFOCUS : TCOD_ctx.app_has_mouse_focus=ev->active.gain; break;
 				default : TCOD_ctx.app_is_active=ev->active.gain; break;
 			}
 		break;
+#endif
 #ifdef TCOD_TOUCH_INPUT
 		/*
 		 * Need to distinguish between:
 		break;
 #if SDL_VERSION_ATLEAST(2,0,0)
 		case SDL_WINDOWEVENT :
-#ifdef TCOD_ANDROID
 			/* At this point, there are some corner cases that need dealing with.  So log this. */
 			/* printf("SDL2 WINDOWEVENT: 0x%04x\n", ev->window.event); */
 			switch (ev->window.event) {
+#ifdef TCOD_ANDROID
 			case SDL_WINDOWEVENT_SIZE_CHANGED:
 			{
 				/* printf("SDL2 WINDOWEVENT (SDL_WINDOWEVENT_SIZE_CHANGED): 0x%04x w=%d h=%d\n", ev->window.event, ev->window.data1, ev->window.data2); */
 					scale_data.force_recalc = 1;
 				break;
 			}
+#endif
+			case SDL_WINDOWEVENT_ENTER:          /**< Window has gained mouse focus */
+				TCOD_ctx.app_has_mouse_focus=true; break;
+			case SDL_WINDOWEVENT_LEAVE:          /**< Window has lost mouse focus */
+				TCOD_ctx.app_has_mouse_focus=false; break;
+			case SDL_WINDOWEVENT_MAXIMIZED:      /**< Window has been maximized */
+				TCOD_ctx.app_is_active=true; break;
+			case SDL_WINDOWEVENT_MINIMIZED:      /**< Window has been minimized */
+				TCOD_ctx.app_is_active=false; break;
 #ifdef NDEBUG_HMM
 			default:
 				TCOD_LOG(("SDL2 WINDOWEVENT (unknown): 0x%04x\n", ev->window.event));
 				break;
 #endif
 			}
-#endif
-		break;
+ 		break;
 #else
 		case SDL_VIDEOEXPOSE :
 			TCOD_sys_console_to_bitmap(screen,TCOD_console_get_width(NULL),TCOD_console_get_height(NULL),consoleBuffer,prevConsoleBuffer);