2013-03-19 18:28:32 -04:00
|
|
|
SOFTWARE_MEANT_FOR_SORTIX=1
|
2012-09-10 17:36:15 -04:00
|
|
|
include ../compiler.mak
|
|
|
|
include ../version.mak
|
|
|
|
include ../dirs.mak
|
|
|
|
|
|
|
|
ifndef OPTLEVEL
|
2013-03-19 18:28:32 -04:00
|
|
|
OPTLEVEL:=-g -O2 -fno-omit-frame-pointer
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUDIR:=$(CPU)
|
|
|
|
|
|
|
|
CPPINCLUDES=-I preproc
|
2013-03-19 18:28:32 -04:00
|
|
|
CPPFLAGS=-DLIBC_LIBRARY $(CPPINCLUDES)
|
|
|
|
FLAGS=-Wall -Wextra $(OPTLEVEL)
|
|
|
|
CFLAGS=-std=gnu99
|
|
|
|
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
|
|
|
|
ASFLAGS=
|
2012-02-11 20:03:34 -05:00
|
|
|
|
2012-09-21 17:57:47 -04:00
|
|
|
FREEOBJS=\
|
|
|
|
abort.o \
|
|
|
|
abs.o \
|
2012-09-22 08:57:20 -04:00
|
|
|
_assert.o \
|
2012-09-28 17:14:00 -04:00
|
|
|
atoi.o \
|
|
|
|
atoll.o \
|
|
|
|
atol.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
bsearch.o \
|
2012-09-26 14:02:53 -04:00
|
|
|
calloc.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
clearerr.o \
|
|
|
|
c++.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
ctime.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
ctype.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
dir.o \
|
2012-09-26 11:56:39 -04:00
|
|
|
errno.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
fabs.o \
|
|
|
|
fbufsize.o \
|
|
|
|
fclose.o \
|
|
|
|
feof.o \
|
|
|
|
ferror.o \
|
|
|
|
fflush.o \
|
|
|
|
fgetc.o \
|
|
|
|
fgets.o \
|
|
|
|
flbf.o \
|
|
|
|
flushlfb.o \
|
|
|
|
fnewline.o \
|
|
|
|
format.o \
|
|
|
|
fpending.o \
|
|
|
|
fpurge.o \
|
|
|
|
fputc.o \
|
|
|
|
fputs.o \
|
|
|
|
freadable.o \
|
|
|
|
freading.o \
|
|
|
|
fread.o \
|
|
|
|
fregister.o \
|
|
|
|
fscanf.o \
|
|
|
|
fseek.o \
|
|
|
|
fseeko.o \
|
|
|
|
fseterr.o \
|
|
|
|
fsetlocking.o \
|
|
|
|
ftell.o \
|
|
|
|
ftello.o \
|
|
|
|
fwritable.o \
|
|
|
|
fwrite.o \
|
|
|
|
fwriting.o \
|
2012-09-26 13:26:04 -04:00
|
|
|
getdelim.o \
|
|
|
|
getline.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
gmtime.o \
|
|
|
|
gmtime_r.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
heap.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
integer.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
localtime.o \
|
|
|
|
localtime_r.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
mbtowc.o \
|
2012-11-08 12:52:49 -05:00
|
|
|
memccpy.o \
|
2012-09-26 15:02:17 -04:00
|
|
|
memchr.o \
|
|
|
|
memcmp.o \
|
|
|
|
memcpy.o \
|
|
|
|
memmove.o \
|
|
|
|
memset.o \
|
2012-09-26 13:40:00 -04:00
|
|
|
op-new.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
rewind.o \
|
2012-03-05 06:37:59 -05:00
|
|
|
sort.o \
|
2012-09-23 06:32:53 -04:00
|
|
|
sprint.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
sscanf.o \
|
|
|
|
stpcpy.o \
|
2012-11-08 12:37:17 -05:00
|
|
|
stpncpy.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
strcasecmp.o \
|
|
|
|
strcat.o \
|
|
|
|
strchrnul.o \
|
|
|
|
strchr.o \
|
|
|
|
strcmp.o \
|
|
|
|
strcoll.o \
|
|
|
|
strcpy.o \
|
|
|
|
strcspn.o \
|
|
|
|
strdup.o \
|
2012-09-26 11:56:39 -04:00
|
|
|
strerror.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
strlen.o \
|
|
|
|
strncasecmp.o \
|
|
|
|
strncat.o \
|
|
|
|
strncmp.o \
|
|
|
|
strncpy.o \
|
2012-11-08 12:50:53 -05:00
|
|
|
strndup.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
strnlen.o \
|
|
|
|
strpbrk.o \
|
|
|
|
strrchr.o \
|
2012-11-08 13:56:29 -05:00
|
|
|
strsignal.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
strspn.o \
|
|
|
|
strstr.o \
|
|
|
|
strtok.o \
|
|
|
|
strtok_r.o \
|
2012-11-08 13:04:55 -05:00
|
|
|
strxfrm.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
ungetc.o \
|
|
|
|
vfscanf.o \
|
|
|
|
vsscanf.o \
|
|
|
|
|
|
|
|
HOSTEDOBJS=\
|
2012-07-25 17:00:17 -04:00
|
|
|
access.o \
|
|
|
|
chdir.o \
|
|
|
|
chmod.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
clock.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
close.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
$(CPUDIR)/fork.o \
|
|
|
|
$(CPUDIR)/signal.o \
|
2013-01-12 13:48:27 -05:00
|
|
|
$(CPUDIR)/syscall.o \
|
2012-12-15 20:10:19 -05:00
|
|
|
dispmsg_issue.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
dlfcn.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
dup.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
env.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
errorprint.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
execle.o \
|
|
|
|
execl.o \
|
|
|
|
execlp.o \
|
|
|
|
execve.o \
|
|
|
|
execv.o \
|
|
|
|
execvpe.o \
|
|
|
|
execvp.o \
|
2012-09-06 16:30:09 -04:00
|
|
|
_exit.o \
|
|
|
|
_Exit.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
exit.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
fchmod.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
fcloseall.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
fcntl.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
fddir-sortix.o \
|
|
|
|
fdio.o \
|
|
|
|
fileno.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
fork.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
fpipe.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
fstat.o \
|
|
|
|
ftruncate.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
getc.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
getcwd.o \
|
|
|
|
getdtablesize.o \
|
2012-09-26 15:02:17 -04:00
|
|
|
getpagesize.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
getpid.o \
|
|
|
|
getppid.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
gettermmode.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
gettimeofday.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
init.o \
|
|
|
|
ioleast.o \
|
|
|
|
isatty.o \
|
|
|
|
kernelinfo.o \
|
2012-09-28 16:50:31 -04:00
|
|
|
kill.o \
|
2012-09-07 14:52:25 -04:00
|
|
|
localeconv.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
lseek.o \
|
2012-09-26 15:02:17 -04:00
|
|
|
memstat.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
mkdir.o \
|
|
|
|
mktemp.o \
|
2012-09-06 16:30:09 -04:00
|
|
|
on_exit.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
open.o \
|
2012-09-30 07:42:35 -04:00
|
|
|
openat.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
pipe.o \
|
|
|
|
print.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
putc.o \
|
2012-09-28 16:50:31 -04:00
|
|
|
raise.o \
|
2012-09-28 14:33:04 -04:00
|
|
|
rand.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
readdirents.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
read.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
rmdir.o \
|
2012-09-26 15:02:17 -04:00
|
|
|
sbrk.o \
|
2012-09-07 14:36:27 -04:00
|
|
|
scanf.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
setjmp.o \
|
|
|
|
setlocale.o \
|
|
|
|
settermmode.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
sfork.o \
|
2012-09-28 16:50:31 -04:00
|
|
|
SIG_DFL.o \
|
|
|
|
SIG_ERR.o \
|
|
|
|
SIG_IGN.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
signal.o \
|
2012-09-21 19:09:20 -04:00
|
|
|
sleep.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
stat.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
stdio.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
tfork.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
time.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
truncate.o \
|
|
|
|
umask.o \
|
|
|
|
unlink.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
uptime.o \
|
2012-09-21 19:09:20 -04:00
|
|
|
usleep.o \
|
2012-09-28 15:06:13 -04:00
|
|
|
utime.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
vscanf.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
wait.o \
|
|
|
|
waitpid.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
winsize.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
write.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
|
|
|
|
OBJS=\
|
|
|
|
$(FREEOBJS) \
|
|
|
|
$(HOSTEDOBJS) \
|
2012-02-11 20:03:34 -05:00
|
|
|
|
2012-09-08 08:37:16 -04:00
|
|
|
CRTOBJ=\
|
|
|
|
crt1.o \
|
|
|
|
crti.o \
|
|
|
|
crtn.o \
|
|
|
|
|
|
|
|
MISCOBJ=\
|
|
|
|
$(CRTOBJ) \
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
UNPROCHEADERDIRS:=$(shell find include -type d)
|
|
|
|
UNPROCHEADERS:=$(shell find include -type f)
|
|
|
|
HEADERDIRS:=$(patsubst include%,preproc%,$(UNPROCHEADERDIRS))
|
|
|
|
HEADERS:=$(patsubst include%,preproc%,$(UNPROCHEADERS))
|
2013-03-19 18:28:32 -04:00
|
|
|
INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERDIRS)))
|
|
|
|
INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS)))
|
2012-02-11 20:03:34 -05:00
|
|
|
|
2012-09-21 17:57:47 -04:00
|
|
|
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
|
2013-03-19 18:28:32 -04:00
|
|
|
SORTIXCPPFLAGS:=$(CPPFLAGS) -DSORTIX_KERNEL
|
|
|
|
SORTIXFLAGS:=$(FLAGS) -ffreestanding
|
|
|
|
SORTIXCFLAGS:=$(CFLAGS)
|
|
|
|
SORTIXCXXFLAGS:=$(CXXFLAGS)
|
|
|
|
ifeq ($(HOST),x86_64-sortix)
|
|
|
|
SORTIXFLAGS:=$(SORTIXFLAGS) -mno-red-zone
|
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
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))
|
2012-09-08 08:37:16 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
all: libs libs-kernel
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
libs: $(BINS)
|
|
|
|
|
|
|
|
libs-kernel: $(BINSKERNEL)
|
|
|
|
|
|
|
|
.PHONY: all libs headers clean install install-include-dirs install-headers \
|
|
|
|
install-lib-dirs install-libs libs-kernel
|
|
|
|
|
|
|
|
FORCE:
|
2012-09-10 15:45:38 -04:00
|
|
|
|
2012-09-23 08:04:53 -04:00
|
|
|
libc.a: $(OBJS)
|
|
|
|
$(HOSTAR) rcs $@ $(OBJS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-23 08:04:53 -04:00
|
|
|
libc-sortix.a: $(SORTIXOBJS)
|
|
|
|
$(HOSTAR) rcs $@ $(SORTIXOBJS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
libg.a:
|
|
|
|
$(HOSTAR) rcs $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
libm.a:
|
|
|
|
$(HOSTAR) rcs $@
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
libpthread.a:
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTAR) rcs $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
libstdc++.a:
|
|
|
|
$(HOSTAR) rcs $@
|
2012-09-08 08:37:16 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
crt1.o: $(CPUDIR)/crt1.o
|
2012-09-08 08:37:16 -04:00
|
|
|
ln -f $< $@
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
crti.o: $(CPUDIR)/crti.o
|
2012-09-08 08:37:16 -04:00
|
|
|
ln -f $< $@
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
crtn.o: $(CPUDIR)/crtn.o
|
2012-09-08 08:37:16 -04:00
|
|
|
ln -f $< $@
|
2011-09-15 16:19:04 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
# header preprocessing
|
2013-03-19 18:28:32 -04:00
|
|
|
$(OBJS) $(SORTIXOBJS): $(HEADERS)
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
$(HEADERDIRS):
|
|
|
|
mkdir -p $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
preproc/%: include/%
|
2012-02-11 20:03:34 -05:00
|
|
|
mxmpp -I decl $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
$(HEADERS): | $(HEADERDIRS)
|
|
|
|
|
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
|
2013-03-19 18:28:32 -04:00
|
|
|
%.o: %.c
|
|
|
|
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
%.o: %.cpp
|
|
|
|
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
%.o: %.s
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTAS) $(ASFLAGS) $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-23 08:04:53 -04:00
|
|
|
# libc-sortix
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix/%.o: %.c
|
|
|
|
$(HOSTCC) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix/%.o: %.cpp
|
|
|
|
$(HOSTCXX) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
clean:
|
2013-03-19 18:28:32 -04:00
|
|
|
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
|
|
|
|
rm -rf $(HEADERDIRS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-09-15 16:38:40 -04:00
|
|
|
# Installation into sysroot
|
2013-03-19 18:28:32 -04:00
|
|
|
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)
|
2011-09-15 16:38:40 -04:00
|
|
|
|