commit e584a50fcb186c8b1dfe83a77b7c85b68988147d
parent da368dfb2da7ea0e12efc1baa2b53b0d12f83734
Author: William Casarin <jb55@jb55.com>
Date: Thu, 9 Jan 2020 22:40:00 -0800
Revert "tcc"
This reverts commit 3ecc86de3665ada0426d6bf15d876f496b04e539.
Diffstat:
5 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/Makefile b/Makefile
@@ -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
diff --git a/src/gl.h b/src/gl.h
@@ -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>
diff --git a/src/hires.c b/src/hires.c
@@ -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();
diff --git a/src/input.h b/src/input.h
@@ -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 { */
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 *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");