diff --git a/.gitignore b/.gitignore index 6d45ee2..ea8d248 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.a obj/ -examples/*.exe +bin/ diff --git a/Makefile b/Makefile index 2929a13..a2ea16a 100644 --- a/Makefile +++ b/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" \ No newline at end of file diff --git a/examples/Makefile b/examples/Makefile index ad126f4..876b0b9 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -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: diff --git a/examples/quad.c b/examples/quad.c new file mode 100644 index 0000000..1ed26b7 --- /dev/null +++ b/examples/quad.c @@ -0,0 +1,39 @@ +#include + +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; +} diff --git a/gearlib.make b/gearlib.make new file mode 100644 index 0000000..a5d66b1 --- /dev/null +++ b/gearlib.make @@ -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 \ No newline at end of file diff --git a/include/gearlib.h b/include/gearlib.h index 83e5f6a..f6da1a6 100644 --- a/include/gearlib.h +++ b/include/gearlib.h @@ -3,18 +3,19 @@ #define MAX_VERTICES 2500 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/include/KHR/khrplatform.h b/include/gearlib/KHR/khrplatform.h similarity index 100% rename from include/KHR/khrplatform.h rename to include/gearlib/KHR/khrplatform.h diff --git a/include/batch.h b/include/gearlib/batch.h similarity index 97% rename from include/batch.h rename to include/gearlib/batch.h index 34ae055..01bb936 100644 --- a/include/batch.h +++ b/include/gearlib/batch.h @@ -6,7 +6,6 @@ #include #include -#include typedef struct BatchStats { uint32_t draw_calls; diff --git a/include/camera.h b/include/gearlib/camera.h similarity index 100% rename from include/camera.h rename to include/gearlib/camera.h diff --git a/include/colors.h b/include/gearlib/colors.h similarity index 100% rename from include/colors.h rename to include/gearlib/colors.h diff --git a/include/debugging.h b/include/gearlib/debugging.h similarity index 100% rename from include/debugging.h rename to include/gearlib/debugging.h diff --git a/include/events.h b/include/gearlib/events.h similarity index 100% rename from include/events.h rename to include/gearlib/events.h diff --git a/include/glad/gl.h b/include/gearlib/glad/gl.h similarity index 100% rename from include/glad/gl.h rename to include/gearlib/glad/gl.h diff --git a/include/init.h b/include/gearlib/init.h similarity index 86% rename from include/init.h rename to include/gearlib/init.h index a863c8e..2957fc2 100644 --- a/include/init.h +++ b/include/gearlib/init.h @@ -1,7 +1,7 @@ #ifndef __INIT_H__ #define __INIT_H__ -#include +#include typedef GLFWwindow* Window; diff --git a/include/opengl.h b/include/gearlib/opengl.h similarity index 72% rename from include/opengl.h rename to include/gearlib/opengl.h index 73ddc0e..aa31212 100644 --- a/include/opengl.h +++ b/include/gearlib/opengl.h @@ -1,7 +1,7 @@ #ifndef __OPENGL_H__ #define __OPENGL_H__ -#include +#include #include #endif diff --git a/include/quad.h b/include/gearlib/quad.h similarity index 100% rename from include/quad.h rename to include/gearlib/quad.h diff --git a/include/raymath.h b/include/gearlib/raymath.h similarity index 100% rename from include/raymath.h rename to include/gearlib/raymath.h diff --git a/include/renderer.h b/include/gearlib/renderer.h similarity index 100% rename from include/renderer.h rename to include/gearlib/renderer.h diff --git a/include/shaders.h b/include/gearlib/shaders.h similarity index 100% rename from include/shaders.h rename to include/gearlib/shaders.h diff --git a/include/slibs.h b/include/gearlib/slibs.h similarity index 95% rename from include/slibs.h rename to include/gearlib/slibs.h index c16b334..757555c 100644 --- a/include/slibs.h +++ b/include/gearlib/slibs.h @@ -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__ } diff --git a/include/stb_image.h b/include/gearlib/stb_image.h similarity index 100% rename from include/stb_image.h rename to include/gearlib/stb_image.h diff --git a/include/textures.h b/include/gearlib/textures.h similarity index 100% rename from include/textures.h rename to include/gearlib/textures.h diff --git a/include/uniform_buffer.h b/include/gearlib/uniform_buffer.h similarity index 100% rename from include/uniform_buffer.h rename to include/gearlib/uniform_buffer.h diff --git a/include/vertex.h b/include/gearlib/vertex.h similarity index 100% rename from include/vertex.h rename to include/gearlib/vertex.h diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..1d8f3a8 --- /dev/null +++ b/premake5.lua @@ -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" diff --git a/src/batch.c b/src/batch.c index ab2556d..07a2c89 100644 --- a/src/batch.c +++ b/src/batch.c @@ -1,11 +1,10 @@ #include #include -#include 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); diff --git a/src/camera.c b/src/camera.c index 6cd1dfd..3dfddce 100644 --- a/src/camera.c +++ b/src/camera.c @@ -2,9 +2,9 @@ #include 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; } diff --git a/src/textures.c b/src/textures.c index 1192f21..128d053 100644 --- a/src/textures.c +++ b/src/textures.c @@ -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){ diff --git a/test.make b/test.make new file mode 100644 index 0000000..da2b015 --- /dev/null +++ b/test.make @@ -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 \ No newline at end of file