switch to premake
This commit is contained in:
parent
7d230f2ccf
commit
8ab0f72f56
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
*.a
|
||||
obj/
|
||||
examples/*.exe
|
||||
bin/
|
||||
|
|
83
Makefile
83
Makefile
|
@ -1,25 +1,58 @@
|
|||
LIBRARY=libgearlib.a
|
||||
|
||||
CC:=gcc
|
||||
AR=ar
|
||||
CFLAGS=-O3 -Iinclude -g
|
||||
LDFLAGS=-lglfw -lm
|
||||
|
||||
CFILES=$(shell cd src && find -L * -type f -name '*.c')
|
||||
OBJDIR=obj
|
||||
OBJ=$(addprefix $(OBJDIR)/, $(CFILES:.c=.o))
|
||||
|
||||
$(LIBRARY): $(OBJ) Makefile
|
||||
$(AR) rcs $(LIBRARY) $(OBJ)
|
||||
|
||||
obj/%.o: src/%.c
|
||||
mkdir -p $(OBJDIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
run: $(LIBRARY)
|
||||
make -C examples test
|
||||
cd examples && ./test
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ) $(LIBRARY)
|
||||
make -C examples clean
|
||||
# Alternative GNU Make workspace makefile autogenerated by Premake
|
||||
|
||||
ifndef config
|
||||
config=debug
|
||||
endif
|
||||
|
||||
ifndef verbose
|
||||
SILENT = @
|
||||
endif
|
||||
|
||||
ifeq ($(config),debug)
|
||||
gearlib_config = debug
|
||||
test_config = debug
|
||||
|
||||
else ifeq ($(config),release)
|
||||
gearlib_config = release
|
||||
test_config = release
|
||||
|
||||
else
|
||||
$(error "invalid configuration $(config)")
|
||||
endif
|
||||
|
||||
PROJECTS := gearlib test
|
||||
|
||||
.PHONY: all clean help $(PROJECTS)
|
||||
|
||||
all: $(PROJECTS)
|
||||
|
||||
gearlib:
|
||||
ifneq (,$(gearlib_config))
|
||||
@echo "==== Building gearlib ($(gearlib_config)) ===="
|
||||
@${MAKE} --no-print-directory -C . -f gearlib.make config=$(gearlib_config)
|
||||
endif
|
||||
|
||||
test: gearlib
|
||||
ifneq (,$(test_config))
|
||||
@echo "==== Building test ($(test_config)) ===="
|
||||
@${MAKE} --no-print-directory -C . -f test.make config=$(test_config)
|
||||
endif
|
||||
|
||||
clean:
|
||||
@${MAKE} --no-print-directory -C . -f gearlib.make clean
|
||||
@${MAKE} --no-print-directory -C . -f test.make clean
|
||||
|
||||
help:
|
||||
@echo "Usage: make [config=name] [target]"
|
||||
@echo ""
|
||||
@echo "CONFIGURATIONS:"
|
||||
@echo " debug"
|
||||
@echo " release"
|
||||
@echo ""
|
||||
@echo "TARGETS:"
|
||||
@echo " all (default)"
|
||||
@echo " clean"
|
||||
@echo " gearlib"
|
||||
@echo " test"
|
||||
@echo ""
|
||||
@echo "For more information, see https://github.com/premake/premake-core/wiki"
|
|
@ -4,11 +4,11 @@ CFLAGS = -O3 -I../include
|
|||
LDFLAGS = -L ../ -lglfw -lgearlib -lm
|
||||
|
||||
CFILES=$(shell find -L * -type f -name '*.c')
|
||||
BINARIES=$(CFILES:.c=.exe)
|
||||
BINARIES=$(CFILES:.c=)
|
||||
|
||||
all: $(BINARIES)
|
||||
|
||||
%.exe: %.c
|
||||
%: %.c
|
||||
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
39
examples/quad.c
Normal file
39
examples/quad.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <gearlib.h>
|
||||
|
||||
int main() {
|
||||
Window window = create_window(800, 600, "textures");
|
||||
glfwSwapInterval(0); // fps unlock
|
||||
setup_quads();
|
||||
|
||||
Camera* camera = create_camera(vec2(0.0f, 0.0f));
|
||||
UniformBuffer* camera_buffer = create_uniform_buffer(sizeof(CameraMatrices));
|
||||
|
||||
double time = glfwGetTime();
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
process_input(window);
|
||||
update_camera(camera, window);
|
||||
set_uniform_data(camera_buffer, camera->m);
|
||||
|
||||
glClearColor(vec4_spread(BLUE));
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
draw_quad(vec2(10, 10), vec2(500, 500), RED);
|
||||
|
||||
flush();
|
||||
|
||||
double end_time = glfwGetTime();
|
||||
double frame_time = end_time - time;
|
||||
time = end_time;
|
||||
|
||||
double fps = 1.0 / frame_time;
|
||||
printf("frame_time: %lf fps: %lf\n", frame_time, fps);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
193
gearlib.make
Normal file
193
gearlib.make
Normal file
|
@ -0,0 +1,193 @@
|
|||
# Alternative GNU Make project makefile autogenerated by Premake
|
||||
|
||||
ifndef config
|
||||
config=debug
|
||||
endif
|
||||
|
||||
ifndef verbose
|
||||
SILENT = @
|
||||
endif
|
||||
|
||||
.PHONY: clean prebuild
|
||||
|
||||
SHELLTYPE := posix
|
||||
ifeq (.exe,$(findstring .exe,$(ComSpec)))
|
||||
SHELLTYPE := msdos
|
||||
endif
|
||||
|
||||
# Configurations
|
||||
# #############################################
|
||||
|
||||
RESCOMP = windres
|
||||
INCLUDES += -Iinclude -Iinclude/gearlib
|
||||
FORCE_INCLUDE +=
|
||||
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
|
||||
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
|
||||
LIBS += -lglfw -lm
|
||||
LDDEPS +=
|
||||
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
|
||||
define PREBUILDCMDS
|
||||
endef
|
||||
define PRELINKCMDS
|
||||
endef
|
||||
define POSTBUILDCMDS
|
||||
endef
|
||||
|
||||
ifeq ($(config),debug)
|
||||
TARGETDIR = bin/Debug/gearlib
|
||||
TARGET = $(TARGETDIR)/libgearlib.a
|
||||
OBJDIR = obj/Debug/gearlib
|
||||
DEFINES += -DDEBUG
|
||||
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
|
||||
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
|
||||
ALL_LDFLAGS += $(LDFLAGS)
|
||||
|
||||
else ifeq ($(config),release)
|
||||
TARGETDIR = bin/Release/gearlib
|
||||
TARGET = $(TARGETDIR)/libgearlib.a
|
||||
OBJDIR = obj/Release/gearlib
|
||||
DEFINES += -DNDEBUG
|
||||
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2
|
||||
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2
|
||||
ALL_LDFLAGS += $(LDFLAGS) -s
|
||||
|
||||
endif
|
||||
|
||||
# Per File Configurations
|
||||
# #############################################
|
||||
|
||||
|
||||
# File sets
|
||||
# #############################################
|
||||
|
||||
GENERATED :=
|
||||
OBJECTS :=
|
||||
|
||||
GENERATED += $(OBJDIR)/batch.o
|
||||
GENERATED += $(OBJDIR)/camera.o
|
||||
GENERATED += $(OBJDIR)/debugging.o
|
||||
GENERATED += $(OBJDIR)/events.o
|
||||
GENERATED += $(OBJDIR)/gl.o
|
||||
GENERATED += $(OBJDIR)/implementations.o
|
||||
GENERATED += $(OBJDIR)/init.o
|
||||
GENERATED += $(OBJDIR)/quad.o
|
||||
GENERATED += $(OBJDIR)/renderer.o
|
||||
GENERATED += $(OBJDIR)/shaders.o
|
||||
GENERATED += $(OBJDIR)/textures.o
|
||||
GENERATED += $(OBJDIR)/uniform_buffer.o
|
||||
OBJECTS += $(OBJDIR)/batch.o
|
||||
OBJECTS += $(OBJDIR)/camera.o
|
||||
OBJECTS += $(OBJDIR)/debugging.o
|
||||
OBJECTS += $(OBJDIR)/events.o
|
||||
OBJECTS += $(OBJDIR)/gl.o
|
||||
OBJECTS += $(OBJDIR)/implementations.o
|
||||
OBJECTS += $(OBJDIR)/init.o
|
||||
OBJECTS += $(OBJDIR)/quad.o
|
||||
OBJECTS += $(OBJDIR)/renderer.o
|
||||
OBJECTS += $(OBJDIR)/shaders.o
|
||||
OBJECTS += $(OBJDIR)/textures.o
|
||||
OBJECTS += $(OBJDIR)/uniform_buffer.o
|
||||
|
||||
# Rules
|
||||
# #############################################
|
||||
|
||||
all: $(TARGET)
|
||||
@:
|
||||
|
||||
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
|
||||
$(PRELINKCMDS)
|
||||
@echo Linking gearlib
|
||||
$(SILENT) $(LINKCMD)
|
||||
$(POSTBUILDCMDS)
|
||||
|
||||
$(TARGETDIR):
|
||||
@echo Creating $(TARGETDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) mkdir -p $(TARGETDIR)
|
||||
else
|
||||
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
|
||||
endif
|
||||
|
||||
$(OBJDIR):
|
||||
@echo Creating $(OBJDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) mkdir -p $(OBJDIR)
|
||||
else
|
||||
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
|
||||
endif
|
||||
|
||||
clean:
|
||||
@echo Cleaning gearlib
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) rm -f $(TARGET)
|
||||
$(SILENT) rm -rf $(GENERATED)
|
||||
$(SILENT) rm -rf $(OBJDIR)
|
||||
else
|
||||
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
|
||||
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
|
||||
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
|
||||
endif
|
||||
|
||||
prebuild: | $(OBJDIR)
|
||||
$(PREBUILDCMDS)
|
||||
|
||||
ifneq (,$(PCH))
|
||||
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
|
||||
$(GCH): $(PCH) | prebuild
|
||||
@echo $(notdir $<)
|
||||
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
|
||||
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) touch "$@"
|
||||
else
|
||||
$(SILENT) echo $null >> "$@"
|
||||
endif
|
||||
else
|
||||
$(OBJECTS): | prebuild
|
||||
endif
|
||||
|
||||
|
||||
# File Rules
|
||||
# #############################################
|
||||
|
||||
$(OBJDIR)/batch.o: src/batch.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/camera.o: src/camera.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/debugging.o: src/debugging.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/events.o: src/events.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/gl.o: src/gl.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/implementations.o: src/implementations.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/init.o: src/init.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/quad.o: src/quad.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/renderer.o: src/renderer.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/shaders.o: src/shaders.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/textures.o: src/textures.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
$(OBJDIR)/uniform_buffer.o: src/uniform_buffer.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
|
||||
-include $(OBJECTS:%.o=%.d)
|
||||
ifneq (,$(PCH))
|
||||
-include $(PCH_PLACEHOLDER).d
|
||||
endif
|
|
@ -3,18 +3,19 @@
|
|||
|
||||
#define MAX_VERTICES 2500
|
||||
|
||||
#include <colors.h>
|
||||
#include <raymath.h>
|
||||
#include <init.h>
|
||||
#include <shaders.h>
|
||||
#include <events.h>
|
||||
#include <debugging.h>
|
||||
#include <vertex.h>
|
||||
#include <renderer.h>
|
||||
#include <camera.h>
|
||||
#include <batch.h>
|
||||
#include <quad.h>
|
||||
#include <textures.h>
|
||||
#include <uniform_buffer.h>
|
||||
#include <gearlib/slibs.h>
|
||||
#include <gearlib/colors.h>
|
||||
#include <gearlib/raymath.h>
|
||||
#include <gearlib/init.h>
|
||||
#include <gearlib/shaders.h>
|
||||
#include <gearlib/events.h>
|
||||
#include <gearlib/debugging.h>
|
||||
#include <gearlib/vertex.h>
|
||||
#include <gearlib/renderer.h>
|
||||
#include <gearlib/camera.h>
|
||||
#include <gearlib/batch.h>
|
||||
#include <gearlib/quad.h>
|
||||
#include <gearlib/textures.h>
|
||||
#include <gearlib/uniform_buffer.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include <gearlib.h>
|
||||
#include <slibs.h>
|
||||
|
||||
typedef struct BatchStats {
|
||||
uint32_t draw_calls;
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __INIT_H__
|
||||
#define __INIT_H__
|
||||
|
||||
#include <opengl.h>
|
||||
#include <gearlib/opengl.h>
|
||||
|
||||
typedef GLFWwindow* Window;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __OPENGL_H__
|
||||
#define __OPENGL_H__
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <gearlib/glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#endif
|
|
@ -11,12 +11,7 @@
|
|||
|
||||
#define sl_auto(name, x) typeof(x) name = x
|
||||
|
||||
#define sl_new(type, ...) \
|
||||
({ \
|
||||
type *ptr = malloc(sizeof(type)); \
|
||||
*ptr = (type){__VA_ARGS__}; \
|
||||
ptr; \
|
||||
})
|
||||
#define sl_new(type) calloc(sizeof(type), 1)
|
||||
|
||||
#define sl_init(type, ...) \
|
||||
(type) { __VA_ARGS__ }
|
38
premake5.lua
Normal file
38
premake5.lua
Normal file
|
@ -0,0 +1,38 @@
|
|||
workspace "gearlib"
|
||||
configurations { "Debug", "Release" }
|
||||
|
||||
project "gearlib"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir "bin/%{cfg.buildcfg}/gearlib"
|
||||
|
||||
files { "include/**.h", "src/**.c" }
|
||||
includedirs { "include", "include/gearlib" }
|
||||
links { "glfw", "m" }
|
||||
|
||||
filter "configurations:Debug"
|
||||
defines { "DEBUG" }
|
||||
symbols "On"
|
||||
|
||||
filter "configurations:Release"
|
||||
defines { "NDEBUG" }
|
||||
optimize "On"
|
||||
|
||||
project "test"
|
||||
kind "ConsoleApp"
|
||||
language "C"
|
||||
targetdir "bin/%{cfg.buildcfg}/test"
|
||||
|
||||
files { "examples/test.c" }
|
||||
includedirs { "include", "include/gearlib" }
|
||||
links { "glfw", "gearlib", "m" }
|
||||
|
||||
debugdir "examples"
|
||||
|
||||
filter "configurations:Debug"
|
||||
defines { "DEBUG" }
|
||||
symbols "On"
|
||||
|
||||
filter "configurations:Release"
|
||||
defines { "NDEBUG" }
|
||||
optimize "On"
|
10
src/batch.c
10
src/batch.c
|
@ -1,11 +1,10 @@
|
|||
#include <gearlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <slibs.h>
|
||||
|
||||
BatchList batches = { 0 };
|
||||
|
||||
RenderBatch* create_batch(size_t vert_size, uint32_t max_verts) {
|
||||
RenderBatch* batch = calloc(sizeof(RenderBatch), 1);
|
||||
RenderBatch* batch = sl_new(RenderBatch);
|
||||
sl_vec_push(batches, batch);
|
||||
|
||||
glCreateBuffers(1, &batch->vbo);
|
||||
|
@ -36,13 +35,6 @@ void flush_batch(RenderBatch* batch) {
|
|||
|
||||
glUseProgram(batch->shader);
|
||||
|
||||
/*glUniformMatrix4fv(0, 1, GL_FALSE,
|
||||
mat4ToFloat(mat4Multiply(batch->camera->view, batch->camera->projection)));*/
|
||||
|
||||
|
||||
//glUniformMatrix4fv(1, 1, GL_FALSE, mat4ToFloat(batch->camera->view));
|
||||
//glUniformMatrix4fv(2, 1, GL_FALSE, mat4ToFloat(batch->camera->projection));
|
||||
|
||||
if(batch->flush_callback != NULL)
|
||||
batch->flush_callback(batch);
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
Camera* create_camera(vec2 pos) {
|
||||
Camera* camera = calloc(sizeof(Camera), 1);
|
||||
Camera* camera = sl_new(Camera);
|
||||
camera->position = vec3(pos, -3.0f);
|
||||
camera->m = calloc(sizeof(CameraMatrices), 1);
|
||||
camera->m = sl_new(CameraMatrices);
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ RenderBatch* create_texture_quad_batch() {
|
|||
compile_shader("assets/texture.vert", GL_VERTEX_SHADER),
|
||||
compile_shader("assets/texture.frag", GL_FRAGMENT_SHADER), 0);
|
||||
|
||||
texture_quad_batch->data = calloc(sizeof(TextureQuadBatchData), 1);
|
||||
texture_quad_batch->data = sl_new(TextureQuadBatchData);
|
||||
texture_quad_batch->flush_callback = &texture_flush_callback;
|
||||
|
||||
batch_add_attrib(texture_quad_batch, (VertexAttrib){
|
||||
|
|
140
test.make
Normal file
140
test.make
Normal file
|
@ -0,0 +1,140 @@
|
|||
# Alternative GNU Make project makefile autogenerated by Premake
|
||||
|
||||
ifndef config
|
||||
config=debug
|
||||
endif
|
||||
|
||||
ifndef verbose
|
||||
SILENT = @
|
||||
endif
|
||||
|
||||
.PHONY: clean prebuild
|
||||
|
||||
SHELLTYPE := posix
|
||||
ifeq (.exe,$(findstring .exe,$(ComSpec)))
|
||||
SHELLTYPE := msdos
|
||||
endif
|
||||
|
||||
# Configurations
|
||||
# #############################################
|
||||
|
||||
RESCOMP = windres
|
||||
INCLUDES += -Iinclude -Iinclude/gearlib
|
||||
FORCE_INCLUDE +=
|
||||
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
|
||||
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
|
||||
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
|
||||
define PREBUILDCMDS
|
||||
endef
|
||||
define PRELINKCMDS
|
||||
endef
|
||||
define POSTBUILDCMDS
|
||||
endef
|
||||
|
||||
ifeq ($(config),debug)
|
||||
TARGETDIR = bin/Debug/test
|
||||
TARGET = $(TARGETDIR)/test
|
||||
OBJDIR = obj/Debug/test
|
||||
DEFINES += -DDEBUG
|
||||
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
|
||||
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
|
||||
LIBS += bin/Debug/gearlib/libgearlib.a -lglfw -lm
|
||||
LDDEPS += bin/Debug/gearlib/libgearlib.a
|
||||
ALL_LDFLAGS += $(LDFLAGS)
|
||||
|
||||
else ifeq ($(config),release)
|
||||
TARGETDIR = bin/Release/test
|
||||
TARGET = $(TARGETDIR)/test
|
||||
OBJDIR = obj/Release/test
|
||||
DEFINES += -DNDEBUG
|
||||
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2
|
||||
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2
|
||||
LIBS += bin/Release/gearlib/libgearlib.a -lglfw -lm
|
||||
LDDEPS += bin/Release/gearlib/libgearlib.a
|
||||
ALL_LDFLAGS += $(LDFLAGS) -s
|
||||
|
||||
endif
|
||||
|
||||
# Per File Configurations
|
||||
# #############################################
|
||||
|
||||
|
||||
# File sets
|
||||
# #############################################
|
||||
|
||||
GENERATED :=
|
||||
OBJECTS :=
|
||||
|
||||
GENERATED += $(OBJDIR)/test.o
|
||||
OBJECTS += $(OBJDIR)/test.o
|
||||
|
||||
# Rules
|
||||
# #############################################
|
||||
|
||||
all: $(TARGET)
|
||||
@:
|
||||
|
||||
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
|
||||
$(PRELINKCMDS)
|
||||
@echo Linking test
|
||||
$(SILENT) $(LINKCMD)
|
||||
$(POSTBUILDCMDS)
|
||||
|
||||
$(TARGETDIR):
|
||||
@echo Creating $(TARGETDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) mkdir -p $(TARGETDIR)
|
||||
else
|
||||
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
|
||||
endif
|
||||
|
||||
$(OBJDIR):
|
||||
@echo Creating $(OBJDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) mkdir -p $(OBJDIR)
|
||||
else
|
||||
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
|
||||
endif
|
||||
|
||||
clean:
|
||||
@echo Cleaning test
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) rm -f $(TARGET)
|
||||
$(SILENT) rm -rf $(GENERATED)
|
||||
$(SILENT) rm -rf $(OBJDIR)
|
||||
else
|
||||
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
|
||||
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
|
||||
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
|
||||
endif
|
||||
|
||||
prebuild: | $(OBJDIR)
|
||||
$(PREBUILDCMDS)
|
||||
|
||||
ifneq (,$(PCH))
|
||||
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
|
||||
$(GCH): $(PCH) | prebuild
|
||||
@echo $(notdir $<)
|
||||
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
|
||||
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
|
||||
ifeq (posix,$(SHELLTYPE))
|
||||
$(SILENT) touch "$@"
|
||||
else
|
||||
$(SILENT) echo $null >> "$@"
|
||||
endif
|
||||
else
|
||||
$(OBJECTS): | prebuild
|
||||
endif
|
||||
|
||||
|
||||
# File Rules
|
||||
# #############################################
|
||||
|
||||
$(OBJDIR)/test.o: examples/test.c
|
||||
@echo "$(notdir $<)"
|
||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||
|
||||
-include $(OBJECTS:%.o=%.d)
|
||||
ifneq (,$(PCH))
|
||||
-include $(PCH_PLACEHOLDER).d
|
||||
endif
|
Loading…
Reference in a new issue