[850] | 1 | # ============================================================================= |
---|
| 2 | # \file Makefile |
---|
| 3 | # \author Cesar Fuguet |
---|
| 4 | # \date July 9, 2014 |
---|
| 5 | # ============================================================================= |
---|
| 6 | include ../common.mk |
---|
| 7 | |
---|
| 8 | # ============================================================================= |
---|
| 9 | # Include files paths |
---|
| 10 | # ============================================================================= |
---|
| 11 | |
---|
| 12 | CONFDIR ?= output |
---|
| 13 | CONF := $(addprefix $(CONFDIR)/config/, hard_config.h) |
---|
| 14 | |
---|
| 15 | INCLUDE += -I$(CONFDIR)/config |
---|
| 16 | |
---|
| 17 | # ============================================================================= |
---|
| 18 | # Utils library |
---|
| 19 | # ============================================================================= |
---|
| 20 | |
---|
| 21 | LIB_SRCS := stdio.c \ |
---|
| 22 | string.c \ |
---|
| 23 | tty.c \ |
---|
| 24 | simhelper.c |
---|
| 25 | |
---|
| 26 | LIB_OBJS := $(addprefix $(BUILD_DIR)/,\ |
---|
| 27 | $(subst .c,.o, $(notdir $(LIB_SRCS)))) |
---|
| 28 | |
---|
| 29 | LIB_TARGET := $(BUILD_DIR)/libutils.a |
---|
| 30 | |
---|
| 31 | # ============================================================================= |
---|
| 32 | # Documentation generation |
---|
| 33 | # ============================================================================= |
---|
| 34 | |
---|
| 35 | DOCCONF := doxygen.config |
---|
| 36 | DOCDIR := doc |
---|
| 37 | |
---|
| 38 | # ============================================================================= |
---|
| 39 | # Object files |
---|
| 40 | # ============================================================================= |
---|
| 41 | |
---|
| 42 | S_SRCS := reset.S |
---|
| 43 | C_SRCS := main.c |
---|
| 44 | |
---|
| 45 | OBJS := $(addprefix $(BUILD_DIR)/,\ |
---|
| 46 | $(subst .c,.o, $(notdir $(C_SRCS))) \ |
---|
| 47 | $(subst .S,.o, $(notdir $(S_SRCS)))) |
---|
| 48 | |
---|
| 49 | TARGET := $(BUILD_DIR)/soft.elf |
---|
| 50 | |
---|
| 51 | # ============================================================================= |
---|
| 52 | # Makefile rules |
---|
| 53 | # ============================================================================= |
---|
| 54 | |
---|
| 55 | all: $(TARGET) |
---|
| 56 | |
---|
| 57 | # Specific dependencies |
---|
| 58 | # NOTE: normal prerequisites | order-only prerequisites |
---|
| 59 | # SEE: http://www.gnu.org/software/make/manual/make.html#Prerequisite-Types |
---|
| 60 | |
---|
| 61 | $(LIB_OBJS): $(CONF) | $(BUILD_DIR) |
---|
| 62 | $(OBJS): $(CONF) | $(BUILD_DIR) |
---|
| 63 | |
---|
| 64 | doc: $(DOCCONF) |
---|
| 65 | doxygen $< |
---|
| 66 | |
---|
| 67 | $(LIB_TARGET): $(LIB_OBJS) |
---|
| 68 | $(AR) rcs $@ $(LIB_OBJS) |
---|
| 69 | |
---|
| 70 | $(TARGET): $(OBJS) ../soft.ld $(LIB_TARGET) |
---|
| 71 | $(LD) -o $@ -T ../soft.ld $(OBJS) -L$(BUILD_DIR) -lutils |
---|
| 72 | $(DU) -D $@ > $@.txt |
---|
| 73 | |
---|
| 74 | $(BUILD_DIR): |
---|
| 75 | $(MKDIR) $@ |
---|
| 76 | |
---|
| 77 | clean: |
---|
| 78 | $(RM) $(BUILD_DIR) |
---|
| 79 | |
---|
| 80 | clean-doc: |
---|
| 81 | $(RM) $(DOCDIR) |
---|
| 82 | |
---|
| 83 | clean-log: |
---|
| 84 | $(RM) $(CONFDIR) |
---|
| 85 | |
---|
| 86 | distclean: clean clean-doc clean-log |
---|