~jb55/polyadvent

e584a50fcb186c8b1dfe83a77b7c85b68988147d — William Casarin 1 year, 10 months ago da368df
Revert "tcc"

This reverts commit 3ecc86de3665ada0426d6bf15d876f496b04e539.
5 files changed, 31 insertions(+), 29 deletions(-)

M Makefile
M src/gl.h
M src/hires.c
M src/input.h
M src/shader.c
M Makefile => Makefile +26 -24
@@ 1,24 1,20 @@
NAME ?= polyadvent
BIN ?= $(NAME)
PREFIX ?= /usr/local
# DEFS= -DGLFW_INCLUDE_NONE -DDEBUG
DEFS= -DGLFW_INCLUDE_NONE
# release build lol
# DEFS= -DGLFW_INCLUDE_NONE -DNDEBUG

# CFLAGS = $(DEFS) -ggdb -O0 -I src -Wall -Wextra -std=c99 \

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
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
SRC=src

SRCS=$(wildcard $(SRC)/*.c)


@@ 33,22 29,28 @@ TESTS += test/test_scene

TOOLS = tools/compile-model

all: tools $(BIN) $(MODELS)
all: $(BIN) $(MODELS)

clean:
	rm -f src/main.o test/*.o tools/*.o polyadvent.o $(TESTS) $(TOOLS) $(MODELS) $(SHLIB) $(BIN) $(SRC)/*.d*
	rm -f src/main.o test/*.o tools/*.o $(OBJS) $(TESTS) $(TOOLS) $(MODELS) $(SHLIB) $(BIN) $(SRC)/*.d*

polyadvent.o: $(SRCS)
	@echo "cc $@"
	@$(CC) $(CFLAGS) -r -o $@ $^
%.d: %.c
	@rm -f $@; \
	$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
	sed 's,\(.*\)\.o[ :]*,src/\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$

test/%: test/%.o polyadvent.o
%.o: %.c
	@echo "cc $<"
	@$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<

test/%: test/%.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

tools/%: tools/%.c polyadvent.o
tools/%: tools/%.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

tools: $(TOOLS)



@@ 61,9 63,9 @@ check: $(TESTS) $(MODELS)
	./test/test_resource
	./test/test_scene

$(BIN): polyadvent.o main.o
$(BIN): main.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

install: $(BIN)
	install -d $(PREFIX)/bin

M src/gl.h => src/gl.h +1 -1
@@ 2,7 2,7 @@
#define POLYADVENT_GL_H

/* #include <epoxy/gl.h> */
#include <SDL.h>
#include <SDL2/SDL.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>

M src/hires.c => src/hires.c +1 -1
@@ 1,7 1,7 @@

#include <time.h>
#include "common.h"
#include <SDL.h>
#include <SDL2/SDL.h>

double hires_time_in_seconds() {
    double ticks_per_sec = (double)SDL_GetPerformanceFrequency();

M src/input.h => src/input.h +1 -1
@@ 3,7 3,7 @@
#ifndef POLYADVENT_INPUT_H
#define POLYADVENT_INPUT_H

#include <SDL.h>
#include <SDL2/SDL.h>
#include "common.h"

/* enum key_state { */

M src/shader.c => src/shader.c +2 -2
@@ 30,7 30,7 @@ static char *cached_file_contents(const char *filename) {
    return file_contents(filename, &len);
}

static char *strsep2(char **stringp, const char *delim) {
static char *strsep(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 = strsep2(&contents, "\n"))) {
    while ((line = strsep(&contents, "\n"))) {
        nline++;
        int line_len = contents - line;
        int size = sizeof("#include");