2012-09-10 17:36:15 -04:00
|
|
|
include ../compiler.mak
|
|
|
|
include ../version.mak
|
|
|
|
include ../dirs.mak
|
|
|
|
|
|
|
|
ifndef OPTLEVEL
|
|
|
|
OPTLEVEL:=-O2
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DEBUG_LIBC),1)
|
|
|
|
FLAGSDEBUG=-g3
|
|
|
|
else
|
|
|
|
FLAGSDEBUG=$(OPTLEVEL)
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUDIR:=$(CPU)
|
|
|
|
|
|
|
|
ifeq ($(HOST),i486-sortix)
|
|
|
|
CPUFLAGS=
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
ifeq ($(HOST),x86_64-sortix)
|
|
|
|
CPUFLAGS=-fPIC -mno-red-zone
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
CPPINCLUDES=-I preproc
|
|
|
|
CPPFLAGS=-DLIBMAXSI_LIBRARY -U_GNU_SOURCE $(CPUDEFINES) $(CPPINCLUDES)
|
|
|
|
FLAGS=$(CPUFLAGS) -Wall -Wextra -fno-stack-protector $(FLAGSDEBUG)
|
2012-02-11 20:03:34 -05:00
|
|
|
CFLAGS=$(FLAGS) -std=c99
|
2012-09-10 17:36:15 -04:00
|
|
|
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
|
2011-08-05 08:25:00 -04:00
|
|
|
ASFLAGS=$(CPUASFLAGS)
|
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-21 17:57:47 -04:00
|
|
|
bsearch.o \
|
|
|
|
clearerr.o \
|
|
|
|
c++.o \
|
|
|
|
ctype.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
dir.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
error.o \
|
|
|
|
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 \
|
|
|
|
heap.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
integer.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
mbtowc.o \
|
2012-02-11 20:03:34 -05:00
|
|
|
memory.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
readparamstring.o \
|
|
|
|
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 \
|
|
|
|
strcasecmp.o \
|
|
|
|
strcat.o \
|
|
|
|
strchrnul.o \
|
|
|
|
strchr.o \
|
|
|
|
strcmp.o \
|
|
|
|
strcoll.o \
|
|
|
|
strcpy.o \
|
|
|
|
strcspn.o \
|
|
|
|
strdup.o \
|
|
|
|
strlen.o \
|
|
|
|
strncasecmp.o \
|
|
|
|
strncat.o \
|
|
|
|
strncmp.o \
|
|
|
|
strncpy.o \
|
|
|
|
strnlen.o \
|
|
|
|
strpbrk.o \
|
|
|
|
strrchr.o \
|
|
|
|
strspn.o \
|
|
|
|
strstr.o \
|
|
|
|
strtok.o \
|
|
|
|
strtok_r.o \
|
|
|
|
ungetc.o \
|
|
|
|
vfscanf.o \
|
|
|
|
vsscanf.o \
|
|
|
|
|
|
|
|
HOSTEDOBJS=\
|
2012-07-25 17:00:17 -04:00
|
|
|
access.o \
|
|
|
|
chdir.o \
|
|
|
|
chmod.o \
|
|
|
|
close.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
$(CPUDIR)/fork.o \
|
|
|
|
$(CPUDIR)/signal.o \
|
|
|
|
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 10:11:38 -04:00
|
|
|
getpid.o \
|
|
|
|
getppid.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
gettermmode.o \
|
|
|
|
init.o \
|
|
|
|
ioleast.o \
|
|
|
|
isatty.o \
|
|
|
|
kernelinfo.o \
|
2012-09-07 14:52:25 -04:00
|
|
|
localeconv.o \
|
2012-07-25 17:00:17 -04:00
|
|
|
lseek.o \
|
|
|
|
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 \
|
|
|
|
pipe.o \
|
|
|
|
print.o \
|
2012-09-21 17:57:47 -04:00
|
|
|
putc.o \
|
|
|
|
random.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-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-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-21 19:09:20 -04:00
|
|
|
usleep.o \
|
2012-09-26 10:11:38 -04:00
|
|
|
vexecle.o \
|
|
|
|
vexecl.o \
|
|
|
|
vexeclp.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=\
|
|
|
|
start.o \
|
|
|
|
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))
|
|
|
|
|
2012-09-21 17:57:47 -04:00
|
|
|
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
|
2012-02-11 20:03:34 -05:00
|
|
|
SORTIXCPPFLAGS:=-DSORTIX_KERNEL
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-23 08:04:53 -04:00
|
|
|
BINS=libc.a libg.a libm.a libstdc++.a libc-sortix.a $(CRTOBJ)
|
2012-09-08 08:37:16 -04:00
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
all: $(BINS)
|
|
|
|
|
2012-09-10 15:45:38 -04:00
|
|
|
.PHONY: all headers clean install install-include-dirs install-headers \
|
|
|
|
install-lib-dirs install-libs
|
|
|
|
|
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
|
|
|
|
2012-01-08 09:45:13 -05:00
|
|
|
libg.a: libc.a
|
2012-03-21 19:52:29 -04:00
|
|
|
ln -sf $< $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
libm.a:
|
|
|
|
$(HOSTAR) rcs $@
|
|
|
|
|
|
|
|
libstdc++.a:
|
|
|
|
$(HOSTAR) rcs $@
|
2012-01-08 09:45:13 -05:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
start.o: $(CPUDIR)/start.o
|
2012-09-08 08:37:16 -04:00
|
|
|
ln -f $< $@
|
|
|
|
|
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
|
|
|
|
$(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
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
%.o: %.cpp headers
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(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
|
2012-02-11 20:03:34 -05:00
|
|
|
sortix:
|
|
|
|
mkdir -p sortix
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-21 17:57:47 -04:00
|
|
|
sortix/%.o: %.c $(HEADERS) sortix
|
|
|
|
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(SORTIXCPPFLAGS) $(CFLAGS)
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
sortix/%.o: %.cpp $(HEADERS) sortix
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTCXX) -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
|
2012-09-10 15:45:38 -04:00
|
|
|
install: install-headers install-libs
|
|
|
|
|
|
|
|
install-include-dirs: headers
|
2012-09-10 17:36:15 -04:00
|
|
|
mkdir -p $(INSTALLINCLUDEDIR)
|
|
|
|
DIRS=$$(echo $(UNPROCHEADERDIRS) | \
|
|
|
|
tr ' ' '\n' | \
|
|
|
|
sed 's/include\/*//'); \
|
|
|
|
for D in $$DIRS; do \
|
|
|
|
mkdir -p $(INSTALLINCLUDEDIR)/$$D || exit $?; \
|
|
|
|
done
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-headers: install-include-dirs headers
|
2012-09-10 17:36:15 -04:00
|
|
|
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
|
2011-09-15 16:38:40 -04:00
|
|
|
|