2019-09-01 14:26:49 +02:00
|
|
|
include Makefile.cfg
|
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
target=fx9860g
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
CONFIG.TARGET = fx
|
|
|
|
CONFIG.TARGET.LONG = fx9860g
|
|
|
|
PREFIX = /usr/lib/gcc/sh3eb-elf/9.1.0/
|
|
|
|
toolchain = sh3eb-elf
|
|
|
|
CONFIG.MACROS = -DFX9860G
|
2019-08-29 15:22:38 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
machine := -m3 -mb
|
2019-08-28 15:29:06 +02:00
|
|
|
|
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
# Compiler flags, assembler flags, dependency generation, archiving
|
|
|
|
cflags := $(machine) -ffreestanding -nostdlib -Wall -Wextra -std=c11 -Os \
|
|
|
|
-fstrict-volatile-bitfields -I include $(CONFIG.MACROS) \
|
2019-09-19 21:07:16 +02:00
|
|
|
$(CONFIG.CFLAGS) $(FLAGS)
|
2019-08-31 19:22:59 +02:00
|
|
|
sflags := $(CONFIG.MACROS)
|
|
|
|
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
|
|
|
|
arflags :=
|
2019-08-28 15:29:06 +02:00
|
|
|
|
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
# Target file
|
|
|
|
target := libfxengine.a
|
|
|
|
|
|
|
|
# Automatic names for object and dependency files
|
2019-09-01 13:23:26 +02:00
|
|
|
src2obj = $(1:src/%=build/%).o
|
|
|
|
src2dep = $(1:src/%=build/%).d
|
2019-08-31 19:22:59 +02:00
|
|
|
|
|
|
|
# Source files
|
|
|
|
src := $(shell find src \
|
|
|
|
-name '*.[csS]' -print)
|
|
|
|
src_obj := $(foreach s,$(src),$(call src2obj,$s))
|
|
|
|
|
|
|
|
|
|
|
|
# All object files
|
|
|
|
obj := $(src_obj) $(spe_obj)
|
|
|
|
|
2019-08-31 13:58:33 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
#
|
|
|
|
# Toolchain
|
|
|
|
#
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
gcc = $(toolchain)-gcc
|
|
|
|
as = $(toolchain)-as
|
|
|
|
ld = $(toolchain)-ld
|
|
|
|
ar = $(toolchain)-ar
|
|
|
|
objcopy = $(toolchain)-objcopy
|
2019-08-28 15:29:06 +02:00
|
|
|
|
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
#
|
|
|
|
# Version management
|
|
|
|
#
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
# Version symbol is obtained by using the last commit hash on 7 nibbles
|
|
|
|
version_hash = 0x0$(shell git rev-parse --short HEAD)
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Build rules
|
|
|
|
#
|
|
|
|
|
|
|
|
all: $(target)
|
|
|
|
|
|
|
|
$(target): $(obj)
|
|
|
|
$(call cmd_l,ar,$@) $(ar) rcs $(arflags) $@ $^
|
|
|
|
|
|
|
|
# Assembler sources
|
2019-09-01 13:23:26 +02:00
|
|
|
build/%.s.o: src/%.s build/%.s.d
|
2019-08-31 19:22:59 +02:00
|
|
|
@ mkdir -p $(dir $@)
|
|
|
|
$(call cmd_b,as,$*.s) $(gcc) -c $< -o $@ $(sflags)
|
2019-09-01 13:23:26 +02:00
|
|
|
build/%.S.o: src/%.S build/%.S.d
|
2019-08-28 15:29:06 +02:00
|
|
|
@ mkdir -p $(dir $@)
|
2019-08-31 19:22:59 +02:00
|
|
|
$(call cmd_b,as,$*.S) $(gcc) -c $< -o $@ $(sflags)
|
|
|
|
|
|
|
|
# C sources
|
2019-09-01 13:23:26 +02:00
|
|
|
build/%.c.o: src/%.c build/%.c.d
|
2019-08-31 19:22:59 +02:00
|
|
|
@ mkdir -p $(dir $@)
|
|
|
|
$(call cmd_b,gcc,$*.c) $(gcc) -c $< -o $@ $(dflags) $(cflags)
|
|
|
|
|
|
|
|
# Version symbol. ld generates a .stack section for unknown reasons; I remove
|
|
|
|
# it in the linker script.
|
|
|
|
version.o: ../.git/HEAD
|
|
|
|
@ mkdir -p $(dir $@)
|
|
|
|
@ echo "_FXENGINE_VERSION = $(version_hash);" > $@.txt
|
|
|
|
$(call cmd_b,ld,$@) $(ld) -r -R $@.txt -o $@
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installing
|
|
|
|
#
|
|
|
|
|
|
|
|
m644 := -m 644
|
|
|
|
|
|
|
|
# Disable -m on Mac OS
|
|
|
|
ifeq "$(shell uname)" "Darwin"
|
|
|
|
m644 :=
|
|
|
|
endif
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-09-07 21:56:35 +02:00
|
|
|
uninstall:
|
|
|
|
rm -f $(PREFIX)/$(target)
|
|
|
|
rm -rf $(PREFIX)/include/fxengine
|
|
|
|
|
2019-09-18 18:51:26 +02:00
|
|
|
install:
|
2019-09-07 21:56:35 +02:00
|
|
|
@make uninstall
|
2019-08-31 19:22:59 +02:00
|
|
|
install -d $(PREFIX)
|
|
|
|
install $(target) $(m644) $(PREFIX)
|
|
|
|
cp -r include/fxengine $(PREFIX)/include
|
2019-08-28 15:29:06 +02:00
|
|
|
|
2019-09-07 21:56:35 +02:00
|
|
|
|
2019-08-31 19:22:59 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Utilities
|
|
|
|
#
|
|
|
|
|
|
|
|
# Directories: make conveniently leaves a '/' at the end of $(dir ...)
|
2019-08-28 15:29:06 +02:00
|
|
|
%/:
|
2019-08-31 19:22:59 +02:00
|
|
|
@ mkdir -p $@
|
|
|
|
# Don't try to unlink directories once they're built (that wouldn't work =p)
|
|
|
|
.PRECIOUS: %/
|
|
|
|
|
|
|
|
# Dependency information
|
|
|
|
-include $(shell [ -d src ] && find src -name *.d)
|
2019-09-01 13:23:26 +02:00
|
|
|
build/%.d: ;
|
|
|
|
.PRECIOUS: build/%.d
|
2019-08-31 19:22:59 +02:00
|
|
|
|
|
|
|
.PHONY: all clean distclean
|
|
|
|
|
|
|
|
# Do not output full commands by default
|
|
|
|
VERBOSE ?=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-28 15:29:06 +02:00
|
|
|
|
|
|
|
|
2019-08-29 15:22:38 +02:00
|
|
|
|