forked from Bananymous/banan-os
96 lines
1.9 KiB
Makefile
96 lines
1.9 KiB
Makefile
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
|
|
|
|
CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra
|
|
CPPFLAGS:=$(CPPFLAGS) -D__is_libc -Iinclude
|
|
LIBK_CFLAGS:=$(CFLAGS)
|
|
LIBK_CPPFLAGS:=$(CPPFLAGS) -D__is_libk
|
|
|
|
ARCHDIR=arch/$(HOSTARCH)
|
|
|
|
include $(ARCHDIR)/make.config
|
|
|
|
CFLAGS:=$(CFLAGS) $(ARCH_CFLAGS)
|
|
CPPFLAGS:=$(CPPFLAGS) $(ARCH_CPPFLAGS)
|
|
LIBK_CFLAGS:=$(LIBK_CFLAGS) $(KERNEL_ARCH_CFLAGS)
|
|
LIBK_CPPFLAGS:=$(LIBK_CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)
|
|
|
|
FREEOBJS=\
|
|
$(ARCH_FREEOBJS) \
|
|
stdio/printf.o \
|
|
stdio/putchar.o \
|
|
stdio/puts.o \
|
|
stdlib/abort.o \
|
|
string/memcmp.o \
|
|
string/memcpy.o \
|
|
string/memmove.o \
|
|
string/memset.o \
|
|
string/strcpy.o \
|
|
string/strlen.o \
|
|
string/strncpy.o \
|
|
string/strstr.o \
|
|
|
|
HOSTEDOBJS=\
|
|
$(ARCH_HOSTEDOBJS) \
|
|
|
|
OBJS=\
|
|
$(FREEOBJS) \
|
|
$(HOSTEDOBJS) \
|
|
|
|
LIBK_OBJS=$(FREEOBJS:.o=.libk.o)
|
|
|
|
#BINARIES=libc.a libk.a # Not ready for libc yet.
|
|
BINARIES=libk.a
|
|
|
|
.PHONY: all clean install install-headers install-libs
|
|
.SUFFIXES: .o .libk.o .cpp .S
|
|
|
|
all: $(BINARIES)
|
|
|
|
libc.a: $(OBJS)
|
|
$(AR) rcs $@ $(OBJS)
|
|
|
|
libk.a: $(LIBK_OBJS)
|
|
$(AR) rcs $@ $(LIBK_OBJS)
|
|
|
|
.cpp.o:
|
|
$(CXX) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
|
|
|
.S.o:
|
|
$(CXX) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
|
|
|
.cpp.libk.o:
|
|
$(CXX) -MD -c $< -o $@ $(LIBK_CFLAGS) $(LIBK_CPPFLAGS)
|
|
|
|
.S.libk.o:
|
|
$(CXX) -MD -c $< -o $@ $(LIBK_CFLAGS) $(LIBK_CPPFLAGS)
|
|
|
|
clean:
|
|
rm -f $(BINARIES) *.a
|
|
rm -f $(OBJS) $(LIBK_OBJS) *.o */*.o */*/*.o
|
|
rm -f $(OBJS:.o=.d) $(LIBK_OBJS:.o=.d) *.d */*.d */*/*.d
|
|
|
|
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 $(BINARIES) $(DESTDIR)$(LIBDIR)
|
|
|
|
-include $(OBJS:.o=.d)
|
|
-include $(LIBK_OBJS:.o=.d) |