libprof/Makefile

47 lines
764 B
Makefile
Raw Normal View History

2019-07-17 19:00:20 +02:00
#! /usr/bin/make -f
# libprof Makefile
cflags := -m3 -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \
-Wextra -Os -I .
target ?= sh-elf
2019-07-17 19:00:20 +02:00
lib := libprof.a
header := libprof.h
2019-07-17 19:00:20 +02:00
2020-06-01 22:59:35 +02:00
PREFIX ?= $(shell $(target)-gcc -print-search-dirs | grep install \
2019-07-17 19:00:20 +02:00
| sed 's/install: //')
2020-06-01 22:59:35 +02:00
ifeq "$(PREFIX)" ""
2019-07-17 19:00:20 +02:00
$(error "Cannot determine compiler install path")
endif
src := $(wildcard *.c)
obj := $(src:%=build/%.o)
# Rules
all: $(lib)
$(lib): $(obj)
$(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:
2020-06-01 22:59:35 +02:00
cp $(lib) $(DESTDIR)$(PREFIX)
cp $(header) $(DESTDIR)$(PREFIX)/include