calculator/Makefile

70 lines
1.8 KiB
Makefile
Raw Normal View History

2018-03-25 21:16:33 -04:00
##
# @file Makefile
# Script to build source files
#
# Copyright (C) 2018 Clyne Sullivan
#
# 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, see <https://www.gnu.org/licenses/>.
#
2018-01-04 11:47:43 -05:00
CROSS = arm-none-eabi-
CC = gcc
AS = as
AR = tools/rba
2018-01-04 11:47:43 -05:00
OBJCOPY = objcopy
2018-03-01 13:03:40 -05:00
STRIP = strip
2018-01-04 11:47:43 -05:00
2018-01-25 11:00:18 -05:00
MCUFLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
2018-01-04 11:47:43 -05:00
AFLAGS = $(MCUFLAGS)
2018-04-19 13:14:39 -04:00
CFLAGS = $(MCUFLAGS) -O2 \
2018-03-29 21:26:53 -04:00
-Iinclude -Iinclude/cmsis \
-fno-builtin -fsigned-char -ffreestanding \
-Wall -Werror -Wextra -pedantic \
-Wno-overlength-strings -Wno-discarded-qualifiers
LFLAGS = -T link.ld
2018-01-04 11:47:43 -05:00
CFILES = $(wildcard src/*.c)
AFILES = $(wildcard src/*.s)
OUTDIR = out
OFILES = $(patsubst src/%.c, $(OUTDIR)/%.o, $(CFILES)) \
$(patsubst src/%.s, $(OUTDIR)/%.asm.o, $(AFILES))
OUT = out/main.elf
2018-03-01 13:03:40 -05:00
INITRD = initrd.img
2018-01-04 11:47:43 -05:00
all: $(OUT)
2018-01-04 11:47:43 -05:00
$(OUT): $(OFILES) initrd/* libinterp.a
2018-03-01 13:03:40 -05:00
@echo " INITRD " $(INITRD)
@rm -f $(INITRD)
@$(AR) $(INITRD) initrd/*
2018-03-01 13:03:40 -05:00
@$(CROSS)$(OBJCOPY) -B arm -I binary -O elf32-littlearm $(INITRD) out/initrd.img.o
@echo " LINK " $(OUT)
2018-03-29 23:08:11 -04:00
@$(CROSS)$(CC) $(CFLAGS) $(LFLAGS) out/*.o -o $(OUT) -L. -linterp -lm
2018-01-04 11:47:43 -05:00
$(OUTDIR)/%.o: src/%.c
@echo " CC " $<
@$(CROSS)$(CC) $(CFLAGS) -c $< -o $@
$(OUTDIR)/%.asm.o: src/%.s
@echo " AS " $<
@$(CROSS)$(AS) $(AFLAGS) -c $< -o $@
2017-12-30 12:27:06 -05:00
clean:
2018-01-04 11:47:43 -05:00
@echo " CLEAN"
@rm -rf out/*