##// END OF EJS Templates
lpc17XX Rules OK, Makefile generator OK
lpc17XX Rules OK, Makefile generator OK

File last commit:

r1:b5a74c12efe8 default
r1:b5a74c12efe8 default
Show More
rules.mk
148 lines | 4.8 KiB | text/x-makefile | MakefileLexer
#/*------------------------------------------------------------------------------
#-- 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=cortex-m3
LIBUC_CFLAGS = $(LIBUC_FMCU)
LIBUC_CFLAGS = --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb
LIBUC_CFLAGS += -ffunction-sections -fdata-sections
LIBUC_LDFLAGS = --gc-sections
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_CXXFLAGS += -Wextra -Wundef -Wcast-align -mthumb -msoft-float
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 =
LIBUC_LIBS =
LIBUC_LIBS_UART = -luart
LIBUC_LIBS_SPI = -lspi
LIBUC_LIBS_IIC = -liic
LIBUC_LIBS_ADC = -ladc
LIBUC_LIBS_DIR = $(LIBUC)/lib/bin/lpc17XX
LIBUC_LIBS_DIR_UART = -L $(LIBUC_LIBS_DIR)/UART
LIBUC_LIBS_DIR_SPI = -L $(LIBUC_LIBS_DIR)/SPI
LIBUC_LIBS_DIR_IIC = -L $(LIBUC_LIBS_DIR)/IIC
LIBUC_LIBS_DIR_ADC = -L $(LIBUC_LIBS_DIR)/ADC
LIBUC_INC_DIR = $(LIBUC)/lib/includes/lpc17XX
LIBUC_INC_DIR_UART = -I $(LIBUC_INC_DIR)/UART
LIBUC_INC_DIR_SPI = -I $(LIBUC_INC_DIR)/SPI
LIBUC_INC_DIR_IIC = -I $(LIBUC_INC_DIR)/IIC
LIBUC_INC_DIR_ADC = -I $(LIBUC_INC_DIR)/ADC
#---------------------------------------------------------------------------------
# DEVICE SPECIAL FILES
#---------------------------------------------------------------------------------
LINKER_SCRIPT = $(ARCH)/LPC17xx.ld
SOURCES += $(ARCH)/startup_LPC17xx.c $(ARCH)/core_cm3.c $(ARCH)/system_LPC17xx.c
LPC17XX_INCDIR=$(ARCH)
all:
@echo "lpc17XX-arm-noabi-gcc rules"
bin: $(TARGET).bin $(TARGET).hex
@echo "compile bin"
lib: $(TARGET).a
@echo "compile lib"
%.a: $(OBJECTFILES)
mkdir -p $(TARGETINSTALLPATH)
mkdir -p $(HEADERSINSTALLPATH)
ar rcs $(TARGETINSTALLPATH)/$@ $(OBJECTFILES)
cp $(HEADERS) $(HEADERSINSTALLPATH)/
%.o: %.c
$(LIBUC_CC) -I $(LPC17XX_INCDIR) $(LIBUC_INCLUDES) -MM $< -MF $*.d -MP
$(LIBUC_CC) -I $(LPC17XX_INCDIR) $(LIBUC_INCLUDES) -c $(LIBUC_CFLAGS) $< -o $@
%.elf: $(LINKER_SCRIPT) $(OBJECTFILES)
$(LIBUC_LD) -Map $(@:.elf=.map) $(LIBUC_LDFLAGS) $(LIBUC_LIBRARIES) -T $^ -o $@
$(LIBUC_OBJDUMP) $(LIBUC_ODFLAGS) $@ > $(@:.elf=.dump)
$(LIBUC_SIZE) $@
%.bin: %.elf
$(LIBUC_OBJCOPY) $(LIBUC_CPFLAGS) -O binary $< $*.bin
%.hex: %.elf
$(LIBUC_OBJCOPY) $(LIBUC_CPFLAGS) -O ihex $< $*.hex
clean:
rm -f *.o *.d *.bin *.hex *.dump *.map *.a
distclean:
rm -f $(TARGETINSTALLPATH)/*.bin
rm -f $(TARGETINSTALLPATH)/*.a