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

282 lines
4.5 KiB
Makefile
Raw Normal View History

2011-08-05 08:25:00 -04:00
ifndef CPU
CPU=x86
endif
ifeq ($(CPU),x86)
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
CPUASFLAGS=-32
endif
ifeq ($(CPU),x64)
CPU=x64
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-fPIC -m64 -mno-red-zone
2011-08-05 08:25:00 -04:00
CPULDFLAGS=-melf_x86_64
CPUASFLAGS=-64
endif
CPPINCLUDES=-I preproc -I ../sortix/include
CPPFLAGS=-DLIBMAXSI_LIBRARY -DSORTIX -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES)
FLAGS=$(CPUFLAGS) -Wall -Wextra -nostdlib -fno-builtin -nostartfiles \
-nodefaultlibs -fno-stack-protector -nostdinc
CFLAGS=$(FLAGS) -std=c99
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -nostdinc++ -fno-rtti
2011-08-05 08:25:00 -04:00
LDFLAGS=$(CPULDFLAGS)
ASFLAGS=$(CPUASFLAGS)
OBJS=\
ctype.o \
2012-07-02 11:16:23 -04:00
crc32.o \
fdio.o \
fpipe.o \
stdio.o \
dir.o \
fddir-sortix.o \
setjmp.o \
setlocale.o \
sortix-sound.o \
readparamstring.o \
process.o \
thread.o \
2012-03-24 10:34:30 -04:00
ioleast.o \
winsize.o \
gettermmode.o \
settermmode.o \
isatty.o \
kernelinfo.o \
init.o \
signal.o \
$(CPU)/signal.o \
$(CPU)/fork.o \
2011-11-28 10:28:56 -05:00
time.o \
2011-11-10 06:27:31 -05:00
random.o \
2012-03-27 10:24:51 -04:00
abs.o \
env.o \
2012-05-30 17:58:04 -04:00
dlfcn.o \
integer.o \
c++.o \
memory.o \
heap.o \
sort.o \
string.o \
error.o \
format.o \
abort.o \
access.o \
2012-09-06 15:36:55 -04:00
_assert.o \
bsearch.o \
chdir.o \
chmod.o \
close.o \
dup.o \
errorprint.o \
exit.o \
_exit.o \
_Exit.o \
2012-09-07 14:28:59 -04:00
fabs.o \
fchmod.o \
fcntl.o \
fstat.o \
ftruncate.o \
getcwd.o \
getdtablesize.o \
localeconv.o \
lseek.o \
mbtowc.o \
mkdir.o \
mktemp.o \
on_exit.o \
open.o \
pipe.o \
print.o \
read.o \
readdirents.o \
rmdir.o \
scanf.o \
fscanf.o \
sscanf.o \
vscanf.o \
vfscanf.o \
vsscanf.o \
stat.o \
truncate.o \
umask.o \
unlink.o \
write.o \
stpcpy.o \
strcasecmp.o \
strcat.o \
strchr.o \
strchrnul.o \
strcmp.o \
strcoll.o \
strcpy.o \
strcspn.o \
strdup.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 \
clearerr.o \
fbufsize.o \
fclose.o \
fcloseall.o \
feof.o \
ferror.o \
fflush.o \
fgetc.o \
fgets.o \
fileno.o \
flbf.o \
flushlfb.o \
fnewline.o \
fpending.o \
fpurge.o \
fputc.o \
fputs.o \
fread.o \
freadable.o \
freading.o \
fregister.o \
fseek.o \
fseeko.o \
fseterr.o \
fsetlocking.o \
ftell.o \
ftello.o \
fwritable.o \
fwrite.o \
fwriting.o \
getc.o \
putc.o \
rewind.o \
ungetc.o \
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=\
c++.o \
memory.o \
heap.o \
string.o \
error.o \
format.o \
2012-07-02 11:16:23 -04:00
crc32.o \
SORTIXOBJS:=$(addprefix sortix/,$(SORTIXOBJS))
SORTIXCPPFLAGS:=-DSORTIX_KERNEL
2011-08-05 08:25:00 -04:00
BINS=libc.a libg.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)
ar rcs libmaxsi.a $(OBJS)
libmaxsi.so: $(OBJS)
ld $(LDFLAGS) -shared -o $@ $(OBJS)
libmaxsi-sortix.a: $(SORTIXOBJS)
ar rcs libmaxsi-sortix.a $(SORTIXOBJS)
libc.a: libmaxsi.a
ln -sf $< $@
2011-08-05 08:25:00 -04:00
libc.so: libmaxsi.so
ln -sf $< $@
2011-08-05 08:25:00 -04:00
libg.a: libc.a
ln -sf $< $@
libg.so: libc.so
ln -sf $< $@
start.o: $(CPU)/start.o
ln -f $< $@
crt1.o: $(CPU)/crt1.o
ln -f $< $@
crti.o: $(CPU)/crti.o
ln -f $< $@
crtn.o: $(CPU)/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
gcc -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.cpp headers
g++ -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.s
as $(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: %.cpp $(HEADERS) sortix
g++ -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
mkdir -p $(SYSROOT)/usr/include
for D in $(UNPROCHEADERDIRS); do mkdir -p $(SYSROOT)/usr/$$D || exit $?; done
install-headers: install-include-dirs headers
for SRC in $(HEADERS); do DEST=`echo $$SRC | sed 's/preproc/include/'`; cp $$SRC $(SYSROOT)/usr/$$DEST || exit $?; done
install-lib-dirs: all
mkdir -p $(SYSROOT)/usr/lib
install-libs: install-lib-dirs all
for F in $(BINS); do cp -P $$F $(SYSROOT)/usr/lib || exit $?; done
touch deleteme.cpp
g++ $(CPUFLAGS) -c deleteme.cpp -o deleteme.o
for F in libgcc.so libm.so libstdc++.so; do ld $(CPULDFLAGS) -shared deleteme.o -o $(SYSROOT)/usr/lib/$$F; done
rm -f deleteme.o deleteme.cpp