Start of Windows build.

This commit is contained in:
Steve 2018-03-23 18:38:12 +00:00
parent 0ddb167bb3
commit 464874faa2
10 changed files with 138 additions and 5 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ data
blobwarsAttrition
*.o
.DS_Store
dist/*

11
build/buildAll.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash -e
VERSION=`egrep 'VERSION = ([0-9.+])' ../common.mk | awk '{print $3}'`
REVISION=`git rev-list HEAD --count`
mkdir -p ../dist
rm -rf ../dist/*
linux/build.sh $VERSION $REVISION
win32/build.sh $VERSION $REVISION

20
build/linux/build.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash -e
cd `dirname $0`
BUILDROOT="build/linux"
cd ../..
VERSION=$1
REVISION=$2
SIZE=0
make clean
make src-dist
make clean
make LOCALE_DIR=locale
make dist
rm -rf blobWarsAttrition

39
build/win32/build.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash -e
cd `dirname $0`
BUILDROOT="build/win32"
cd ../..
VERSION=$1
REVISION=$2
FOLDER="blobWarsAttrition-$1"
OUT="$BUILDROOT/$FOLDER"
make -f makefile.win32 clean
make -f makefile.win32
mkdir -p $OUT
rm -rf $OUT/*
cp blobWarsAttrition.exe $OUT
cp -rL data $OUT
cp -rL gfx $OUT
cp -rL music $OUT
cp -rL sound $OUT
cp -rL manual $OUT
cp -rL locale $OUT
cp LICENSE $OUT
cp README.md $OUT
cp /usr/x86_64-w64-mingw32/bin/*.dll $OUT
cd $BUILDROOT
zip -r blobWarsAttrition-${VERSION}-${REVISION}.win32.zip $FOLDER
mv *.zip ../../dist
rm -rf $FOLDER

View File

@ -2,6 +2,8 @@ VERSION = 0.8
REVISION = 0
LOCALE_MO = $(patsubst %.po,%.mo,$(wildcard locale/*.po))
OUT = bin
SEARCHPATH += src
SEARCHPATH += src/combat
SEARCHPATH += src/entities

View File

@ -1,6 +1,5 @@
PROG = blobwarsAttrition
CC = gcc
OUT = bin
PREFIX ?= /usr
BIN_DIR ?= $(PREFIX)/bin
DATA_DIR ?= /opt/$(PROG)
@ -27,7 +26,7 @@ CXXFLAGS += -fms-extensions -std=gnu11
LDFLAGS += `sdl2-config --libs` -lSDL2_mixer -lSDL2_image -lSDL2_ttf -lm -lz -lpng
SHARED_FILES = CHANGELOG LICENSE README.md data gfx manual music sound icons
SHARED_FILES = LICENSE README.md data gfx manual music sound icons
DIST_FILES = $(SHARED_FILES) locale $(PROG)
SRC_DIST_FILES = $(SHARED_FILES) src makefile* common.mk
@ -79,7 +78,7 @@ uninstall:
dist:
$(RM) -rf $(PROG)-$(VERSION)
mkdir $(PROG)-$(VERSION)
cp -r $(DIST_FILES) $(PROG)-$(VERSION)
cp -rL $(DIST_FILES) $(PROG)-$(VERSION)
tar czf $(PROG)-$(VERSION)-$(REVISION).linux-x86.tar.gz $(PROG)-$(VERSION)
mkdir -p dist
mv $(PROG)-$(VERSION)-$(REVISION).linux-x86.tar.gz dist
@ -89,7 +88,7 @@ dist:
src-dist:
$(RM) -rf $(PROG)-$(VERSION)
mkdir $(PROG)-$(VERSION)
cp -r $(SRC_DIST_FILES) $(PROG)-$(VERSION)
cp -rL $(SRC_DIST_FILES) $(PROG)-$(VERSION)
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short >$(PROG)-$(VERSION)/CHANGELOG.raw
tar czf $(PROG)-$(VERSION)-$(REVISION).src.tar.gz $(PROG)-$(VERSION)
mkdir -p dist

21
makefile.win32 Normal file
View File

@ -0,0 +1,21 @@
PROG = blobWarsAttrition.exe
CC = x86_64-w64-mingw32-gcc
SDLC = /usr/x86_64-w64-mingw32/bin/sdl2-config
LIBPATH = /usr/x86_64-w64-mingw32/lib
LOCALE_DIR = locale
SEARCHPATH += src/plat/win32
OBJS += win32Init.o
CXXFLAGS += `$(SDLC) --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\"
CXXFLAGS += -Wall -Wempty-body -ansi -pedantic -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds
CXXFLAGS += -g -lefence
CXXFLAGS += -fms-extensions -std=gnu11
LDFLAGS += `$(SDLC) --libs` -lm -lSDL2_mixer -lSDL2_image -lSDL2_ttf -lSDL2main
include common.mk
# linking the program.
$(PROG): $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS) -L$(LIBPATH)

View File

@ -35,6 +35,7 @@ extern void playMusic(int loop);
extern char *readFile(const char *filename);
extern void returnToTitle(void);
extern void startSectionTransition(void);
extern char *strtok_r(char *str, const char *delim, char **nextp);
extern App app;
extern Colors colors;

View File

@ -6,7 +6,6 @@
* This code is free software, available under zlib/libpng license.
* http://www.libpng.org/pub/png/src/libpng-LICENSE.txt
*/
#include <SDL_video.h>
#ifdef __cplusplus
extern "C" { /* This helps CPP projects that include this header */

View File

@ -111,3 +111,43 @@ void *resize(void *array, int oldSize, int newSize)
return newArray;
}
/*
* public domain strtok_r() by Charlie Gordon
*
* from comp.lang.c 9/14/2007
*
* http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
*
* (Declaration that it's public domain):
* http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
*/
char *strtok_r(char *str, const char *delim, char **nextp)
{
char *ret;
if (str == NULL)
{
str = *nextp;
}
str += strspn(str, delim);
if (*str == '\0')
{
return NULL;
}
ret = str;
str += strcspn(str, delim);
if (*str)
{
*str++ = '\0';
}
*nextp = str;
return ret;
}