commit d8883da3c0721c709a3e6884a012a828605f56a2 Author: Lephenixnoir Date: Wed Jul 17 13:00:20 2019 -0400 build system diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6365fc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Build files +build/ +libprof.a diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..510e178 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +#! /usr/bin/make -f +# libprof Makefile + +cflags := -m3 -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -Wall \ + -Wextra -Os -std=c11 +target := sh3eb-elf +lib := libprof.a + +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) + ar rcs $@ $^ + +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) diff --git a/libprof.c b/libprof.c new file mode 100644 index 0000000..5a896c7 --- /dev/null +++ b/libprof.c @@ -0,0 +1,2 @@ +#include +#include