Skip to content

Commit

Permalink
Added a bunch of structure, lots stolen from lighting.
Browse files Browse the repository at this point in the history
 As usual, incomplete.
  • Loading branch information
icculus committed Mar 24, 2006
1 parent 7d15310 commit 507f43a
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUILD_REVISION.txt
@@ -0,0 +1 @@
1
54 changes: 54 additions & 0 deletions buildver.c
@@ -0,0 +1,54 @@
/*
* This is in a seperate file so that we can recompile it every time
* without it forcing a recompile on something ccache would otherwise not
* have to rebuild...this file's checksum changes every time you build it
* due to the __DATE__ and __TIME__ macros.
*
* The makefile will rebuild this file everytime it relinks an executable
* so that we'll always have a unique build string.
*
* APPNAME and APPREV need to be predefined in the build system.
* The rest are supposed to be supplied by the compiler.
*/

#ifndef APPID
#error Please define APPID in the build system.
#endif

#ifndef APPREV
#error Please define APPREV in the build system.
#endif

#ifndef __VERSION__
#define __VERSION__ (Unknown compiler version)
#endif

#ifndef __DATE__
#define __DATE__ (Unknown build date)
#endif

#ifndef __TIME__
#define __TIME__ (Unknown build time)
#endif

#ifndef COMPILER
#if (defined __GNUC__)
#define COMPILER "GCC"
#elif (defined _MSC_VER)
#define COMPILER "Visual Studio"
#else
#error Please define your platform.
#endif
#endif

// macro mess so we can turn APPID and APPREV into a string literal...
#define MAKEBUILDVERSTRINGLITERAL2(id, rev) \
#id ", Revision " #rev ", Built " __DATE__ " " __TIME__ ", by " \
COMPILER " version " __VERSION__

#define MAKEBUILDVERSTRINGLITERAL(id, rev) MAKEBUILDVERSTRINGLITERAL2(id, rev)

const char *GBuildVer = MAKEBUILDVERSTRINGLITERAL(APPID, APPREV);

/* end of buildver.c ... */

9 changes: 9 additions & 0 deletions fileio.h
Expand Up @@ -3,6 +3,10 @@

#include "universal.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
* File i/o may go through multiple layers: the archive attached to the binary,
* then an archive in there that's being read entirely out of memory that's
Expand Down Expand Up @@ -57,8 +61,13 @@ struct MojoArchive
void *opaque;
};

MojoArchive *MojoArchive_newFromDirectory(const char *dirname);
MojoArchive *MojoArchive_newFromInput(MojoInput *io, const char *origfname);

#ifdef __cplusplus
}
#endif

#endif

/* end of fileio.h ... */
Expand Down
199 changes: 199 additions & 0 deletions makefile
@@ -0,0 +1,199 @@

APPID := mojosetup
APPREV := $(shell head -n 1 BUILD_REVISION.txt)
ifeq ($(strip $(APPREV)),)
$(error Cannot determine build revision. Does BUILD_REVISION.txt exist?)
endif

#target := macosx_ppc
#target := macosx_x86
#target := linux_x86
#target := linux_ppc

ifeq ($(strip $(target)),)
arch := $(shell uname -m)
os := $(shell uname -s)

ifeq ($(strip $(os)),Darwin)
ifeq ($(strip $(arch)),Power Macintosh)
target := macosx_ppc
endif
ifeq ($(strip $(arch)),x86)
target := macosx_x86
endif
ifeq ($(strip $(arch)),i386)
target := macosx_x86
endif
endif

ifeq ($(strip $(os)),Linux)
ifeq ($(strip $(arch)),i686)
target := linux_x86
endif
ifeq ($(strip $(arch)),x86_64)
target := linux_x86
endif
ifeq ($(strip $(arch)),amd64)
target := linux_x86
endif
ifeq ($(strip $(arch)),ppc)
target := linux_ppc
endif
endif
endif


#----------------------------------------------------------------------

settarget := false
ifeq ($(strip $(target)),macosx_ppc)
isunix := true
islinux := false
ismacosx := true
iswindows := false
is32bit := true
is64bit := false
isbigendian := true
settarget := true
endif
ifeq ($(strip $(target)),macosx_x86)
isunix := true
islinux := false
ismacosx := true
iswindows := false
is32bit := true
is64bit := false
isbigendian := false
settarget := true
endif
ifeq ($(strip $(target)),linux_x86)
isunix := true
islinux := true
ismacosx := false
iswindows := false
is32bit := true
is64bit := false
isbigendian := false
settarget := true
endif
ifeq ($(strip $(target)),linux_ppc)
isunix := true
islinux := true
ismacosx := false
iswindows := false
is32bit := true
is64bit := false
isbigendian := true
settarget := true
endif

