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

463 lines
7.2 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 \
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 \
gmtime.o \
gmtime_r.o \
heap.o \
integer.o \
2013-03-19 03:59:26 -04:00
ldiv.o \
lldiv.o \
localtime.o \
localtime_r.o \
mbrtowc.o \
mbtowc.o \
2012-11-08 12:52:49 -05:00
memccpy.o \
memchr.o \
memcmp.o \
memcpy.o \
memmove.o \
memset.o \
2012-09-26 13:40:00 -04:00
op-new.o \
rewind.o \
setbuf.o \
setvbuf.o \
sort.o \
sprint.o \
sscanf.o \
stpcpy.o \
2012-11-08 12:37:17 -05:00
stpncpy.o \
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 \
strlen.o \
strncasecmp.o \
strncat.o \
strncmp.o \
strncpy.o \
2012-11-08 12:50:53 -05:00
strndup.o \
strnlen.o \
strpbrk.o \
strrchr.o \
2012-11-08 13:56:29 -05:00
strsignal.o \
strspn.o \
strstr.o \
strtok.o \
strtok_r.o \
2012-11-08 13:04:55 -05:00
strxfrm.o \
2013-03-21 20:09:03 -04:00
time/asctime.o \
time/asctime_r.o \
2013-03-22 09:14:07 -04:00
time/ctime.o \
time/ctime_r.o \
timespec.o \
2013-03-21 19:13:30 -04:00
time/strftime.o \
ungetc.o \
vfscanf.o \
vsscanf.o \
wcrtomb.o \
wctomb.o \
2012-12-20 10:18:24 -05:00
wctype.o \
HOSTEDOBJS=\
access.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-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 \
clock.o \
close.o \
2013-01-06 10:49:36 -05:00
$(CPUDIR)/calltrace.o \
$(CPUDIR)/fork.o \
$(CPUDIR)/signal.o \
$(CPUDIR)/syscall.o \
2013-01-12 20:27:51 -05:00
creat.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 \
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 \
fcloseall.o \
fcntl.o \
fddir-sortix.o \
fdio.o \
fileno.o \
fork.o \
fpipe.o \
2013-03-20 17:20:22 -04:00
freopen.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 \
getpagesize.o \
getpid.o \
getppid.o \
gettermmode.o \
gettimeofday.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 \
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 \
print.o \
putc.o \
2013-01-08 09:09:23 -05:00
pwent.o \
raise.o \
rand.o \
readdirents.o \
2013-03-19 15:18:15 -04:00
readlinkat.o \
readlink.o \
read.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 \
setjmp.o \
setlocale.o \
settermmode.o \
2013-01-12 20:37:14 -05:00
setuid.o \
sfork.o \
SIG_DFL.o \
SIG_ERR.o \
SIG_IGN.o \
signal.o \
2012-09-21 19:09:20 -04:00
sleep.o \
stat.o \
stdio.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 \
tfork.o \
time.o \
truncateat.o \
truncate.o \
umask.o \
2012-10-23 07:50:33 -04:00
unlinkat.o \
unlink.o \
uptime.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 \
winsize.o \
write.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)