CommonPIC32

Annotated mk/common.mk

150:82a63936a118
2019-06-11 Paul Boddie Added initial library documentation.
paul@24 1
# Makefile - Common definitions for building PIC32 deployment payloads
paul@24 2
#
paul@24 3
# Copyright (C) 2015, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
paul@24 4
# Copyright (C) Xiangfu Liu <xiangfu@sharism.cc>
paul@24 5
#
paul@24 6
# This program is free software: you can redistribute it and/or modify
paul@24 7
# it under the terms of the GNU General Public License as published by
paul@24 8
# the Free Software Foundation, either version 3 of the License, or
paul@24 9
# (at your option) any later version.
paul@24 10
#
paul@24 11
# This program is distributed in the hope that it will be useful,
paul@24 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@24 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@24 14
# GNU General Public License for more details.
paul@24 15
#
paul@24 16
# You should have received a copy of the GNU General Public License
paul@24 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
paul@24 18
paul@24 19
ARCH = mipsel-linux-gnu
paul@24 20
CC = $(ARCH)-gcc
paul@24 21
LD = $(ARCH)-ld
paul@24 22
NM = $(ARCH)-nm
paul@24 23
OBJCOPY=$(ARCH)-objcopy
paul@24 24
OBJDUMP=$(ARCH)-objdump
paul@24 25
paul@38 26
# These paths are relative to each example directory.
paul@38 27
paul@90 28
DATADIR = ../../data
paul@38 29
INCDIR = ../../include
paul@38 30
LIBDIR = ../../lib
paul@38 31
paul@24 32
# NOTE: -O2 is actually needed to prevent memcpy references, whereas probably
paul@24 33
# NOTE: one of the -f{freestanding, no-hosted, no-builtin} options should work.
paul@24 34
# NOTE: See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
paul@24 35
paul@24 36
CFLAGS = -O2 -Wall \
paul@24 37
	-fno-unit-at-a-time -fno-zero-initialized-in-bss \
paul@24 38
	-ffreestanding -fno-hosted -fno-builtin \
paul@24 39
	-march=mips32 \
paul@38 40
	-I. \
paul@38 41
	-I$(INCDIR)
paul@24 42
LDFLAGS = -nostdlib -EL
paul@24 43
paul@24 44
# Ordering of objects is important and cannot be left to replacement rules.
paul@24 45
paul@38 46
START_SRC = $(LIBDIR)/start.S
paul@38 47
START_OBJ = $(LIBDIR)/start.o
paul@24 48
paul@24 49
# Application-specific files appear after the above but before those below in
paul@24 50
# the application Makefiles.
paul@24 51
paul@108 52
COMMON_SRC = $(LIBDIR)/payload.c $(LIBDIR)/init.c $(LIBDIR)/debug.c $(LIBDIR)/utils.c $(LIBDIR)/cpu.S
paul@108 53
COMMON_OBJ = $(LIBDIR)/payload.o $(LIBDIR)/init.o $(LIBDIR)/debug.o $(LIBDIR)/utils.o $(LIBDIR)/cpu.o
paul@41 54
paul@118 55
DISPLAY_COMMON_SRC = $(LIBDIR)/display.c $(LIBDIR)/font.c $(LIBDIR)/image.c $(LIBDIR)/viewport.c
paul@118 56
DISPLAY_COMMON_OBJ = $(LIBDIR)/display.o $(LIBDIR)/font.o $(LIBDIR)/image.o $(LIBDIR)/viewport.o
paul@87 57
paul@87 58
DISPLAY_SRC = $(DISPLAY_COMMON_SRC) $(LIBDIR)/vga_display.c
paul@87 59
DISPLAY_OBJ = $(DISPLAY_COMMON_OBJ) $(LIBDIR)/vga_display.o
paul@87 60
paul@24 61
# Common linker script.
paul@24 62
paul@38 63
SCRIPT = $(LIBDIR)/payload.ld