Fix building on MSYS2
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "GameLib.h"
|
||||
extern int gamelib_debug;
|
||||
|
||||
@@ -1,33 +1,41 @@
|
||||
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
// Copyright (C) 2011-2015 Valeriano Alfonso Rodriguez (Kableado)
|
||||
|
||||
#ifdef WIN32
|
||||
// Windows
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#define USE_OpenGL 1
|
||||
#define USE_OpenGLES 0
|
||||
// Windows
|
||||
# define _WIN32_WINNT 0x0501
|
||||
# include <math.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glext.h>
|
||||
# define USE_OpenGL 1
|
||||
# define USE_OpenGLES 0
|
||||
# define GL_CLAMP_TO_EDGE 0x812F
|
||||
#else
|
||||
#ifdef EMSCRIPTEN
|
||||
// Emscripten
|
||||
#include <GLES2/gl2.h>
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <emscripten.h>
|
||||
#define USE_OpenGL 0
|
||||
#define USE_OpenGLES 1
|
||||
#define SDL_GetKeyState SDL_GetKeyboardState
|
||||
// Emscripten
|
||||
# include <math.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <GLES2/gl2.h>
|
||||
# define GL_GLEXT_PROTOTYPES 1
|
||||
# include <GLES2/gl2ext.h>
|
||||
# include <emscripten.h>
|
||||
# define USE_OpenGL 0
|
||||
# define USE_OpenGLES 1
|
||||
# define SDL_GetKeyState SDL_GetKeyboardState
|
||||
#else
|
||||
// UNIX
|
||||
#include <GL/gl.h>
|
||||
#define USE_OpenGL 1
|
||||
#define USE_OpenGLES 0
|
||||
// UNIX
|
||||
# include <math.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <GL/gl.h>
|
||||
# define USE_OpenGL 1
|
||||
# define USE_OpenGLES 0
|
||||
#endif
|
||||
#endif
|
||||
#include "lodepng.c"
|
||||
@@ -707,7 +715,7 @@ DrawImg Draw_LoadImage(char *filename){
|
||||
(unsigned*)&image->h,
|
||||
filename);
|
||||
if(error){
|
||||
printf("Draw_LoadImage: PNG decoder error %u: %s\n", error, lodepng_error_text(error));
|
||||
printf("Draw_LoadImage: PNG decoder error %u: %s on file %s\n", error, lodepng_error_text(error),filename);
|
||||
return(NULL);
|
||||
}
|
||||
image->x=-(int)(image->w/2);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
|
||||
// Copyright (C) 2011-2015 Valeriano Alfonso Rodriguez (Kableado)
|
||||
|
||||
#ifndef _DRAW_H_
|
||||
#define _DRAW_H_
|
||||
|
||||
4
Makefile
4
Makefile
@@ -1,4 +1,6 @@
|
||||
ifneq (,$(findstring MINGW,$(shell uname -s)))
|
||||
|
||||
IsMinGW=$(findstring MSYS,$(shell uname -s)) $(findstring MINGW,$(shell uname -s))
|
||||
ifneq (,$(IsMinGW))
|
||||
TARGET_ARCH=mingw
|
||||
else
|
||||
TARGET_ARCH=linux
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
|
||||
########################
|
||||
# Utility Declarations #
|
||||
########################
|
||||
ifeq ($(VERBOSE_BUILD),true)
|
||||
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
||||
DO_CXX=$(CXX) $(CFLAGS) -o $@ -c $<
|
||||
else
|
||||
DO_CC=@$(ECHO) "CC: $@" ;\
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
DO_CXX=@$(ECHO) "CXX: $@" ;\
|
||||
$(CXX) $(CFLAGS) -o $@ -c $<
|
||||
endif
|
||||
|
||||
########################
|
||||
# GameLib Declarations #
|
||||
@@ -59,23 +71,23 @@ rebuild: clean all
|
||||
# GameLib Rules #
|
||||
#################
|
||||
$(BUILDDIR)/GameLib/Time.o: GameLib/Time.c $(HEADS)
|
||||
$(CC) -c GameLib/Time.c -o $(BUILDDIR)/GameLib/Time.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Util.o: GameLib/Util.c $(HEADS)
|
||||
$(CC) -c GameLib/Util.c -o $(BUILDDIR)/GameLib/Util.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/QuadArray2D.o: GameLib/QuadArray2D.c $(HEADS)
|
||||
$(CC) -c GameLib/QuadArray2D.c -o $(BUILDDIR)/GameLib/QuadArray2D.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Draw.o: GameLib/Draw.c $(HEADS)
|
||||
$(CC) -c GameLib/Draw.c -o $(BUILDDIR)/GameLib/Draw.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Input.o: GameLib/Input.c $(HEADS)
|
||||
$(CC) -c GameLib/Input.c -o $(BUILDDIR)/GameLib/Input.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Audio.o: GameLib/Audio.c $(HEADS)
|
||||
$(CC) -c GameLib/Audio.c -o $(BUILDDIR)/GameLib/Audio.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Entity.o: GameLib/Entity.c $(HEADS)
|
||||
$(CC) -c GameLib/Entity.c -o $(BUILDDIR)/GameLib/Entity.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/Anim.o: GameLib/Anim.c $(HEADS)
|
||||
$(CC) -c GameLib/Anim.c -o $(BUILDDIR)/GameLib/Anim.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/GameLib/GameLib.o: GameLib/GameLib.c $(HEADS)
|
||||
$(CC) -c GameLib/GameLib.c -o $(BUILDDIR)/GameLib/GameLib.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
|
||||
|
||||
##############
|
||||
@@ -83,13 +95,11 @@ $(BUILDDIR)/GameLib/GameLib.o: GameLib/GameLib.c $(HEADS)
|
||||
##############
|
||||
|
||||
$(BUILDDIR)/Game/GameEnts.o: Game/GameEnts.c $(HEADS)
|
||||
$(CC) -c Game/GameEnts.c -o $(BUILDDIR)/Game/GameEnts.o $(CFLAGS)
|
||||
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/Game/GameMap.o: Game/GameMap.c $(HEADS)
|
||||
$(CC) -c Game/GameMap.c -o $(BUILDDIR)/Game/GameMap.o $(CFLAGS)
|
||||
|
||||
$(DO_CC)
|
||||
$(BUILDDIR)/Game/main.o: Game/main.c $(HEADS)
|
||||
$(CC) -c Game/main.c -o $(BUILDDIR)/Game/main.o $(CFLAGS)
|
||||
$(DO_CC)
|
||||
|
||||
|
||||
################
|
||||
@@ -97,10 +107,12 @@ $(BUILDDIR)/Game/main.o: Game/main.c $(HEADS)
|
||||
################
|
||||
|
||||
$(RES_GAMELIB_OUT): $(GAMELIBS_OBJS)
|
||||
$(AR) rcs $(RES_GAMELIB_OUT) $(GAMELIBS_OBJS)
|
||||
@$(ECHO) "STATICLIB: $@"
|
||||
@$(AR) rcs $(RES_GAMELIB_OUT) $(GAMELIBS_OBJS)
|
||||
|
||||
$(RES_GAME_OUT): $(RES_GAMELIB_OUT) $(GAME_OBJS)
|
||||
$(CC) $(GAME_OBJS) $(RES_GAMELIB_OUT) -o $(RES_GAME_OUT) $(LIBS) $(CFLAGS) $(LDFLAGS)
|
||||
@$(ECHO) "LINK: $@"
|
||||
@$(CC) $(GAME_OBJS) $(RES_GAMELIB_OUT) -o $(RES_GAME_OUT) $(LIBS) $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ AR = emar
|
||||
LAUNCHER = start
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
ECHO = echo
|
||||
|
||||
LIBS=
|
||||
CFLAGS= -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration
|
||||
#LDFLAGS= --embed-file data
|
||||
LDFLAGS= --preload-file data
|
||||
LIBS =
|
||||
CFLAGS = -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration -DEMSCRIPTEN
|
||||
LDFLAGS = --preload-file data
|
||||
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.html
|
||||
BUILDDIR=build-emscripten
|
||||
RES_GAMELIB = libgame.a
|
||||
RES_GAME = game.html
|
||||
BUILDDIR = build-emscripten
|
||||
|
||||
ifeq ($(target),release)
|
||||
CFLAGS= -s FULL_ES2=1 -s ASM_JS=1 -O2 --llvm-lto 1 -Wno-implicit-function-declaration
|
||||
|
||||
@@ -3,13 +3,14 @@ AR = ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
ECHO = echo
|
||||
|
||||
LIBS= -lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11
|
||||
CFLAGS= -Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
||||
LDFLAGS=
|
||||
LIBS = -lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11
|
||||
CFLAGS = -Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
||||
LDFLAGS =
|
||||
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game
|
||||
BUILDDIR=build-linux
|
||||
RES_GAMELIB = libgame.a
|
||||
RES_GAME = game
|
||||
BUILDDIR = build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
||||
|
||||
include Makefile.common
|
||||
|
||||
@@ -3,14 +3,15 @@ AR = i486-mingw32-ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
ECHO = echo
|
||||
|
||||
LIBS= -L/usr/i486-mingw/lib -D_GNU_SOURCE=1 -Dmain=SDL_main -lopengl32
|
||||
CFLAGS= -I/usr/i486-mingw/include -lmingw32 -lSDLmain -lSDL -mwindows
|
||||
LDFLAGS=
|
||||
LIBS = -L/usr/i486-mingw/lib -D_GNU_SOURCE=1 -Dmain=SDL_main -lopengl32 -lmingw32 -lSDLmain -lSDL
|
||||
CFLAGS = -I/usr/i486-mingw/include -mwindows
|
||||
LDFLAGS =
|
||||
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.exe
|
||||
BUILDDIR=build-mingw
|
||||
RES_GAMELIB = libgame.a
|
||||
RES_GAME = game.exe
|
||||
BUILDDIR = build-mingw
|
||||
|
||||
include Makefile.common
|
||||
|
||||
|
||||
@@ -3,14 +3,15 @@ AR = ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
ECHO = echo
|
||||
|
||||
LIBS=-I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -lopengl32
|
||||
CFLAGS= -L/mingw/lib -lmingw32 -lSDLmain -lSDL -mwindows -g
|
||||
LDFLAGS=
|
||||
LIBS = -L/mingw/lib -Dmain=SDL_main -lopengl32 -lSDLmain -lSDL
|
||||
CFLAGS = -I/mingw/include -g -mwindows -D_GNU_SOURCE=1
|
||||
LDFLAGS =
|
||||
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.exe
|
||||
BUILDDIR=build-mingw
|
||||
RES_GAMELIB = libgame.a
|
||||
RES_GAME = game.exe
|
||||
BUILDDIR = build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
||||
|
||||
include Makefile.common
|
||||
|
||||
|
||||
@@ -4,22 +4,29 @@ prefix=$( dirname "$0" )
|
||||
usage="\
|
||||
Uso: gamelib-config [--cflags] [--libs] [--static-libs] [--builddir] [--platform]"
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Preparar configuracion
|
||||
uname=$( uname )
|
||||
unamem=$( uname -m )
|
||||
if test $1 = "emscripten"; then
|
||||
uname="EMSCRIPTEN"
|
||||
unamem="EMSCRIPTEN"
|
||||
shift
|
||||
gcctarget=$( gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2 )
|
||||
if test $# > 0; then
|
||||
if test $1 = "emscripten"; then
|
||||
uname="EMSCRIPTEN"
|
||||
unamem="EMSCRIPTEN"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
case "$uname" in
|
||||
*MINGW*)
|
||||
*MINGW* | *MSYS*)
|
||||
# Configuracion de Win32/Mingw
|
||||
libs="-lopengl32"
|
||||
cflags="-Dmain=SDL_main -lmingw32 -lSDLmain -lSDL -mwindows -g"
|
||||
builddir="build-mingw"
|
||||
platform="win32"
|
||||
libs="-lopengl32 -lmingw32 -lSDLmain -lSDL"
|
||||
cflags="-Dmain=SDL_main -mwindows -g"
|
||||
builddir="build-$gcctarget"
|
||||
platform="$gcctarget"
|
||||
exeextension=".exe"
|
||||
;;
|
||||
*EMSCRIPTEN*)
|
||||
@@ -33,22 +40,13 @@ case "$uname" in
|
||||
*)
|
||||
# Configuracion de Linux
|
||||
libs="-lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11"
|
||||
cflags="-Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/"
|
||||
builddir="build-linux-$unamem"
|
||||
platform="linux-$unamem"
|
||||
cflags="-Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/"
|
||||
builddir="build-$gcctarget"
|
||||
platform="$gcctarget"
|
||||
exeextension=""
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--cflags)
|
||||
@@ -76,4 +74,3 @@ while test $# -gt 0; do
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user