polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 3ecc86de3665ada0426d6bf15d876f496b04e539
parent dfd8601efc68d6104d256e3a83092e9fc3dd3d20
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  9 Jan 2020 22:38:22 -0800

tcc

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
MMakefile | 50++++++++++++++++++++++++--------------------------
Msrc/gl.h | 2+-
Msrc/hires.c | 2+-
Msrc/input.h | 2+-
Msrc/shader.c | 4++--
5 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,20 +1,24 @@ NAME ?= polyadvent BIN ?= $(NAME) PREFIX ?= /usr/local -DEFS= -DGLFW_INCLUDE_NONE +# DEFS= -DGLFW_INCLUDE_NONE -DDEBUG # release build lol # DEFS= -DGLFW_INCLUDE_NONE -DNDEBUG # CFLAGS = $(DEFS) -ggdb -O0 -I src -Wall -Wextra -std=c99 \ -CFLAGS = $(DEFS) -Ofast -I src -Wall -Werror -Wextra -std=c99 \ - -Wno-unused-function \ - -Wno-unused-parameter \ - -Wno-unused-variable \ - -Wmissing-field-initializers \ - -Wno-cast-align \ - -Wno-padded -LDFLAGS = -lSDL2 -lGL -lm +CFLAGS = $(DEFS) -Ofast -DSDL_DISABLE_IMMINTRIN_H \ + $(shell pkg-config --cflags sdl2 gl x11) \ + -DSTBI_NO_SIMD \ + -I src -Wall -Werror -Wextra -std=c99 \ + -Wno-unused-function \ + -Wno-unused-parameter \ + -Wno-unused-variable \ + -Wmissing-field-initializers \ + -Wno-cast-align \ + -Wno-padded + +LDFLAGS = $(shell pkg-config --libs-only-L gl xcb xi xau xdmcp xext xcursor xrender xrandr xfixes xinerama xscrnsaver xxf86vm) $(shell pkg-config --libs sdl2) -lGL -lm SRC=src SRCS=$(wildcard $(SRC)/*.c) @@ -29,28 +33,22 @@ TESTS += test/test_scene TOOLS = tools/compile-model -all: $(BIN) $(MODELS) +all: tools $(BIN) $(MODELS) clean: - rm -f src/main.o test/*.o tools/*.o $(OBJS) $(TESTS) $(TOOLS) $(MODELS) $(SHLIB) $(BIN) $(SRC)/*.d* + rm -f src/main.o test/*.o tools/*.o polyadvent.o $(TESTS) $(TOOLS) $(MODELS) $(SHLIB) $(BIN) $(SRC)/*.d* -%.d: %.c - @rm -f $@; \ - $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ - sed 's,\(.*\)\.o[ :]*,src/\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ +polyadvent.o: $(SRCS) + @echo "cc $@" + @$(CC) $(CFLAGS) -r -o $@ $^ -%.o: %.c - @echo "cc $<" - @$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< - -test/%: test/%.o $(OBJS) +test/%: test/%.o polyadvent.o @echo "link $@" - @$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ + @$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -tools/%: tools/%.o $(OBJS) +tools/%: tools/%.c polyadvent.o @echo "link $@" - @$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ + @$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ tools: $(TOOLS) @@ -63,9 +61,9 @@ check: $(TESTS) $(MODELS) ./test/test_resource ./test/test_scene -$(BIN): main.o $(OBJS) +$(BIN): polyadvent.o main.o @echo "link $@" - @$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ install: $(BIN) install -d $(PREFIX)/bin diff --git a/src/gl.h b/src/gl.h @@ -2,7 +2,7 @@ #define POLYADVENT_GL_H /* #include <epoxy/gl.h> */ -#include <SDL2/SDL.h> +#include <SDL.h> #include <GL/gl.h> #include <GL/glx.h> #include <GL/glext.h> diff --git a/src/hires.c b/src/hires.c @@ -1,7 +1,7 @@ #include <time.h> #include "common.h" -#include <SDL2/SDL.h> +#include <SDL.h> double hires_time_in_seconds() { double ticks_per_sec = (double)SDL_GetPerformanceFrequency(); diff --git a/src/input.h b/src/input.h @@ -3,7 +3,7 @@ #ifndef POLYADVENT_INPUT_H #define POLYADVENT_INPUT_H -#include <SDL2/SDL.h> +#include <SDL.h> #include "common.h" /* enum key_state { */ diff --git a/src/shader.c b/src/shader.c @@ -30,7 +30,7 @@ static char *cached_file_contents(const char *filename) { return file_contents(filename, &len); } -static char *strsep(char **stringp, const char *delim) { +static char *strsep2(char **stringp, const char *delim) { if (*stringp == NULL) { return NULL; } char *token_start = *stringp; *stringp = strpbrk(token_start, delim); @@ -45,7 +45,7 @@ static char **resolve_imports(char *contents, int *nlines, int level) { char *resolved_contents; char fname_buf[32] = {0}; - while ((line = strsep(&contents, "\n"))) { + while ((line = strsep2(&contents, "\n"))) { nline++; int line_len = contents - line; int size = sizeof("#include");