2014-01-24 04:05:30 -05:00
|
|
|
ifneq ($(MKENV_INCLUDED),1)
|
|
|
|
# We assume that mkenv is in the same directory as this file.
|
|
|
|
THIS_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
|
|
|
include $(dir $(THIS_MAKEFILE))mkenv.mk
|
|
|
|
endif
|
|
|
|
|
|
|
|
# This file expects that OBJ contains a list of all of the object files.
|
|
|
|
# The directory portion of each object file is used to locate the source
|
|
|
|
# and should not contain any ..'s but rather be relative to the top of the
|
|
|
|
# tree.
|
|
|
|
#
|
|
|
|
# So for example, py/map.c would have an object file name py/map.o
|
|
|
|
# The object files will go into the build directory and mantain the same
|
|
|
|
# directory structure as the source tree. So the final dependency will look
|
|
|
|
# like this:
|
|
|
|
#
|
|
|
|
# build/py/map.o: py/map.c
|
|
|
|
#
|
|
|
|
# We set vpath to point to the top of the tree so that the source files
|
|
|
|
# can be located. By following this scheme, it allows a single build rule
|
|
|
|
# to be used to compile all .c files.
|
|
|
|
|
|
|
|
vpath %.S . $(TOP)
|
|
|
|
$(BUILD)/%.o: %.S
|
|
|
|
$(ECHO) "CC $<"
|
|
|
|
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
vpath %.s . $(TOP)
|
|
|
|
$(BUILD)/%.o: %.s
|
|
|
|
$(ECHO) "AS $<"
|
|
|
|
$(Q)$(AS) -o $@ $<
|
|
|
|
|
|
|
|
define compile_c
|
|
|
|
$(ECHO) "CC $<"
|
|
|
|
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
|
|
|
|
@# The following fixes the dependency file.
|
|
|
|
@# See http://make.paulandlesley.org/autodep.html for details.
|
2014-04-06 20:35:45 -04:00
|
|
|
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
|
|
|
$(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
2014-01-24 04:05:30 -05:00
|
|
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
2014-04-06 20:35:45 -04:00
|
|
|
$(RM) -f $(@:.o=.d)
|
2014-01-24 04:05:30 -05:00
|
|
|
endef
|
|
|
|
|
|
|
|
vpath %.c . $(TOP)
|
|
|
|
$(BUILD)/%.o: %.c
|
|
|
|
$(call compile_c)
|
|
|
|
|
2014-03-15 02:41:28 -04:00
|
|
|
$(BUILD)/%.pp: %.c
|
|
|
|
$(ECHO) "PreProcess $<"
|
|
|
|
$(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $<
|
|
|
|
|
2014-01-24 04:05:30 -05:00
|
|
|
# The following rule uses | to create an order only prereuisite. Order only
|
|
|
|
# prerequisites only get built if they don't exist. They don't cause timestamp
|
|
|
|
# checkng to be performed.
|
|
|
|
#
|
|
|
|
# $(sort $(var)) removes duplicates
|
|
|
|
#
|
|
|
|
# The net effect of this, is it causes the objects to depend on the
|
|
|
|
# object directories (but only for existance), and the object directories
|
|
|
|
# will be created if they don't exist.
|
|
|
|
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
2014-04-14 13:47:14 -04:00
|
|
|
$(OBJ): $(PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
|
2014-01-24 04:05:30 -05:00
|
|
|
$(OBJ_DIRS):
|
2014-04-06 20:35:45 -04:00
|
|
|
$(MKDIR) -p $@
|
2014-01-24 04:05:30 -05:00
|
|
|
|
|
|
|
ifneq ($(PROG),)
|
|
|
|
# Build a standalone executable (unix and unix-cpy do this)
|
|
|
|
|
|
|
|
all: $(PROG)
|
|
|
|
|
|
|
|
$(PROG): $(OBJ)
|
2014-01-25 11:55:31 -05:00
|
|
|
$(ECHO) "LINK $@"
|
2014-01-24 04:05:30 -05:00
|
|
|
$(Q)$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)
|
|
|
|
ifndef DEBUG
|
2014-04-06 20:35:45 -04:00
|
|
|
$(Q)$(STRIP) $(PROG)
|
2014-01-24 04:05:30 -05:00
|
|
|
endif
|
2014-04-06 20:35:45 -04:00
|
|
|
$(Q)$(SIZE) $(PROG)
|
2014-01-24 04:05:30 -05:00
|
|
|
|
|
|
|
clean: clean-prog
|
|
|
|
clean-prog:
|
|
|
|
$(RM) -f $(PROG)
|
2014-04-10 19:41:59 -04:00
|
|
|
$(RM) -f $(PROG).map
|
2014-01-24 04:05:30 -05:00
|
|
|
|
|
|
|
.PHONY: clean-prog
|
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) -rf $(BUILD)
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
print-cfg:
|
|
|
|
$(ECHO) "PY_SRC = $(PY_SRC)"
|
|
|
|
$(ECHO) "BUILD = $(BUILD)"
|
|
|
|
$(ECHO) "OBJ = $(OBJ)"
|
|
|
|
.PHONY: print-cfg
|
|
|
|
|
|
|
|
-include $(OBJ:.o=.P)
|