153a5a1b3Sopenharmony_ci#!/bin/bash
253a5a1b3Sopenharmony_ci
353a5a1b3Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
453a5a1b3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
553a5a1b3Sopenharmony_ci# you may not use this file except in compliance with the License.
653a5a1b3Sopenharmony_ci# You may obtain a copy of the License at
753a5a1b3Sopenharmony_ci#
853a5a1b3Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
953a5a1b3Sopenharmony_ci#
1053a5a1b3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1153a5a1b3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1253a5a1b3Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1353a5a1b3Sopenharmony_ci# See the License for the specific language governing permissions and
1453a5a1b3Sopenharmony_ci# limitations under the License.
1553a5a1b3Sopenharmony_ciset -e
1653a5a1b3Sopenharmony_ci
1753a5a1b3Sopenharmony_ciPASRC_PATH=$1
1853a5a1b3Sopenharmony_ciPASRC_OUT_PATH=$2
1953a5a1b3Sopenharmony_ci
2053a5a1b3Sopenharmony_cifunction clean_pa_src() {
2153a5a1b3Sopenharmony_ci    echo "Clean local generated files"
2253a5a1b3Sopenharmony_ci    rm -rf ABOUT-NLS Makefile Makefile.in PulseAudioConfig.cmake PulseAudioConfigVersion.cmake aclocal.m4
2353a5a1b3Sopenharmony_ci    rm -rf autom4te.cache/ build-aux/ config.h config.h.in config.h.in~ config.log config.status configure
2453a5a1b3Sopenharmony_ci    rm -rf libpulse-mainloop-glib.pc libpulse-simple.pc libpulse.pc libtool stamp-h1
2553a5a1b3Sopenharmony_ci}
2653a5a1b3Sopenharmony_ci
2753a5a1b3Sopenharmony_ciclean_pa_src
2853a5a1b3Sopenharmony_ci
2953a5a1b3Sopenharmony_cised -i 's/\.\/git-version-gen .tarball-version//g' configure.ac
3053a5a1b3Sopenharmony_cised -i 's/\[m4_esyscmd()\],//g' configure.ac
3153a5a1b3Sopenharmony_cised -i 's/src doxygen man po/src doxygen man #po/g' Makefile.am
3253a5a1b3Sopenharmony_ci
3353a5a1b3Sopenharmony_ciPA_CONFIG_OPTIONS="
3453a5a1b3Sopenharmony_ci    --without-caps
3553a5a1b3Sopenharmony_ci    --disable-alsa
3653a5a1b3Sopenharmony_ci    --disable-x11
3753a5a1b3Sopenharmony_ci    --disable-oss-output
3853a5a1b3Sopenharmony_ci    --disable-coreaudio-output
3953a5a1b3Sopenharmony_ci    --disable-alsa
4053a5a1b3Sopenharmony_ci    --disable-esound
4153a5a1b3Sopenharmony_ci    --disable-gsettings
4253a5a1b3Sopenharmony_ci    --disable-dbus
4353a5a1b3Sopenharmony_ci    --disable-udev
4453a5a1b3Sopenharmony_ci    --disable-ipv6
4553a5a1b3Sopenharmony_ci    --disable-openssl
4653a5a1b3Sopenharmony_ci    --disable-avahi
4753a5a1b3Sopenharmony_ci    --disable-jack
4853a5a1b3Sopenharmony_ci"
4953a5a1b3Sopenharmony_ci# We check for this here, because if pkg-config is not found in the
5053a5a1b3Sopenharmony_ci# system, it's likely that the pkg.m4 macro file is also not present,
5153a5a1b3Sopenharmony_ci# which will make PKG_PROG_PKG_CONFIG be undefined and the generated
5253a5a1b3Sopenharmony_ci# configure file faulty.
5353a5a1b3Sopenharmony_ciif ! pkg-config --version &>/dev/null; then
5453a5a1b3Sopenharmony_ci    echo "pkg-config is required to bootstrap this program"
5553a5a1b3Sopenharmony_ci
5653a5a1b3Sopenharmony_cifi
5753a5a1b3Sopenharmony_ci# Other necessary programs
5853a5a1b3Sopenharmony_ciif ! autopoint --version &>/dev/null ; then
5953a5a1b3Sopenharmony_ci    echo "autopoint is required to bootstrap this program"
6053a5a1b3Sopenharmony_ci
6153a5a1b3Sopenharmony_cifi
6253a5a1b3Sopenharmony_ci
6353a5a1b3Sopenharmony_ciautoreconf --force --install --verbose
6453a5a1b3Sopenharmony_ci
6553a5a1b3Sopenharmony_ciif test "x$NOCONFIGURE" = "x"; then
6653a5a1b3Sopenharmony_ci    CFLAGS="$CFLAGS -g -O0" $PASRC_PATH/configure --enable-force-preopen ${PA_CONFIG_OPTIONS} && \
6753a5a1b3Sopenharmony_ci        make clean
6853a5a1b3Sopenharmony_cifi
6953a5a1b3Sopenharmony_ci
7053a5a1b3Sopenharmony_cised -i 's/#define ENABLE_NLS 1//g' config.h
7153a5a1b3Sopenharmony_cised -i 's/#define HAVE_SHM_OPEN 1//g' config.h
7253a5a1b3Sopenharmony_cised -i 's/#define HAVE_RUNNING_FROM_BUILD_TREE 1//g' config.h
7353a5a1b3Sopenharmony_cised -i 's/#define HAVE_CPUID_H 1//g' config.h
7453a5a1b3Sopenharmony_cised -i 's/#define HAVE_EXECINFO_H 1//g' config.h
7553a5a1b3Sopenharmony_cised -i 's/#define HAVE_MEMFD 1//g' config.h
7653a5a1b3Sopenharmony_ciecho "#define PACKAGE_NAME \"pulseaudio\"" >> config.h
77