repositories
/
TD_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TP 13 exo1: Implement all the required features.
[TD_C.git]
/
TP_13
/
exo1
/
Makefile
diff --git
a/TP_13/exo1/Makefile
b/TP_13/exo1/Makefile
index 146115f0af178fc9623f83ebfacc19a8f3fa5930..fd958781e5a24c5afff621cac8df9daabc8639e3 100644
(file)
--- a/
TP_13/exo1/Makefile
+++ b/
TP_13/exo1/Makefile
@@
-1,21
+1,28
@@
# Sample Makefile to build simple project.
#
# This Makefile expect all source files (.c) to be at the same level, in the
# Sample Makefile to build simple project.
#
# This Makefile expect all source files (.c) to be at the same level, in the
-# current working directory.
+# $(SRC_PATH) directory.
+#
+# This Makefile expect all embedded library source files (.c) to be at the same level, in the
+# $(LIBRARY_PATH) directory.
#
# It will automatically generate dependencies, compile all files, and produce a
#
# It will automatically generate dependencies, compile all files, and produce a
-# binary using the provided name.
+# binary using the provided name
linked against the library if necessary
.
#
# Set BINARY_NAME to the name of the binary file to build.
#
# Set BINARY_NAME to the name of the binary file to build.
-# Set BUILD_TYPE to either debug or release
+# Set LIBRARY_NAME to the name of the library file to build.
+# The default path for the library code and object is lib.
+# By default the linker will look for $(BINARY_NAME) library name.
+# Set BUILD_TYPE to either debug or release.
#
# Automatic dependencies code from:
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr
BINARY_NAME=exo1
#
# 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
LIBRARY_NAME=libexo1
LIBRARY_PATH:=lib
BUILD_TYPE=debug
+#BUILD_TYPE=release
# ====================================
# DO NOT CHANGE STUFF BEYOND THIS LINE
# ====================================
# DO NOT CHANGE STUFF BEYOND THIS LINE
@@
-42,7
+49,9
@@
STRIP_FLAG = -s
OPTI_FLAG = -O3
endif
OPTI_FLAG = -O3
endif
-CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG)
+# Putting header files in the source directory is not the purpose of this INCLUDES variable
+INCLUDES := $(INCLUDES) -I$(LIBRARY_PATH)
+CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES)
LIBCFLAGS := -fPIC $(CFLAGS)
LDFLAGS := $(LDFLAGS) $(STRIP_FLAG)
LIBLDFLAGS := -shared $(LDFLAGS)
LIBCFLAGS := -fPIC $(CFLAGS)
LDFLAGS := $(LDFLAGS) $(STRIP_FLAG)
LIBLDFLAGS := -shared $(LDFLAGS)
@@
-52,7
+61,7
@@
LDLIBS := $(LDLIBS) -L$(LIBRARY_PATH) -l$(BINARY_NAME)
OBJDIR := $(BUILDDIR)/objs
$(shell mkdir -p $(OBJDIR))
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)))
LIBSRCS=$(wildcard $(LIBRARY_PATH)/*.c)
OBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SRCS)))
LIBOBJS=$(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(LIBSRCS)))
@@
-62,15
+71,6
@@
$(shell mkdir -p $(DEPDIR))
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(notdir $*).Td
POSTCOMPILE = mv -f $(DEPDIR)/$(notdir $*).Td $(DEPDIR)/$(notdir $*).d
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 $@ $^
$(LIBRARY_PATH)/$(LIBRARY_NAME).a: $(LIBOBJS)
@echo "[AR StO] $@"
@$(AR) rcs $@ $^
@@
-91,22
+91,18
@@
$(BINARY_NAME).static: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LDLIBS) -o $@
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LDLIBS) -o $@
-#$(BINARY_NAME).staticlocal: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a
-# @echo "[LD ] $@"
-# @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
-
$(BINARY_NAME).dynamic: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).so
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(BINARY_NAME).dynamic: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).so
@echo "[LD ] $@"
@$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
-$(OBJ
S): $(SRCS)
$(DEPDIR)/%.d
+$(OBJ
DIR)/%.o: $(SRC_PATH)/%.c
$(DEPDIR)/%.d
@echo "[C ] $(notdir $*)"
@$(CC) $(DEPFLAGS) $(CFLAGS) -c $< -o $@
@$(POSTCOMPILE)
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))
@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)
@echo "[C ] $(notdir $*)"
@$(CC) $(DEPFLAGS) $(LIBCFLAGS) -c $< -o $@
@$(POSTCOMPILE)