ICU-22363 Add support for QNX 7.1

Signed-off-by: James Choi <chachoi@blackberry.com>
diff --git a/.gitignore b/.gitignore
index 566ca39..e900461 100644
--- a/.gitignore
+++ b/.gitignore
@@ -279,3 +279,15 @@
 tools/unicode/c/genuca/genuca
 tools/unicode/c/genuca/genuca.8
 tools/unicode/c/icudefs.txt
+
+# QNX files
+icu4c/build_qnx/linux-x86_64-o/*
+icu4c/build_qnx/nto-aarch64-le/*
+icu4c/build_qnx/nto-x86_64-o/*
+!icu4c/build_qnx/linux-x86_64-o/GNUmakefile
+!icu4c/build_qnx/nto-aarch64-le/GNUmakefile
+!icu4c/build_qnx/nto-x86_64-o/GNUmakefile
+!icu4c/build_qnx/**/Makefile
+icu4c/build_qnx/linux-x86_64-o/Makefile
+icu4c/build_qnx/nto-aarch64-le/Makefile
+icu4c/build_qnx/nto-x86_64-o/Makefile
diff --git a/icu4c/build_qnx/Makefile b/icu4c/build_qnx/Makefile
new file mode 100755
index 0000000..0c7c61b
--- /dev/null
+++ b/icu4c/build_qnx/Makefile
@@ -0,0 +1,52 @@
+INSTALL_TARGETS =
+
+ifeq ($(strip $(CPULIST)),)
+  INSTALL_TARGETS += install-aarch64 install-x86_64
+else
+
+ifeq ($(filter aarch64,$(CPULIST)), aarch64)
+  INSTALL_TARGETS += install-aarch64
+endif
+
+ifeq ($(filter x86_64,$(CPULIST)), x86_64)
+  INSTALL_TARGETS += install-x86_64
+endif
+endif
+
+linux_CLEANFILES_LIST := $(filter-out linux-x86_64-o/GNUmakefile, $(wildcard linux-x86_64-o/*))
+aarch64_CLEANFILES_LIST := $(filter-out nto-aarch64-le/GNUmakefile, $(wildcard nto-aarch64-le/*))
+x86_64_CLEANFILES_LIST := $(filter-out nto-x86_64-o/GNUmakefile, $(wildcard nto-x86_64-o/*))
+
+all: install
+
+install: install-linux $(INSTALL_TARGETS)
+
+hinstall:
+
+clean: clean-linux clean-aarch64 clean-x86_64
+
+clean-linux:
+ifneq ($(strip $(linux_CLEANFILES_LIST)),)
+	rm -rf $(linux_CLEANFILES_LIST)
+endif
+
+clean-aarch64:
+ifneq ($(strip $(aarch64_CLEANFILES_LIST)),)
+	rm -rf $(aarch64_CLEANFILES_LIST)
+endif
+
+clean-x86_64:
+ifneq ($(strip $(x86_64_CLEANFILES_LIST)),)
+	rm -rf  $(x86_64_CLEANFILES_LIST)
+endif
+
+install-linux:
+	$(MAKE) -C linux-x86_64-o -f GNUmakefile
+
+install-aarch64: install-linux
+	$(MAKE) -C nto-aarch64-le -f GNUmakefile install
+
+install-x86_64: install-linux
+	$(MAKE) -C nto-x86_64-o -f GNUmakefile install
+
+
diff --git a/icu4c/build_qnx/build-hooks b/icu4c/build_qnx/build-hooks
new file mode 100755
index 0000000..85f82ce
--- /dev/null
+++ b/icu4c/build_qnx/build-hooks
@@ -0,0 +1,79 @@
+function hook_preconfigure {
+	if [ "${TARGET_SYSNAME}" == "nto" ]; then
+# set the current directory for use in configure_opts
+		CURDIR="${PWD}"
+# prefix is the base path where files are installed in the target filesystem.  It is also
+# the base path for all architecture independent files
+		configure_opts="${configure_opts} --prefix=/usr"
+# exec-prefix is the base path for architecture dependent files.
+		configure_opts="${configure_opts} --exec-prefix=/${cpudir}/usr"
+		configure_opts="${configure_opts} --with-cross-build=${CURDIR}/../linux-x86_64-o"
+		configure_opts="${configure_opts} --with-data-packaging=auto"
+		configure_opts="${configure_opts} --srcdir=../../source"
+
+		CFLAGS="$CFLAGS -fPIC"
+		CPPFLAGS="$CPPFLAGS -fPIC"
+		CXXFLAGS="$CXXFLAGS -std=gnu++11"
+	else
+# prefix is the base path where architecture independent files are installed in the target filesystem
+		configure_opts="${configure_opts} --prefix=/"
+		configure_opts="${configure_opts} --srcdir=../../source"
+	fi
+}
+
+function hook_configure {
+    if [ -z "${ac_version}" ]; then
+        unset _guess
+        _pat='/[Gg]enerated.*[Aa]utoconf/s/.*\([1-9]\.[0-9][0-9]*\).*/\1/p'
+        [ "${_guess}" ] || _guess=$(../../source/configure --version | sed -n -e "${_pat}")
+        [ "${_guess}" ] || _guess=$(sed -n -e "1,10{
+            ${_pat}
+        }" <../../source/configure)
+        AutoconfVersion ${_guess}
+    fi
+    ../../source/configure \
+        ${ac_host:+"--host=${ac_host}"} \
+        ${ac_build:+"--build=${ac_build}"} \
+        ${configure_opts} \
+        ${ac_params:+${CC:+"CC=${CC}"}} \
+        ${ac_params:+${CFLAGS:+"CFLAGS=-O2 ${CFLAGS}"}} \
+        ${ac_params:+${CPPFLAGS:+"CPPFLAGS=${CPPFLAGS}"}} \
+        ${ac_params:+${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}} \
+        ${ac_params:+${CXX:+"CXX=${CXX}"}} \
+        ${ac_params:+${CXXFLAGS:+"CXXFLAGS=-O2 ${CXXFLAGS}"}} \
+        ${ac_params:+${ac_autotools:+${ac_autotools}}} \
+        || Error "configure failed";
+}
+
+
+function hook_premake {
+	if [ "${TARGET_SYSNAME}" == "nto" ]; then
+		DESTDIR=${DESTDIR:-${INSTALL_ROOT_nto}}
+		export DESTDIR
+	fi
+}
+
+function hook_postmake {
+	if [ "${TARGET_SYSNAME}" == "linux" ]; then
+		make -fMakefile config/icucross.mk
+		make -fMakefile config/icucross.inc
+	fi
+
+	if [ "${TARGET_SYSNAME}" == "nto" ]; then
+		if [ -e "data/out/tmp/icudt72l.dat" ]; then
+			cp -fv data/out/tmp/icudt72l.dat "${DESTDIR}/usr/share/icu/"
+		fi
+		cd test
+		JLEVEL=4 make all-recursive
+		cd -
+		mkdir -p ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test/testdata
+		mkdir -p ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/data/out
+		cp test/cintltst/cintltst ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
+		cp test/intltest/intltest ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
+		cp test/iotest/iotest ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests
+		cp -r data/out/build ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/data/out
+		cp -r test/testdata/out ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test/testdata
+		cp -r ../../source/test/testdata ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/test
+		cp -r ../../source/data ${INSTALL_ROOT_nto}/${cpudir}/usr/bin/icu_tests/
+	fi
+}
diff --git a/icu4c/build_qnx/linux-x86_64-o/GNUmakefile b/icu4c/build_qnx/linux-x86_64-o/GNUmakefile
new file mode 100755
index 0000000..d5e18a7
--- /dev/null
+++ b/icu4c/build_qnx/linux-x86_64-o/GNUmakefile
@@ -0,0 +1,6 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+include $(MKFILES_ROOT)/qmake-cfg.mk
diff --git a/icu4c/build_qnx/nto-aarch64-le/GNUmakefile b/icu4c/build_qnx/nto-aarch64-le/GNUmakefile
new file mode 100755
index 0000000..d5e18a7
--- /dev/null
+++ b/icu4c/build_qnx/nto-aarch64-le/GNUmakefile
@@ -0,0 +1,6 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+include $(MKFILES_ROOT)/qmake-cfg.mk
diff --git a/icu4c/build_qnx/nto-x86_64-o/GNUmakefile b/icu4c/build_qnx/nto-x86_64-o/GNUmakefile
new file mode 100755
index 0000000..d5e18a7
--- /dev/null
+++ b/icu4c/build_qnx/nto-x86_64-o/GNUmakefile
@@ -0,0 +1,6 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+include $(MKFILES_ROOT)/qmake-cfg.mk
diff --git a/icu4c/source/configure b/icu4c/source/configure
index 8d3828e..e161e11 100755
--- a/icu4c/source/configure
+++ b/icu4c/source/configure
@@ -5867,6 +5867,10 @@
   AR="$ac_cv_prog_AR"
 fi
 
+if [ -n "$QNX_TARGET" ]; then
+  AR="x86_64-linux-gnu-ar"
+  RANLIB=""x86_64-linux-gnu-ranlib
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable renaming of symbols" >&5
 $as_echo_n "checking whether to enable renaming of symbols... " >&6; }
