2019-09-20 13:22:16 +02:00
|
|
|
include Makefile.cfg
|
|
|
|
|
2019-09-18 17:44:47 +02:00
|
|
|
#! /usr/bin/make -f
|
|
|
|
# liblog Makefile
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
ifeq "$(MODEL)" ""
|
|
|
|
$(error "Cannot determine choosed model")
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq "$(MODEL)" "fx"
|
|
|
|
modelflag := -DFX9860G
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq "$(MODEL)" "cg"
|
|
|
|
modelflag := -DFXCG50
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2019-09-18 17:44:47 +02:00
|
|
|
cflags := -m3 -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \
|
2019-09-20 13:22:16 +02:00
|
|
|
-Wextra -Os -I . $(modelflag)
|
2019-09-18 17:44:47 +02:00
|
|
|
target ?= sh3eb-elf
|
2019-09-20 13:22:16 +02:00
|
|
|
lib := liblog-$(MODEL).a
|
2019-09-18 17:44:47 +02:00
|
|
|
header := liblog.h
|
|
|
|
|
|
|
|
prefix := $(shell $(target)-gcc -print-search-dirs | grep install \
|
|
|
|
| sed 's/install: //')
|
|
|
|
|
|
|
|
ifeq "$(prefix)" ""
|
|
|
|
$(error "Cannot determine compiler install path")
|
|
|
|
endif
|
|
|
|
|
|
|
|
src := $(wildcard *.c)
|
2019-09-20 13:22:16 +02:00
|
|
|
obj := $(src:%=build-$(MODEL)/%.o)
|
2019-09-18 17:44:47 +02:00
|
|
|
|
|
|
|
# Rules
|
|
|
|
|
|
|
|
all: $(lib)
|
|
|
|
|
|
|
|
$(lib): $(obj)
|
|
|
|
$(target)-ar rcs $@ $^
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
build-$(MODEL)/%.c.o: %.c | build-$(MODEL)/
|
2019-09-18 17:44:47 +02:00
|
|
|
$(target)-gcc -c $< -o $@ $(cflags)
|
|
|
|
|
|
|
|
# Misc rules
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@ rm -rf build
|
|
|
|
distclean: clean
|
|
|
|
@ rm -f $(lib)
|
|
|
|
|
|
|
|
%/:
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
.PRECIOUS: %/
|
|
|
|
|
|
|
|
# Install
|
|
|
|
|
|
|
|
install:
|
|
|
|
cp $(lib) $(prefix)
|
|
|
|
cp $(header) $(prefix)/include
|