rules.mk
198 lines
| 6.4 KiB
| text/x-makefile
|
MakefileLexer
r11 | #/*------------------------------------------------------------------------------ | |||
#-- This file is a part of the libuc, microcontroler library | ||||
#-- Copyright (C) 2011, Alexis Jeandet | ||||
#-- | ||||
#-- This program is free software; you can redistribute it and/or modify | ||||
#-- it under the terms of the GNU General Public License as published by | ||||
#-- the Free Software Foundation; either version 3 of the License, or | ||||
#-- (at your option) any later version. | ||||
#-- | ||||
#-- This program is distributed in the hope that it will be useful, | ||||
#-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
#-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
#-- GNU General Public License for more details. | ||||
#-- | ||||
#-- You should have received a copy of the GNU General Public License | ||||
#-- along with this program; if not, write to the Free Software | ||||
#-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
#------------------------------------------------------------------------------- | ||||
#-- Author : Alexis Jeandet | ||||
#-- Mail : alexis.jeandet@gmail.com | ||||
#-------------------------------------------------------------------------------*/ | ||||
#--------------------------------------------------------------------------------- | ||||
# GCC EXECUTABLES | ||||
#--------------------------------------------------------------------------------- | ||||
LIBUC_PREFIX = arm-none-eabi- | ||||
LIBUC_CC = $(LIBUC_PREFIX)gcc | ||||
LIBUC_CXX = $(LIBUC_PREFIX)g++ | ||||
LIBUC_AR = $(LIBUC_PREFIX)ar | ||||
LIBUC_AS = $(LIBUC_PREFIX)as | ||||
LIBUC_LD = $(LIBUC_PREFIX)ld | ||||
LIBUC_SIZE = $(LIBUC_PREFIX)size | ||||
LIBUC_STRIP = $(LIBUC_PREFIX)strip -s | ||||
LIBUC_READELF = $(LIBUC_PREFIX)readelf | ||||
LIBUC_OBJCOPY=$(LIBUC_PREFIX)objcopy | ||||
LIBUC_OBJDUMP=$(LIBUC_PREFIX)objdump | ||||
#--------------------------------------------------------------------------------- | ||||
# GCC FLAGS | ||||
#--------------------------------------------------------------------------------- | ||||
LIBUC_FMCU = -mcpu=arm7tdmi | ||||
LIBUC_CFLAGS = $(LIBUC_FMCU) | ||||
r12 | LIBUC_CFLAGS += -g -gdwarf-2 -fomit-frame-pointer | |||
LIBUC_CFLAGS += -Wall -Wextra -Wundef -Wcast-align -DROM_RUN | ||||
LIBUC_LDFLAGS = -nostartfiles | ||||
r11 | LIBUC_ODFLAGS = -x --syms | |||
LIBUC_CPFLAGS = | ||||
LIBUC_CFLAGS_WARN_ON = -Wall | ||||
LIBUC_CFLAGS_WARN_OFF = -w | ||||
LIBUC_CFLAGS_RELEASE = -O2 | ||||
LIBUC_CFLAGS_DEBUG = -g | ||||
LIBUC_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -g | ||||
LIBUC_CFLAGS_STATIC_LIB = -fPIC | ||||
LIBUC_CFLAGS_SOFT_FPU = -msoft-float | ||||
LIBUC_CFLAGS_HARD_FPU = | ||||
LIBUC_CXXFLAGS = $(LIBUC_FMCU) | ||||
LIBUC_CXXFLAGS += -g -gdwarf-2 $(LIBUC_FMCU) | ||||
LIBUC_CXXFLAGS += -Wall -Wextra -Wundef -Wcast-align | ||||
LIBUC_CXXFLAGS_WARN_ON = -Wall | ||||
LIBUC_CXXFLAGS_WARN_OFF = -w | ||||
LIBUC_CXXFLAGS_RELEASE = -O2 | ||||
LIBUC_CXXFLAGS_DEBUG = -g | ||||
LIBUC_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -g | ||||
LIBUC_CXXFLAGS_STATIC_LIB = -fPIC | ||||
LIBUC_CXXFLAGS_SOFT_FPU = -msoft-float | ||||
LIBUC_CXXFLAGS_HARD_FPU = | ||||
r12 | ||||
r11 | #--------------------------------------------------------------------------------- | |||
# LIBRARY DEFINITIONS | ||||
#--------------------------------------------------------------------------------- | ||||
LIBUC_LIBS_DIR = $(LIBUC)/lib/bin/lpc21XX | ||||
r12 | LIBUC_INC_DIR = $(LIBUC)/lib/includes/lpc21XX | |||
include $(LIBUC)/rules/common/libsrules.mk | ||||
r11 | ||||
#--------------------------------------------------------------------------------- | ||||
# BOARD SUPORT PACKAGES | ||||
#--------------------------------------------------------------------------------- | ||||
LIBUC_BSP_DIR=$(LIBUC)/bsp | ||||
LIBUC_BSP_BIN_DIR= $(LIBUC_BSP_DIR)/bin | ||||
LIBUC_BSP_INC_DIR= $(LIBUC_BSP_DIR)/includes | ||||
LIBUC_BSP = -L $(LIBUC_BSP_BIN_DIR)/$(BSP) -static -lbsp | ||||
LIBUC_BSP_INC = -I $(LIBUC_BSP_INC_DIR)/$(BSP) | ||||
#--------------------------------------------------------------------------------- | ||||
# DEVICE SPECIAL FILES | ||||
#--------------------------------------------------------------------------------- | ||||
r12 | LINKER_SCRIPT = $(ARCHFOLDER)/LPC2378-ROM.ld | |||
DEVSOURCES += | ||||
DEVSOURCESND = $(notdir $(DEVSOURCES)) | ||||
DEVOBJECTFILES += $(DEVSOURCESND:.c=.o) | ||||
DEVOBJECTFILES := $(addprefix $(OBJDIR)/,$(DEVOBJECTFILES)) | ||||
OBJECTFILES += $(DEVOBJECTFILES) | ||||
ASMDEVSOURCES += $(ARCHFOLDER)/crt0.S | ||||
ASMDEVSOURCESND = $(notdir $(ASMDEVSOURCES)) | ||||
ASMDEVOBJECTFILES += $(ASMDEVSOURCESND:.S=.o) | ||||
ASMDEVOBJECTFILES := $(addprefix $(OBJDIR)/,$(ASMDEVOBJECTFILES)) | ||||
ASMOBJECTFILES += $(ASMDEVOBJECTFILES) | ||||
#RUN_MODE=ROM_RUN | ||||
#LIBUC_CFLAGS += -D$(RUN_MODE) | ||||
LPC23XX_INCDIR=$(ARCHFOLDER) | ||||
r11 | ||||
#--------------------------------------------------------------------------------- | ||||
# RULES | ||||
#--------------------------------------------------------------------------------- | ||||
all: | ||||
r12 | @echo "lpc23XX-arm-noabi-gcc rules" | |||
r11 | ||||
r12 | bin: $(ASMDEVSOURCESND) $(DEVSOURCESND) $(BINDIR)/$(TARGET).bin $(BINDIR)/$(TARGET).hex | |||
r11 | @echo "compile bin" | |||
r12 | $(DEVSOURCESND): $(DEVSOURCES) | |||
cp -f $(DEVSOURCES) ./ | ||||
$(ASMDEVSOURCESND): $(ASMDEVSOURCES) | ||||
cp -f $(ASMDEVSOURCES) ./ | ||||
r11 | ||||
r12 | lib: $(TARGETINSTALLPATH)/$(TARGET).a | |||
r11 | @echo "compile lib" | |||
%.a: $(OBJECTFILES) | ||||
mkdir -p $(TARGETINSTALLPATH) | ||||
mkdir -p $(HEADERSINSTALLPATH) | ||||
r12 | $(LIBUC_AR) rcs $@ $(OBJECTFILES) #$(LIBUC_AR) rcs $(TARGETINSTALLPATH)/$@ $(OBJECTFILES) | |||
r11 | cp -f $(HEADERS) $(HEADERSINSTALLPATH)/ | |||
r12 | ||||
#%.o: %.c | ||||
# $(LIBUC_CC) -O3 -I $(LPC17XX_INCDIR) $(LIBUC_INCLUDES) $(LIBUC_BSP_INC) -MM $< -MF $*.d -MP | ||||
# $(LIBUC_CC) -O3 -I $(LPC17XX_INCDIR) $(LIBUC_INCLUDES) $(LIBUC_BSP_INC) -c $(LIBUC_CFLAGS) $< -o $@ | ||||
r11 | ||||
r12 | $(OBJECTFILES) : $(OBJDIR)/%.o : %.c $(INC_LIBS_DEPS) $(HEADERS) | |||
mkdir -p $(OBJDIR) | ||||
$(LIBUC_CC) -O3 -I $(LPC23XX_INCDIR) $(LIBUC_INCLUDES) $(LIBUC_BSP_INC) -MM $< -MF $*.d -MP | ||||
$(LIBUC_CC) -O3 -I $(LPC23XX_INCDIR) $(LIBUC_INCLUDES) $(LIBUC_BSP_INC) -c $(LIBUC_CFLAGS) $< -o $@ | ||||
r11 | ||||
r12 | $(ASMOBJECTFILES) : $(OBJDIR)/%.o : %.S $(INC_LIBS_DEPS) $(HEADERS) | |||
mkdir -p $(OBJDIR) | ||||
$(LIBUC_CC) -O3 -I $(LPC23XX_INCDIR) $(LIBUC_INCLUDES) $(LIBUC_BSP_INC) -c $(LIBUC_CFLAGS) $< -o $@ | ||||
%.elf: $(LINKER_SCRIPT) $(ASMOBJECTFILES) $(OBJECTFILES) | ||||
mkdir -p $(BINDIR) | ||||
$(LIBUC_CC) $(LIBUC_LDFLAGS) $(LIBUC_CFLAGS) -T $^ -o $@ $(LIBUC_BSP) $(LIBUC_LIBRARIES) | ||||
r11 | $(LIBUC_OBJDUMP) $(LIBUC_ODFLAGS) $@ > $(@:.elf=.dump) | |||
$(LIBUC_SIZE) $@ | ||||
r12 | ||||
%.bin: %.elf $(BIN_LIBS_DEPS) | ||||
r11 | $(LIBUC_OBJCOPY) $(LIBUC_CPFLAGS) -O binary $< $*.bin | |||
r12 | @echo "BIN_LIBS_DEPS" | |||
@echo $(BIN_LIBS_DEPS) | ||||
r11 | ||||
%.hex: %.elf | ||||
$(LIBUC_OBJCOPY) $(LIBUC_CPFLAGS) -O ihex $< $*.hex | ||||
clean: | ||||
rm -f *.o *.d *.bin *.hex *.dump *.map *.a | ||||
r12 | rm -f $(OBJECTFILES) | |||
rm -f $(BINDIR)/*.bin | ||||
rm -f $(BINDIR)/*.hex | ||||
rm -f $(BINDIR)/*.dump | ||||
rm -f $(BINDIR)/*.map | ||||
rm -f $(BINDIR)/*.a | ||||
rm -f $(DEVSOURCESND) | ||||
r11 | ||||
distclean: | ||||
rm -f $(TARGETINSTALLPATH)/*.bin | ||||
rm -f $(TARGETINSTALLPATH)/*.a | ||||
r12 | ||||