Commit 7eb9e3c3 authored by Jonas Termansen's avatar Jonas Termansen

Refactor Sortix build system and de-autoconf mxmpp.

parent 0c7d1486
......@@ -7,4 +7,6 @@
libmaxsi
builds
sysroot
sysroot-overlay
initrd
release
This diff is collapsed.
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-O2
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
......@@ -16,24 +17,21 @@ BINARIES:=\
benchsyscall \
benchctxswitch \
INSTALLBINARIES:=$(addprefix $(DESTDIR)$(BINDIR)/,$(BINARIES))
all: $(BINARIES)
.PHONY: all install uninstall clean
install: all
mkdir -p $(INSTALLBINDIR)/$(HOST)
install $(BINARIES) $(INSTALLBINDIR)/$(HOST)
mkdir -p $(DESTDIR)$(BINDIR)
install $(BINARIES) $(DESTDIR)$(BINDIR)
uninstall:
for FILE in $(INSTALLBINDIR); do \
rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
rm -f $(INSTALLBINARIES)
%: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
sh: mxsh
cp $< $@
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@
clean:
rm -f $(BINARIES) *.o
......
ifndef BITS
BITS:=$(shell getconf LONG_BIT)
COMPILER_MAK_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
include $(COMPILER_MAK_DIR)/platform.mak
# Warn if default target is used and the software shouldn't be built under Sortix.
ifeq ($(BUILD_IS_SORTIX),1)
ifeq ($(MAKEFILE_NOT_MEANT_FOR_SORTIX), 1)
makefile_not_meant_for_sortix:
@echo This makefile isn\'t meant to work under Sortix
@exit 1
endif
endif
ifndef HOST
ifeq ($(BITS),64)
HOST:=x86_64-sortix
else
HOST:=i486-sortix
# Warn if default target is used and the software should be built under Sortix.
ifeq ($(BUILD_IS_SORTIX),0)
ifeq ($(MAKEFILE_MEANT_FOR_SORTIX), 1)
makefile_meant_for_sortix:
@echo This makefile is meant to work under Sortix, not $(BUILD)
@exit 1
endif
endif
# Warn if default target is used and the software shouldn't be built for Sortix.
ifeq ($(HOST_IS_SORTIX),1)
ifeq ($(SOFTWARE_NOT_MEANT_FOR_SORTIX), 1)
software_not_meant_for_sortix:
@echo This software isn\'t meant to work under Sortix
@exit 1
endif
MFLAGS:=$(MFLAGS) HOST=$(HOST)
endif
# Warn if default target is used and the software should be built for Sortix.
ifeq ($(HOST_IS_SORTIX),0)
ifeq ($(SOFTWARE_MEANT_FOR_SORTIX), 1)
software_meant_for_sortix:
@echo This software is meant to work under Sortix, not $(HOST)
@echo Attempt was $(MAKE) $(MAKEFLAGS)
@echo Try: $(MAKE) $(MAKEFLAGS) HOST=$(UNAME_PLATFORM)-sortix
@exit 1
endif
endif
# Provide deprecated CPU variable so makefiles can select CPU-specific dirs.
ifeq ($(HOST),i486-sortix)
MACHINE:=i486
CPU:=x86
OTHER_PLATFORMS=x86-64-sortix
endif
ifeq ($(HOST),x86_64-sortix)
MACHINE:=x86_64
CPU:=x64
OTHER_PLATFORMS=i486-sortix
endif
# Determine the prefix for build tools.
ifndef BUILD_TOOL_PREFIX
BUILD_TOOL_PREFIX:=
endif
# Determine the prefix for host tools.
ifndef HOST_TOOL_PREFIX
ifeq ($(BUILD),$(HOST))
HOST_TOOL_PREFIX:=$(BUILD_TOOL_PREFIX)
else
HOST_TOOL_PREFIX:=$(HOST)-
endif
endif
# Determine the names of the tools that target the build platform.
ifndef BUILDCC
BUILDCC:=gcc
BUILDCC:=$(BUILD_TOOL_PREFIX)gcc
endif
ifndef BUILDCXX
BUILDCXX:=g++
BUILDCXX:=$(BUILD_TOOL_PREFIX)g++
endif
ifndef BUILDAR
BUILDAR:=ar
BUILDAR:=$(BUILD_TOOL_PREFIX)ar
endif
ifndef BUILDAS
BUILDAS:=as
BUILDAS:=$(BUILD_TOOL_PREFIX)as
endif
ifndef BUILDLD
BUILDAS:=ld
BUILDAS:=$(BUILD_TOOL_PREFIX)ld
endif
ifndef BUILDOBJCOPY
BUILDOBJCOPY:=objcopy
BUILDOBJCOPY:=$(BUILD_TOOL_PREFIX)objcopy
endif
# Determine the names of the tools that target the host platform.
ifndef HOSTCC
HOSTCC:=$(HOST)-gcc
HOSTCC:=$(HOST_TOOL_PREFIX)gcc
endif
ifndef HOSTCXX
HOSTCXX:=$(HOST)-g++
HOSTCXX:=$(HOST_TOOL_PREFIX)g++
endif
ifndef HOSTAR
HOSTAR:=$(HOST)-ar
HOSTAR:=$(HOST_TOOL_PREFIX)ar
endif
ifndef HOSTAS
HOSTAS:=$(HOST)-as
HOSTAS:=$(HOST_TOOL_PREFIX)as
endif
ifndef HOSTLD
HOSTLD:=$(HOST)-ld
HOSTLD:=$(HOST_TOOL_PREFIX)ld
endif
ifndef HOSTOBJCOPY
HOSTOBJCOPY:=$(HOST)-objcopy
HOSTOBJCOPY:=$(HOST_TOOL_PREFIX)objcopy
endif
CC:=$(HOSTCC)
CXX:=$(HOSTCXX)
AR=:$(HOSTAR)
AR:=$(HOSTAR)
AS:=$(HOSTAS)
LD:=$(HOSTLD)
OBJCOPY:=$(HOSTOBJCOPY)
......
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')
ifeq ($(HOST_IS_SORTIX),1)
DEFAULT_PREFIX=
else
DEFAULT_PREFIX=/usr/local
endif
ifeq ($(HOST_IS_SORTIX),1)
DEFAULT_EXEC_PREFIX=$(PREFIX)/$(HOST)
else
DEFAULT_EXEC_PREFIX=$(PREFIX)
endif
PREFIX?=$(DEFAULT_PREFIX)
EXEC_PREFIX?=$(DEFAULT_EXEC_PREFIX)
BINDIR?=$(EXEC_PREFIX)/bin
SBINDIR?=$(EXEC_PREFIX)/sbin
LIBEXECDIR?=$(EXEC_PREFIX)/libexec
BOOTDIR?=$(PREFIX)/boot
DATAROOTDIR?=$(PREFIX)/share
DATADIR?=$(DATAROOTDIR)
SYSCONFDIR?=$(PREFIX)/etc
SHAREDSTATEDIR?=$(PREFIX)/com
LOCALSTATEDIR?=$(PREFIX)/var
RUNSTATEDIR?=$(LOCALSTATEDIR)/run
INCLUDEDIR?=$(PREFIX)/include
DOCDIR?=$(DATAROOTDIR)/doc
INFODIR?=$(DATAROOTDIR)/info
HTMLDIR?=$(DOCDIR)
DVIDIR?=$(DOCDIR)
PSDIR?=$(DOCDIR)
PDFDIR?=$(DOCDIR)
PSDIR?=$(DOCDIR)
LIBDIR?=$(EXEC_PREFIX)/lib
LOCALEDIR?=$(DATAROOTDIR/locale
MANDIR?=$(DATAROOTDIR)/man
MAN1DIR?=$(MANDIR)/man1
MAN2DIR?=$(MANDIR)/man2
MAN3DIR?=$(MANDIR)/man3
MAN4DIR?=$(MANDIR)/man4
MAN5DIR?=$(MANDIR)/man5
MAN6DIR?=$(MANDIR)/man6
MAN7DIR?=$(MANDIR)/man7
MAN8DIR?=$(MANDIR)/man8
MAN9DIR?=$(MANDIR)/man9
MANEXT?=.1
MAN1EXT?=.1
MAN2EXT?=.2
MAN3EXT?=.3
MAN4EXT?=.4
MAN5EXT?=.5
MAN6EXT?=.6
MAN7EXT?=.7
MAN8EXT?=.8
MAN9EXT?=.9
DESTDIR?=
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-O2
OPTLEVEL:=-g -O2
endif
ifndef CXXFLAGS
......@@ -47,32 +48,25 @@ clean:
rm -f *.o client/*.o server/*.o
%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
$(HOSTCXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
# Installation into sysroot
install: install-headers install-client install-server
install-include-dirs: headers
mkdir -p $(INSTALLINCLUDEDIR)
for D in $$(find include/ -type d | sed 's/include\/*//'); do \
mkdir -p $(INSTALLINCLUDEDIR)/$$D || exit $?; \
done
mkdir -p $(DESTDIR)$(INCLUDEDIR)
install-headers: install-include-dirs headers
for SRC in $$(find include/ -type f); do \
DEST=`echo $$SRC | sed 's/include\///'`; \
cp -P $$SRC $(INSTALLINCLUDEDIR)/$$DEST || exit $?; \
done
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
install-client-dirs:
mkdir -p $(INSTALLLIBDIR)
mkdir -p $(INSTALLLIBDIR)/$(HOST)
mkdir -p $(DESTDIR)$(LIBDIR)
install-client: install-client-dirs
cp -P client/libdispd.a $(INSTALLLIBDIR)/$(HOST)
install-client: install-client-dirs client
cp -P client/libdispd.a $(DESTDIR)$(LIBDIR)
install-server-dirs:
mkdir -p $(INSTALLBINDIR)/$(HOST)
mkdir -p $(DESTDIR)$(BINDIR)
install-server: install-server-dirs
install server/dispd $(INSTALLBINDIR)/$(HOST)
install-server: install-server-dirs server
install server/dispd $(DESTDIR)$(BINDIR)
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL=-O2
OPTLEVEL=-g -O2
endif
ifndef CXXFLAGS
......@@ -18,6 +19,8 @@ conway \
snake \
asteroids \
INSTALLBINARIES:=$(addprefix $(DESTDIR)$(BINDIR)/,$(BINARIES))
LIBS:=-ldispd
all: $(BINARIES)
......@@ -25,19 +28,14 @@ all: $(BINARIES)
.PHONY: all install uninstall clean
install: all
mkdir -p $(INSTALLBINDIR)/$(HOST)
install $(BINARIES) $(INSTALLBINDIR)/$(HOST)
mkdir -p $(DESTDIR)$(BINDIR)
install $(BINARIES) $(DESTDIR)$(BINDIR)
uninstall:
for FILE in $(INSTALLBINDIR); do \
rm -f $(INSTALLBINDIR)/$(HOST)/$$FILE; \
done
rm -f $(INSTALLBINARIES)
%: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(LIBS)
sh: mxsh
cp $< $@
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(LIBS)
clean:
rm -f $(BINARIES) *.o
......
......@@ -397,7 +397,7 @@ public:
private:
static const size_t MIN_POLYS = 5;
static const size_t MAX_POLYS = 12;
static const float MAX_TURN_SPEED = 50.0f;
static constexpr float MAX_TURN_SPEED = 50.0f;
size_t numpolygons;
float slice;
float polydists[MAX_POLYS+1];
......
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-O2
endif
ifeq ($(DEBUG_LIBC),1)
FLAGSDEBUG=-g3
else
FLAGSDEBUG=$(OPTLEVEL)
OPTLEVEL:=-g -O2 -fno-omit-frame-pointer
endif
CPUDIR:=$(CPU)
ifeq ($(HOST),i486-sortix)
CPUFLAGS=
endif
ifeq ($(HOST),x86_64-sortix)
CPUFLAGS=-fPIC -mno-red-zone
endif
CPPINCLUDES=-I preproc
CPPFLAGS=-DLIBC_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 -fno-rtti
ASFLAGS=$(CPUASFLAGS)
CPPFLAGS=-DLIBC_LIBRARY $(CPPINCLUDES)
FLAGS=-Wall -Wextra $(OPTLEVEL)
CFLAGS=-std=gnu99
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
ASFLAGS=
FREEOBJS=\
abort.o \
......@@ -224,7 +211,6 @@ $(FREEOBJS) \
$(HOSTEDOBJS) \
CRTOBJ=\
start.o \
crt1.o \
crti.o \
crtn.o \
......@@ -236,16 +222,33 @@ UNPROCHEADERDIRS:=$(shell find include -type d)
UNPROCHEADERS:=$(shell find include -type f)
HEADERDIRS:=$(patsubst include%,preproc%,$(UNPROCHEADERDIRS))
HEADERS:=$(patsubst include%,preproc%,$(UNPROCHEADERS))
INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERDIRS)))
INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS)))
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
SORTIXCPPFLAGS:=-DSORTIX_KERNEL
SORTIXCPPFLAGS:=$(CPPFLAGS) -DSORTIX_KERNEL
SORTIXFLAGS:=$(FLAGS) -ffreestanding
SORTIXCFLAGS:=$(CFLAGS)
SORTIXCXXFLAGS:=$(CXXFLAGS)
ifeq ($(HOST),x86_64-sortix)
SORTIXFLAGS:=$(SORTIXFLAGS) -mno-red-zone
endif
BINS=libc.a libg.a libm.a libstdc++.a libc-sortix.a $(CRTOBJ)
BINS=libc.a libg.a libm.a libpthread.a libstdc++.a $(CRTOBJ)
BINSKERNEL=libc-sortix.a
INSTALLLIBS:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINS))
INSTALLLIBSKERNEL:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINSKERNEL))
all: $(BINS)
all: libs libs-kernel
.PHONY: all headers clean install install-include-dirs install-headers \
install-lib-dirs install-libs
libs: $(BINS)
libs-kernel: $(BINSKERNEL)
.PHONY: all libs headers clean install install-include-dirs install-headers \
install-lib-dirs install-libs libs-kernel
FORCE:
libc.a: $(OBJS)
$(HOSTAR) rcs $@ $(OBJS)
......@@ -253,17 +256,17 @@ libc.a: $(OBJS)
libc-sortix.a: $(SORTIXOBJS)
$(HOSTAR) rcs $@ $(SORTIXOBJS)
libg.a: libc.a
ln -sf $< $@
libg.a:
$(HOSTAR) rcs $@
libm.a:
$(HOSTAR) rcs $@
libstdc++.a:
libpthread.a:
$(HOSTAR) rcs $@
start.o: $(CPUDIR)/start.o
ln -f $< $@
libstdc++.a:
$(HOSTAR) rcs $@
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@
......@@ -275,63 +278,66 @@ crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@
# header preprocessing
$(OBJS) $(SORTIXOBJS): $(HEADERS)
$(HEADERDIRS):
mkdir -p $@
preproc/%: include/% $(HEADERDIRS)
preproc/%: include/%
mxmpp -I decl $< -o $@
$(HEADERS): | $(HEADERDIRS)
headers: $(HEADERDIRS) $(HEADERS)
# standard library
%.o: %.c headers
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
%.o: %.c
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
%.o: %.cpp headers
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
%.o: %.s
$(HOSTAS) $(ASFLAGS) $< -o $@
# libc-sortix
sortix:
mkdir -p sortix
sortix/%.o: %.c
$(HOSTCC) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCFLAGS)
sortix/%.o: %.c $(HEADERS) sortix
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CFLAGS)
sortix/%.o: %.cpp $(HEADERS) sortix
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CXXFLAGS)
sortix/%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCXXFLAGS)
clean:
rm -f *.o sortix/*.o c/*.o x86/*.o x64/*.o *.a *.so
rm -f $(OBJS)
rm -rf sortix $(HEADERDIRS)
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
rm -rf $(HEADERDIRS)
# Installation into sysroot
install: install-headers install-libs
install-include-dirs: headers
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\///'`; \
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
install: install-headers install-libs install-libs-kernel
$(INSTALLHEADERDIRS) $(DESTDIR)$(LIBDIR):
mkdir -p $@
$(DESTDIR)$(INCLUDEDIR)/%: preproc/%
cp $< $@
$(INSTALLHEADERS): | $(INSTALLHEADERDIRS)
$(DESTDIR)$(LIBDIR)/%: %
cp -P $< $@
$(INSTALLLIBS): | $(DESTDIR)$(LIBDIR)
$(INSTALLLIBSKERNEL): | $(DESTDIR)$(LIBDIR)
$(DESTDIR)$(INCLUDEDIR) $(DESTDIR)$(LIBDIR) $(INSTALLHEADERS): FORCE
install-include-dirs: $(INSTALLHEADERDIRS)
install-headers: $(INSTALLHEADERDIRS) $(INSTALLHEADERS)
install-lib-dirs: $(DESTDIR)$(LIBDIR)
install-libs: $(INSTALLLIBS)
install-libs-kernel: $(INSTALLLIBSKERNEL)
......@@ -34,6 +34,11 @@
#define __END_DECLS
#endif
/* Sortix system components implicitly use the native API. */
#if defined(LIBC_LIBRARY) || defined(SORTIX_KERNEL)
#define _SORTIX_SOURCE 1
#endif
/* By default, assume the source is compiled using the native API. */
#if !defined(_SORTIX_SOURCE) && \
!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) && \
......
......@@ -23,12 +23,6 @@
*******************************************************************************/
/* NOTE: This is almost identical to what is in start.s. crt1.s is used when
compiling with the real cross compiler, while start.s is used when
using the older hacky way of building Sortix. Please try to keep these
files alike by doing changes both places until we only build Sortix
with real cross compilers. */
.section .text
.global _start
......
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
start.s
A stub for linking to the C runtime on Sortix.
*******************************************************************************/
/* NOTE: This is almost identical to what is in crt1.s. crt1.s is used when
compiling with the real cross compiler, while start.s is used when
using the older hacky way of building Sortix. Please try to keep these
files alike by doing changes both places until we only build Sortix
with real cross compilers. */
.globl _start
.section .text
.type _start, @function
_start:
movq %rcx, environ # envp
pushq %rsi
pushq %rdi