liblog/Makefile

63 lines
1004 B
Makefile
Raw Permalink Normal View History

include Makefile.cfg
2019-09-18 17:44:47 +02:00
#! /usr/bin/make -f
# liblog Makefile
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 \
-Wextra -Os -I . $(modelflag)
target ?= sh-elf
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)
obj := $(src:%=build-$(MODEL)/%.o)
2019-09-18 17:44:47 +02:00
# Rules
all: $(lib)
$(lib): $(obj)
$(target)-ar rcs $@ $^
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-fx
@ rm -rf build-cg
2019-09-18 17:44:47 +02:00
distclean: clean
@ rm -f $(lib)
%/:
mkdir -p $@
.PRECIOUS: %/
# Install
install:
cp $(lib) $(prefix)
cp $(header) $(prefix)/include