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