| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 | # This file is part of the OpenADK project. OpenADK is copyrighted# material, please see the LICENCE file in the top-level directory.shopt -s extglobtopdir=$(pwd)opath=$PATHout=0if [ -z $(which gmake 2>/dev/null ) ];then	makecmd=$(which make 2>/dev/null )else	makecmd=$(which gmake 2>/dev/null )fiif [[ $NO_ERROR != @(0|1) ]]; then	echo Please do not invoke this script directly!	exit 1fiset -erm -rf $topdir/tmpmkdir -p $topdir/tmpcd $topdir/tmprm -f fooecho >FOOif [[ -e foo ]]; then	cat >&2 <<-EOF		ERROR: OpenADK cannot be built in a case-insensitive file system. 	EOF	exit 1firm -f FOOos=$(uname)case $os inLinux)	# supported with no extra quirks at the moment	;;FreeBSD)	# supported with no extra quirks at the moment	;;MirBSD)	# supported with no extra quirks at the moment	;;CYG*)	echo "Building OpenADK on $os needs a small registry change."	echo 'See http://www.cygwin.com/1.7/cygwin-ug-net/using-specialnames.html'	;;NetBSD)	echo "Building OpenADK on $os is currently unsupported."	echo "Sorry."	echo	echo There are unresolved issues relating to ncurses not	echo being included in NetBSD®, and these provided by pkgsrc®	echo lack important header files.	;;OpenBSD)	# supported with no extra quirks at the moment	# although some packages' autoconf scripts may	# not properly recognise OpenBSD	;;*)	# unsupported	echo "Building OpenADK on $os is currently unsupported."	echo "Sorry."	exit 1	;;esacset +ecat >Makefile <<'EOF'include ${TOPDIR}/prereq.mkHOSTCFLAGS+=	-O2all: run-testtest: test.c	${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}run-test: test	./testEOFcat >test.c <<-'EOF'	#include <stdio.h>	int	main()	{		printf("Yay! Native compiler works.\n");		return (0);	}EOFX=$($makecmd TOPDIR=$topdir 2>&1)if [[ $X != *@(Native compiler works)* ]]; then	echo "$X" | sed 's/^/| /'	echo Cannot compile a simple test programme.	echo You must install a host make and C compiler,	echo usually GCC, to proceed.	echo	out=1firm test 2>/dev/null#if ! which cpp >/dev/null 2>&1; then#	echo You must install a C preprocessor to continue.#	echo#	out=1#fiif ! which tar >/dev/null 2>&1; then	echo You must install GNU tar to continue.	echo	out=1fiif ! (tar --version | grep GNU) >/dev/null 2>&1;then	if ! which gtar >/dev/null 2>&1; then		echo You must install GNU tar to continue.		echo		out=1	fifiif ! which gzip >/dev/null 2>&1; then	echo You must install gzip to continue.	echo	out=1fiif ! which lzma >/dev/null 2>&1; then	echo You must install lzma to continue.	echo	out=1fiif ! which bzip2 >/dev/null 2>&1; then	echo You must install bzip2 to continue.	echo	out=1fiif ! which cpio >/dev/null 2>&1; then	echo You must install cpio to continue.	echo	out=1fiif ! which unzip >/dev/null 2>&1; then	echo You must install unzip to continue.	echo	out=1fiif ! which patch >/dev/null 2>&1; then	echo You must install patch to continue.	echo	out=1ficat >test.c <<-'EOF'	#include <stdio.h>	#include <zlib.h>	#ifndef STDIN_FILENO	#define STDIN_FILENO 0	#endif	int	main()	{		gzFile zstdin;		char buf[1024];		int i;		zstdin = gzdopen(STDIN_FILENO, "rb");		i = gzread(zstdin, buf, sizeof (buf));		if ((i > 0) && (i < sizeof (buf)))			buf[i] = '\0';		buf[sizeof (buf) - 1] = '\0';		printf("%s\n", buf);		return (0);	}EOFX=$(echo 'Yay! Native compiler works.' | gzip | \    $makecmd TOPDIR=$topdir LDADD=-lz 2>&1)if [[ $X != *@(Native compiler works)* ]]; then	echo "$X" | sed 's/^/| /'	echo Cannot compile a libz test programm.	echo You must install the zlib development package,	echo usually called libz-dev, and the run-time library.	echo	out=1fi[[ -s /usr/include/ncurses.h ]] || if [[ -s /usr/pkg/include/ncurses.h ]]; then	echo 'HOSTCFLAGS+= -isystem /usr/pkg/include' >>$topdir/prereq.mk	echo 'HOSTLDFLAGS+=-L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib' >>$topdir/prereq.mkelse	echo Install ncurses header files, please.	echo	out=1fiif ! which gawk >/dev/null 2>&1; then	echo You must install GNU awk to continue.	echo	out=1fiif ! which sed >/dev/null 2>&1; then	echo You must install GNU sed to continue.	echo	out=1fiif ! sed --version 2>/dev/null|grep GNU >/dev/null;then	if ! which gsed >/dev/null 2>&1; then		echo You must install GNU sed to continue.		echo		out=1	fifiif ! which wget >/dev/null 2>&1; then	echo You must install wget to continue.	echo	out=1fiif ! which autoconf >/dev/null 2>&1; then	echo You must install autoconf to continue.	echo	out=1fiif ! which automake >/dev/null 2>&1; then	echo You must install automake to continue.	echo	out=1fiif ! which libtool >/dev/null 2>&1; then	echo You must install libtool to continue.	echo	out=1fiif ! which file >/dev/null 2>&1; then	echo You must install \"file\" to continue.	echo	out=1fiif ! which perl >/dev/null 2>&1; then	echo You must install perl to continue.	echo	out=1ficd $topdirrm -rf tmpexit $out
 |