subdirs=kernel
targets=crtbegin.o,crtend.o,crti.o,crtn.o,libc,start.o
as=$(CC)
cppflags_force=-nostdinc -isystem ../include
cflags_force=-ffreestanding
cflags=-W -Wall -g -O2 -fstack-protector
asflags_force=$(CFLAGSF)
asflags=$(CFLAGS) -c
ldflags_force=-nostdlib
ldflags=-Wl,-z,relro -Wl,-z,now
dist=Makefile,chacha/chacha.c,chacha/ecrypt-config.h,chacha/ecrypt-machine.h,chacha/ecrypt-portable.h,chacha/ecrypt-sync.h,dlfcn.h,endian.h,ssp.h,start.h,syscalls.h

#targets
[crtbegin.o]
type=command
command=cp -f -- `$(CC) $(CFLAGSF) -print-file-name=crtbeginS.o` $(OBJDIR)crtbegin.o
install=$(LIBDIR)

[crtend.o]
type=command
command=cp -f -- `$(CC) $(CFLAGSF) -print-file-name=crtendS.o` $(OBJDIR)crtend.o
install=$(LIBDIR)

[crti.o]
type=object
install=$(LIBDIR)
sources=crti.S

[crtn.o]
type=object
install=$(LIBDIR)
sources=crtn.S

[libc]
type=library
sources=ctype.c,dirent.c,dlfcn.c,errno.c,fcntl.c,float.c,fnmatch.c,grp.c,iconv.c,langinfo.c,libgen.c,locale.c,net/if.c,poll.c,pwd.c,regex.c,search.c,setjmp.c,signal.c,ssp.c,stdlib.c,stdio.c,string.c,strings.c,stropts.c,sys/ipc.c,sys/mman.c,sys/mount.c,sys/msg.c,sys/ptrace.c,sys/reboot.c,sys/resource.c,sys/select.c,sys/shm.c,sys/stat.c,sys/statvfs.c,sys/sysctl.c,sys/time.c,sys/times.c,sys/utsname.c,sys/wait.c,syscalls.S,syslog.c,termios.c,time.c,ucontext.c,unistd.c,utime.c,utmpx.c,wchar.c
asflags=-fPIC
cflags=-fPIC
ldflags=`$(CC) -print-libgcc-file-name` $(OBJDIR)./ssp/libssp.a
install=$(LIBDIR)

[start.o]
type=object
sources=start.S
asflags=-fPIE
install=$(LIBDIR)

#sources
[crti.S]
depends=kernel/linux/amd64/crti.S,kernel/linux/i386/crti.S,kernel/netbsd/amd64/crti.S,kernel/netbsd/i386/crti.S

[crtn.S]
depends=kernel/linux/amd64/crtn.S,kernel/linux/i386/crtn.S,kernel/netbsd/amd64/crtn.S,kernel/netbsd/i386/crtn.S

[dirent.c]
depends=../include/compat/dirent.h,../include/dirent.h

[dlfcn.c]
depends=dlfcn.h,endian.h,../include/dl/dlfcn.h,../include/dl/elf.h

[fcntl.c]
depends=syscalls.h

[regex.c]
depends=dlfcn.h,../config.h

[ssp.c]
depends=ssp.h,syscalls.h

[stdio.c]
depends=start.h

[stdlib.c]
depends=chacha/chacha.c,chacha/ecrypt-config.h,chacha/ecrypt-machine.h,chacha/ecrypt-portable.h,chacha/ecrypt-sync.h

[sys/ipc.c]
depends=syscalls.h

[sys/mman.c]
depends=syscalls.h

[sys/mount.c]
depends=syscalls.h

[sys/msg.c]
depends=syscalls.h

[sys/ptrace.c]
depends=syscalls.h

[sys/resource.c]
depends=syscalls.h

[sys/select.c]
depends=syscalls.h

[sys/shm.c]
depends=syscalls.h

[sys/stat.c]
depends=../include/compat/sys/stat.h,../include/sys/stat.h,syscalls.h

[sys/statvfs.c]
depends=syscalls.h

[sys/sysctl.c]
depends=syscalls.h

[sys/times.c]
depends=syscalls.h

[sys/wait.c]
depends=syscalls.h

[syscalls.S]
depends=../include/kernel/darwin/sys/syscall.h,../include/kernel/deforaos/sys/syscall.h,../include/kernel/freebsd/sys/syscall.h,../include/kernel/linux/sys/syscall.h,../include/kernel/netbsd/sys/syscall.h,../include/kernel/openbsd/sys/syscall.h,kernel/darwin/amd64/syscalls.S,kernel/freebsd/amd64/syscalls.S,kernel/freebsd/i386/syscalls.S,kernel/linux/common.S,kernel/linux/amd64/syscalls.S,kernel/linux/arm/syscalls.S,kernel/linux/i386/syscalls.S,kernel/linux/sparc/syscalls.S,kernel/netbsd/amd64/syscalls.S,kernel/netbsd/i386/syscalls.S,kernel/netbsd/sparc/syscalls.S,kernel/netbsd/sparc64/syscalls.S,kernel/openbsd/arm/syscalls.S,kernel/openbsd/i386/syscalls.S

[termios.c]
depends=syscalls.h

[ucontext.c]
depends=syscalls.h

[unistd.c]
depends=syscalls.h

[start.S]
depends=../include/kernel/darwin/sys/syscall.h,../include/kernel/freebsd/sys/syscall.h,../include/kernel/linux/sys/syscall.h,../include/kernel/netbsd/sys/syscall.h,../include/kernel/openbsd/sys/syscall.h,kernel/freebsd/amd64/start.S,kernel/freebsd/i386/start.S,kernel/linux/amd64/start.S,kernel/linux/arm/start.S,kernel/linux/i386/start.S,kernel/linux/sparc/start.S,kernel/netbsd/start.S,kernel/netbsd/amd64/start.S,kernel/netbsd/i386/start.S,kernel/netbsd/sparc64/start.S,kernel/netbsd/sparc/start.S,kernel/openbsd/start.S,kernel/openbsd/arm/start.S,kernel/openbsd/i386/start.S,kernel/solaris/sparc/start.S,kernel/whitix/i386/start.S
