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

Use cross compiler in build system.

parent 81530bc5
BITS:=$(shell getconf LONG_BIT)
ifndef CPU
ifeq ($(BITS),64)
CPU:=x64
else
CPU:=x86
endif
MFLAGS:=$(MFLAGS) CPU=$(CPU)
include compiler.mak
include version.mak
ifneq ($(BUILD_LIBC),0)
MODULES:=$(MODULES) libmaxsi
endif
ALLMODULES:=$(ALLMODULES) libmaxsi
ifneq ($(BUILD_GAMES),0)
MODULES:=$(MODULES) games
endif
ALLMODULES:=$(ALLMODULES) games
ifndef O
O=-O2
MFLAGS:=$(MFLAGS) 0=$(O)
ifneq ($(BUILD_MKINITRD),0)
MODULES:=$(MODULES) mkinitrd
endif
ifndef BENCH
BENCH:=1
ALLMODULES:=$(ALLMODULES) mkinitrd
ifneq ($(BUILD_UTILS),0)
MODULES:=$(MODULES) utils
endif
ALLMODULES:=$(ALLMODULES) utils
ifneq ($(BUILD_BENCH),0)
MODULES:=$(MODULES) bench
endif
ifeq ($(BENCH),1)
EXTRAMODULES:=$(EXTRAMODULES) bench
ALLMODULES:=$(ALLMODULES) bench
ifneq ($(BUILD_KERNEL),0)
MODULES:=$(MODULES) sortix
endif
ALLMODULES:=$(ALLMODULES) sortix
ifndef SYSROOT
SYSROOT:=$(shell pwd)/sysroot
MFLAGS:=$(MFLAGS) SYSROOT=$(SYSROOT)
endif
REMOTE=192.168.2.6
REMOTEUSER=sortie
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
MODULES=libmaxsi games mkinitrd utils $(EXTRAMODULES) sortix
ALLMODULES=libmaxsi games mkinitrd utils bench sortix
ifndef PREFIXNAME
PREFIXNAME:=/
MFLAGS:=$(MFLAGS) PREFIXNAME=$(PREFIXNAME)
endif
include dirs.mak
VERSION=0.8dev
DEBNAME:=sortix_$(VERSION)_$(CPU)
DEBSRCNAME:=sortix_$(VERSION)
DEBDIR:=builds/$(DEBNAME)
......@@ -39,42 +51,63 @@ DEBFILE:=builds/$(DEBNAME).deb
PACKAGENAME:=sortix
ISODIR:=builds/$(DEBNAME)-iso
ISOFILE:=builds/$(DEBNAME).iso
INITRDDIR:=initrd
INITRD=sortix/sortix.initrd
INITRD=$(INSTALLBOOTDIR)/$(HOST)/sortix.initrd
MFLAGS:=$(MFLAGS) VERSION=$(VERSION)
all: $(INITRD)
suball:
(for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $?; done)
.PHONY: all suball sysroot-base-headers sysroot-fsh clean distclean \
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:
(for D in libmaxsi sortix; do ($(MAKE) install-headers $(MFLAGS) --directory $$D) || exit $?; done)
suball: sysroot-base-headers
(for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $$?; done)
clean:
rm -rf $(SYSROOT)
rm -f $(INITRD)
rm -f initrd/*
(for D in $(ALLMODULES); do $(MAKE) clean $(MFLAGS) --directory $$D || exit $?; done)
sysroot-base-headers: sysroot-fsh
(for D in libmaxsi sortix; do ($(MAKE) install-headers $(MFLAGS) --directory $$D) || exit $$?; done)
sysroot-fsh:
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 -f sortix.iso
clean-sysroot:
rm -rf "$(SYSROOT)"
distclean: clean clean-builds clean-sysroot
everything: all deb iso
everything-all-archs:
$(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) everything $(MFLAGS) CPU=x64
$(MAKE) all $(MFLAGS) HOST=x86_64-sortix
# Initializing RamDisk
$(INITRD): suball
mkinitrd/mkinitrd initrd -o $(INITRD)
mkinitrd/mkinitrd $(SYSROOT)/bin/$(HOST) -o $(INITRD)
# Statistics
linecount:
......@@ -92,18 +125,6 @@ install: all
uninstall:
rm -f /boot/sortix.bin
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
......@@ -114,7 +135,7 @@ debfile: all
mkdir -p $(DEBDIR)
mkdir -p $(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` \
+ `stat --printf="%s" $(DEBDIR)/boot/sortix.initrd` \
+ 1023 \) / 1024 > $(DEBDIR)/boot/deb.size
......@@ -137,14 +158,14 @@ debsource: all
rm -rf $(DEBSRCDIR)
mkdir -p $(DEBSRCDIR)
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
(cd builds && tar cfz $(DEBSRCNAME)-src.tar.gz $(DEBSRCNAME)-src)
rm -rf $(DEBSRCDIR)
# Bootable images
iso: all debsource
$(ISOFILE): all debsource
rm -rf $(ISODIR)
mkdir -p builds
mkdir -p $(ISODIR)
......@@ -155,8 +176,10 @@ iso: all debsource
grub-mkrescue -o $(ISOFILE) $(ISODIR)
rm -rf $(ISODIR)
iso: $(ISOFILE)
sortix.iso: iso
cp $(ISOFILE) sortix.iso
cp $(ISOFILE) $@
# Virtualization
run-virtualbox: sortix.iso
......@@ -165,4 +188,3 @@ run-virtualbox: sortix.iso
run-virtualbox-debug: sortix.iso
virtualbox --debug --start-running --startvm sortix
*.o
benchctxswitch
benchsyscall
# Set up variables such that we can easily cross-compile.
OSROOT=..
include ../crosscompilemakefile.mak
include ../compiler.mak
include ../version.mak
include ../dirs.mak
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra
ifndef OPTLEVEL
OPTLEVEL=-O2
endif
INITRDDIR:=../initrd
LOCALBINARIES:=\
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
BINARIES:=\
benchsyscall \
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)
cp $(LOCALBINARIES) $(INITRDDIR)
rm -f $(LOCALBINARIES)
uninstall:
for FILE in $(INSTALLBINDIR); do \
rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
%: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c $< -o $@.o
$(LD) $(LDFLAGS) $@.o -o $@ $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
sh: mxsh
cp $< $@
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 @@
*.a
pong
conway
snake
asteroids
# Set up variables such that we can easily cross-compile.
OSROOT=..
include ../crosscompilemakefile.mak
include ../compiler.mak
include ../version.mak
include ../dirs.mak
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra
ifndef OPTLEVEL
OPTLEVEL=-O2
endif
INITRDDIR:=../initrd
LOCALBINARIES:=\
ifndef CXXFLAGS
CXXFLAGS:=$(OPTLEVEL)
endif
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
BINARIES:=\
pong \
conway \
snake \
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)
cp $(LOCALBINARIES) $(INITRDDIR)
rm -f $(LOCALBINARIES)
uninstall:
for FILE in $(INSTALLBINDIR); do \
rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
%: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c $< -o $@.o
$(LD) $(LDFLAGS) $@.o -o $@ $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
sh: mxsh
cp $< $@
clean:
rm -f $(BINARIES) $(LOCALBINARIES) *.o
rm -f $(BINARIES) *.o
ifndef CPU
CPU=x86
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-O2
endif
ifeq ($(DEBUG_LIBC),1)
FLAGSDEBUG=-g3
else
FLAGSDEBUG=$(OPTLEVEL)
endif
ifeq ($(CPU),x86)
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
CPUASFLAGS=-32
CPUDIR:=$(CPU)
ifeq ($(HOST),i486-sortix)
CPUFLAGS=
endif
ifeq ($(CPU),x64)
CPU=x64
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-fPIC -m64 -mno-red-zone
CPULDFLAGS=-melf_x86_64
CPUASFLAGS=-64
ifeq ($(HOST),x86_64-sortix)
CPUFLAGS=-fPIC -mno-red-zone
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
CPPINCLUDES=-I preproc
CPPFLAGS=-DLIBMAXSI_LIBRARY -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES)
FLAGS=$(CPUFLAGS) -Wall -Wextra -fno-stack-protector $(FLAGSDEBUG)
CFLAGS=$(FLAGS) -std=c99
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -nostdinc++ -fno-rtti
LDFLAGS=$(CPULDFLAGS)
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
ASFLAGS=$(CPUASFLAGS)
OBJS=\
......@@ -48,8 +51,8 @@ isatty.o \
kernelinfo.o \
init.o \
signal.o \
$(CPU)/signal.o \
$(CPU)/fork.o \
$(CPUDIR)/signal.o \
$(CPUDIR)/fork.o \
time.o \
random.o \
abs.o \
......@@ -188,7 +191,7 @@ crc32.o \
SORTIXOBJS:=$(addprefix sortix/,$(SORTIXOBJS))
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)
......@@ -196,36 +199,33 @@ all: $(BINS)
install-lib-dirs install-libs
libmaxsi.a: $(OBJS)
ar rcs libmaxsi.a $(OBJS)
libmaxsi.so: $(OBJS)
ld $(LDFLAGS) -shared -o $@ $(OBJS)
$(HOSTAR) rcs libmaxsi.a $(OBJS)
libmaxsi-sortix.a: $(SORTIXOBJS)
ar rcs libmaxsi-sortix.a $(SORTIXOBJS)
$(HOSTAR) rcs libmaxsi-sortix.a $(SORTIXOBJS)
libc.a: libmaxsi.a
ln -sf $< $@
libc.so: libmaxsi.so
ln -sf $< $@
libg.a: libc.a
ln -sf $< $@
libg.so: libc.so
ln -sf $< $@
libm.a:
$(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
start.o: $(CPU)/start.o
start.o: $(CPUDIR)/start.o
ln -f $< $@
crt1.o: $(CPU)/crt1.o
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@
crti.o: $(CPU)/crti.o
crti.o: $(CPUDIR)/crti.o
ln -f $< $@
crtn.o: $(CPU)/crtn.o
crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@
# header preprocessing
......@@ -239,20 +239,20 @@ headers: $(HEADERDIRS) $(HEADERS)
# standard library
%.o: %.c headers
gcc -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
%.o: %.cpp headers
g++ -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: %.s
as $(ASFLAGS) $< -o $@
$(HOSTAS) $(ASFLAGS) $< -o $@
# libmaxsi-sortix
sortix:
mkdir -p sortix
sortix/%.o: %.cpp $(HEADERS) sortix
g++ -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CXXFLAGS)
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CXXFLAGS)
clean:
rm -f *.o sortix/*.o c/*.o x86/*.o x64/*.o *.a *.so
......@@ -263,19 +263,26 @@ clean:
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
mkdir -p $(INSTALLINCLUDEDIR)
DIRS=$$(echo $(UNPROCHEADERDIRS) | \
tr ' ' '\n' | \
sed 's/include\/*//'); \
for D in $$DIRS; do \
mkdir -p $(INSTALLINCLUDEDIR)/$$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
for SRC in $(HEADERS); do \
DEST=`echo $$SRC | sed 's/preproc\///'`; \
cp -P $$SRC $(INSTALLINCLUDEDIR)/$$DEST || exit $?; \
done
install-lib-dirs:
mkdir -p $(INSTALLLIBDIR)
mkdir -p $(INSTALLLIBDIR)/$(HOST)
install-libs: install-lib-dirs
for F in $(BINS); do \
cp -P $$F $(INSTALLLIBDIR)/$(HOST) || exit $?; \
done
ifndef O
O:=-O3
endif
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef CPU
CPU=x86
ifndef OPTLEVEL
OPTLEVEL:=-O2
endif
ifeq ($(CPU),x86)
BUILDID=x86
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
CPUASFLAGS=-32
CPUFLAGS=
CPULDFLAGS=
CPUNASMFLAGS=-felf32
CPUOBJS=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x86.o
CPUOBJS:=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x86.o
endif
ifeq ($(CPU),x64)
BUILDID=x64
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-m64 -ffreestanding -mno-red-zone
CPULDFLAGS=-melf64-little -z max-page-size=0x1000
CPUASFLAGS=-64
CPUFLAGS=-ffreestanding -mno-red-zone
CPULDFLAGS=-z max-page-size=0x1000
CPUNASMFLAGS=-felf64
CPUOBJS=$(CPU)/base.o $(CPU)/x64.o
CPUOBJS:=$(CPU)/base.o $(CPU)/x64.o