2019-07-17 19:00:20 +02:00
|
|
|
#! /usr/bin/make -f
|
|
|
|
# libprof Makefile
|
|
|
|
|
|
|
|
cflags := -m3 -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \
|
2019-07-17 19:00:49 +02:00
|
|
|
-Wextra -Os -I .
|
|
|
|
target ?= sh3eb-elf
|
2019-07-17 19:00:20 +02:00
|
|
|
lib := libprof.a
|
2019-07-17 19:00:49 +02:00
|
|
|
header := libprof.h
|
2019-07-17 19:00:20 +02:00
|
|
|
|
|
|
|
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/%.o)
|
|
|
|
|
|
|
|
# Rules
|
|
|
|
|
|
|
|
all: $(lib)
|
|
|
|
|
|
|
|
$(lib): $(obj)
|
2019-07-29 16:17:21 +02:00
|
|
|
$(target)-ar rcs $@ $^
|
2019-07-17 19:00:20 +02:00
|
|
|
|
|
|
|
build/%.c.o: %.c | build/
|
|
|
|
$(target)-gcc -c $< -o $@ $(cflags)
|
|
|
|
|
|
|
|
# Misc rules
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@ rm -rf build
|
|
|
|
distclean: clean
|
|
|
|
@ rm -f $(lib)
|
|
|
|
|
|
|
|
%/:
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
.PRECIOUS: %/
|
|
|
|
|
|
|
|
# Install
|
|
|
|
|
|
|
|
install:
|
|
|
|
cp $(lib) $(prefix)
|
2019-07-17 19:00:49 +02:00
|
|
|
cp $(header) $(prefix)/include
|