Commit d83579a1 authored by Slava Monich's avatar Slava Monich

Merge pull request #9 from monich/order-only-prereq

Build directories are better described as order-only prerequisites
parents d19ebd7f fda7027b
......@@ -52,8 +52,6 @@ endif
DEBUG_CFLAGS = $(WARNINGS) $(DEBUG_FLAGS) $(DEBUG_DEFS) $(CFLAGS)
RELEASE_CFLAGS = $(WARNINGS) $(RELEASE_FLAGS) $(RELEASE_DEFS) $(CFLAGS)
DEBUG_LIBS = $(LIBS)
RELEASE_LIBS = $(LIBS)
#
# Files
......@@ -66,8 +64,6 @@ RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
# Dependencies
#
DEBUG_EXE_DEPS = $(DEBUG_BUILD_DIR)
RELEASE_EXE_DEPS = $(RELEASE_BUILD_DIR)
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
......@@ -75,6 +71,9 @@ ifneq ($(strip $(DEPS)),)
endif
endif
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
#
# Rules
#
......@@ -102,11 +101,11 @@ $(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_EXE): $(DEBUG_EXE_DEPS) $(DEBUG_OBJS)
$(LD) $(DEBUG_FLAGS) $(DEBUG_OBJS) $(DEBUG_LIBS) -o $@
$(DEBUG_EXE): $(DEBUG_OBJS)
$(LD) $(DEBUG_FLAGS) $^ $(LIBS) -o $@
$(RELEASE_EXE): $(RELEASE_EXE_DEPS) $(RELEASE_OBJS)
$(LD) $(RELEASE_FLAGS) $(RELEASE_OBJS) $(RELEASE_LIBS) -o $@
$(RELEASE_EXE): $(RELEASE_OBJS)
$(LD) $(RELEASE_FLAGS) $^ $(LIBS) -o $@
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif
......@@ -115,14 +115,14 @@ RELEASE_LIBS = \
# Files
#
.PRECIOUS: $(GEN_SRC:%=$(GEN_DIR)/%)
DEBUG_OBJS = \
$(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
$(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
$(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
$(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
.PRECIOUS: $(GEN_FILES)
#
# Dependencies
......@@ -139,13 +139,11 @@ RELEASE_DEPS = \
DEBUG_EXE_DEPS = \
$(MMS_LIB_DEBUG_LIB) \
$(MMS_OFONO_DEBUG_LIB) \
$(MMS_HANDLER_DEBUG_LIB) \
$(DEBUG_BUILD_DIR)
$(MMS_HANDLER_DEBUG_LIB)
RELEASE_EXE_DEPS = \
$(MMS_LIB_RELEASE_LIB) \
$(MMS_OFONO_RELEASE_LIB) \
$(MMS_HANDLER_RELEASE_LIB) \
$(RELEASE_BUILD_DIR)
$(MMS_HANDLER_RELEASE_LIB)
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
......@@ -153,6 +151,10 @@ ifneq ($(strip $(DEPS)),)
endif
endif
$(GEN_FILES): | $(GEN_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
#
# Rules
#
......
......@@ -110,6 +110,9 @@ ifneq ($(strip $(DEPS)),)
endif
endif
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
#
# Rules
#
......@@ -130,11 +133,11 @@ $(DEBUG_BUILD_DIR):
$(RELEASE_BUILD_DIR):
mkdir -p $@
$(DEBUG_LIB): $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
$(AR) $(ARFLAGS) $@ $(DEBUG_OBJS)
$(DEBUG_LIB): $(DEBUG_OBJS)
$(AR) $(ARFLAGS) $@ $^
$(RELEASE_LIB): $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
$(AR) $(ARFLAGS) $@ $(RELEASE_OBJS)
$(RELEASE_LIB): $(RELEASE_OBJS)
$(AR) $(ARFLAGS) $@ $^
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
......
......@@ -72,14 +72,14 @@ RELEASE_CFLAGS = $(RELEASE_FLAGS) $(RELEASE_DEFS) $(CFLAGS)
# Files
#
.PRECIOUS: $(GEN_SRC:%=$(GEN_DIR)/%)
DEBUG_OBJS = \
$(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
$(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
$(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
$(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
.PRECIOUS: $(GEN_FILES)
#
# Dependencies
......@@ -92,6 +92,10 @@ ifneq ($(strip $(DEPS)),)
endif
endif
$(GEN_FILES): | $(GEN_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
#
# Rules
#
......@@ -130,8 +134,8 @@ $(DEBUG_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
$(RELEASE_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_LIB): $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
$(AR) $(ARFLAGS) $@ $(DEBUG_OBJS)
$(DEBUG_LIB): $(DEBUG_OBJS)
$(AR) $(ARFLAGS) $@ $^
$(RELEASE_LIB): $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
$(AR) $(ARFLAGS) $@ $(RELEASE_OBJS)
$(RELEASE_LIB): $(RELEASE_OBJS)
$(AR) $(ARFLAGS) $@ $^
......@@ -54,28 +54,24 @@ endif
DEBUG_CFLAGS = $(DEBUG_FLAGS) $(DEBUG_DEFS) $(CFLAGS)
RELEASE_CFLAGS = $(RELEASE_FLAGS) $(RELEASE_DEFS) $(CFLAGS)
DEBUG_LIBS = $(LIBS)
RELEASE_LIBS = $(LIBS)
#
# Files
#
.PRECIOUS: $(GEN_SRC:%=$(GEN_DIR)/%)
DEBUG_OBJS = \
$(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
$(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = \
$(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
$(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
.PRECIOUS: $(GEN_FILES)
#
# Dependencies
#
DEBUG_EXE_DEPS = $(DEBUG_BUILD_DIR)
RELEASE_EXE_DEPS = $(RELEASE_BUILD_DIR)
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
......@@ -83,6 +79,10 @@ ifneq ($(strip $(DEPS)),)
endif
endif
$(GEN_FILES): | $(GEN_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
#
# Rules
#
......@@ -98,6 +98,9 @@ release: $(RELEASE_EXE)
clean:
rm -fr $(BUILD_DIR) $(SRC_DIR)/*~
$(GEN_DIR):
mkdir -p $@
$(DEBUG_BUILD_DIR):
mkdir -p $@
......@@ -119,11 +122,11 @@ $(DEBUG_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
$(RELEASE_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_EXE): $(DEBUG_EXE_DEPS) $(DEBUG_OBJS)
$(LD) $(DEBUG_FLAGS) $(DEBUG_OBJS) $(DEBUG_LIBS) -o $@
$(DEBUG_EXE): $(DEBUG_OBJS)
$(LD) $(DEBUG_FLAGS) $^ $(LIBS) -o $@
$(RELEASE_EXE): $(RELEASE_EXE_DEPS) $(RELEASE_OBJS)
$(LD) $(RELEASE_FLAGS) $(RELEASE_OBJS) $(RELEASE_LIBS) -o $@
$(RELEASE_EXE): $(RELEASE_OBJS)
$(LD) $(RELEASE_FLAGS) $^ $(LIBS) -o $@
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment