1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/libmaxsi/Makefile

288 lines
4.4 KiB
Makefile
Raw Normal View History

2012-09-10 17:36:15 -04:00
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-O2
endif
ifeq ($(DEBUG_LIBC),1)
FLAGSDEBUG=-g3
else
FLAGSDEBUG=$(OPTLEVEL)
2011-08-05 08:25:00 -04:00
endif
2012-09-10 17:36:15 -04:00
CPUDIR:=$(CPU)
ifeq ($(HOST),i486-sortix)
CPUFLAGS=
2011-08-05 08:25:00 -04:00
endif
2012-09-10 17:36:15 -04:00
ifeq ($(HOST),x86_64-sortix)
CPUFLAGS=-fPIC -mno-red-zone
2011-08-05 08:25:00 -04:00
endif
2012-09-10 17:36:15 -04:00
CPPINCLUDES=-I preproc
CPPFLAGS=-DLIBMAXSI_LIBRARY -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES)
FLAGS=$(CPUFLAGS) -Wall -Wextra -fno-stack-protector $(FLAGSDEBUG)
CFLAGS=$(FLAGS) -std=c99
2012-09-10 17:36:15 -04:00
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
2011-08-05 08:25:00 -04:00
ASFLAGS=$(CPUASFLAGS)
FREEOBJS=\
abort.o \
abs.o \
_assert.o \
bsearch.o \
clearerr.o \
c++.o \
ctype.o \
dir.o \
error.o \
fabs.o \
fbufsize.o \
fclose.o \
feof.o \
ferror.o \
fflush.o \
fgetc.o \
fgets.o \
flbf.o \
flushlfb.o \
fnewline.o \
format.o \
fpending.o \
fpurge.o \
fputc.o \
fputs.o \
freadable.o \
freading.o \
fread.o \
fregister.o \
fscanf.o \
fseek.o \
fseeko.o \
fseterr.o \
fsetlocking.o \
ftell.o \
ftello.o \
fwritable.o \
fwrite.o \
fwriting.o \
heap.o \
integer.o \
mbtowc.o \
memory.o \
readparamstring.o \
rewind.o \
sort.o \
sscanf.o \
stpcpy.o \
strcasecmp.o \
strcat.o \
strchrnul.o \
strchr.o \
strcmp.o \
strcoll.o \
strcpy.o \
strcspn.o \
strdup.o \
string.o \
strlen.o \
strncasecmp.o \
strncat.o \
strncmp.o \
strncpy.o \
strnlen.o \
strpbrk.o \
strrchr.o \
strspn.o \
strstr.o \
strtok.o \
strtok_r.o \
ungetc.o \
vfscanf.o \
vsscanf.o \
HOSTEDOBJS=\
access.o \
chdir.o \
chmod.o \
close.o \
$(CPUDIR)/fork.o \
$(CPUDIR)/signal.o \
dlfcn.o \
dup.o \
env.o \
errorprint.o \
_exit.o \
exit.o \
_Exit.o \
fchmod.o \
fcloseall.o \
fcntl.o \
fddir-sortix.o \
fdio.o \
fileno.o \
fpipe.o \
fstat.o \
ftruncate.o \
getc.o \
getcwd.o \
getdtablesize.o \
gettermmode.o \
init.o \
ioleast.o \
isatty.o \
kernelinfo.o \
localeconv.o \
lseek.o \
mkdir.o \
mktemp.o \
on_exit.o \
open.o \
pipe.o \
print.o \
process.o \
putc.o \
random.o \
readdirents.o \
read.o \
rmdir.o \
scanf.o \
setjmp.o \
setlocale.o \
settermmode.o \
signal.o \
2012-09-21 19:09:20 -04:00
sleep.o \
stat.o \
stdio.o \
time.o \
truncate.o \
umask.o \
unlink.o \
2012-09-21 19:09:20 -04:00
usleep.o \
vscanf.o \
winsize.o \
write.o \
OBJS=\
$(FREEOBJS) \
$(HOSTEDOBJS) \
CRTOBJ=\
start.o \
crt1.o \
crti.o \
crtn.o \
MISCOBJ=\
$(CRTOBJ) \
UNPROCHEADERDIRS:=$(shell find include -type d)
UNPROCHEADERS:=$(shell find include -type f)
HEADERDIRS:=$(patsubst include%,preproc%,$(UNPROCHEADERDIRS))
HEADERS:=$(patsubst include%,preproc%,$(UNPROCHEADERS))
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
SORTIXCPPFLAGS:=-DSORTIX_KERNEL
2011-08-05 08:25:00 -04:00
2012-09-10 17:36:15 -04:00
BINS=libc.a libg.a libm.a libstdc++.a libmaxsi.a libmaxsi-sortix.a $(CRTOBJ)
2011-08-05 08:25:00 -04:00
all: $(BINS)
.PHONY: all headers clean install install-include-dirs install-headers \
install-lib-dirs install-libs
2011-08-05 08:25:00 -04:00
libmaxsi.a: $(OBJS)
2012-09-10 17:36:15 -04:00
$(HOSTAR) rcs libmaxsi.a $(OBJS)
2011-08-05 08:25:00 -04:00
libmaxsi-sortix.a: $(SORTIXOBJS)
2012-09-10 17:36:15 -04:00
$(HOSTAR) rcs libmaxsi-sortix.a $(SORTIXOBJS)
2011-08-05 08:25:00 -04:00
libc.a: libmaxsi.a
ln -sf $< $@
2011-08-05 08:25:00 -04:00
libg.a: libc.a
ln -sf $< $@
2012-09-10 17:36:15 -04:00
libm.a:
$(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
2012-09-10 17:36:15 -04:00
start.o: $(CPUDIR)/start.o
ln -f $< $@
2012-09-10 17:36:15 -04:00
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@
2012-09-10 17:36:15 -04:00
crti.o: $(CPUDIR)/crti.o
ln -f $< $@
2012-09-10 17:36:15 -04:00
crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@
# header preprocessing
$(HEADERDIRS):
mkdir -p $@
2011-08-05 08:25:00 -04:00
preproc/%: include/% $(HEADERDIRS)
mxmpp -I decl $< -o $@
2011-08-05 08:25:00 -04:00
headers: $(HEADERDIRS) $(HEADERS)
2011-08-05 08:25:00 -04:00
# standard library
%.o: %.c headers
2012-09-10 17:36:15 -04:00
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.cpp headers
2012-09-10 17:36:15 -04:00
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.s
2012-09-10 17:36:15 -04:00
$(HOSTAS) $(ASFLAGS) $< -o $@
2011-08-05 08:25:00 -04:00
# libmaxsi-sortix
sortix:
mkdir -p sortix
2011-08-05 08:25:00 -04:00
sortix/%.o: %.c $(HEADERS) sortix
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CFLAGS)
sortix/%.o: %.cpp $(HEADERS) sortix
2012-09-10 17:36:15 -04:00
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CXXFLAGS)
2011-08-05 08:25:00 -04:00
clean:
rm -f *.o sortix/*.o c/*.o x86/*.o x64/*.o *.a *.so
rm -f $(OBJS)
rm -rf sortix $(HEADERDIRS)
2011-08-05 08:25:00 -04:00
# Installation into sysroot
install: install-headers install-libs
install-include-dirs: headers
2012-09-10 17:36:15 -04:00
mkdir -p $(INSTALLINCLUDEDIR)
DIRS=$$(echo $(UNPROCHEADERDIRS) | \
tr ' ' '\n' | \
sed 's/include\/*//'); \
for D in $$DIRS; do \
mkdir -p $(INSTALLINCLUDEDIR)/$$D || exit $?; \
done
install-headers: install-include-dirs headers
2012-09-10 17:36:15 -04:00
for SRC in $(HEADERS); do \
DEST=`echo $$SRC | sed 's/preproc\///'`; \
cp -P $$SRC $(INSTALLINCLUDEDIR)/$$DEST || exit $?; \
done
install-lib-dirs:
mkdir -p $(INSTALLLIBDIR)
mkdir -p $(INSTALLLIBDIR)/$(HOST)
install-libs: install-lib-dirs
for F in $(BINS); do \
cp -P $$F $(INSTALLLIBDIR)/$(HOST) || exit $?; \
done