From 33a9a63787154facfdaddaf719e727947c159800 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 15 Feb 2018 00:59:08 +0200 Subject: Initial commit Stuff in src/linker will get rewritten from scratch eventually, it's all horrible. But for now focus is getting on shit work. --- Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c9c552a --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +PREFIX ?= /usr/local +BINDIR ?= /bin + +MAKEFLAGS += --no-builtin-rules + +# GCC 7: -Wstringop-overflow=, -Walloc-size-larger-than=, -Wduplicated-{branches,cond} +WARNINGS := -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=3 -Wstack-usage=12500 \ + -Wfloat-equal -Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2 -Wno-unused-parameter + +override CFLAGS ?= -g +override CFLAGS += -std=c11 $(WARNINGS) +override CPPFLAGS += -Isrc + +bins = app +all: $(bins) runtime/libc.so runtime/libandroid.so runtime/liblog.so + +%.o: %.c + $(COMPILE.c) $^ -o $@ + +%.so: + $(LINK.c) -shared $(filter %.c,$^) $(LDLIBS) -o $@ + +%.a: + $(AR) rvs $@ $^ + +$(bins): %: + $(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -o $@ + +runtime: + mkdir -p $@ + +runtime/libc.so: private CFLAGS += -D_GNU_SOURCE +runtime/libc.so: runtime src/libc.c +runtime/libpthread.so: private CFLAGS += -D_GNU_SOURCE +runtime/libpthread.so: private LDLIBS += -lpthread +runtime/libpthread.so: runtime src/libpthread.c +runtime/libandroid.so: runtime src/libandroid.c +runtime/liblog.so: runtime src/liblog.c + +linker.a: CFLAGS += -D_GNU_SOURCE -DANDROID_X86_LINKER -DLINKER_DEBUG=1 +linker.a: CFLAGS += -Wno-pedantic -Wno-variadic-macros -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast +linker.a: src/linker/dlfcn.o src/linker/linker.o src/linker/linker_environ.o src/linker/rt.o src/linker/strlcpy.o + +app: private LDLIBS += -ldl -Wl,-rpath,runtime +app: src/app.c linker.a runtime/libc.so runtime/libpthread.so runtime/libandroid.so runtime/liblog.so + +install-bin: $(bins) + install -Dm755 $^ -t "$(DESTDIR)$(PREFIX)$(BINDIR)" + +install: install-bin + +clean: + $(RM) $(bins) *.a src/linker/*.o + $(RM) -r runtime + +.PHONY: all clean install -- cgit v1.2.3