ifneq ($(strip $(settarget)),true)
$(error unknown target.)
endif

CC := ccache gcc
CXX := ccache g++
LD := g++

ifeq ($(iswindows),true)
EXEEXT := .exe
endif
#ifeq ($(isunix),true)
# EXEEXT := -bin
#endif

EXE := $(APPID)$(EXEEXT)
EXES := $(EXE)

#OPTS := -O3 -fno-strict-aliasing -falign-loops=16 -ffast-math -fno-math-errno
OPTS := -O0

DEFINES := \
-DAPPID=$(APPID) \
-DAPPREV=$(APPREV) \

INCLUDES := \
-I. \

ifeq ($(isunix),true)
DEFINES += -DPLATFORM_UNIX=1
endif

ifeq ($(islinux),true)
DEFINES += -DPLATFORM_LINUX=1
endif

ifeq ($(ismacosx),true)
DEFINES += -DPLATFORM_MACOSX=1
LIBS += -framework Carbon
#OPTS += -mdynamic-no-pic
endif

ifeq ($(iswindows),true)
DEFINES += -DPLATFORM_WINDOWS=1
endif

ifeq ($(is32bit),true)
DEFINES += -DPLATFORM_32BITS=1
endif

ifeq ($(is64bit),true)
ifeq ($(is32bit),true)
$(error is64bit and is32bit both defined)
endif
DEFINES += -DPLATFORM_64BITS=1
endif

ifeq ($(isbigendian),true)
DEFINES += -DPLATFORM_BIGENDIAN=1
else
DEFINES += -DPLATFORM_LITTLEENDIAN=1
endif

ZLIBSRCS := \
$(PHYSFSDIR)/zlib123/adler32.c \
$(PHYSFSDIR)/zlib123/compress.c \
$(PHYSFSDIR)/zlib123/crc32.c \
$(PHYSFSDIR)/zlib123/deflate.c \
$(PHYSFSDIR)/zlib123/gzio.c \
$(PHYSFSDIR)/zlib123/infback.c \
$(PHYSFSDIR)/zlib123/inffast.c \
$(PHYSFSDIR)/zlib123/inflate.c \
$(PHYSFSDIR)/zlib123/inftrees.c \
$(PHYSFSDIR)/zlib123/trees.c \
$(PHYSFSDIR)/zlib123/uncompr.c \
$(PHYSFSDIR)/zlib123/zutil.c \

# We force this to build every time, so it can't be an explicit dependency...
LIBS += bin/buildver.o

CFLAGS := -g -pipe -Wall -Werror -fexceptions -fsigned-char $(OPTS) $(INCLUDES) $(DEFINES)
CXXFLAGS := $(CFLAGS)

.PHONY: clean all docs $(APPID)

all: $(APPID)

$(APPID): $(EXE)

docs:
( cat $(ENGINEDIR)/Doxyfile ; echo 'PROJECT_NUMBER="Build Revision $(APPREV)"' ) | doxygen -

clean:
rm -rf $(OBJS) $(EXES) bin/$(SDLDIR)/lib/$(target)/libSDLmain.a docs bin/test/*.o bin/tools/*/*.o

bin/%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<

bin/%.o : %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

#$(EXE) : $(OBJS) $(STATICLIBS)
# $(CXX) $(CXXFLAGS) -c -o bin/$(ENGINEDIR)/buildver.o $(ENGINEDIR)/buildver.cpp
# $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)

$(APPID)$(EXEEXT) : $(OBJS) $(STATICLIBS)
$(CXX) $(CXXFLAGS) -c -o bin/$(ENGINEDIR)/buildver.o $(ENGINEDIR)/buildver.cpp
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)

# end of makefile ...
18 changes: 18 additions & 0 deletions platform.h
@@ -0,0 +1,18 @@
#ifndef _INCL_PLATFORM_H_
#define _INCL_PLATFORM_H_

#include "universal.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif

#endif

/* end of platform.h ... */

8 changes: 8 additions & 0 deletions universal.h
Expand Up @@ -3,6 +3,10 @@

/* Include this file from everywhere...it provides basic type sanity, etc. */

#ifdef __cplusplus
extern "C" {
#endif

typedef char int8;
typedef unsigned char uint8;
typedef short int16;
Expand All @@ -14,6 +18,10 @@ typedef unsigned long long uint64;

typedef int boolean;

#ifdef __cplusplus
}
#endif

#endif

/* end of universal.h ... */
Expand Down

0 comments on commit 507f43a

Please sign in to comment.