Commit 9cf092d3 authored by Jonas Termansen's avatar Jonas Termansen

Use cross compiler in build system.

parent 81530bc5
BITS:=$(shell getconf LONG_BIT) include compiler.mak
ifndef CPU include version.mak
ifeq ($(BITS),64)
CPU:=x64 ifneq ($(BUILD_LIBC),0)
else MODULES:=$(MODULES) libmaxsi
CPU:=x86 endif
endif ALLMODULES:=$(ALLMODULES) libmaxsi
MFLAGS:=$(MFLAGS) CPU=$(CPU)
ifneq ($(BUILD_GAMES),0)
MODULES:=$(MODULES) games
endif endif
ALLMODULES:=$(ALLMODULES) games
ifndef O ifneq ($(BUILD_MKINITRD),0)
O=-O2 MODULES:=$(MODULES) mkinitrd
MFLAGS:=$(MFLAGS) 0=$(O)
endif endif
ifndef BENCH ALLMODULES:=$(ALLMODULES) mkinitrd
BENCH:=1
ifneq ($(BUILD_UTILS),0)
MODULES:=$(MODULES) utils
endif
ALLMODULES:=$(ALLMODULES) utils
ifneq ($(BUILD_BENCH),0)
MODULES:=$(MODULES) bench
endif endif
ifeq ($(BENCH),1) ALLMODULES:=$(ALLMODULES) bench
EXTRAMODULES:=$(EXTRAMODULES) bench
ifneq ($(BUILD_KERNEL),0)
MODULES:=$(MODULES) sortix
endif endif
ALLMODULES:=$(ALLMODULES) sortix
ifndef SYSROOT ifndef SYSROOT
SYSROOT:=$(shell pwd)/sysroot SYSROOT:=$(shell pwd)/sysroot
MFLAGS:=$(MFLAGS) SYSROOT=$(SYSROOT) MFLAGS:=$(MFLAGS) SYSROOT=$(SYSROOT)
endif
ifndef PREFIXNAME
PREFIXNAME:=/
MFLAGS:=$(MFLAGS) PREFIXNAME=$(PREFIXNAME)
endif endif
REMOTE=192.168.2.6 include dirs.mak
REMOTEUSER=sortie
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
MODULES=libmaxsi games mkinitrd utils $(EXTRAMODULES) sortix
ALLMODULES=libmaxsi games mkinitrd utils bench sortix
VERSION=0.8dev
DEBNAME:=sortix_$(VERSION)_$(CPU) DEBNAME:=sortix_$(VERSION)_$(CPU)
DEBSRCNAME:=sortix_$(VERSION) DEBSRCNAME:=sortix_$(VERSION)
DEBDIR:=builds/$(DEBNAME) DEBDIR:=builds/$(DEBNAME)
...@@ -39,42 +51,63 @@ DEBFILE:=builds/$(DEBNAME).deb ...@@ -39,42 +51,63 @@ DEBFILE:=builds/$(DEBNAME).deb
PACKAGENAME:=sortix PACKAGENAME:=sortix
ISODIR:=builds/$(DEBNAME)-iso ISODIR:=builds/$(DEBNAME)-iso
ISOFILE:=builds/$(DEBNAME).iso ISOFILE:=builds/$(DEBNAME).iso
INITRDDIR:=initrd INITRD=$(INSTALLBOOTDIR)/$(HOST)/sortix.initrd
INITRD=sortix/sortix.initrd
MFLAGS:=$(MFLAGS) VERSION=$(VERSION) MFLAGS:=$(MFLAGS) VERSION=$(VERSION)
all: $(INITRD) all: $(INITRD)
suball: .PHONY: all suball sysroot-base-headers sysroot-fsh clean distclean \
(for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $?; done) everything everything-all-archs all-archs linecount install uninstall \
deb debfile debsource iso run-virtualbox run-virtualbox-debug \
clean-builds clean-sysroot
sysroot-base-headers: suball: sysroot-base-headers
(for D in libmaxsi sortix; do ($(MAKE) install-headers $(MFLAGS) --directory $$D) || exit $?; done) (for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $$?; done)
clean: sysroot-base-headers: sysroot-fsh
rm -rf $(SYSROOT) (for D in libmaxsi sortix; do ($(MAKE) install-headers $(MFLAGS) --directory $$D) || exit $$?; done)
rm -f $(INITRD)
rm -f initrd/* sysroot-fsh:
(for D in $(ALLMODULES); do $(MAKE) clean $(MFLAGS) --directory $$D || exit $?; done) mkdir -p "$(SYSROOT)"
for DIRNAME in bin boot lib include; do (\
mkdir -p "$(SYSROOT)/$$DIRNAME" &&\
mkdir -p "$(SYSROOT)/$$DIRNAME/$(HOST)" \
) || exit $$?; done;
if [ ! -e "$(SYSROOT)/usr" ]; then ln -s . "$(SYSROOT)/usr"; fi
distclean: clean cleanbuilds clean:
rm -f "$(INITRD)"
rm -f sortix/sortix.initrd # Backwards compatibility, not needed for newer builds.
rm -f initrd/* # Backwards compatibility, not needed for newer builds.
(for D in $(ALLMODULES); do $(MAKE) clean $(MFLAGS) --directory $$D || exit $$?; done)
cleanbuilds: clean-builds:
rm -rf builds/ rm -rf builds/
rm -f sortix.iso rm -f sortix.iso
clean-sysroot:
rm -rf "$(SYSROOT)"
distclean: clean clean-builds clean-sysroot
everything: all deb iso everything: all deb iso
everything-all-archs: everything-all-archs:
$(MAKE) clean $(MFLAGS) $(MAKE) clean $(MFLAGS)
$(MAKE) everything $(MFLAGS) CPU=x86 $(MAKE) everything $(MFLAGS) HOST=i486-sortix
$(MAKE) clean $(MFLAGS)
$(MAKE) everything $(MFLAGS) HOST=x86_64-sortix
all-archs:
$(MAKE) clean $(MFLAGS)
$(MAKE) all $(MFLAGS) HOST=i486-sortix
$(MAKE) clean $(MFLAGS) $(MAKE) clean $(MFLAGS)
$(MAKE) everything $(MFLAGS) CPU=x64 $(MAKE) all $(MFLAGS) HOST=x86_64-sortix
# Initializing RamDisk # Initializing RamDisk
$(INITRD): suball $(INITRD): suball
mkinitrd/mkinitrd initrd -o $(INITRD) mkinitrd/mkinitrd $(SYSROOT)/bin/$(HOST) -o $(INITRD)
# Statistics # Statistics
linecount: linecount:
...@@ -92,18 +125,6 @@ install: all ...@@ -92,18 +125,6 @@ install: all
uninstall: uninstall:
rm -f /boot/sortix.bin rm -f /boot/sortix.bin
rm -f /etc/grub.d/42_sortix rm -f /etc/grub.d/42_sortix
update-grub
# Remote machine
install-remote: all
scp -r ./ $(REMOTE):$(REMOTECOPYDIR)
scp sortix/sortix.bin root@$(REMOTE):/boot
scp $(INITRD) root@$(REMOTE):/boot
ssh root@$(REMOTE) "init 6"
uninstall-remote:
ssh root@$(REMOTE) "rm /boot/sortix.bin"
# Packaging # Packaging
...@@ -114,7 +135,7 @@ debfile: all ...@@ -114,7 +135,7 @@ debfile: all
mkdir -p $(DEBDIR) mkdir -p $(DEBDIR)
mkdir -p $(DEBDIR)/boot mkdir -p $(DEBDIR)/boot
cp sortix/sortix.bin $(DEBDIR)/boot cp sortix/sortix.bin $(DEBDIR)/boot
cp sortix/sortix.initrd $(DEBDIR)/boot cp $(INITRD) $(DEBDIR)/boot
expr \( `stat --printf="%s" $(DEBDIR)/boot/sortix.bin` \ expr \( `stat --printf="%s" $(DEBDIR)/boot/sortix.bin` \
+ `stat --printf="%s" $(DEBDIR)/boot/sortix.initrd` \ + `stat --printf="%s" $(DEBDIR)/boot/sortix.initrd` \
+ 1023 \) / 1024 > $(DEBDIR)/boot/deb.size + 1023 \) / 1024 > $(DEBDIR)/boot/deb.size
...@@ -137,14 +158,14 @@ debsource: all ...@@ -137,14 +158,14 @@ debsource: all
rm -rf $(DEBSRCDIR) rm -rf $(DEBSRCDIR)
mkdir -p $(DEBSRCDIR) mkdir -p $(DEBSRCDIR)
for D in `ls | grep -v builds | grep -v sysroot`; do cp -r $$D $(DEBSRCDIR); done for D in `ls | grep -v builds | grep -v sysroot`; do cp -r $$D $(DEBSRCDIR); done
(cd $(DEBSRCDIR) && make distclean) (cd $(DEBSRCDIR) && make distclean SYSROOT=$(shell pwd)/$(DEBSRCDIR)/sysroot)
rm -rf $(DEBSRCDIR)/sysroot rm -rf $(DEBSRCDIR)/sysroot
(cd builds && tar cfz $(DEBSRCNAME)-src.tar.gz $(DEBSRCNAME)-src) (cd builds && tar cfz $(DEBSRCNAME)-src.tar.gz $(DEBSRCNAME)-src)
rm -rf $(DEBSRCDIR) rm -rf $(DEBSRCDIR)
# Bootable images # Bootable images
iso: all debsource $(ISOFILE): all debsource
rm -rf $(ISODIR) rm -rf $(ISODIR)
mkdir -p builds mkdir -p builds
mkdir -p $(ISODIR) mkdir -p $(ISODIR)
...@@ -155,8 +176,10 @@ iso: all debsource ...@@ -155,8 +176,10 @@ iso: all debsource
grub-mkrescue -o $(ISOFILE) $(ISODIR) grub-mkrescue -o $(ISOFILE) $(ISODIR)
rm -rf $(ISODIR) rm -rf $(ISODIR)
iso: $(ISOFILE)
sortix.iso: iso sortix.iso: iso
cp $(ISOFILE) sortix.iso cp $(ISOFILE) $@
# Virtualization # Virtualization
run-virtualbox: sortix.iso run-virtualbox: sortix.iso
...@@ -165,4 +188,3 @@ run-virtualbox: sortix.iso ...@@ -165,4 +188,3 @@ run-virtualbox: sortix.iso
run-virtualbox-debug: sortix.iso run-virtualbox-debug: sortix.iso
virtualbox --debug --start-running --startvm sortix virtualbox --debug --start-running --startvm sortix
*.o *.o
benchctxswitch
benchsyscall
# Set up variables such that we can easily cross-compile. include ../compiler.mak
OSROOT=.. include ../version.mak
include ../crosscompilemakefile.mak include ../dirs.mak
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra ifndef OPTLEVEL
OPTLEVEL=-O2
endif
INITRDDIR:=../initrd ifndef CXXFLAGS
LOCALBINARIES:=\ CXXFLAGS:=$(OPTLEVEL)
endif
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
BINARIES:=\
benchsyscall \ benchsyscall \
benchctxswitch \ benchctxswitch \
BINARIES:=$(addprefix $(INITRDDIR)/,$(LOCALBINARIES)) all: $(BINARIES)
.PHONY: all install uninstall clean
all: install install: all
mkdir -p $(INSTALLBINDIR)/$(HOST)
install $(BINARIES) $(INSTALLBINDIR)/$(HOST)
install: $(LOCALBINARIES) uninstall:
cp $(LOCALBINARIES) $(INITRDDIR) for FILE in $(INSTALLBINDIR); do \
rm -f $(LOCALBINARIES) rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
%: %.cpp %: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c $< -o $@.o $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(LD) $(LDFLAGS) $@.o -o $@ $(LIBS)
sh: mxsh sh: mxsh
cp $< $@ cp $< $@
clean: clean:
rm -f $(BINARIES) $(LOCALBINARIES) *.o rm -f $(BINARIES) *.o
ifndef BITS
BITS:=$(shell getconf LONG_BIT)
endif
ifndef HOST
ifeq ($(BITS),64)
HOST:=x86_64-sortix
else
HOST:=i486-sortix
endif
MFLAGS:=$(MFLAGS) HOST=$(HOST)
endif
ifeq ($(HOST),i486-sortix)
CPU:=x86
endif
ifeq ($(HOST),x86_64-sortix)
CPU:=x64
endif
ifndef BUILDCC
BUILDCC:=gcc
endif
ifndef BUILDCXX
BUILDCXX:=g++
endif
ifndef BUILDAR
BUILDAR:=ar
endif
ifndef BUILDAS
BUILDAS:=as
endif
ifndef BUILDLD
BUILDAS:=ld
endif
ifndef BUILDOBJCOPY
BUILDOBJCOPY:=objcopy
endif
ifndef HOSTCC
HOSTCC:=$(HOST)-gcc
endif
ifndef HOSTCXX
HOSTCXX:=$(HOST)-g++
endif
ifndef HOSTAR
HOSTAR:=$(HOST)-ar
endif
ifndef HOSTAS
HOSTAS:=$(HOST)-as
endif
ifndef HOSTLD
HOSTLD:=$(HOST)-ld
endif
ifndef HOSTOBJCOPY
HOSTOBJCOPY:=$(HOST)-objcopy
endif
CC:=$(HOSTCC)
CXX:=$(HOSTCXX)
AR=:$(HOSTAR)
AS:=$(HOSTAS)
LD:=$(HOSTLD)
OBJCOPY:=$(HOSTOBJCOPY)
ifndef CPU
CPU=x86
endif
ifeq ($(CPU),x86)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
endif
ifeq ($(CPU),x64)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-m64
CPULDFLAGS=-melf_x86_64
endif
LIBMAXSIROOT:=$(OSROOT)/libmaxsi
SORTIXROOT:=$(OSROOT)/sortix
LIBC:=$(LIBMAXSIROOT)/start.o $(LIBMAXSIROOT)/libc.a
LIBS:=$(LIBC)
CPPFLAGS:=$(CPUDEFINES) -U_GNU_SOURCE -Ulinux -Dsortix
FLAGS:=-nostdinc -nostdlib -nostartfiles -nodefaultlibs
INCLUDES:=-I $(LIBMAXSIROOT)/preproc -I $(SORTIXROOT)/include
LD:=ld
LDFLAGS:=$(CPULDFLAGS)
CC:=gcc
CFLAGS:=$(CPUFLAGS) $(FLAGS) $(INCLUDES)
CXX:=g++
CXXFLAGS:=$(CPUFLAGS) $(FLAGS) $(INCLUDES) -fno-exceptions -fno-rtti
ifndef SYSROOT
SYSROOT:=/
endif
# The locations from where the program will be invoked/run on the host machine.
# For instance, on Sortix programs are normally run from the /bin union
# directory, even though they are actually installed somewhere else.
ifndef RUNPREFIXNAME
RUNPREFIXNAME:=/
endif
RUNPREFIXNAME:=$(shell echo "$(RUNPREFIXNAME)" | sed 's/\/\/*/\//g')
ifndef RUNPREFIX
RUNPREFIX:=/$(RUNPREFIXNAME)
endif
RUNPREFIX:=$(shell echo "$(RUNPREFIX)" | sed 's/\/\/*/\//g')
ifndef RUNBINDIR
RUNBINDIR:=$(RUNPREFIX)/bin
endif
RUNBINDIR:=$(shell echo "$(RUNBINDIR)" | sed 's/\/\/*/\//g')
ifndef RUNLIBDIR
RUNLIBDIR:=$(RUNPREFIX)/lib
endif
RUNLIBDIR:=$(shell echo "$(RUNLIBDIR)" | sed 's/\/\/*/\//g')
ifndef RUNINCLUDEDIR
RUNINCLUDEDIR:=$(RUNPREFIX)/include
endif
RUNINCLUDEDIR:=$(shell echo "$(RUNINCLUDEDIR)" | sed 's/\/\/*/\//g')
ifndef RUNBOOTDIR
RUNBOOTDIR:=$(RUNPREFIX)/boot
endif
RUNBOOTDIR:=$(shell echo "$(RUNBOOTDIR)" | sed 's/\/\/*/\//g')
# Where the program will be really installed on the host machine. For instance,
# on Sortix programs are run from the /bin union directory, but they are
# installed somewhere else, these variables tells where. Note that programs must
# not depend on being installed here, they should detect the proper directories
# at (preferably) runtime, or during the install configuration step when
# installed through package management.
ifndef PREFIXNAME
PREFIXNAME:=/data/local
endif
PREFIXNAME:=$(shell echo "$(PREFIXNAME)" | sed 's/\/\/*/\//g')
ifndef PREFIX
PREFIX:=$(SYSROOT)/$(PREFIXNAME)
endif
PREFIX:=$(shell echo "$(PREFIX)" | sed 's/\/\/*/\//g')
ifndef BINDIR
BINDIR:=$(PREFIX)/bin
endif
BINDIR:=$(shell echo "$(BINDIR)" | sed 's/\/\/*/\//g')
ifndef LIBDIR
LIBDIR:=$(PREFIX)/lib
endif
LIBDIR:=$(shell echo "$(LIBDIR)" | sed 's/\/\/*/\//g')
ifndef INCLUDEDIR
INCLUDEDIR:=$(PREFIX)/include
endif
INCLUDEDIR:=$(shell echo "$(INCLUDEDIR)" | sed 's/\/\/*/\//g')
ifndef BOOTDIR
BOOTDIR:=$(PREFIX)/boot
endif
BOOTDIR:=$(shell echo "$(BOOTDIR)" | sed 's/\/\/*/\//g')
# Where the program will be installed on the build machine. This is mostly
# useful if cross compiling or producing a software distribution image. By
# default programs will be installed in the same location as the host machine.
ifdef INSTALLPREFIX
INSTALLPREFIX_WAS_SPECIFIED=1
endif
ifndef INSTALLPREFIX
INSTALLPREFIX:=$(PREFIX)
endif
INSTALLPREFIX:=$(shell echo "$(INSTALLPREFIX)" | sed 's/\/\/*/\//g')
ifndef INSTALLBINDIR
ifdef INSTALLPREFIX_WAS_SPECIFIED
INSTALLBINDIR:=$(INSTALLPREFIX)/bin
else
INSTALLBINDIR:=$(BINDIR)
endif
endif
INSTALLBINDIR:=$(shell echo "$(INSTALLBINDIR)" | sed 's/\/\/*/\//g')
ifndef INSTALLLIBDIR
ifdef INSTALLPREFIX_WAS_SPECIFIED
INSTALLLIBDIR:=$(INSTALLPREFIX)/lib
else
INSTALLLIBDIR:=$(LIBDIR)
endif
endif
INSTALLLIBDIR:=$(shell echo "$(INSTALLLIBDIR)" | sed 's/\/\/*/\//g')
ifndef INSTALLINCLUDEDIR
ifdef INSTALLPREFIX_WAS_SPECIFIED
INSTALLINCLUDEDIR:=$(INSTALLPREFIX)/include
else
INSTALLINCLUDEDIR:=$(INCLUDEDIR)
endif
endif
INSTALLINCLUDEDIR:=$(shell echo "$(INSTALLINCLUDEDIR)" | sed 's/\/\/*/\//g')
ifndef INSTALLBOOTDIR
ifdef INSTALLPREFIX_WAS_SPECIFIED
INSTALLBOOTDIR:=$(INSTALLPREFIX)/boot
else
INSTALLBOOTDIR:=$(BOOTDIR)
endif
endif
INSTALLBOOTDIR:=$(shell echo "$(INSTALLBOOTDIR)" | sed 's/\/\/*/\//g')
...@@ -6,3 +6,5 @@ ...@@ -6,3 +6,5 @@
*.a *.a
pong pong
conway conway
snake
asteroids
# Set up variables such that we can easily cross-compile. include ../compiler.mak
OSROOT=.. include ../version.mak
include ../crosscompilemakefile.mak include ../dirs.mak
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra ifndef OPTLEVEL
OPTLEVEL=-O2
endif
INITRDDIR:=../initrd ifndef CXXFLAGS
LOCALBINARIES:=\ CXXFLAGS:=$(OPTLEVEL)
endif
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
BINARIES:=\
pong \ pong \
conway \ conway \
snake \ snake \
asteroids \ asteroids \
BINARIES:=$(addprefix $(INITRDDIR)/,$(LOCALBINARIES)) all: $(BINARIES)
.PHONY: all install uninstall clean
all: install install: all
mkdir -p $(INSTALLBINDIR)/$(HOST)
install $(BINARIES) $(INSTALLBINDIR)/$(HOST)
install: $(LOCALBINARIES) uninstall:
cp $(LOCALBINARIES) $(INITRDDIR) for FILE in $(INSTALLBINDIR); do \
rm -f $(LOCALBINARIES) rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
%: %.cpp %: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c $< -o $@.o $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(LD) $(LDFLAGS) $@.o -o $@ $(LIBS)
sh: mxsh sh: mxsh
cp $< $@ cp $< $@
clean: clean:
rm -f $(BINARIES) $(LOCALBINARIES) *.o rm -f $(BINARIES) *.o
ifndef CPU include ../compiler.mak
CPU=x86 include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-O2
endif
ifeq ($(DEBUG_LIBC),1)
FLAGSDEBUG=-g3
else
FLAGSDEBUG=$(OPTLEVEL)
endif endif
ifeq ($(CPU),x86) CPUDIR:=$(CPU)
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32 ifeq ($(HOST),i486-sortix)
CPULDFLAGS=-melf_i386 CPUFLAGS=
CPUASFLAGS=-32
endif endif
ifeq ($(CPU),x64) ifeq ($(HOST),x86_64-sortix)
CPU=x64 CPUFLAGS=-fPIC -mno-red-zone
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-fPIC -m64 -mno-red-zone
CPULDFLAGS=-melf_x86_64
CPUASFLAGS=-64
endif endif
CPPINCLUDES=-I preproc -I ../sortix/include CPPINCLUDES=-I preproc
CPPFLAGS=-DLIBMAXSI_LIBRARY -DSORTIX -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES) CPPFLAGS=-DLIBMAXSI_LIBRARY -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES)
FLAGS=$(CPUFLAGS) -Wall -Wextra -nostdlib -fno-builtin -nostartfiles \ FLAGS=$(CPUFLAGS) -Wall -Wextra -fno-stack-protector $(FLAGSDEBUG)
-nodefaultlibs -fno-stack-protector -nostdinc
CFLAGS=$(FLAGS) -std=c99 CFLAGS=$(FLAGS) -std=c99
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -nostdinc++ -fno-rtti CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
LDFLAGS=$(CPULDFLAGS)
ASFLAGS=$(CPUASFLAGS) ASFLAGS=$(CPUASFLAGS)
OBJS=\ OBJS=\
...@@ -48,8 +51,8 @@ isatty.o \ ...@@ -48,8 +51,8 @@ isatty.o \
kernelinfo.o \ kernelinfo.o \
init.o \ init.o \
signal.o \ signal.o \
$(CPU)/signal.o \ $(CPUDIR)/signal.o \
$(CPU)/fork.o \ $(CPUDIR)/fork.o \
time.o \ time.o \
random.o \ random.o \
abs.o \ abs.o \
...@@ -188,7 +191,7 @@ crc32.o \ ...@@ -188,7 +191,7 @@ crc32.o \
SORTIXOBJS:=$(addprefix sortix/,$(SORTIXOBJS)) SORTIXOBJS:=$(addprefix sortix/,$(SORTIXOBJS))
SORTIXCPPFLAGS:=-DSORTIX_KERNEL SORTIXCPPFLAGS:=-DSORTIX_KERNEL
BINS=libc.a libg.a libmaxsi.a libmaxsi-sortix.a $(CRTOBJ) BINS=libc.a libg.a libm.a libstdc++.a libmaxsi.a libmaxsi-sortix.a $(CRTOBJ)
all: $(BINS) all: $(BINS)
...@@ -196,36 +199,33 @@ all: $(BINS) ...@@ -196,36 +199,33 @@ all: $(BINS)
install-lib-dirs install-libs install-lib-dirs install-libs
libmaxsi.a: $(OBJS) libmaxsi.a: $(OBJS)
ar rcs libmaxsi.a $(OBJS) $(HOSTAR) rcs libmaxsi.a $(OBJS)
libmaxsi.so: $(OBJS)
ld $(LDFLAGS) -shared -o $@ $(OBJS)
libmaxsi-sortix.a: $(SORTIXOBJS) libmaxsi-sortix.a: $(SORTIXOBJS)
ar rcs libmaxsi-sortix.a $(SORTIXOBJS) $(HOSTAR) rcs libmaxsi-sortix.a $(SORTIXOBJS)
libc.a: libmaxsi.a libc.a: libmaxsi.a
ln -sf $< $@ ln -sf $< $@
libc.so: libmaxsi.so
ln -sf $< $@
libg.a: libc.a libg.a: libc.a
ln -sf $< $@ ln -sf $< $@
libg.so: libc.so libm.a:
ln -sf $< $@ $(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
start.o: $(CPU)/start.o start.o: $(CPUDIR)/start.o
ln -f $< $@ ln -f $< $@
crt1.o: $(CPU)/crt1.o crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@ ln -f $< $@
crti.o: $(CPU)/crti.o crti.o: $(CPUDIR)/crti.o
ln -f $< $@ ln -f $< $@
crtn.o: $(CPU)/crtn.o crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@ ln -f $< $@
# header preprocessing # header preprocessing
...@@ -239,20 +239,20 @@ headers: $(HEADERDIRS) $(HEADERS) ...@@ -239,20 +239,20 @@ headers: $(HEADERDIRS) $(HEADERS)
# standard library # standard library
%.o: %.c headers %.o: %.c headers
gcc -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
%.o: %.cpp headers