xref: /aosp_15_r20/external/icu/icu4c/build_qnx/build-hooks (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1# © 2023 and later: Unicode, Inc. and others.
2# License & terms of use: http://www.unicode.org/copyright.html
3function hook_preconfigure {
4	if [ "${TARGET_SYSNAME}" == "nto" ]; then
5# set the current directory for use in configure_opts
6		CURDIR="${PWD}"
7# prefix is the base path where files are installed in the target filesystem.  It is also
8# the base path for all architecture independent files
9		configure_opts="${configure_opts} --prefix=/usr"
10# exec-prefix is the base path for architecture dependent files.
11		configure_opts="${configure_opts} --exec-prefix=/${cpudir}/usr"
12		configure_opts="${configure_opts} --with-cross-build=${CURDIR}/../linux-x86_64-o"
13		configure_opts="${configure_opts} --with-data-packaging=auto"
14		configure_opts="${configure_opts} --srcdir=../../source"
15
16		CFLAGS="$CFLAGS -fPIC"
17		CPPFLAGS="$CPPFLAGS -fPIC"
18		CXXFLAGS="$CXXFLAGS -std=gnu++17"
19	else
20# prefix is the base path where architecture independent files are installed in the target filesystem
21		configure_opts="${configure_opts} --prefix=/"
22		configure_opts="${configure_opts} --srcdir=../../source"
23	fi
24}
25
26function hook_configure {
27    if [ -z "${ac_version}" ]; then
28        unset _guess
29        _pat='/[Gg]enerated.*[Aa]utoconf/s/.*\([1-9]\.[0-9][0-9]*\).*/\1/p'
30        [ "${_guess}" ] || _guess=$(../../source/configure --version | sed -n -e "${_pat}")
31        [ "${_guess}" ] || _guess=$(sed -n -e "1,10{
32            ${_pat}
33        }" <../../source/configure)
34        AutoconfVersion ${_guess}
35    fi
36    ../../source/configure \
37        ${ac_host:+"--host=${ac_host}"} \
38        ${ac_build:+"--build=${ac_build}"} \
39        ${configure_opts} \
40        ${ac_params:+${CC:+"CC=${CC}"}} \
41        ${ac_params:+${CFLAGS:+"CFLAGS=-O2 ${CFLAGS}"}} \
42        ${ac_params:+${CPPFLAGS:+"CPPFLAGS=${CPPFLAGS}"}} \
43        ${ac_params:+${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}} \
44        ${ac_params:+${CXX:+"CXX=${CXX}"}} \
45        ${ac_params:+${CXXFLAGS:+"CXXFLAGS=-O2 ${CXXFLAGS}"}} \
46        ${ac_params:+${ac_autotools:+${ac_autotools}}} \
47        || Error "configure failed";
48}
49
50
51function hook_premake {
52	if [ "${TARGET_SYSNAME}" == "nto" ]; then
53		DESTDIR=${DESTDIR:-${INSTALL_ROOT_nto}}
54		export DESTDIR
55	fi
56}
57
58function hook_postmake {
59	if [ "${TARGET_SYSNAME}" == "linux" ]; then
60		make -fMakefile config/icucross.mk
61		make -fMakefile config/icucross.inc
62	fi
63
64	if [ "${TARGET_SYSNAME}" == "nto" ]; then
65		if [ -e "data/out/tmp/icudt72l.dat" ]; then
66			cp -fv data/out/tmp/icudt72l.dat "${DESTDIR}/usr/share/icu/"
67		fi
68		cd test
69		JLEVEL=4 make all-recursive
70		cd -
71		mkdir -p ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test/testdata
72		mkdir -p ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/data/out
73		cp test/cintltst/cintltst ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
74		cp test/intltest/intltest ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
75		cp test/iotest/iotest ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
76		cp -r data/out/build ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/data/out
77		cp -r test/testdata/out ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test/testdata
78		cp -r ../../source/test/testdata ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test
79		cp -r ../../source/data ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/
80	fi
81}
82