On Having Built Linux for a Small System


Explanation: Config/uClibc-dev/v0.9.20.mak

${EXTTEMP}/uClibc-${VERSION}/.configured:
	${MAKE} extract LIST="$(strip ${SOURCES})"
	[ -r ${XTC_ROOT}/etc/uClibc-${VERSION}-config ] \
	|| ( 	mkdir -p ${XTC_ROOT}/etc || exit 1 ;\
		cd ${XTC_ROOT}/etc/ || exit 1 ;\
		( \
		echo 'DEVEL_PREFIX="'${XTC_ROOT}'/usr/'${TARGET_SPEC}'"' ;\
		echo 'KERNEL_SOURCE="'${XTC_ROOT}'/usr/'${TARGET_SPEC}'/src/linux"' ;\
		echo 'SHARED_LIB_LOADER_PATH="/lib"' ;\
		echo '# ASSUME_DEVPTS is not set' ;\
		echo 'MALLOC=y' ;\
		echo '# MALLOC_930716 is not set' ;\
		echo 'DO_C99_MATH=y' ;\
		echo 'UCLIBC_HAS_IPV6=y' ;\
		echo '# UCLIBC_HAS_LFS is not set' ;\
		echo 'UCLIBC_HAS_RPC=y' ;\
		echo 'UCLIBC_HAS_FULL_RPC=y' ;\
		echo '# UNIX98PTY_ONLY is not set' ;\
		) > uClibc-${VERSION}-config || exit 1 ;\
		( case "${TARGET_CPU}" in \
		  mips)	\
			echo 'TARGET_ARCH="'${TARGET_CPU}'"' ;\
			echo 'TARGET_'${TARGET_CPU}'=y' ;\
			echo 'ARCH_SUPPORTS_BIG_ENDIAN=y' ;\
			echo 'ARCH_BIG_ENDIAN=y' ;\
			echo 'CONFIG_MIPS_ISA_MIPS32=y' ;\
		  ;; \
		  i386) \
			echo 'TARGET_ARCH="'${TARGET_CPU}'"' ;\
			echo 'TARGET_'${TARGET_CPU}'=y' ;\
		  ;; \
		  *)	\
			echo "Unexpected TARGET_CPU '${TARGET_CPU}'" 1>&2 ;\
			exit 1 \
		  ;; \
		  esac \
		  ) && uClibc-${VERSION}-config || exit 1 \
	  )
	( cd ${EXTTEMP}/uClibc-${VERSION} || exit 1 ;\
		[ -r Rules.mak.OLD ] || mv Rules.mak Rules.mak.OLD || exit 1 ;\
		cat Rules.mak.OLD \
			| sed	' /^CROSS/	s%=.*%= '${XTC_ROOT}'/usr/bin/'$(shell echo ${TARGET_SPEC} | sed 's/-[^-]*-/-xnc_k-/')'-% ; /(CROSS)/	s%$$(CROSS)%$$(shell if [ -n "$${CROSS}" ] ; then echo $${CROSS} ; else echo "'`echo ${HTC_GCC} | sed 's/gcc$$//'`'" ; fi)% ; /USE_CACHE/ s/#//' > Rules.mak || exit 1 ;\
		for MF in libc/sysdeps/linux/*/Makefile ; do \
			[ -r $${MF}.OLD ] || mv $${MF} $${MF}.OLD || exit 1 ;\
			cat $${MF}.OLD \
				| sed 's/-g,,/-g , ,/' \
				> $${MF} || exit 1 ;\
		done \
	) || exit 1
	touch ${EXTTEMP}/uClibc-${VERSION}/.configured

${EXTTEMP}/uClibc-dev-${VERSION}-xtc/.built: ${EXTTEMP}/uClibc-${VERSION}/.configured
	(	[ ! -d ${EXTTEMP}/uClibc-dev-${VERSION}-xtc ] || rm -rf ${EXTTEMP}/uClibc-dev-${VERSION}-xtc || exit 1 ;\
		mv ${EXTTEMP}/uClibc-${VERSION} ${EXTTEMP}/uClibc-dev-${VERSION}-xtc || exit 1 ;\
		cd ${EXTTEMP}/uClibc-dev-${VERSION}-xtc || exit 1 ;\
		cp ${XTC_ROOT}/etc/uClibc-${VERSION}-config .config || exit 1 ;\
		yes '' | ${MAKE} HOSTCC=${HTC_GCC} oldconfig \
			  || exit 1 ;\
		${MAKE} || exit 1 \
	) || exit 1
	touch ${EXTTEMP}/uClibc-dev-${VERSION}-xtc/.built

.PHONY: install-xtc
install-xtc: ${EXTTEMP}/uClibc-dev-${VERSION}-xtc/.built
	(	cd ${EXTTEMP}/uClibc-dev-${VERSION}-xtc || exit 1 ;\
		${MAKE} install_dev || exit 1 ;\
		${MAKE} RUNTIME_PREFIX=${XTC_ROOT}'/usr/'${TARGET_SPEC}'/' install_runtime || exit 1 ;\
		( cd ${XTC_ROOT}/usr/${TARGET_SPEC}/lib || exit 1 ;\
			for F in *.so ; do [ -L $${F} ] && ln -sf $${F}.0 $${F} ; done \
		) || exit 1 \
	) || exit 1