Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #*****************************************************************************#
- # Makefile: Generic makefile for compiling cmsis examples. #
- #-----------------------------------------------------------------------------#
- # Jesús Alonso Fernández @doragasu, 2012 #
- #*****************************************************************************#
- # TODO: Update the build recipes so they consider .h file dependencies.
- # Set root directory
- ROOT ?= ../../..
- # Import default variables
- include $(ROOT)/Makefile.inc
- # Linker libraries and flags
- LIBC := $(shell $(PREFIX)$(CC) -print-file-name=libc.a)
- LIBGCC := $(shell $(PREFIX)$(CC) -print-libgcc-file-name)
- LIBM := $(shell $(PREFIX)$(CC) -print-file-name=libm.a)
- LIBDSP := $(ROOT)/Lib/libdsplib_lm4f.a
- LIBS := $(LIBDSP) $(LIBM) $(LIBGCC) $(LIBC)
- LFLAGS = --static --gc-sections
- # Startup code and linker script from Mauro Scomparin (scompo)
- STARTUP = $(HOME)/src/stellaris/stellaris-launchpad-template-gcc/LM4F_startup.c
- LN_SCRIPT = $(HOME)/src/stellaris/stellaris-launchpad-template-gcc/LM4F.ld
- OUT_DIR = out
- OUT_ELF = $(OUT_DIR)/output.elf
- OUT_BIN = $(OUT_DIR)/output.bin
- # -- End of user defined variables --
- # Source file for the startup code
- start_src=$(notdir $(STARTUP))
- # Objects to be build
- objects = $(patsubst %.c,$(OUT_DIR)/%.o,$(wildcard *.c))
- objects += $(patsubst %.c,$(OUT_DIR)/%.o,$(notdir $(STARTUP)))
- # Default target. Builds the binary file
- $(OUT_BIN): $(OUT_ELF)
- $(PREFIX)$(OBJCOPY) -O binary $< $@
- # Builds the elf file
- $(OUT_ELF): $(objects)
- $(PREFIX)$(LD) $(LFLAGS) $(objects) $(LIBS) -T$(LN_SCRIPT) -o $@
- # Builds startup code
- $(start_src:%.c=$(OUT_DIR)/%.o): $(STARTUP) | $(OUT_DIR)
- $(PREFIX)$(CC) $(CFLAGS) -c $< -o $@
- # Builds every C file in the project directory
- $(OUT_DIR)/%.o: %.c | $(OUT_DIR)
- $(PREFIX)$(CC) $(CFLAGS) -c $< -o $@
- $(OUT_DIR):
- $(MKDIR) $(OUT_DIR)
- .PHONY: clean
- clean:
- $(RM) $(objects) $(OUT_ELF) $(OUT_BIN)
- $(RM) -d $(OUT_DIR)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement