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
|
|
|
|
CPUFLAGS=-fPIC -m64
|
|
|
|
CPULDFLAGS=-melf_x86_64
|
|
|
|
CPUASFLAGS=-64
|
|
|
|
endif
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
CPPINCLUDES=-I preproc -I ..
|
|
|
|
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 \
|
|
|
|
file.o \
|
|
|
|
fdio.o \
|
|
|
|
stdio.o \
|
|
|
|
dir.o \
|
|
|
|
fddir-sortix.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
sortix-sound.o \
|
|
|
|
process.o \
|
|
|
|
thread.o \
|
|
|
|
io.o \
|
2012-01-22 10:48:57 -05:00
|
|
|
terminal.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
init.o \
|
2011-09-15 16:38:40 -04:00
|
|
|
signal.o \
|
|
|
|
$(CPU)/signal.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-02-11 20:03:34 -05:00
|
|
|
integer.o \
|
|
|
|
c++.o \
|
|
|
|
memory.o \
|
|
|
|
heap.o \
|
|
|
|
string.o \
|
|
|
|
error.o \
|
|
|
|
format.o \
|
|
|
|
|
|
|
|
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 \
|
|
|
|
|
|
|
|
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
|
|
|
|
ln -sf $< $@
|
|
|
|
|
|
|
|
libc.so: libmaxsi.so
|
|
|
|
ln -sf $< $@
|
|
|
|
|
2012-01-08 09:45:13 -05:00
|
|
|
libg.a: libc.a
|
|
|
|
ln -sf $< $@
|
|
|
|
|
|
|
|
libg.so: libc.so
|
|
|
|
ln -sf $< $@
|
|
|
|
|
2011-09-15 16:19:04 -04:00
|
|
|
start.o: $(CPU)/start.o
|
|
|
|
ln -sf $< $@
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|