sortix-mirror/libc/Makefile

539 lines
9.1 KiB
Makefile
Raw Normal View History

SOFTWARE_MEANT_FOR_SORTIX=1
2012-09-10 21:36:15 +00:00
include ../compiler.mak
include ../version.mak
include ../dirs.mak
ifndef OPTLEVEL
OPTLEVEL:=-g -O2 -fno-omit-frame-pointer
2011-08-05 12:25:00 +00:00
endif
2012-09-10 21:36:15 +00: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=\
assert/_assert.o \
clearerr.o \
c++.o \
ctype/ctype.o \
2013-06-21 22:30:45 +00:00
dirent/alphasort.o \
dirent/dir.o \
2013-06-24 17:20:46 +00:00
dirent/versionsort.o \
2012-09-26 15:56:39 +00: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 \
2012-09-26 17:40:00 +00:00
op-new.o \
rewind.o \
setbuf.o \
setvbuf.o \
2013-01-08 14:10:24 +00:00
sigaddset.o \
sigdelset.o \
sigemptyset.o \
2013-04-22 08:06:44 +00:00
sigfillset.o \
2013-01-08 14:10:24 +00:00
sigismember.o \
sprint.o \
sscanf.o \
stdlib/abort.o \
stdlib/abs.o \
stdlib/atof.o \
stdlib/atoi.o \
stdlib/atoll.o \
stdlib/atol.o \
stdlib/bsearch.o \
stdlib/calloc.o \
stdlib/div.o \
stdlib/heap.o \
stdlib/integer.o \
stdlib/ldiv.o \
stdlib/lldiv.o \
stdlib/mblen.o \
stdlib/mbstowcs.o \
stdlib/mbtowc.o \
stdlib/qsort.o \
stdlib/strtod.o \
stdlib/strtof.o \
stdlib/strtold.o \
stdlib/wcstombs.o \
stdlib/wctomb.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 \
2013-06-24 17:11:46 +00:00
string/strverscmp.o \
string/strxfrm.o \
2013-03-22 00:09:03 +00:00
time/asctime.o \
time/asctime_r.o \
2013-05-15 17:09:37 +00:00
time/gmtime.o \
time/gmtime_r.o \
2013-03-23 01:41:28 +00:00
time/mktime.o \
timespec.o \
2013-03-21 23:13:30 +00:00
time/strftime.o \
2013-03-23 01:41:28 +00: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 \
wctype/wctype.o \
HOSTEDOBJS=\
access.o \
2013-05-11 23:24:42 +00:00
alarmns.o \
alarm.o \
2013-03-19 21:40:37 +00:00
arpa/inet/inet_addr.o \
arpa/inet/inet_ntoa.o \
arpa/inet/inet_ntop.o \
arpa/inet/inet_pton.o \
2013-01-06 15:49:36 +00:00
calltrace.o \
chdir.o \
chmod.o \
2012-10-23 18:02:33 +00:00
chown.o \
chroot.o \
close.o \
2013-04-16 09:44:29 +00:00
confstr.o \
2013-01-06 15:49:36 +00:00
$(CPUDIR)/calltrace.o \
$(CPUDIR)/fork.o \
2013-03-31 13:00:12 +00:00
$(CPUDIR)/setjmp.o \
$(CPUDIR)/signal.o \
$(CPUDIR)/syscall.o \
dirent/fddir-sortix.o \
2013-06-21 22:12:10 +00:00
dirent/scandir.o \
2012-12-16 01:10:19 +00:00
dispmsg_issue.o \
dlfcn.o \
2013-06-27 18:47:24 +00:00
dup2.o \
dup.o \
errorprint.o \
execle.o \
execl.o \
execlp.o \
execve.o \
execv.o \
execvpe.o \
execvp.o \
_exit.o \
2012-10-23 21:55:33 +00:00
faccessat.o \
2013-05-29 12:03:53 +00:00
fchdirat.o \
2012-10-24 11:06:12 +00:00
fchdir.o \
2012-10-24 22:29:48 +00:00
fchmodat.o \
fchmod.o \
2012-10-24 17:43:11 +00:00
fchownat.o \
2012-10-24 17:52:28 +00:00
fchown.o \
fchrootat.o \
fchroot.o \
fcloseall.o \
fcntl/creat.o \
fcntl/fcntl.o \
fcntl/openat.o \
fcntl/open.o \
fdio.o \
2013-04-21 22:29:58 +00:00
fgetpos.o \
fileno.o \
fork.o \
fpipe.o \
2013-03-20 21:20:22 +00:00
freopen.o \
2013-04-21 22:29:58 +00:00
fsetpos.o \
fsmarshall/fsm_bootstraprootfd.o \
fsmarshall/fsm_closechannel.o \
fsmarshall/fsm_closeserver.o \
fsmarshall/fsm_fsbind.o \
fsmarshall/fsm_listen.o \
fsmarshall/fsm_mkserver.o \
fsmarshall/fsm_recv.o \
fsmarshall/fsm_send.o \
fstatat.o \
fstat.o \
2013-03-20 12:16:12 +00:00
fsync.o \
ftruncate.o \
2013-03-19 21:01:01 +00:00
futimens.o \
getc.o \
getcwd.o \
getdtablesize.o \
2013-01-13 01:37:14 +00:00
getegid.o \
geteuid.o \
getgid.o \
2013-04-12 22:42:13 +00:00
gethostname.o \
2013-04-15 22:08:33 +00:00
getlogin.o \
getlogin_r.o \
getpagesize.o \
2013-06-11 23:02:01 +00:00
getpgid.o \
getpid.o \
getppid.o \
gettermmode.o \
2013-01-13 01:37:14 +00:00
getuid.o \
grp/grent.o \
init.o \
2013-03-21 20:35:51 +00:00
ioctl.o \
ioleast.o \
isatty.o \
kernelinfo.o \
kill.o \
2013-01-14 21:58:34 +00:00
lchown.o \
libgen/basename.o \
libgen/dirname.o \
2012-10-25 13:43:53 +00:00
linkat.o \
2012-10-23 18:09:43 +00:00
link.o \
localeconv.o \
lseek.o \
lstat.o \
memstat.o \
2012-10-23 22:07:39 +00:00
mkdirat.o \
mkdir.o \
2013-06-01 11:24:27 +00:00
mkpartition.o \
2013-03-19 21:40:37 +00: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 \
2013-03-22 12:58:43 +00:00
pathconf.o \
pipe.o \
2012-12-29 22:09:09 +00:00
poll.o \
2013-01-14 21:58:07 +00:00
popen.o \
2012-12-29 22:09:09 +00:00
ppoll.o \
2013-05-03 19:43:01 +00:00
preadv.o \
print.o \
2013-05-01 20:01:09 +00:00
psignal.o \
putc.o \
pwd/pwent.o \
2013-05-03 19:43:01 +00:00
pwritev.o \
raise.o \
readdirents.o \
2013-03-19 19:18:15 +00:00
readlinkat.o \
readlink.o \
read.o \
2013-05-03 19:43:01 +00:00
readv.o \
removeat.o \
remove.o \
2012-12-20 15:19:07 +00:00
renameat.o \
rename.o \
rmdir.o \
sbrk.o \
scanf.o \
2013-03-03 13:21:40 +00:00
select.o \
2013-01-13 01:37:14 +00:00
setegid.o \
seteuid.o \
setgid.o \
setlocale.o \
2013-06-11 23:02:01 +00:00
setpgid.o \
settermmode.o \
2013-01-13 01:37:14 +00:00
setuid.o \
sfork.o \
2013-04-18 10:42:04 +00:00
sigaction.o \
SIG_DFL.o \
SIG_ERR.o \
SIG_IGN.o \
signal.o \
2013-04-18 10:59:30 +00:00
sigprocmask.o \
2012-09-21 23:09:20 +00:00
sleep.o \
stat.o \
stdio.o \
stdlib/canonicalize_file_name_at.o \
stdlib/canonicalize_file_name.o \
stdlib/env.o \
stdlib/_Exit.o \
stdlib/exit.o \
stdlib/mktemp.o \
stdlib/on_exit.o \
stdlib/rand.o \
stdlib/realpath.o \
stdlib/system.o \
2013-04-16 08:11:15 +00:00
sysconf.o \
2013-03-19 21:40:37 +00: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-05-12 20:10:34 +00:00
sys/time/gettimeofday.o \
2013-06-12 00:18:07 +00:00
tcgetpgrp.o \
tcgetwinsize.o \
2013-06-12 00:18:07 +00:00
tcsetpgrp.o \
tfork.o \
2013-05-12 20:10:34 +00:00
time/clock_getres.o \
time/clock_gettime.o \
time/clock_gettimeres.o \
2013-05-14 16:41:49 +00:00
time/clock_nanosleep.o \
2013-05-15 13:00:48 +00:00
time/clock.o \
2013-05-12 20:10:34 +00:00
time/clock_settime.o \
time/clock_settimeres.o \
2013-05-16 13:51:43 +00:00
time/ctime.o \
time/ctime_r.o \
2013-05-15 13:08:47 +00:00
time/difftime.o \
2013-05-16 13:51:43 +00:00
time/localtime.o \
time/localtime_r.o \
2013-05-14 16:41:49 +00:00
time/nanosleep.o \
2013-05-15 10:37:39 +00:00
time/timens.o \
2013-05-12 20:10:34 +00:00
time/time.o \
2013-10-13 21:56:58 +00:00
time/timer_create.o \
time/timer_delete.o \
time/timer_getoverrun.o \
time/timer_gettime.o \
time/timer_settime.o \
2013-05-15 12:41:42 +00:00
time/times.o \
2013-03-29 13:29:11 +00:00
tmpfile.o \
2013-04-22 09:37:29 +00:00
tmpnam.o \
truncateat.o \
truncate.o \
2013-03-23 22:58:20 +00:00
ttyname.o \
umask.o \
2012-10-23 11:50:33 +00:00
unlinkat.o \
unlink.o \
2012-09-21 23:09:20 +00:00
usleep.o \
2013-03-19 21:01:01 +00:00
utimensat.o \
utimens.o \
utime.o \
vscanf.o \
wait.o \
waitpid.o \
write.o \
2013-05-03 19:43:01 +00: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 12:25:00 +00: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 12:25:00 +00: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 12:25:00 +00:00
libc-sortix.a: $(SORTIXOBJS)
$(HOSTAR) rcs $@ $(SORTIXOBJS)
2011-08-05 12:25:00 +00:00
libg.a:
$(HOSTAR) rcs $@
2012-09-10 21:36:15 +00:00
libm.a:
$(HOSTAR) rcs $@
libpthread.a:
2012-09-10 21:36:15 +00:00
$(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
2012-09-10 21:36:15 +00:00
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@
2012-09-10 21:36:15 +00:00
crti.o: $(CPUDIR)/crti.o
ln -f $< $@
2012-09-10 21:36:15 +00:00
crtn.o: $(CPUDIR)/crtn.o
ln -f $< $@
# header preprocessing
$(OBJS) $(SORTIXOBJS): $(HEADERS)
$(HEADERDIRS):
mkdir -p $@
2011-08-05 12:25:00 +00:00
preproc/%: include/%
mxmpp -I decl $< -o $@
2011-08-05 12:25:00 +00:00
$(HEADERS): | $(HEADERDIRS)
headers: $(HEADERDIRS) $(HEADERS)
2011-08-05 12:25:00 +00:00
# standard library
%.o: %.c
$(HOSTCC) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CFLAGS)
2011-08-05 12:25:00 +00:00
%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(FLAGS) $(CXXFLAGS)
2011-08-05 12:25:00 +00:00
%.o: %.s
2012-09-10 21:36:15 +00:00
$(HOSTAS) $(ASFLAGS) $< -o $@
2011-08-05 12:25:00 +00:00
# libc-sortix
sortix/%.o: %.c
$(HOSTCC) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCFLAGS)
2011-08-05 12:25:00 +00:00
sortix/%.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(SORTIXCPPFLAGS) $(SORTIXFLAGS) $(SORTIXCXXFLAGS)
2011-08-05 12:25:00 +00:00
clean:
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
rm -rf $(HEADERDIRS)
2011-08-05 12:25:00 +00: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)