Blame project/pydist.sh

481942
#!/bin/sh
481942
481942
# pydist.sh: a reference-only, development-time script
481942
# objective: generate pydist.mk based on the scripts found
481942
#            under $PYTHON_SRCDIR/Lib, excluding the 'test'
481942
#            and 'plat-*' sub-directories.
481942
91ec82
if [ -z "$PYTHON_SRCDIR" ]; then
91ec82
	printf 'Variable PYTHON_SRCDIR is not set!\n'
91ec82
	exit 2
91ec82
fi
91ec82
91ec82
cd "$PYTHON_SRCDIR"/Lib || exit 2
91ec82
91ec82
pydirs=$(find . -type d | grep -v -e '^\./test' -e '^./plat-' | sort)
91ec82
pysrcs=$(mktemp)
91ec82
pypycs=$(mktemp)
91ec82
91ec82
if [ -z $pysrcs ]; then
91ec82
	exit 2
91ec82
fi
91ec82
91ec82
if [ -z $pypycs ]; then
91ec82
	exit 2
91ec82
fi
91ec82
481942
printf 'PYCOPY        = $(PROJECT_DIR)/project/pycopy.sh\n'
481942
printf 'PYCOPY_PYTHON = $(NICKNAME)\n'
481942
printf 'PYCOPY_PREFIX = $(PREFIX)\n\n'
481942
481942
printf 'PYDIST_LIBDIR = lib\n'
481942
printf 'PYDIST_PYCDIR = lib/$(NICKNAME)\n\n\n'
481942
481942
printf 'PYDIST_SYSCFG_SRCS = \\\n'
481942
printf '\t$(PYDIST_PYCDIR)/./_sysconfigdata.py\n\n'
481942
91ec82
cpvar=$(printf '\tcp -p $(%s)' 'PYDIST_SYSCFG_SRCS')
91ec82
printf '%-64s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)\n' "$cpvar" >> $pysrcs
481942
91ec82
cpvar=$(printf '\tcp -p $(%s:%s.py=%s.pyc)' 'PYDIST_SYSCFG_SRCS' '%' '%')
91ec82
printf '%-68s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)\n' "$cpvar" >> $pypycs
481942
481942
for pydir in $pydirs; do
481942
	if [ $(find "$pydir" -name '*.py' | wc -l) != '0' ]; then
481942
		pyvar=$(printf "PYDIST_%s_SRCS" $pydir \
481942
			| sed -e 's@\_\.@@g' -e 's@/@_@g' -e 's@-@_@g' \
481942
			| tr "[:lower:]" "[:upper:]")
481942
481942
		printf "%s = "'\\'"\n" "$pyvar"
481942
		pyvars="$pyvars $pyvar"
481942
91ec82
		cpvar=$(printf '\tcp -p $(%s)' "$pyvar")
91ec82
		printf '%-64s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s\n' "$cpvar" "$pydir" >> $pysrcs
91ec82
91ec82
		cpvar=$(printf '\tcp -p $(%s:%s.py=%s.pyc)' "$pyvar" '%' '%')
91ec82
		printf '%-68s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s\n' "$cpvar" "$pydir" >> $pypycs
91ec82
481942
		for pysrc in $pydir/*.py; do
481942
			if [ $pysrc != $pydir/py3_test_grammar.py ]; then
481942
				printf "\t"'$(PYDIST_PYCDIR)/'"%s "'\\'"\n" $pysrc
481942
			fi
481942
		done | sort;
481942
481942
		echo
481942
	fi
481942
done
481942
481942
printf '\n\n'
481942
printf 'pydist.tag:\n'
481942
481942
for pydir in $pydirs; do
481942
	if [ $pydir != '.' ]; then
481942
		printf '\tmkdir -p $(PYDIST_PYCDIR)/%s\n' $pydir
481942
	fi
481942
done
481942
481942
printf '\ttouch pydist.tag\n'
481942
printf '\n\n'
481942
481942
for pydir in $pydirs; do
481942
	pyrule=$(printf '$(PYDIST_PYCDIR)/'"%s/%s.py:" "$pydir" '%')
481942
	printf "%-64s"'$(SOURCE_DIR)/Lib/'"%s/%s.py"' pydist.tag\n' "$pyrule" "$pydir" '%'
481942
481942
	pyrule_python=$(printf "\t\t"'PYCOPY_PYTHON=$(PYCOPY_PYTHON)')
481942
	pyrule_prefix=$(printf "\t\t"'PYCOPY_PREFIX=$(PYCOPY_PREFIX)')
481942
	pyrule_dstdir=$(printf "\t\t"'PYCOPY_DSTDIR=$(PYDIST_PYCDIR)/'"%s" "$pydir")
481942
481942
	printf "%s"' \\\n' "$pyrule_python"
481942
	printf "%s"' \\\n' "$pyrule_prefix"
481942
	printf "%s"' \\\n' "$pyrule_dstdir"
481942
	printf '\t\t$(PYCOPY) $<\n\n'
481942
done
481942
481942
printf 'PYDIST_PY_SRCS = \\\n'
481942
481942
for pyvar in PYDIST_SYSCFG_SRCS $pyvars; do
481942
	printf "\t"'$('"%s"') \\\n' $pyvar
481942
done
481942
481942
printf '\n\n'
481942
printf 'pydist-py-srcs:\t$(PYDIST_PY_SRCS)\n\n'
481942
printf 'pydist-py-srcs-clean:\n'
481942
printf '\trm -f $(PYDIST_PY_SRCS)\n'
481942
printf '\trm -f pydist.tag\n\n'
481942
printf 'clean:\tpydist-py-srcs-clean\n\n'
481942
91ec82
printf '\n\n'
91ec82
printf 'pydist-install-tree:\n'
91ec82
91ec82
for pydir in $pydirs; do
91ec82
	if [ $pydir != '.' ]; then
91ec82
		printf '\tmkdir -p $(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s\n' $pydir
91ec82
	fi
91ec82
done
91ec82
91ec82
printf '\n\n'
91ec82
printf 'pydist-install-py: $(PYDIST_PY_SRCS)\n'
91ec82
printf 'pydist-install-py: pydist-install-tree\n'
91ec82
printf 'pydist-install-py:\n'
91ec82
cat $pysrcs
91ec82
91ec82
printf '\n\n'
91ec82
printf 'pydist-install-pyc: $(PYCGEN_OBJS)\n'
91ec82
printf 'pydist-install-pyc: pydist-install-tree\n'
91ec82
printf 'pydist-install-pyc:\n'
91ec82
cat $pypycs
91ec82
91ec82
printf '\n\n'
91ec82
printf 'install-app:\tpydist-install-py\n'
91ec82
printf 'install-app:\tpydist-install-pyc\n'
91ec82
91ec82
printf '\n\n'
481942
printf '.PHONY:\tpydist-py-srcs\n'
481942
printf '.PHONY:\tpydist-py-srcs-clean\n\n'
481942
91ec82
printf '.PHONY:\tpydist-install-tree\n'
91ec82
printf '.PHONY:\tpydist-install-py\n'
91ec82
printf '.PHONY:\tpydist-install-pyc\n'
91ec82
481942
exit 0