banan-os/BAN/Makefile

89 lines
1.9 KiB
Makefile
Raw Normal View History

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
CPPFLAGS:=$(CPPFLAGS)
2022-12-13 16:13:38 +02:00
LIBBANK_CFLAGS:=$(CFLAGS) -D__is_kernel -Iinclude -ffreestanding -Wall -Wextra
LIBBANK_CPPFLAGS:=$(CPPFLAGS) -fno-rtti -fno-exceptions -fno-threadsafe-statics
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)
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 \
BAN/StringView.o \
HOSTEDOBJS=\
$(ARCH_HOSTEDOBJS) \
OBJS=\
$(FREEOBJS) \
$(HOSTEDOBJS) \
2022-12-13 16:13:38 +02:00
LIBBANK_OBJS=$(FREEOBJS:.o=.bank.o)
2022-12-13 12:10:50 +02:00
BINARIES=libbank.a
.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)
cd $(BUILDDIR) && $(AR) rcs $@ $(OBJS)
2022-12-13 16:13:38 +02:00
libbank.a: always $(LIBBANK_OBJS)
cd $(BUILDDIR) && $(AR) rcs $@ $(LIBBANK_OBJS)
.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)
.S.bank.o:
2022-12-13 16:13:38 +02:00
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(LIBBANK_CFLAGS) $(LIBBANK_CPPFLAGS)
clean:
rm -rf $(BUILDDIR)
always:
2022-12-13 16:13:38 +02:00
mkdir -p $(BUILDDIR)/BAN
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)