TOPDIR=../libc

include $(TOPDIR)/Makeconfig

files=_G_config.h \
	a.out.h \
	alloca.h \
	ansidecl.h \
	ar.h \
	argz.h \
	arpa/ftp.h \
	arpa/inet.h \
	arpa/nameser.h \
	arpa/telnet.h \
	arpa/tftp.h \
	assert.h \
	bsd/bsd.h \
	bsd/errno.h \
	bsd/sgtty.h \
	bsd/signal.h \
	bsd/stdlib.h \
	bsd/sys/ttychars.h \
	bsd/tzfile.h \
	bsd/unistd.h \
	bstring.h \
	bytesex.h \
	confname.h \
	confstr.h \
	ctype.h \
	des_crypt.h \
	dirent.h \
	elf.h \
	endian.h \
	err.h \
	errno.h \
	fcntl.h \
	features.h \
	fnmatch.h \
	fpu_control.h \
	ftw.h \
	getopt.h \
	glob.h \
	gmp-mparam.h \
	gnu-stabs.h \
	gnu/types.h \
	grp.h \
	huge_val.h \
	i386/fpu_control.h \
	i386/gmp-mparam.h \
	i386/ieeefp.h \
	i386/jmp_buf.h \
	i386/syscall.h \
	ieee754.h \
	ieee854.h \
	jmp_buf.h \
	langinfo.h \
	lastlog.h \
	libelf.h \
	libio.h \
	limits.h \
	link.h \
	locale.h \
	m68k/__math.h \
	m68k/fpu_control.h \
	m68k/gmp-mparam.h \
	m68k/ieeefp.h \
	m68k/jmp_buf.h \
	m68k/syscall.h \
	malloc.h \
	math.h \
	memory.h \
	mntent.h \
	nan.h \
	net/if.h \
	net/if_arp.h \
	net/if_route.h \
	net/ppp-comp.h \
	net/ppp_defs.h \
	net/route.h \
	netatalk/at.h \
	netdb.h \
	netinet/igmp.h \
	netinet/in.h \
	netinet/in_systm.h \
	netinet/ip.h \
	netinet/ip_fw.h \
	netinet/ip_icmp.h \
	netinet/ip_mroute.h \
	netinet/ip_tcp.h \
	netinet/ip_udp.h \
	netinet/protocols.h \
	netinet/tcp.h \
	netinet/udp.h \
	nl_types.h \
	nlist.h \
	obstack.h \
	paths.h \
	posix1_lim.h \
	posix2_lim.h \
	posix_opt.h \
	printf.h \
	protocols/routed.h \
	protocols/rwhod.h \
	protocols/talkd.h \
	protocols/timed.h \
	pthread.h \
	pthread/mit/cleanup.h \
	pthread/mit/cond.h \
	pthread/mit/debug_out.h \
	pthread/mit/fd.h \
	pthread/mit/fd_pipe.h \
	pthread/mit/kernel.h \
	pthread/mit/kthread.h \
	pthread/mit/machdep.h \
	pthread/mit/mutex.h \
	pthread/mit/posix.h \
	pthread/mit/prio_queue.h \
	pthread/mit/pthread.h \
	pthread/mit/pthread_attr.h \
	pthread/mit/pthread_once.h \
	pthread/mit/queue.h \
	pthread/mit/sleep.h \
	pthread/mit/specific.h \
	pthread/mit/state.def \
	pthread/mit/sys/compat.h \
	pthread/mit/sys/timers.h \
	pthread/mit/sys/types.h \
	pthread/mit/types.h \
	pthread/mit/unistd.h \
	pthread/mit/util.h \
	pthread/mit/version.h \
	pthread/mit/xtypes.h \
	pwd.h \
	regex.h \
	regexp.h \
	resolv.h \
	rpc.h \
	rpc/auth.h \
	rpc/auth_des.h \
	rpc/auth_unix.h \
	rpc/clnt.h \
	rpc/key_prot.h \
	rpc/key_prot.x \
	rpc/pmap_clnt.h \
	rpc/pmap_prot.h \
	rpc/pmap_rmt.h \
	rpc/rpc.h \
	rpc/rpc_msg.h \
	rpc/svc.h \
	rpc/svc_auth.h \
	rpc/types.h \
	rpc/xdr.h \
	rpcsvc/bootparam_prot \
	rpcsvc/bootparam_prot.x \
	rpcsvc/klm_prot.h \
	rpcsvc/klm_prot.x \
	rpcsvc/mount.h \
	rpcsvc/mount.x \
	rpcsvc/nfs_prot.h \
	rpcsvc/nfs_prot.x \
	rpcsvc/nlm_prot.h \
	rpcsvc/nlm_prot.x \
	rpcsvc/rex.h \
	rpcsvc/rex.x \
	rpcsvc/rquota.h \
	rpcsvc/rquota.x \
	rpcsvc/rstat.h \
	rpcsvc/rstat.x \
	rpcsvc/rusers.h \
	rpcsvc/rusers.x \
	rpcsvc/sm_inter.h \
	rpcsvc/sm_inter.x \
	rpcsvc/spray.h \
	rpcsvc/spray.x \
	rpcsvc/yp.h \
	rpcsvc/yp.x \
	rpcsvc/yp_prot.h \
	rpcsvc/ypclnt.h \
	rpcsvc/yppasswd.h \
	rpcsvc/yppasswd.x \
	rpcsvc/ypupdate_prot.h \
	rpcsvc/ypupdate_prot.x \
	rx.h \
	sched.h \
	search.h \
	setjmp.h \
	shadow.h \
	sharedlib.h \
	signal.h \
	stab.def \
	stab.h \
	stdio.h \
	stdlib.h \
	string.h \
	strings.h \
	sys/acct.h \
	sys/bitypes.h \
	sys/cdefs.h \
	sys/debugreg.h \
	sys/dir.h \
	sys/dirent.h \
	sys/errno.h \
	sys/fcntl.h \
	sys/file.h \
	sys/ioctl.h \
	sys/ipc.h \
	sys/kd.h \
	sys/mman.h \
	sys/mount.h \
	sys/msg.h \
	sys/mtio.h \
	sys/param.h \
	sys/poll.h \
	sys/procfs.h \
	sys/ptrace.h \
	sys/queue.h \
	sys/quota.h \
	sys/resource.h \
	sys/sem.h \
	sys/serial.h \
	sys/shm.h \
	sys/signal.h \
	sys/socket.h \
	sys/socketcall.h \
	sys/socketio.h \
	sys/socketvar.h \
	sys/soundcard.h \
	sys/stat.h \
	sys/syscall.h \
	sys/sysctl.h \
	sys/sysinfo.h \
	sys/syslog.h \
	sys/sysmacros.h \
	sys/termio.h \
	sys/termios.h \
	sys/time.h \
	sys/timeb.h \
	sys/times.h \
	sys/timex.h \
	sys/tty.h \
	sys/types.h \
	sys/uio.h \
	sys/ultrasound.h \
	sys/un.h \
	sys/user.h \
	sys/utsname.h \
	sys/varargs.h \
	sys/vfs.h \
	sys/vm86.h \
	sys/vt.h \
	sys/wait.h \
	syscall.h \
	sysexits.h \
	syslog.h \
	tar.h \
	termio.h \
	termios.h \
	time.h \
	ulimit.h \
	unistd.h \
	utime.h \
	utmp.h \
	values.h \
	wait.h \
	waitflags.h \
	waitstatus.h \
	wchar.h \
	wctype.h

all lib include: asm linux

asm: linux

linux:
	$(RM) -f dummy.c
	echo "#include <linux/version.h>" > dummy.c
	dir=`$(CC) -M dummy.c 2> /dev/null | grep linux/version.h | sed -e 's,.*[ 	]\([^ 	]*\)linux/version.h.*,\1,'`; \
	$(RM) -f dummy.c; \
	if [ x"$$dir"x = xx -o ! -d $$dir ]; \
	then \
	  echo No kernel header files found!; \
	  exit 1; \
	else \
	  $(RM) -fr asm linux; \
	  ln -s $$dir/asm .; \
	  ln -s $$dir/linux .; \
	fi

clean:
	$(RM) -f asm linux

install:
	@for f in $(files); \
	do \
	  cmp -s $$f $(TARGET_ROOTDIR)/usr/include/$$f; \
	  if [ $$? != 0 ]; \
	  then \
	    echo cp $$f $(TARGET_ROOTDIR)/usr/include/$$f; \
	    cp $$f $(TARGET_ROOTDIR)/usr/include/$$f; \
	  fi \
	done
