FENIX_libc/makefile

129 lines
2.4 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?=
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) \
2020-12-22 02:54:51 +00:00
ctype/isalnum.o \
ctype/isalpha.o \
ctype/isascii.o \
ctype/isblank.o \
ctype/iscntrl.o \
ctype/isdigit.o \
ctype/isgraph.o \
ctype/islower.o \
ctype/isprint.o \
ctype/ispunct.o \
ctype/isspace.o \
ctype/isupper.o \
ctype/isxdigit.o \
ctype/tolower.o \
ctype/toupper.o \
stdlib/abort.o \
stdlib/bsearch.o \
2020-12-21 19:45:13 +00:00
stdio/printf.o \
stdio/putchar.o \
stdio/puts.o \
string/memcmp.o \
string/memcpy.o \
string/memmove.o \
string/memset.o \
string/strcmp.o \
2020-12-22 02:54:51 +00:00
string/strcspn.o \
2020-12-21 19:45:13 +00:00
string/strlen.o \
2022-05-28 16:15:26 +00:00
string/strtok.o
2020-12-21 19:45:13 +00:00
HOSTEDOBJS=\
2020-12-22 02:54:51 +00:00
$(ARCH_HOSTEDOBJS) \
2020-12-01 23:39:05 +00:00
math/cos.o \
math/cosf.o \
math/cosl.o \
math/fabs.o \
math/fabsf.o \
math/fabsl.o \
2022-05-28 16:15:26 +00:00
math/__fpclassify.o \
math/__signbit.o \
2020-12-01 23:39:05 +00:00
stdlib/abs.o \
stdlib/div.o \
stdlib/labs.o \
stdlib/ldiv.o \
stdlib/llabs.o \
stdlib/lldiv.o \
stdlib/rand.o \
time/time.o
OBJS=\
$(FREEOBJS) \
2020-12-01 23:39:05 +00:00
$(HOSTEDOBJS)
LIBK_OBJS=$(FREEOBJS:.o=.libk.o)
BINARIES=libk.a #Add libc.a later
.PHONY: all clean install install-headers install-libs
.SUFFIXES: .o .libk.o .c .S
all: $(BINARIES)
libc.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
libk.a: $(LIBK_OBJS)
$(AR) rcs $@ $(LIBK_OBJS)
.c.o:
$(CC) -MD -c $< -o $@ -std=c99 $(CFLAGS) $(CPPFLAGS)
.c.S:
$(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
.c.libk.o:
$(CC) -MD -c $< -o $@ -std=c99 $(LIBK_CFLAGS) $(LIBK_CPPFLAGS)
.S.libk.o:
$(CC) -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 include/. $(DESTDIR)$(INCLUDEDIR)/.
2020-12-21 19:45:13 +00:00
cp -R arch/$(HOSTARCH)/*.h $(DESTDIR)$(INCLUDEDIR)/.
install-libs: $(BINARIES)
2020-12-01 23:39:05 +00:00
mkdir -p $(DESTDIR)$(LIBDIR)
cp $(BINARIES) $(DESTDIR)$(LIBDIR)
-include $(OBJS:.o=.d)
-include $(LIBK_OBJS:.o=.d)