SubDir HAIKU_TOP src bin coreutils src ;

# filter warnings we don't want here
TARGET_WARNING_CCFLAGS = [ FFilter $(TARGET_WARNING_CCFLAGS)
	: -Wall -Wmissing-prototypes -Wsign-compare ] ;

SubDirCcFlags -DHAVE_CONFIG_H -DB_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT ;
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) lib ] ;

local coreutils_rsrc = [ FGristFiles coreutils.rsrc ] ;

ResComp $(coreutils_rsrc) : [ FGristFiles coreutils.rdef ] ;

StdBinCommands
	base64.c
	basename.c
	cat.c
	cksum.c
	comm.c
	csplit.c
	cut.c
	date.c
	dd.c
	dircolors.c
	dirname.c
	echo.c 
	env.c
	expand.c
	expr.c
	factor.c
	false.c
	fmt.c
	fold.c
	getlimits.c
	head.c
	join.c
	link.c
	ln.c
	logname.c
	mkfifo.c
	mknod.c
	mktemp.c
	nl.c
	nohup.c
	nproc.c
	od.c
	paste.c
	pathchk.c
	pr.c
	printenv.c
	printf.c
	ptx.c
	readlink.c
	seq.c
	shred.c
	shuf.c
	split.c
	stat.c
	stty.c
	su.c
	sum.c
	sync.c
	tac.c
	tee.c
	test.c
	touch.c
	tr.c
	true.c
	truncate.c
	tsort.c
	tty.c
	unexpand.c
	uniq.c
	unlink.c
#	uptime.c
	wc.c
	whoami.c
	yes.c
	: libfetish.a : $(coreutils_rsrc) ;

# set set-uid bit on su
MODE on su = 04755 ;


# commands requiring select, uname, etc.

StdBinCommands
	hostname.c
	tail.c
	: libfetish.a $(TARGET_SELECT_UNAME_ETC_LIB) : $(coreutils_rsrc) ;

#commands requiring something in libroot.so (getrlimit, fchdir...)

StdBinCommands
	chmod.c
	chroot.c
	du.c
	pwd.c
	sleep.c
	sort.c
        : libfetish.a libroot.so : $(coreutils_rsrc) ;

# df.c
# hostid.c
# pinky.c
# users.c
# who.c

BinCommand "[" : lbracket.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand kill : kill.c operand2sig.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand id : id.c group-list.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand groups : groups.c [ FGristFiles group-list.o ] : libfetish.a : $(coreutils_rsrc) ;

BinCommand ls : 
	ls.c ls-ls.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand rm : 
	rm.c remove.c : libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand chgrp : 
	chgrp.c chown-core.c : libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand chown : 
	chown.c [ FGristFiles chown-core.o ]
	: libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand cp : 
	cp.c copy.c cp-hash.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand mv : 
	mv.c [ FGristFiles copy.o cp-hash.o remove.o ]
	: libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand md5sum : md5sum-md5sum.c : libfetish.a : $(coreutils_rsrc) ;
BinCommand sha1sum : md5sum-sha1sum.c : libfetish.a : $(coreutils_rsrc) ;
BinCommand sha224sum : md5sum-sha224sum.c : libfetish.a : $(coreutils_rsrc) ;
BinCommand sha256sum : md5sum-sha256sum.c : libfetish.a : $(coreutils_rsrc) ;
BinCommand sha384sum : md5sum-sha384sum.c : libfetish.a : $(coreutils_rsrc) ;
BinCommand sha512sum : md5sum-sha512sum.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand vdir : 
	[ FGristFiles ls.o ] ls-vdir.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand dir :
	[ FGristFiles ls.o ] ls-dir.c : libfetish.a : $(coreutils_rsrc) ;

BinCommand <bin>install : install.c prog-fprintf.c [ FGristFiles copy.o cp-hash.o ]
	: libfetish.a : $(coreutils_rsrc) ;

BinCommand mkdir : mkdir.c [ FGristFiles prog-fprintf.o ] : libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand rmdir : rmdir.c [ FGristFiles prog-fprintf.o ] : libfetish.a libroot.so : $(coreutils_rsrc) ;

BinCommand uname : uname.c uname-uname.c : libfetish.a $(TARGET_SELECT_UNAME_ETC_LIB) : $(coreutils_rsrc) ;

BinCommand timeout : timeout.c [ FGristFiles operand2sig.o ] : libfetish.a : $(coreutils_rsrc) ;
