2011-08-05 08:25:00 -04:00
|
|
|
ifndef CPU
|
|
|
|
CPU=x86
|
|
|
|
endif
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
BINS=libc.a libg.a libmaxsi.a libmaxsi-sortix.a
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
ifeq ($(CPU),x86)
|
|
|
|
CPUDEFINES=-DPLATFORM_X86
|
|
|
|
CPUFLAGS=-m32
|
|
|
|
CPULDFLAGS=-melf_i386
|
|
|
|
CPUASFLAGS=-32
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
|
|
|
CPU=x64
|
|
|
|
CPUDEFINES=-DPLATFORM_X64
|
2012-07-02 09:58:52 -04:00
|
|
|
CPUFLAGS=-fPIC -m64 -mno-red-zone
|
2011-08-05 08:25:00 -04:00
|
|
|
CPULDFLAGS=-melf_x86_64
|
|
|
|
CPUASFLAGS=-64
|
|
|
|
endif
|
|
|
|
|
2012-03-21 19:52:29 -04:00
|
|
|
CPPINCLUDES=-I preproc -I ../sortix/include
|
2012-02-11 20:03:34 -05:00
|
|
|
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)
|
2012-02-11 20:03:34 -05:00
|
|
|
|
|
|
|
OBJS=\
|
|
|
|
ctype.o \
|
2012-07-02 11:16:23 -04:00
|
|
|
crc32.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
fdio.o \
|
2012-05-21 06:52:27 -04:00
|
|
|
fpipe.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
stdio.o \
|
|
|
|
dir.o \
|
|
|
|
fddir-sortix.o \
|
2012-03-04 17:15:32 -05:00
|
|
|
setjmp.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
sortix-sound.o \
|
2012-07-01 08:49:19 -04:00
|
|
|
readparamstring.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
process.o \
|
|
|
|
thread.o \
|
2012-03-24 10:34:30 -04:00
|
|
|
ioleast.o \
|
2012-07-24 12:43:34 -04:00
|
|
|
winsize.o \
|
2012-08-18 17:17:12 -04:00
|
|
|
gettermmode.o \
|
|
|
|
settermmode.o \
|
|
|
|
isatty.o \
|
2012-03-07 12:04:59 -05:00
|
|
|
kernelinfo.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
init.o \
|
2011-09-15 16:38:40 -04:00
|
|
|
signal.o \
|
|
|
|
$(CPU)/signal.o \
|
2012-04-05 17:00:47 -04:00
|
|
|
$(CPU)/fork.o \
|
2011-09-15 16:19:04 -04:00
|
|
|
start.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 \
|
2012-04-03 14:15:34 -04:00
|
|
|
env.o \
|
2012-05-30 17:58:04 -04:00
|
|
|
dlfcn.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
integer.o \
|
|
|
|
c++.o \
|
|
|
|
memory.o \
|
|
|
|
heap.o \
|
2012-03-05 06:37:59 -05:00
|
|
|
sort.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
string.o \
|
|
|
|
error.o \
|
|
|
|
format.o \
|
2012-09-06 16:30:09 -04:00
|
|
|
abort.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
access.o \
|
2012-09-06 15:36:55 -04:00
|
|
|
_assert.o \
|
2012-09-07 07:00:59 -04:00
|
|
|
bsearch.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
chdir.o \
|
|
|
|
chmod.o \
|
|
|
|
close.o \
|
|
|
|
dup.o \
|
|
|
|
errorprint.o \
|
2012-09-06 16:30:09 -04:00
|
|
|
exit.o \
|
|
|
|
_exit.o \
|
|
|
|
_Exit.o \
|
2012-09-07 14:28:59 -04:00
|
|
|
fabs.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
fchmod.o \
|
|
|
|
fcntl.o \
|
|
|
|
fstat.o \
|
|
|
|
ftruncate.o \
|
|
|
|
getcwd.o \
|
|
|
|
getdtablesize.o \
|
|
|
|
lseek.o \
|
|
|
|
mbtowc.o \
|
|
|
|
mkdir.o \
|
|
|
|
mktemp.o \
|
2012-09-06 16:30:09 -04:00
|
|
|
on_exit.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
open.o \
|
|
|
|
pipe.o \
|
|
|
|
print.o \
|
|
|
|
read.o \
|
|
|
|
readdirents.o \
|
|
|
|
rmdir.o \
|
2012-09-07 14:36:27 -04:00
|
|
|
scanf.o \
|
|
|
|
fscanf.o \
|
|
|
|
sscanf.o \
|
|
|
|
vscanf.o \
|
|
|
|
vfscanf.o \
|
|
|
|
vsscanf.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
stat.o \
|
|
|
|
truncate.o \
|
|
|
|
umask.o \
|
|
|
|
unlink.o \
|
|
|
|
write.o \
|
2012-07-26 08:17:56 -04:00
|
|
|
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 \
|
2012-07-31 08:16:03 -04:00
|
|
|
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 \
|
2012-02-11 20:03:34 -05:00
|
|
|
|
|
|
|
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 \
|
2012-02-11 20:03:34 -05:00
|
|
|
|
|
|
|
SORTIXOBJS:=$(addprefix sortix/,$(SORTIXOBJS))
|
|
|
|
SORTIXCPPFLAGS:=-DSORTIX_KERNEL
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
all: $(BINS)
|
|
|
|
|
|
|
|
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
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
libc.so: libmaxsi.so
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-01-08 09:45:13 -05:00
|
|
|
libg.a: libc.a
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
|
|
|
libg.so: libc.so
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
2011-09-15 16:19:04 -04:00
|
|
|
start.o: $(CPU)/start.o
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2011-09-15 16:19:04 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
# header preprocessing
|
|
|
|
$(HEADERDIRS):
|
|
|
|
mkdir -p $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-12 07:54:07 -05:00
|
|
|
preproc/%: include/% $(HEADERDIRS)
|
2012-02-11 20:03:34 -05:00
|
|
|
mxmpp -I decl $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
headers: $(HEADERDIRS) $(HEADERS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
# standard library
|
|
|
|
%.o: %.c headers
|
|
|
|
gcc -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
%.o: %.cpp headers
|
|
|
|
g++ -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
%.o: %.s
|
|
|
|
as $(ASFLAGS) $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
# libmaxsi-sortix
|
2012-02-11 20:03:34 -05:00
|
|
|
sortix:
|
|
|
|
mkdir -p sortix
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
sortix/%.o: %.cpp $(HEADERS) sortix
|
2012-03-21 19:52:29 -04:00
|
|
|
g++ -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
clean:
|
2012-02-11 20:03:34 -05:00
|
|
|
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
|
|
|
|
2011-09-15 16:38:40 -04:00
|
|
|
# Installation into sysroot
|
|
|
|
install:
|
|
|
|
mkdir -p $(SYSROOT)/usr/lib
|
2012-01-08 09:45:13 -05:00
|
|
|
for F in $(BINS); do cp -P $$F $(SYSROOT)/usr/lib || exit $?; done
|
2012-02-11 20:03:34 -05:00
|
|
|
for D in $(UNPROCHEADERDIRS); do mkdir -p $(SYSROOT)/usr/$$D || exit $?; done
|
|
|
|
for SRC in $(HEADERS); do DEST=`echo $$SRC | sed 's/preproc/include/'`; cp $$SRC $(SYSROOT)/usr/$$DEST || exit $?; done
|
2011-09-15 16:38:40 -04:00
|
|
|
mkdir -p $(SYSROOT)/usr/include
|
2012-01-07 18:15:06 -05:00
|
|
|
cp start.o $(SYSROOT)/usr/lib/crtbegin.o
|
2011-09-15 16:38:40 -04:00
|
|
|
touch deleteme.cpp
|
|
|
|
g++ $(CPUFLAGS) -c deleteme.cpp -o deleteme.o
|
2012-01-07 18:15:06 -05:00
|
|
|
for F in crt0.o crtn.o crt1.o crtend.o crtbeginT.o crti.o; do cp deleteme.o $(SYSROOT)/usr/lib/$$F; done
|
2012-01-08 09:53:10 -05:00
|
|
|
for F in libgcc.so libm.so libstdc++.so; do ld $(CPULDFLAGS) -shared deleteme.o -o $(SYSROOT)/usr/lib/$$F; done
|
2011-09-15 16:38:40 -04:00
|
|
|
rm -f deleteme.o deleteme.cpp
|
|
|
|
|