# Automatic dependencies code from:
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr
BINARY_NAME=exo2
-LIBOBJS=clist.o ui.o# object to put in the library
+LIBOBJS=clist.o ui.o # object to put in the library
LIBRARY_NAME=libtpC
-#LDLIBS=-L. -ltpC
BUILD_TYPE=debug
# ====================================
$(LIBRARY_NAME).so: $(OBJSLIB)
@echo "[LD ShO] $@"
- @$(LD) $(CFLAGS) $(LIBLDFLAGS) $^ $(LDLIBS) -o $@
+ @$(LD) $(CFLAGS) $(LIBLDFLAGS) $^ -o $@
$(BINARY_NAME): $(OBJS)
@echo "[LD ] $@"
BINARY_PATH:=src
LIBRARY_NAME=libexo1
LIBRARY_PATH:=lib
-#LDLIBS=-L$(LIBRARY_PATH) -l$(BINARY_NAME)
BUILD_TYPE=debug
# ====================================
OPTI_FLAG = -O3
endif
-#FIXME: Add a way to better control the library build flag
-CFLAGS := -fPIC $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG)
+CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG)
+LIBCFLAGS := -fPIC $(CFLAGS)
LDFLAGS := $(LDFLAGS) $(STRIP_FLAG)
LIBLDFLAGS := -shared $(LDFLAGS)
STATICLIBLDFLAGS := -static $(LDFLAGS)
+LDLIBS := $(LDLIBS) -L$(LIBRARY_PATH) -l$(BINARY_NAME)
OBJDIR := $(BUILDDIR)/objs
$(shell mkdir -p $(OBJDIR))
$(LIBRARY_PATH)/$(LIBRARY_NAME).so: $(LIBOBJS)
@echo "[LD ShO] $@"
- @$(LD) $(CFLAGS) $(LIBLDFLAGS) $^ $(LDLIBS) -o $@
+ @$(LD) $(LIBCFLAGS) $(LIBLDFLAGS) $^ -o $@
#$(BINARY_NAME): $(OBJS) $(LIBOBJS)
# @echo "[LD ] $@"
-# $(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
+# @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(BINARY_NAME): $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
@echo "[LD ] $@"
- @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
+ @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
-LOCALLDLIBS=-L$(LIBRARY_PATH) -l$(BINARY_NAME)
$(BINARY_NAME).static: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
@echo "[LD ] $@"
- @$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
+ @$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LDLIBS) -o $@
#$(BINARY_NAME).staticlocal: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
# @echo "[LD ] $@"
-# @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
+# @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(BINARY_NAME).dynamic: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).so
@echo "[LD ] $@"
- @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LOCALLDLIBS) $(LDLIBS) -o $@
+ @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJS): $(SRCS) $(DEPDIR)/%.d
- @echo "[C ] $*"
+ @echo "[C ] $(notdir $*)"
@$(CC) $(DEPFLAGS) $(CFLAGS) -c $< -o $@
@$(POSTCOMPILE)
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))
$(LIBOBJS): $(LIBSRCS) $(DEPDIR)/%.d
- @echo "[C ] $*"
- @$(CC) $(DEPFLAGS) $(CFLAGS) -c $< -o $@
+ @echo "[C ] $(notdir $*)"
+ @$(CC) $(DEPFLAGS) $(LIBCFLAGS) -c $< -o $@
@$(POSTCOMPILE)
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(LIBSRCS))))
.PRECIOUS: $(DEPDIR)/%.d
+#FIXME: add an install target
+
clean:
@echo "[CLN]"
-@rm -r $(BUILDDIR)