2011-08-05 08:25:00 -04:00
i f n d e f C P U
CPU = x86
e n d i f
i f e q ( $( CPU ) , x 8 6 )
CPUDEFINES = -DPLATFORM_X86
CPUFLAGS = -m32
CPULDFLAGS = -melf_i386
CPUASFLAGS = -32
CPUNASMFLAGS = -felf32
e n d i f
i f e q ( $( CPU ) , x 6 4 )
CPU = x64
CPUDEFINES = -DPLATFORM_X64
CPUFLAGS = -fPIC -m64
CPULDFLAGS = -melf_x86_64
CPUASFLAGS = -64
CPUNASMFLAGS = -felf64
2011-09-15 16:19:04 -04:00
LIBMAXSI_NO_SHARED = 1 # This doesn't work yet
2011-08-05 08:25:00 -04:00
e n d i f
DEFINES = -DLIBMAXSI_LIBRARY -DSORTIX $( CPUDEFINES)
FLAGSRELEASE = -O2
FLAGSDEBUG = -O2
FLAGS = $( CPUFLAGS) -std= gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-stack-protector -nostdinc $( FLAGSRELEASE) $( DEFINES)
LDFLAGS = $( CPULDFLAGS)
ASFLAGS = $( CPUASFLAGS)
NASMFLAGS = $( CPUNASMFLAGS)
Implemented large parts of the stdio(3), including fprintf.
Made FILE an interface to various backends. This allows application writers
to override the standard FILE API functions with their own backends. This
is highly unportable - it'd be nice if a real standard existed for this.
glibc already does something like this internally, but AFAIK you can't hook
into it.
Added fdopen(3), fopen(3), fregister(3), funregister(3), fread(3),
fwrite(3), fseek(3), clearerr(3), ferror(3), feof(3), rewind(3), ftell(3),
fflush(3), fclose(3), fileno(3), fnewline(3), fcloseall(3), memset(3),
stdio(3), vfprintf(3), fprintf(3), and vprintf(3).
Added a file-descriptor backend to the FILE API.
fd's {0, 1, 2} are now initialized as stdin, stdout, and stderr when the
standard library initializes.
fcloseall(3) is now called on exit(3).
decl/intn_t_.h now @include(size_t.h) instead of declaring it itself.
Added <stdint.h>.
The following programs now flush stdout: cat(1), clear(1), editor(1),
init(1), mxsh(1).
printf(3) is now hooked up against vprintf(3), while Maxsi::PrintF
remains using the system call, for now.
2011-12-23 22:08:10 -05:00
COBJS = \
c / f i l e . o \
c / f d i o . o \
c / s t d i o . o \
2011-08-05 08:25:00 -04:00
CHEADERS = \
c / h / u n i s t d . h \
c / h / s t d l i b . h \
c / h / w c h a r . h \
c / h / s t d d e f . h \
c / h / f c n t l . h \
c / h / s t d a r g . h \
c / h / w c t y p e . h \
c / h / f e a t u r e s . h \
c / h / s t r i n g . h \
2011-11-22 11:26:47 -05:00
c / h / e r r n o . h \
2011-11-26 05:00:45 -05:00
c / h / e r r o r . h \
2011-11-20 18:02:53 -05:00
c / h / s y s / r e a d d i r e n t s . h \
2011-08-05 08:25:00 -04:00
c / h / s y s / s t a t . h \
c / h / s y s / t y p e s . h \
2011-11-06 16:00:29 -05:00
c / h / s y s / w a i t . h \
2011-09-14 12:11:52 -04:00
c / h / s t d i o . h \
2011-09-15 16:38:40 -04:00
c / h / s i g n a l . h \
Implemented large parts of the stdio(3), including fprintf.
Made FILE an interface to various backends. This allows application writers
to override the standard FILE API functions with their own backends. This
is highly unportable - it'd be nice if a real standard existed for this.
glibc already does something like this internally, but AFAIK you can't hook
into it.
Added fdopen(3), fopen(3), fregister(3), funregister(3), fread(3),
fwrite(3), fseek(3), clearerr(3), ferror(3), feof(3), rewind(3), ftell(3),
fflush(3), fclose(3), fileno(3), fnewline(3), fcloseall(3), memset(3),
stdio(3), vfprintf(3), fprintf(3), and vprintf(3).
Added a file-descriptor backend to the FILE API.
fd's {0, 1, 2} are now initialized as stdin, stdout, and stderr when the
standard library initializes.
fcloseall(3) is now called on exit(3).
decl/intn_t_.h now @include(size_t.h) instead of declaring it itself.
Added <stdint.h>.
The following programs now flush stdout: cat(1), clear(1), editor(1),
init(1), mxsh(1).
printf(3) is now hooked up against vprintf(3), while Maxsi::PrintF
remains using the system call, for now.
2011-12-23 22:08:10 -05:00
c / h / s t d i n t . h \
2011-08-05 08:25:00 -04:00
2011-11-27 10:55:44 -05:00
COMMONOBJS = c++.o memory.o heap.o string.o error.o format.o
2011-08-05 08:25:00 -04:00
SORTIXOBJS := $( addprefix sortix/,$( COMMONOBJS) )
2011-09-14 12:11:52 -04:00
LIBMAXSIOBJS := $( COMMONOBJS) \
s o r t i x - k e y b o a r d . o \
s o r t i x - s o u n d . o \
p r o c e s s . o \
t h r e a d . o \
i o . o \
i n i t . o \
2011-09-15 16:38:40 -04:00
s i g n a l . o \
$( CPU ) / s i g n a l . o \
2011-09-15 16:19:04 -04:00
s t a r t . o \
2011-11-28 10:28:56 -05:00
t i m e . o \
2011-11-10 06:27:31 -05:00
r a n d o m . o \
2011-12-16 10:49:27 -05:00
i n t e g e r . o
2011-09-14 12:11:52 -04:00
2011-09-15 16:38:40 -04:00
MAXSIHEADERS = \
2011-08-21 06:47:59 -04:00
e r r o r . h \
i o . h \
m e m o r y . h \
p l a t f o r m . h \
s t r i n g . h \
s y s c a l l . h \
t h r e a d . h \
2011-08-27 14:57:39 -04:00
p r o c e s s . h \
2011-08-21 06:47:59 -04:00
t y p e s . h \
f o r m a t . h \
k e y b o a r d . h \
2011-10-25 12:21:06 -04:00
s o r t e d l i s t . h \
2011-09-15 16:38:40 -04:00
s i g n a l . h \
s i g n a l n u m . h \
2011-08-21 06:47:59 -04:00
s o r t i x - v g a . h \
2011-08-21 18:25:28 -04:00
s o r t i x - k e y b o a r d . h \
s o r t i x - s o u n d . h \
2011-08-05 08:25:00 -04:00
OBJS := $( LIBMAXSIOBJS)
2011-09-15 16:19:04 -04:00
BINS :=
i f n d e f L I B M A X S I _ N O _ S H A R E D
BINS:= $( BINS) libmaxsi.so
e n d i f
2011-08-05 08:25:00 -04:00
i f n d e f L I B M A X S I _ N O _ S T A T I C
BINS:= $( BINS) libmaxsi.a
e n d i f
i f n d e f L I B M A X S I _ N O _ S O R T I X
2011-09-15 16:19:04 -04:00
BINS:= $( BINS) libmaxsi-sortix.a
2011-08-05 08:25:00 -04:00
e n d i f
i f n d e f L I B M A X S I _ N O _ L I B C
OBJS:= $( OBJS) $( COBJS)
2011-09-15 16:19:04 -04:00
ifndef LIBMAXSI_NO_SHARED
BINS:= $( BINS) libc.so
endif
2011-08-05 08:25:00 -04:00
ifndef LIBMAXSI_NO_STATIC
BINS:= $( BINS) libc.a
endif
2011-09-15 16:38:40 -04:00
HEADERS:= $( MAXSIHEADERS) $( CHEADERS)
2011-08-05 08:25:00 -04:00
e l s e
DEFINES:= $( DEFINES) -DLIBMAXSI_NO_LIBC
e n d i f
CFLAGS := $( FLAGS) -std= c99 -Ic/h -I..
CXXFLAGS := $( FLAGS) -nostdinc++ -fno-rtti -I.. -Ic/h
SORTIXFLAGS := $( CXXFLAGS) -DSORTIX_KERNEL -I.. -I../..
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
ln -sf $< $@
libc.so : libmaxsi .so
ln -sf $< $@
2011-09-15 16:19:04 -04:00
start.o : $( CPU ) /start .o
ln -sf $< $@
2011-08-05 08:25:00 -04:00
# libmaxsi
*.cpp : $( HEADERS )
%.o : %.cpp
g++ -c $< -o $@ $( CXXFLAGS)
%.h : hsrc /%.h
echo "/* WARNING: This header is generated - edits will be lost! */" > $@
mxmpp -I decl $< >> $@
%.o : %.s
as $( ASFLAGS) $< -o $@
%.o : %.asm
nasm $( CPUNASMFLAGS) $< -o $@
# libc
c/*.c : $( CHEADERS )
c/%.o : c /%.c
gcc -c $< -o $@ $( CFLAGS)
c/h/%.h : c /hsrc /%.h
2011-08-06 19:36:27 -04:00
mkdir -p c/h
2011-08-06 19:37:43 -04:00
mkdir -p c/h/sys
2011-08-05 08:25:00 -04:00
echo "/* WARNING: This header is generated - edits will be lost! */" > $@
mxmpp -I decl -I c/decl $< >> $@
# libmaxsi-sortix
sortix/*.cpp : $( HEADERS )
sortix/%.o : %.cpp $( HEADERS )
g++ -c $< -o $@ $( SORTIXFLAGS)
sortix/%.o : sortix /%.cpp
g++ -c $< -o $@ $( SORTIXFLAGS)
clean :
2011-09-15 16:19:04 -04:00
rm -f *.o sortix/*.o c/*.o x86/*.o x64/*.o *.a *.so $( CHEADERS) $( HEADERS)
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
for F in $( BINS) ; do cp --preserve= links $$ F $( SYSROOT) /usr/lib || exit $? ; done
mkdir -p $( SYSROOT) /usr/include
for F in $( CHEADERS) ; do F = ` echo $$ F | sed 's/c\/h\///g' ` ; mkdir -p $( SYSROOT) /usr/include/` dirname $$ F` ; cp c/h/$$ F $( SYSROOT) /usr/include/$$ F || exit $? ; done
mkdir -p $( SYSROOT) /usr/include/libmaxsi
for F in $( MAXSIHEADERS) ; do cp $$ F $( SYSROOT) /usr/include/libmaxsi || exit $? ; done
cp start.o $( SYSROOT) /usr/lib/crt1.o
touch deleteme.cpp
g++ $( CPUFLAGS) -c deleteme.cpp -o deleteme.o
for F in crt0.o crtn.o crtbegin.o crtend.o crtbeginT.o crti.o; do cp deleteme.o $( SYSROOT) /usr/lib/$$ F; done
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