Building of the static library
This commit is contained in:
12
Makefile
12
Makefile
@@ -1,26 +1,14 @@
|
||||
ifneq (,$(findstring MINGW,$(shell uname -s)))
|
||||
TARGET_ARCH=mingw
|
||||
else
|
||||
ARCH:=$(shell uname)
|
||||
ifeq ($(ARCH), Darwin)
|
||||
TARGET_ARCH=macosx
|
||||
else
|
||||
TARGET_ARCH=linux
|
||||
endif # Darwin
|
||||
endif # windir
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ifeq ($(TARGET_ARCH),mingw)
|
||||
include Makefile.win32
|
||||
else
|
||||
ifeq ($(TARGET_ARCH),linux)
|
||||
include Makefile.linux
|
||||
else
|
||||
ifeq ($(TARGET_ARCH),macosx)
|
||||
include Makefile.macosx
|
||||
endif # macosx
|
||||
endif # linux
|
||||
endif # mingw
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# GameLib Declarations #
|
||||
########################
|
||||
CFLAGS += -IGameLib
|
||||
HEADS= \
|
||||
GAMELIB_HEADS = \
|
||||
GameLib/Time.h \
|
||||
GameLib/Util.h \
|
||||
GameLib/QuadArray2D.h \
|
||||
@@ -14,7 +14,7 @@ HEADS= \
|
||||
GameLib/Anim.h \
|
||||
GameLib/Entity.h \
|
||||
GameLib/GameLib.h
|
||||
OBJS= \
|
||||
GAMELIBS_OBJS = \
|
||||
$(BUILDDIR)/GameLib/Time.o \
|
||||
$(BUILDDIR)/GameLib/Util.o \
|
||||
$(BUILDDIR)/GameLib/QuadArray2D.o \
|
||||
@@ -23,34 +23,34 @@ OBJS= \
|
||||
$(BUILDDIR)/GameLib/Audio.o \
|
||||
$(BUILDDIR)/GameLib/Anim.o \
|
||||
$(BUILDDIR)/GameLib/Entity.o \
|
||||
$(BUILDDIR)/GameLib/GameLib.o \
|
||||
|
||||
$(BUILDDIR)/GameLib/GameLib.o
|
||||
RES_GAMELIB_OUT = $(BUILDDIR)/$(RES_GAMELIB)
|
||||
|
||||
#####################
|
||||
# Game Declarations #
|
||||
#####################
|
||||
HEADS+= GameEnts.h GameMap.h
|
||||
|
||||
OBJS+= \
|
||||
GAME_HEADS = $(GAMELIB_HEADS) GameEnts.h GameMap.h
|
||||
GAME_OBJS = \
|
||||
$(BUILDDIR)/GameEnts.o \
|
||||
$(BUILDDIR)/GameMap.o \
|
||||
$(BUILDDIR)/main.o
|
||||
RES_GAME_OUT = $(BUILDDIR)/$(RES_GAME)
|
||||
|
||||
|
||||
#################
|
||||
# General Rules #
|
||||
#################
|
||||
all: $(BUILDDIR) $(BUILDDIR)/$(RESULT)
|
||||
all: $(BUILDDIR) $(RES_GAME_OUT)
|
||||
|
||||
$(BUILDDIR):
|
||||
mkdir $(BUILDDIR)
|
||||
mkdir $(BUILDDIR)/GameLib
|
||||
$(MKDIR) $(BUILDDIR)
|
||||
$(MKDIR) $(BUILDDIR)/GameLib
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(BUILDDIR)/$(RESULT)
|
||||
$(RM) $(GAMELIBS_OBJS) $(RES_GAMELIB_OUT) $(GAME_OBJS) $(RES_GAME_OUT)
|
||||
|
||||
run: $(BUILDDIR) $(BUILDDIR)/$(RESULT)
|
||||
$(LAUNCHER) ./$(BUILDDIR)/$(RESULT) debug
|
||||
run: $(BUILDDIR) $(RES_GAME_OUT)
|
||||
$(LAUNCHER) ./$(RES_GAME_OUT) debug
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
@@ -95,8 +95,11 @@ $(BUILDDIR)/main.o: main.c $(HEADS)
|
||||
# Result Rules #
|
||||
################
|
||||
|
||||
$(BUILDDIR)/$(RESULT): $(OBJS)
|
||||
$(CC) -o $(BUILDDIR)/$(RESULT) $(OBJS) $(LIBS) $(CFLAGS) $(LDFLAGS)
|
||||
$(RES_GAMELIB_OUT): $(GAMELIBS_OBJS)
|
||||
$(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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
CC= emcc
|
||||
LAUNCHER= start
|
||||
RM=rm -rf
|
||||
CC = emcc
|
||||
AR = emar
|
||||
LAUNCHER = start
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
|
||||
LIBS=
|
||||
CFLAGS= -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration
|
||||
#LDFLAGS= --embed-file data
|
||||
LDFLAGS= --preload-file data
|
||||
|
||||
|
||||
RESULT=game.html
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.html
|
||||
BUILDDIR=build-emscripten
|
||||
|
||||
ifeq ($(target),release)
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
CC=gcc
|
||||
LAUNCHER=
|
||||
RM=rm -rf
|
||||
CC = gcc
|
||||
AR = ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
|
||||
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=
|
||||
|
||||
RESULT=game
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game
|
||||
BUILDDIR=build-linux
|
||||
|
||||
include Makefile.common
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
CC= i486-mingw32-gcc
|
||||
LAUNCHER=
|
||||
RM=rm -rf
|
||||
CC = i486-mingw32-gcc
|
||||
AR = i486-mingw32-ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
|
||||
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=
|
||||
|
||||
RESULT=game.exe
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.exe
|
||||
BUILDDIR=build-mingw
|
||||
|
||||
include Makefile.common
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
CC=gcc
|
||||
LAUNCHER=
|
||||
RM=rm -rf
|
||||
CC = gcc
|
||||
AR = ar
|
||||
LAUNCHER =
|
||||
RM = rm -rf
|
||||
MKDIR = mkdir
|
||||
|
||||
LIBS=-I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -lopengl32
|
||||
CFLAGS= -L/mingw/lib -lmingw32 -lSDLmain -lSDL -mwindows -g
|
||||
LDFLAGS=
|
||||
|
||||
RESULT=game.exe
|
||||
RES_GAMELIB=libgame.a
|
||||
RES_GAME=game.exe
|
||||
BUILDDIR=build-mingw
|
||||
|
||||
include Makefile.common
|
||||
|
||||
73
gamelib-config
Normal file
73
gamelib-config
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
|
||||
prefix=$( dirname "$0" )
|
||||
usage="\
|
||||
Uso: gamelib-config [--cflags] [--libs] [--static-libs] [--builddir] [--platform]"
|
||||
|
||||
|
||||
# Preparar configuracion
|
||||
uname=$( uname )
|
||||
unamem=$( uname -m )
|
||||
if test $1 = "emscripten"; then
|
||||
uname="EMSCRIPTEN"
|
||||
unamem="EMSCRIPTEN"
|
||||
shift
|
||||
fi
|
||||
case "$uname" in
|
||||
*MINGW*)
|
||||
# Configuracion de Win32/Mingw
|
||||
libs="-lopengl32"
|
||||
cflags="-Dmain=SDL_main -lmingw32 -lSDLmain -lSDL -mwindows -g"
|
||||
builddir="build-mingw"
|
||||
platform="win32"
|
||||
;;
|
||||
*EMSCRIPTEN*)
|
||||
# Configuracion de Emscripten
|
||||
libs=""
|
||||
cflags="-s FULL_ES2=1 -s ASM_JS=1 -Wno-implicit-function-declaration"
|
||||
builddir="build-emscripten"
|
||||
platform="emscripten"
|
||||
;;
|
||||
*)
|
||||
# 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"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--cflags)
|
||||
echo "$cflags -I$prefix/GameLib"
|
||||
;;
|
||||
--libs)
|
||||
echo "$libs"
|
||||
;;
|
||||
--static-libs)
|
||||
echo "$prefix/$builddir/libgame.a"
|
||||
;;
|
||||
--builddir)
|
||||
echo "$builddir"
|
||||
;;
|
||||
--platform)
|
||||
echo "$platform"
|
||||
;;
|
||||
*)
|
||||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user