| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 | # 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 [[ $NO_ERROR != @(0|1) ]]; then	echo Please do not invoke this script directly!	exit 1fiset -erm -rf $topdir/tmpmkdir -p $topdir/tmpcd $topdir/tmpos=$(uname)rm -f fooecho >FOOif [[ -e foo ]]; then	cat >&2 <<-EOF		ERROR: OpenADK cannot be built in a case-insensitive file system. 	EOF	case $os in		CYG*)			echo "Building OpenADK on $os needs a small registry change."			echo 'http://cygwin.com/cygwin-ug-net/using-specialnames.html'			;;		Darwin*)			echo "Building OpenADK on $os needs a case-sensitive disk partition."			echo "For Snow Leopard and above you can use diskutil to resize your existing disk."			echo "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"			echo "For older versions you might consider to use a disk image:"			echo "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"			;;	esac	exit 1firm -f FOOcase $os inLinux)	;;FreeBSD)	;;MirBSD)	;;CYG*)	;;NetBSD)	;;OpenBSD)	if ! which gmake >/dev/null 2>&1; then		echo You must install GNU make to continue.		echo		out=1	fi	;;Darwin*)	;;*)	# unsupported	echo "Building OpenADK on $os is currently unsupported."	echo "Sorry."	exit 1	;;esacset +eif [ -z $(which gmake 2>/dev/null ) ];then	makecmd=$(which make 2>/dev/null )else	makecmd=$(which gmake 2>/dev/null )ficat >Makefile <<'EOF'include ${TOPDIR}/prereq.mkall: run-testtest: test.c	${CC_FOR_BUILD} ${CFLAGS_FOR_BUILD} -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/nullif ! which tar >/dev/null 2>&1; then	echo You must install tar to continue.	echo	out=1fiif ! which gzip >/dev/null 2>&1; then	echo You must install gzip 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=1fiif [[ ! -s /usr/include/ncurses.h ]]; then	if [[ ! -s /usr/include/curses.h ]]; then		if [[ ! -s /usr/include/ncurses/ncurses.h ]]; then			echo Install ncurses header files, please.			echo			out=1		fi	fifiif ! which wget >/dev/null 2>&1; then	echo You must install wget to continue.	echo	out=1fiif ! which perl >/dev/null 2>&1; then	echo You must install perl to continue.	echo	out=1fiif ! which g++ >/dev/null 2>&1; then	echo  "You need a C++ compiler to continue."	echo	out=1fi# always required, but can be provided by hosthost_build_bc=0if ! which bc >/dev/null 2>&1; then	host_build_bc=1fihost_build_bison=0if ! which bison >/dev/null 2>&1; then	host_build_bison=1fihost_build_bzip2=0if ! which bzip2 >/dev/null 2>&1; then	host_build_bzip2=1fihost_build_file=0if ! which file >/dev/null 2>&1; then	host_build_file=1fihost_build_flex=0if ! which flex >/dev/null 2>&1; then	host_build_flex=1fihost_build_m4=0if ! which m4 >/dev/null 2>&1; then	host_build_m4=1fihost_build_mksh=0if ! which mksh >/dev/null 2>&1; then	host_build_mksh=1fihost_build_patch=0if ! which patch >/dev/null 2>&1; then	host_build_patch=1fihost_build_pkgconf=0if ! which pkgconf >/dev/null 2>&1; then	host_build_pkgconf=1fihost_build_findutils=0if ! which gxargs >/dev/null 2>&1; then	if which xargs >/dev/null 2>&1; then		if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then			host_build_findutils=1		fi	fifiif ! which gfind >/dev/null 2>&1; then	if which find >/dev/null 2>&1; then		if ! find --version 2>/dev/null|grep GNU >/dev/null;then			host_build_findutils=1		fi	fifihost_build_gawk=0if ! which gawk >/dev/null 2>&1; then	host_build_gawk=1fihost_build_sed=0if ! which gsed >/dev/null 2>&1; then	if which sed >/dev/null 2>&1; then		if ! sed --version 2>/dev/null|grep GNU >/dev/null;then			host_build_sed=1		fi	fifihost_build_xz=0if ! which xz >/dev/null 2>&1; then	host_build_xz=1fi# optionalhost_build_cdrtools=0if ! which mkisofs >/dev/null 2>&1; then	host_build_cdrtools=1fihost_build_ccache=0if ! which ccache >/dev/null 2>&1; then	host_build_ccache=1fihost_build_genext2fs=0if ! which genext2fs >/dev/null 2>&1; then	host_build_genext2fs=1fihost_build_lzma=0if ! which lzma >/dev/null 2>&1; then	host_build_lzma=1fihost_build_lzop=0if ! which lzop >/dev/null 2>&1; then	host_build_lzop=1fihost_build_qemu=0if ! which qemu-img >/dev/null 2>&1; then	host_build_qemu=1fiecho "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereqprintf "\t%s\n" "boolean" >> $topdir/target/config/Config.in.prereqprintf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq# always requiredif [ $host_build_bc -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_bison -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_bzip2 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_file -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_flex -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_gawk -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_m4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_mksh -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_patch -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_pkgconf -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_findutils -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_sed -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_xz -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq ;fi# optionalif [ $host_build_ccache -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CCACHE if ADK_HOST_NEED_CCACHE" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_cdrtools -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_genext2fs -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_lzma -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_lzop -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_qemu -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq ;ficd $topdirrm -rf tmpexit $out
 |