1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/libc/Makefile

536 lines
8.7 KiB
Makefile
Raw Normal View History

SOFTWARE_MEANT_FOR_SORTIX=1
2012-09-10 17:36:15 -04:00
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
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
CPPFLAGS=-DLIBC_LIBRARY $(CPPINCLUDES)
FLAGS=-Wall -Wextra $(OPTLEVEL)
CFLAGS=-std=gnu99
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
ASFLAGS=
FREEOBJS=\
abort.o \
abs.o \
_assert.o \
2013-03-19 17:10:27 -04:00
atof.o \
atoi.o \
atoll.o \
atol.o \
bsearch.o \
2012-09-26 14:02:53 -04:00
calloc.o \
clearerr.o \
c++.o \
ctype.o \
dirent/dir.o \
2013-03-19 03:59:26 -04:00
div.o \
2012-09-26 11:56:39 -04:00
errno.o \
fabs.o \
fbufsize.o \
fclose.o \
fdeletefile.o \
feof.o \
ferror.o \
fflush.o \
fflush_stop_reading.o \
fflush_stop_writing.o \
fgetc.o \
fgets.o \
flbf.o \
flushlbf.o \
fnewfile.o \
format.o \
fpending.o \
fpurge.o \
fputc.o \
fputs.o \
freadable.o \
freading.o \
fread.o \
fregister.o \
fresetfile.o \
fscanf.o \
fseek.o \
fseeko.o \
fsetdefaultbuf.o \
fseterr.o \
fsetlocking.o \
fshutdown.o \
ftell.o \
ftello.o \
fwritable.o \
fwrite.o \
fwriting.o \
getdelim.o \
getline.o \
heap.o \
integer.o \
2013-03-19 03:59:26 -04:00
ldiv.o \
lldiv.o \
2013-04-22 04:16:09 -04:00
mblen.o \
2013-03-23 20:27:48 -04:00
mbstowcs.o \
mbtowc.o \
2012-09-26 13:40:00 -04:00
op-new.o \
rewind.o \
setbuf.o \
setvbuf.o \
2013-01-08 09:10:24 -05:00
sigaddset.o \
sigdelset.o \
sigemptyset.o \
2013-04-22 04:06:44 -04:00
sigfillset.o \
2013-01-08 09:10:24 -05:00
sigismember.o \
sort.o \
sprint.o \
sscanf.o \
string/memccpy.o \
string/memchr.o \
string/memcmp.o \
string/memcpy.o \
string/memmove.o \
string/memset.o \
string/stpcpy.o \
string/stpncpy.o \
string/strcasecmp.o \
string/strcat.o \
string/strchrnul.o \
string/strchr.o \
string/strcmp.o \
string/strcoll.o \
string/strcpy.o \
string/strcspn.o \
string/strdup.o \
string/strerror.o \
string/strlen.o \
string/strncasecmp.o \
string/strncat.o \
string/strncmp.o \
string/strncpy.o \
string/strndup.o \
string/strnlen.o \
string/strpbrk.o \
string/strrchr.o \
string/strsignal.o \
string/strspn.o \
string/strstr.o \
string/strtok.o \
string/strtok_r.o \
string/strxfrm.o \
2013-03-23 14:20:44 -04:00
strtod.o \
strtof.o \
strtold.o \
2013-03-21 20:09:03 -04:00
time/asctime.o \
time/asctime_r.o \
2013-05-15 13:09:37 -04:00
time/gmtime.o \
time/gmtime_r.o \
2013-03-22 21:41:28 -04:00
time/mktime.o \
timespec.o \
2013-03-21 19:13:30 -04:00
time/strftime.o \
2013-03-22 21:41:28 -04:00
time/timegm.o \
ungetc.o \
vfscanf.o \
vsscanf.o \
wchar/mbrlen.o \
wchar/mbrtowc.o \
wchar/mbsrtowcs.o \
wchar/wcrtomb.o \
wchar/wcscat.o \
wchar/wcschrnul.o \
wchar/wcschr.o \
wchar/wcscmp.o \
wchar/wcscpy.o \
wchar/wcscspn.o \
wchar/wcslen.o \
wchar/wcsncat.o \
wchar/wcsncpy.o \
wchar/wcsrchr.o \
wchar/wcsrtombs.o \
wchar/wcsspn.o \
wchar/wcstok.o \
2013-03-23 20:39:43 -04:00
wcstombs.o \
wctomb.o \
2012-12-20 10:18:24 -05:00
wctype.o \
HOSTEDOBJS=\
access.o \
2013-05-11 19:24:42 -04:00
alarmns.o \
alarm.o \
2013-03-19 17:40:37 -04:00
arpa/inet/inet_addr.o \
arpa/inet/inet_ntoa.o \
arpa/inet/inet_ntop.o \
arpa/inet/inet_pton.o \
2013-03-29 09:57:17 -04:00
basename.o \
2013-01-06 10:49:36 -05:00
calltrace.o \
2013-03-19 12:23:41 -04:00
canonicalize_file_name_at.o \
canonicalize_file_name.o \
chdir.o \
chmod.o \
2012-10-23 14:02:33 -04:00
chown.o \
chroot.o \
close.o \
2013-04-16 05:44:29 -04:00
confstr.o \
2013-01-06 10:49:36 -05:00
$(CPUDIR)/calltrace.o \
$(CPUDIR)/fork.o \
2013-03-31 09:00:12 -04:00
$(CPUDIR)/setjmp.o \
$(CPUDIR)/signal.o \
$(CPUDIR)/syscall.o \
2013-01-12 20:27:51 -05:00
creat.o \
dirent/fddir-sortix.o \
2013-06-21 18:12:10 -04:00
dirent/scandir.o \
2013-03-29 09:57:17 -04:00
dirname.o \
2012-12-15 20:10:19 -05:00
dispmsg_issue.o \
dlfcn.o \
2013-06-27 14:47:24 -04:00
dup2.o \
dup.o \
env.o \
errorprint.o \
execle.o \
execl.o \
execlp.o \
execve.o \
execv.o \
execvpe.o \
execvp.o \
_exit.o \
_Exit.o \
exit.o \
2012-10-23 17:55:33 -04:00
faccessat.o \
2013-05-29 08:03:53 -04:00
fchdirat.o \
2012-10-24 07:06:12 -04:00
fchdir.o \
2012-10-24 18:29:48 -04:00
fchmodat.o \
fchmod.o \
2012-10-24 13:43:11 -04:00
fchownat.o \
2012-10-24 13:52:28 -04:00
fchown.o \
fchrootat.o \
fchroot.o \
fcloseall.o \
fcntl.o \
fdio.o \
2013-04-21 18:29:58 -04:00
fgetpos.o \
fileno.o \
fork.o \
fpipe.o \
2013-03-20 17:20:22 -04:00
freopen.o \
2013-04-21 18:29:58 -04:00
fsetpos.o \
2013-01-30 14:33:13 -05:00
fsm_bootstraprootfd.o \
fsm_closechannel.o \
fsm_closeserver.o \
fsm_fsbind.o \
fsm_listen.o \
fsm_mkserver.o \
fsm_recv.o \
fsm_send.o \
fstatat.o \
fstat.o \
2013-03-20 08:16:12 -04:00
fsync.o \
ftruncate.o \
2013-03-19 17:01:01 -04:00
futimens.o \
getc.o \
getcwd.o \
getdtablesize.o \
2013-01-12 20:37:14 -05:00
getegid.o \
geteuid.o \
getgid.o \
2013-04-12 18:42:13 -04:00
gethostname.o \
2013-04-15 18:08:33 -04:00
getlogin.o \
getlogin_r.o \
getpagesize.o \
2013-06-11 19:02:01 -04:00
getpgid.o \
getpid.o \
getppid.o \
gettermmode.o \
2013-01-12 20:37:14 -05:00
getuid.o \
2013-01-12 21:14:43 -05:00
grent.o \
init.o \
2013-03-21 16:35:51 -04:00
ioctl.o \
ioleast.o \
isatty.o \
kernelinfo.o \
kill.o \
2013-01-14 16:58:34 -05:00
lchown.o \
2012-10-25 09:43:53 -04:00
linkat.o \
2012-10-23 14:09:43 -04:00
link.o \
localeconv.o \
lseek.o \
lstat.o \
memstat.o \
2012-10-23 18:07:39 -04:00
mkdirat.o \
mkdir.o \
2013-06-01 07:24:27 -04:00
mkpartition.o \
mktemp.o \
2013-03-19 17:40:37 -04:00
netdb/endhostent.o \
netdb/endnetent.o \
netdb/endprotoent.o \
netdb/endservent.o \
netdb/freeaddrinfo.o \
netdb/gai_strerror.o \
netdb/getaddrinfo.o \
netdb/gethostent.o \
netdb/getnameinfo.o \
netdb/getnetbyaddr.o \
netdb/getnetbyname.o \
netdb/getnetent.o \
netdb/getprotobyname.o \
netdb/getprotobynumber.o \
netdb/getprotoent.o \
netdb/getservbyname.o \
netdb/getservbyport.o \
netdb/getservent.o \
netdb/sethostent.o \
netdb/setnetent.o \
netdb/setprotoent.o \
netdb/setservent.o \
on_exit.o \
openat.o \
open.o \
2013-03-22 08:58:43 -04:00
pathconf.o \
pipe.o \
2012-12-29 17:09:09 -05:00
poll.o \
2013-01-14 16:58:07 -05:00
popen.o \
2012-12-29 17:09:09 -05:00
ppoll.o \
2013-05-03 15:43:01 -04:00
preadv.o \
print.o \
2013-05-01 16:01:09 -04:00
psignal.o \
putc.o \
2013-01-08 09:09:23 -05:00
pwent.o \
2013-05-03 15:43:01 -04:00
pwritev.o \
raise.o \
rand.o \
readdirents.o \
2013-03-19 15:18:15 -04:00
readlinkat.o \
readlink.o \
read.o \
2013-05-03 15:43:01 -04:00
readv.o \
2013-03-19 13:53:56 -04:00
realpath.o \
removeat.o \
remove.o \
2012-12-20 10:19:07 -05:00
renameat.o \
rename.o \
rmdir.o \
sbrk.o \
scanf.o \
2013-03-03 08:21:40 -05:00
select.o \
2013-01-12 20:37:14 -05:00
setegid.o \
seteuid.o \
setgid.o \
setlocale.o \
2013-06-11 19:02:01 -04:00
setpgid.o \
settermmode.o \
2013-01-12 20:37:14 -05:00
setuid.o \
sfork.o \
2013-04-18 06:42:04 -04:00
sigaction.o \
SIG_DFL.o \
SIG_ERR.o \
SIG_IGN.o \
signal.o \
2013-04-18 06:59:30 -04:00
sigprocmask.o \
2012-09-21 19:09:20 -04:00
sleep.o \
stat.o \
stdio.o \
2013-04-16 04:11:15 -04:00
sysconf.o \
2013-03-19 17:40:37 -04:00
sys/socket/accept4.o \
sys/socket/accept.o \
sys/socket/bind.o \
sys/socket/connect.o \
sys/socket/getpeername.o \
sys/socket/getsockname.o \
sys/socket/getsockopt.o \
sys/socket/listen.o \
sys/socket/recvfrom.o \
sys/socket/recvmsg.o \
sys/socket/recv.o \
sys/socket/sendmsg.o \
sys/socket/send.o \
sys/socket/sendto.o \
sys/socket/setsockopt.o \
sys/socket/shutdown.o \
sys/socket/sockatmark.o \
sys/socket/socket.o \
sys/socket/socketpair.o \
2013-01-14 13:27:19 -05:00
system.o \
2013-05-12 16:10:34 -04:00
sys/time/gettimeofday.o \
2013-06-11 20:18:07 -04:00
tcgetpgrp.o \
tcgetwinsize.o \
2013-06-11 20:18:07 -04:00
tcsetpgrp.o \
tfork.o \
2013-05-12 16:10:34 -04:00
time/clock_getres.o \
time/clock_gettime.o \
time/clock_gettimeres.o \
2013-05-14 12:41:49 -04:00
time/clock_nanosleep.o \
2013-05-15 09:00:48 -04:00
time/clock.o \
2013-05-12 16:10:34 -04:00
time/clock_settime.o \
time/clock_settimeres.o \
2013-05-16 09:51:43 -04:00
time/ctime.o \
time/ctime_r.o \
2013-05-15 09:08:47 -04:00
time/difftime.o \
2013-05-16 09:51:43 -04:00
time/localtime.o \
time/localtime_r.o \
2013-05-14 12:41:49 -04:00
time/nanosleep.o \
2013-05-15 06:37:39 -04:00
time/timens.o \
2013-05-12 16:10:34 -04:00
time/time.o \
2013-10-13 17:56:58 -04:00
time/timer_create.o \
time/timer_delete.o \
time/timer_getoverrun.o \
time/timer_gettime.o \
time/timer_settime.o \
2013-05-15 08:41:42 -04:00
time/times.o \
2013-03-29 09:29:11 -04:00
tmpfile.o \
2013-04-22 05:37:29 -04:00
tmpnam.o \
truncateat.o \
truncate.o \
2013-03-23 18:58:20 -04:00
ttyname.o \
umask.o \
2012-10-23 07:50:33 -04:00
unlinkat.o \
unlink.o \
2012-09-21 19:09:20 -04:00
usleep.o \
2013-03-19 17:01:01 -04:00
utimensat.o \
utimens.o \
utime.o \
vscanf.o \
wait.o \
waitpid.o \
write.o \
2013-05-03 15:43:01 -04:00
writev.o \
OBJS=\
$(FREEOBJS) \
$(HOSTEDOBJS) \
CRTOBJ=\
crt1.o \
crti.o \
crtn.o \
MISCOBJ=\
$(CRTOBJ) \
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:=$(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
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: libs libs-kernel
2011-08-05 08:25:00 -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:
libc.a: $(OBJS)
$(HOSTAR) rcs $@ $(OBJS)
2011-08-05 08:25:00 -04:00
libc-sortix.a: $(SORTIXOBJS)
$(HOSTAR) rcs $@ $(SORTIXOBJS)
2011-08-05 08:25:00 -04:00
libg.a:
$(HOSTAR) rcs $@
2012-09-10 17:36:15 -04:00
libm.a:
$(HOSTAR) rcs $@
libpthread.a:
2012-09-10 17:36:15 -04:00
$(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
2012-09-10 17:36:15 -04:00
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@
2012-09-10 17:36:15 -04:00
crti.o: $(CPUDIR)/crti.o
ln -f $< $@
2012-09-10 17:36:15 -04:00
crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@
# header preprocessing
$(OBJS) $(SORTIXOBJS): $(HEADERS)
$(HEADERDIRS):
mkdir -p $@
2011-08-05 08:25:00 -04:00
preproc/%: include/%
mxmpp -I decl $< -o $@
2011-08-05 08:25:00 -04:00
$(HEADERS): | $(HEADERDIRS)
headers: $(HEADERDIRS) $(HEADERS)
2011-08-05 08:25:00 -04:00
# standard library
%.o: %.c
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
2011-08-05 08:25:00 -04:00
%.o: %.s
2012-09-10 17:36:15 -04:00
$(HOSTAS) $(ASFLAGS) $< -o $@
2011-08-05 08:25:00 -04:00
# libc-sortix
sortix/%.o: %.c
$(HOSTCC) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCFLAGS)
2011-08-05 08:25:00 -04:00
sortix/%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCXXFLAGS)
2011-08-05 08:25:00 -04:00
clean:
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
rm -rf $(HEADERDIRS)
2011-08-05 08:25:00 -04:00
# Installation into sysroot
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)