public function generatePackageDependenciesM4($contentM4)
    {
        $packageDependencies = $this->config->get('package-dependencies');
        if (\is_array($packageDependencies)) {
            $pkgconfigM4 = $this->backend->getTemplateFileContents('pkg-config.m4');
            $pkgconfigCheckM4 = $this->backend->getTemplateFileContents('pkg-config-check.m4');
            $extraCFlags = '';

            foreach ($packageDependencies as $pkg => $version) {
                $pkgM4Buf = $pkgconfigCheckM4;

                $operator = '=';
                $operatorCmd = '--exact-version';
                $ar = explode('=', $version);
                if (1 == \count($ar)) {
                    if ('*' == $version) {
                        $version = '0.0.0';
                        $operator = '>=';
                        $operatorCmd = '--atleast-version';
                    }
                } else {
                    switch ($ar[0]) {
                        case '<':
                            $operator = '<=';
                            $operatorCmd = '--max-version';
                            $version = trim($ar[1]);
                            break;
                        case '>':
                            $operator = '>=';
                            $operatorCmd = '--atleast-version';
                            $version = trim($ar[1]);
                            break;
                        default:
                            $version = trim($ar[1]);
                            break;
                    }
                }

                $toReplace = [
                    '%PACKAGE_LOWER%' => strtolower($pkg),
                    '%PACKAGE_UPPER%' => strtoupper($pkg),
                    '%PACKAGE_REQUESTED_VERSION%' => $operator.' '.$version,
                    '%PACKAGE_PKG_CONFIG_COMPARE_VERSION%' => $operatorCmd.'='.$version,
                ];

                foreach ($toReplace as $mark => $replace) {
                    $pkgM4Buf = str_replace($mark, $replace, $pkgM4Buf);
                }

                $pkgconfigM4 .= $pkgM4Buf;
                $extraCFlags .= '$PHP_'.strtoupper($pkg).'_INCS ';
            }
            $contentM4 = str_replace('%PROJECT_EXTRA_CFLAGS%', '%PROJECT_EXTRA_CFLAGS% '.$extraCFlags, $contentM4);

            $contentM4 = str_replace('%PROJECT_PACKAGE_DEPENDENCIES%', $pkgconfigM4, $contentM4);

            return $contentM4;
        }

        $contentM4 = str_replace('%PROJECT_PACKAGE_DEPENDENCIES%', '', $contentM4);

        return $contentM4;
    }