2022-12-13 10:39:57 +02:00
|
|
|
DEFAULT_HOST!=../default-host.sh
|
|
|
|
HOST?=DEFAULT_HOST
|
|
|
|
HOSTARCH!=../target-triplet-to-arch.sh $(HOST)
|
|
|
|
|
|
|
|
CFLAGS?=-O2 -g
|
|
|
|
CPPFLAGS?=
|
|
|
|
LDFLAGS?=
|
|
|
|
LIBS?=
|
|
|
|
|
|
|
|
DESTDIR?=
|
|
|
|
PREFIX?=/usr/local
|
|
|
|
EXEC_PREFIX?=$(PREFIX)
|
|
|
|
INCLUDEDIR?=$(PREFIX)/include
|
|
|
|
LIBDIR?=$(EXEC_PREFIX)/lib
|
|
|
|
|
2023-01-13 00:04:15 +02:00
|
|
|
CFLAGS:=$(CFLAGS) -Iinclude -ffreestanding -Wall -Wextra -Werror=return-type
|
2022-12-13 10:39:57 +02:00
|
|
|
CPPFLAGS:=$(CPPFLAGS)
|
2022-12-13 16:13:38 +02:00
|
|
|
LIBBANK_CFLAGS:=$(CFLAGS) -D__is_kernel -Iinclude -ffreestanding -Wall -Wextra
|
2023-02-09 23:05:26 +02:00
|
|
|
LIBBANK_CPPFLAGS:=$(CPPFLAGS) -fno-rtti -fno-exceptions
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
ARCHDIR=arch/$(HOSTARCH)
|
|
|
|
|
|
|
|
include $(ARCHDIR)/make.config
|
|
|
|
|
|
|
|
CFLAGS:=$(CFLAGS) $(ARCH_CFLAGS)
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) $(ARCH_CPPFLAGS)
|
2022-12-13 16:13:38 +02:00
|
|
|
LIBBANK_CFLAGS:=$(LIBBANK_CFLAGS) $(KERNEL_ARCH_CFLAGS)
|
|
|
|
LIBBANK_CPPFLAGS:=$(LIBBANK_CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
BUILDDIR=$(abspath build)
|
|
|
|
|
2022-12-13 16:13:38 +02:00
|
|
|
FREEOBJS= \
|
|
|
|
$(ARCH_FREEOBJS) \
|
2023-01-17 11:38:16 +02:00
|
|
|
BAN/Memory.o \
|
2022-12-13 16:13:38 +02:00
|
|
|
BAN/String.o \
|
2022-12-13 20:41:32 +02:00
|
|
|
BAN/StringView.o \
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
HOSTEDOBJS=\
|
|
|
|
$(ARCH_HOSTEDOBJS) \
|
|
|
|
|
|
|
|
OBJS=\
|
|
|
|
$(FREEOBJS) \
|
|
|
|
$(HOSTEDOBJS) \
|
|
|
|
|
2022-12-13 16:13:38 +02:00
|
|
|
LIBBANK_OBJS=$(FREEOBJS:.o=.bank.o)
|
2022-12-13 10:39:57 +02:00
|
|
|
|
2022-12-13 12:10:50 +02:00
|
|
|
BINARIES=libbank.a
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
.PHONY: all always clean install install-headers install-libs
|
|
|
|
.SUFFIXES: .o .bank.o .cpp .S
|
|
|
|
|
|
|
|
all: $(BINARIES)
|
|
|
|
|
2022-12-13 12:10:50 +02:00
|
|
|
libban.a: always $(OBJS)
|
2022-12-13 10:39:57 +02:00
|
|
|
cd $(BUILDDIR) && $(AR) rcs $@ $(OBJS)
|
|
|
|
|
2022-12-13 16:13:38 +02:00
|
|
|
libbank.a: always $(LIBBANK_OBJS)
|
|
|
|
cd $(BUILDDIR) && $(AR) rcs $@ $(LIBBANK_OBJS)
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
.cpp.o:
|
|
|
|
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(CFLAGS) $(CPPFLAGS)
|
|
|
|
|
|
|
|
.S.o:
|
|
|
|
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(CFLAGS) $(CPPFLAGS)
|
|
|
|
|
|
|
|
.cpp.bank.o:
|
2022-12-13 16:13:38 +02:00
|
|
|
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(LIBBANK_CFLAGS) $(LIBBANK_CPPFLAGS)
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
.S.bank.o:
|
2022-12-13 16:13:38 +02:00
|
|
|
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(LIBBANK_CFLAGS) $(LIBBANK_CPPFLAGS)
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(BUILDDIR)
|
|
|
|
|
|
|
|
always:
|
2022-12-13 16:13:38 +02:00
|
|
|
mkdir -p $(BUILDDIR)/BAN
|
2022-12-13 10:39:57 +02:00
|
|
|
|
|
|
|
install: install-headers install-libs
|
|
|
|
|
|
|
|
install-headers:
|
|
|
|
mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDEDIR)/.
|
|
|
|
|
|
|
|
install-libs: $(BINARIES)
|
|
|
|
mkdir -p $(DESTDIR)$(LIBDIR)
|
|
|
|
cp $(BUILDDIR)/$(BINARIES) $(DESTDIR)$(LIBDIR)
|
|
|
|
|
|
|
|
-include $(OBJS:.o=.d)
|
2022-12-13 16:13:38 +02:00
|
|
|
-include $(LIBBANK_OBJS:.o=.d)
|