diff --git a/icu4c/source/test/cintltst/Makefile.in b/icu4c/source/test/cintltst/Makefile.in
index 6516fb1..5c0fb8f 100644
--- a/icu4c/source/test/cintltst/Makefile.in
+++ b/icu4c/source/test/cintltst/Makefile.in
@@ -36,7 +36,11 @@
 
 # we define ICU_UNICODE_VERSION so we can test it
 CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil
+ifdef QNX_TARGET
+DEFS += -D'ICU_UNICODE_VERSION="$(UNICODE_VERSION)"' -D'ICU_VERSION="@VERSION@"' -D'ICUDATA_NAME="$(ICUDATA_PLATFORM_NAME)"' -D'U_TOPSRCDIR="/var/icu_tests"' -D'U_TOPBUILDDIR="/var/icu_tests/"'
+else
 DEFS += -D'ICU_UNICODE_VERSION="$(UNICODE_VERSION)"' -D'ICU_VERSION="@VERSION@"' -D'ICUDATA_NAME="$(ICUDATA_PLATFORM_NAME)"' -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
+endif
 LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUTOOLUTIL) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
 
 OBJECTS = callcoll.o calltest.o capitst.o cbiapts.o cbkittst.o \
diff --git a/icu4c/source/test/intltest/Makefile.in b/icu4c/source/test/intltest/Makefile.in
index f57f8d9..af3493d 100644
--- a/icu4c/source/test/intltest/Makefile.in
+++ b/icu4c/source/test/intltest/Makefile.in
@@ -36,7 +36,11 @@
 
 CPPFLAGS += -I$(srcdir) -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/tools/ctestfw
 CPPFLAGS += -DUNISTR_FROM_CHAR_EXPLICIT= -DUNISTR_FROM_STRING_EXPLICIT= -DUCHAR_TYPE=char16_t
+ifdef QNX_TARGET
+DEFS += -D'U_TOPSRCDIR="/var/icu_tests"' -D'U_TOPBUILDDIR="/var/icu_tests/"'
+else
 DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
+endif
 LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M) $(LIB_THREAD)
 
 OBJECTS = aliastst.o allcoll.o apicoll.o astrotst.o callimts.o calregts.o caltest.o \
diff --git a/icu4c/source/test/iotest/Makefile.in b/icu4c/source/test/iotest/Makefile.in
index 9d2b94c..16c510f 100644
--- a/icu4c/source/test/iotest/Makefile.in
+++ b/icu4c/source/test/iotest/Makefile.in
@@ -36,7 +36,11 @@
 
 CPPFLAGS += -I$(srcdir) -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/io
 CPPFLAGS += -DUNISTR_FROM_CHAR_EXPLICIT= -DUNISTR_FROM_STRING_EXPLICIT=
+ifdef QNX_TARGET
+DEFS += -D'U_TOPSRCDIR="/var/icu_tests"' -D'U_TOPBUILDDIR="/var/icu_tests/"'
+else
 DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
+endif
 LIBS = $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(LIBICUIO) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
 
 OBJECTS = iotest.o stream.o strtst.o filetst.o trnstst.o