xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-extended/bash/bash.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunSUMMARY = "An sh-compatible command language interpreter"
2*4882a593SmuzhiyunHOMEPAGE = "http://tiswww.case.edu/php/chet/bash/bashtop.html"
3*4882a593SmuzhiyunDESCRIPTION = "Bash is the GNU Project's Bourne Again SHell, a complete implementation of the IEEE POSIX and Open Group shell specification with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features."
4*4882a593SmuzhiyunSECTION = "base/shell"
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunDEPENDS = "ncurses bison-native virtual/libiconv"
7*4882a593Smuzhiyun
8*4882a593Smuzhiyuninherit autotools gettext texinfo update-alternatives ptest
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunEXTRA_AUTORECONF += "--exclude=autoheader"
11*4882a593SmuzhiyunEXTRA_OECONF = "--enable-job-control --without-bash-malloc bash_cv_wexitstatus_offset=8"
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun# If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the
14*4882a593Smuzhiyun# startup files, even if they are not interactive.
15*4882a593Smuzhiyun# This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
16*4882a593SmuzhiyunCFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun# This can vary depending upon the host
19*4882a593SmuzhiyunCFLAGS += "-DHEREDOC_PIPESIZE=65536"
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun# Disable bracketed paste mode by default (enabled by default in bash 5.1). It
22*4882a593Smuzhiyun# causes a lot of garbage in non-interactive shells
23*4882a593SmuzhiyunCFLAGS += "-DBRACKETED_PASTE_DEFAULT=0"
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunALTERNATIVE:${PN} = "bash sh"
26*4882a593SmuzhiyunALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
27*4882a593SmuzhiyunALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
28*4882a593SmuzhiyunALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
29*4882a593SmuzhiyunALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
30*4882a593SmuzhiyunALTERNATIVE_PRIORITY = "100"
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunRDEPENDS:${PN} += "base-files"
33*4882a593SmuzhiyunRDEPENDS:${PN}:class-nativesdk = ""
34*4882a593SmuzhiyunRDEPENDS:${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunRDEPENDS:${PN}-ptest:append:libc-glibc = " \
37*4882a593Smuzhiyun	glibc-gconv-big5hkscs \
38*4882a593Smuzhiyun	glibc-gconv-iso8859-1 \
39*4882a593Smuzhiyun	glibc-utils \
40*4882a593Smuzhiyun	locale-base-de-de \
41*4882a593Smuzhiyun	locale-base-en-us \
42*4882a593Smuzhiyun	locale-base-fr-fr \
43*4882a593Smuzhiyun	locale-base-fr-fr.iso-8859-1 \
44*4882a593Smuzhiyun	locale-base-zh-hk.big5-hkscs \
45*4882a593Smuzhiyun	"
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunCACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
48*4882a593Smuzhiyun
49*4882a593Smuzhiyundo_configure:prepend () {
50*4882a593Smuzhiyun    if [ ! -e ${S}/acinclude.m4 ]; then
51*4882a593Smuzhiyun       cat ${S}/aclocal.m4 > ${S}/acinclude.m4
52*4882a593Smuzhiyun    fi
53*4882a593Smuzhiyun}
54*4882a593Smuzhiyun
55*4882a593Smuzhiyundo_compile:prepend() {
56*4882a593Smuzhiyun    # Remove any leftover .build files. This ensures that bash always has the
57*4882a593Smuzhiyun    # same version number and keeps builds reproducible
58*4882a593Smuzhiyun    rm -f ${B}/.build
59*4882a593Smuzhiyun}
60*4882a593Smuzhiyun
61*4882a593Smuzhiyundo_compile_ptest () {
62*4882a593Smuzhiyun	oe_runmake buildtest
63*4882a593Smuzhiyun}
64*4882a593Smuzhiyun
65*4882a593Smuzhiyundo_install:prepend () {
66*4882a593Smuzhiyun	# Ensure determinism as this counter increases for each make call
67*4882a593Smuzhiyun	rm -f ${B}/.build
68*4882a593Smuzhiyun}
69*4882a593Smuzhiyun
70*4882a593Smuzhiyundo_install:append () {
71*4882a593Smuzhiyun	# Move /usr/bin/bash to /bin/bash, if need
72*4882a593Smuzhiyun	if [ "${base_bindir}" != "${bindir}" ]; then
73*4882a593Smuzhiyun		mkdir -p ${D}${base_bindir}
74*4882a593Smuzhiyun		mv ${D}${bindir}/bash ${D}${base_bindir}
75*4882a593Smuzhiyun	fi
76*4882a593Smuzhiyun}
77*4882a593Smuzhiyundo_install:append:class-target () {
78*4882a593Smuzhiyun	# Clean buildhost references in bashbug
79*4882a593Smuzhiyun	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
80*4882a593Smuzhiyun		-e "s,-I${WORKDIR}/\S* ,,g" \
81*4882a593Smuzhiyun		-e 's|${DEBUG_PREFIX_MAP}||g' \
82*4882a593Smuzhiyun		${D}${bindir}/bashbug
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun	# Clean buildhost references in bash.pc
85*4882a593Smuzhiyun	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
86*4882a593Smuzhiyun	     ${D}${libdir}/pkgconfig/bash.pc
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun	# Clean buildhost references in Makefile.inc
89*4882a593Smuzhiyun	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
90*4882a593Smuzhiyun		-e 's|${DEBUG_PREFIX_MAP}||g' \
91*4882a593Smuzhiyun		-e 's:${HOSTTOOLS_DIR}/::g' \
92*4882a593Smuzhiyun		-e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
93*4882a593Smuzhiyun		${D}${libdir}/bash/Makefile.inc
94*4882a593Smuzhiyun}
95*4882a593Smuzhiyun
96*4882a593Smuzhiyundo_install_ptest () {
97*4882a593Smuzhiyun	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
98*4882a593Smuzhiyun	cp ${B}/Makefile ${D}${PTEST_PATH}
99*4882a593Smuzhiyun	cp ${B}/config.h ${D}${PTEST_PATH}
100*4882a593Smuzhiyun	cp ${B}/version.h ${D}${PTEST_PATH}
101*4882a593Smuzhiyun	cp ${S}/y.tab.[ch] ${D}${PTEST_PATH}
102*4882a593Smuzhiyun	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
103*4882a593Smuzhiyun        sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
104*4882a593Smuzhiyun	    -e 's|${DEBUG_PREFIX_MAP}||g' \
105*4882a593Smuzhiyun	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
106*4882a593Smuzhiyun	    -e 's:${HOSTTOOLS_DIR}/::g' \
107*4882a593Smuzhiyun	    -e 's:${UNINATIVE_LOADER}:${base_bindir}/false:g' \
108*4882a593Smuzhiyun	     ${D}${PTEST_PATH}/Makefile
109*4882a593Smuzhiyun}
110*4882a593Smuzhiyun# The uninative loader is different on i386 & x86_64 hosts. Since it is only
111*4882a593Smuzhiyun# being replaced with /bin/false anyway, it doesn't need to be part of the task
112*4882a593Smuzhiyun# hash
113*4882a593Smuzhiyundo_install_ptest[vardepsexclude] += "UNINATIVE_LOADER"
114*4882a593Smuzhiyun
115*4882a593Smuzhiyunpkg_postinst:${PN} () {
116*4882a593Smuzhiyun	grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
117*4882a593Smuzhiyun}
118*4882a593Smuzhiyun
119*4882a593Smuzhiyunpkg_postrm:${PN} () {
120*4882a593Smuzhiyun	printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
121*4882a593Smuzhiyun}
122*4882a593Smuzhiyun
123*4882a593SmuzhiyunPACKAGES += "${PN}-bashbug"
124*4882a593SmuzhiyunFILES:${PN} = "${bindir}/bash ${base_bindir}/bash.bash"
125*4882a593SmuzhiyunFILES:${PN}-bashbug = "${bindir}/bashbug"
126*4882a593Smuzhiyun
127*4882a593SmuzhiyunPACKAGE_BEFORE_PN += "${PN}-loadable"
128*4882a593SmuzhiyunRDEPENDS:${PN}-loadable += "${PN}"
129*4882a593SmuzhiyunFILES:${PN}-loadable += "${libdir}/bash/*"
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunRPROVIDES:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"
132