1SUMMARY = "An sh-compatible command language interpreter"
2HOMEPAGE = "http://tiswww.case.edu/php/chet/bash/bashtop.html"
3SECTION = "base/shell"
4
5DEPENDS = "ncurses bison-native virtual/libiconv"
6
7inherit autotools gettext texinfo update-alternatives ptest
8
9EXTRA_AUTORECONF += "--exclude=autoheader --exclude=aclocal"
10EXTRA_OECONF = "--enable-job-control --without-bash-malloc bash_cv_wexitstatus_offset=8"
11
12# If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the
13# startup files, even if they are not interactive.
14# This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
15CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
16
17ALTERNATIVE_${PN} = "bash sh"
18ALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
19ALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
20ALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
21ALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
22ALTERNATIVE_PRIORITY = "100"
23
24RDEPENDS_${PN} += "base-files"
25RDEPENDS_${PN}_class-nativesdk = ""
26RDEPENDS_${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
27
28DEPENDS_append_libc-glibc = " virtual/libc-locale"
29RDEPENDS_${PN}-ptest_append_libc-glibc = " \
30	glibc-gconv-big5hkscs \
31	glibc-gconv-iso8859-1 \
32	glibc-utils \
33	locale-base-de-de \
34	locale-base-en-us \
35	locale-base-fr-fr \
36	locale-base-fr-fr.iso-8859-1 \
37	locale-base-zh-hk.big5-hkscs \
38	"
39
40CACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
41
42do_compile_ptest () {
43	oe_runmake buildtest
44}
45
46do_install_append () {
47	# Move /usr/bin/bash to /bin/bash, if need
48	if [ "${base_bindir}" != "${bindir}" ]; then
49		mkdir -p ${D}${base_bindir}
50		mv ${D}${bindir}/bash ${D}${base_bindir}
51	fi
52}
53do_install_append_class-target () {
54	# Clean buildhost references in bashbug
55	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
56		-e "s,-I${WORKDIR}/\S* ,,g" \
57		-e 's|${DEBUG_PREFIX_MAP}||g' \
58		${D}${bindir}/bashbug
59
60	# Clean buildhost references in bash.pc
61	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
62	     ${D}${libdir}/pkgconfig/bash.pc
63
64	# Clean buildhost references in Makefile.inc
65	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
66		-e 's|${DEBUG_PREFIX_MAP}||g' \
67		-e 's:${HOSTTOOLS_DIR}/::g' \
68		-e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
69		${D}${libdir}/bash/Makefile.inc
70}
71
72do_install_ptest () {
73	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
74	cp ${B}/Makefile ${D}${PTEST_PATH}
75	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
76        sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
77	    -e 's|${DEBUG_PREFIX_MAP}||g' \
78	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
79	    -e 's:${HOSTTOOLS_DIR}/::g' \
80	    -e 's:${UNINATIVE_LOADER}:${base_bindir}/false:g' \
81	     ${D}${PTEST_PATH}/Makefile
82}
83# The uninative loader is different on i386 & x86_64 hosts. Since it is only
84# being replaced with /bin/false anyway, it doesn't need to be part of the task
85# hash
86do_install_ptest[vardepsexclude] += "UNINATIVE_LOADER"
87
88pkg_postinst_${PN} () {
89	grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
90}
91
92pkg_postrm_${PN} () {
93	printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
94}
95
96PACKAGES += "${PN}-bashbug"
97FILES_${PN} = "${bindir}/bash ${base_bindir}/bash.bash"
98FILES_${PN}-bashbug = "${bindir}/bashbug"
99
100PACKAGE_BEFORE_PN += "${PN}-loadable"
101RDEPENDS_${PN}-loadable += "${PN}"
102FILES_${PN}-loadable += "${libdir}/bash/*"
103
104RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"
105