# Automatic dependencies code from:
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr
BINARY_NAME=exo1
-BINARY_PATH:=src
+SRC_PATH:=src
LIBRARY_NAME=libexo1
LIBRARY_PATH:=lib
BUILD_TYPE=debug
+#BUILD_TYPE=release
# ====================================
# DO NOT CHANGE STUFF BEYOND THIS LINE
OPTI_FLAG = -O3
endif
-CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG)
+INCLUDES := $(INCLUDES) -I$(SRC_PATH) -I$(LIBRARY_PATH)
+CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES)
LIBCFLAGS := -fPIC $(CFLAGS)
LDFLAGS := $(LDFLAGS) $(STRIP_FLAG)
LIBLDFLAGS := -shared $(LDFLAGS)
OBJDIR := $(BUILDDIR)/objs
$(shell mkdir -p $(OBJDIR))
-SRCS=$(wildcard $(BINARY_PATH)/*.c)
+SRCS=$(wildcard $(SRC_PATH)/*.c)
LIBSRCS=$(wildcard $(LIBRARY_PATH)/*.c)
OBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SRCS)))
LIBOBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(LIBSRCS)))
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(notdir $*).Td
POSTCOMPILE = mv -f $(DEPDIR)/$(notdir $*).Td $(DEPDIR)/$(notdir $*).d
-print:
- @echo $(basename $(notdir $(SRCS)))
- @echo $(notdir $(SRCS))
- @echo $(DEPDIR)/%d
- @echo $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))
- @echo $(OBJS) $(LIBOBJS)
- @echo $(SRCS) $(LIBSRCS)
- @echo $(POSTCOMPILE)
-
$(LIBRARY_PATH)/$(LIBRARY_NAME).a: $(LIBOBJS)
@echo "[AR StO] $@"
@$(AR) rcs $@ $^
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
-$(OBJS): $(SRCS) $(DEPDIR)/%.d
+$(OBJDIR)/%.o: $(SRC_PATH)/%.c $(DEPDIR)/%.d
@echo "[C ] $(notdir $*)"
@$(CC) $(DEPFLAGS) $(CFLAGS) -c $< -o $@
@$(POSTCOMPILE)
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))
-$(LIBOBJS): $(LIBSRCS) $(DEPDIR)/%.d
+$(OBJDIR)/%.o: $(LIBRARY_PATH)/%.c $(DEPDIR)/%.d
@echo "[C ] $(notdir $*)"
@$(CC) $(DEPFLAGS) $(LIBCFLAGS) -c $< -o $@
@$(POSTCOMPILE)