Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clitic committed Nov 28, 2022
0 parents commit 6088706
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build/*
subprojects/glib/*
subprojects/libffi/*
subprojects/packagecache/*
subprojects/pcre2-10.40/*
subprojects/proxy-libintl/*
subprojects/zlib-1.2.11/*
subprojects/gvdb.wrap
subprojects/libffi.wrap
subprojects/pcre2.wrap
subprojects/proxy-libintl.wrap
subprojects/zlib.wrap
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "pkg-config"]
path = pkg-config
url = https://gitlab.freedesktop.org/pkg-config/pkg-config
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h1 align="center">pkg-config</h1>

<p align="center">
<a href="https://github.com/clitic/pkg-config">
<img src="https://img.shields.io/github/downloads/clitic/pkg-config/total?style=flat-square">
</a>
<a href="https://github.com/clitic/pkg-config">
<img src="https://img.shields.io/github/repo-size/clitic/pkg-config?logo=github&style=flat-square">
</a>
</p>

[pkg-config](https://gitlab.freedesktop.org/pkg-config/pkg-config) is a script to make putting together all the build flags when compiling/linking a lot easier. Visit [releases](https://github.com/clitic/pkg-config/releases) for prebuilt binaries. Extract archive and add `bin` directory in your `PATH` environment variable.

## Building

1. Install [meson](https://mesonbuild.com/SimpleStart.html) build system. Then install any one of these c compiler: [msvc](https://visualstudio.microsoft.com), [gcc](https://gcc.gnu.org), [mingw](https://www.mingw-w64.org/downloads) or [clang](https://github.com/llvm/llvm-project).

2. Now recursively clone pkg-config repository.

```bash
git clone https://github.com/clitic/pkg-config --recursive --depth 1
cd pkg-config
```

3. Now setup pkg-config using meson. Use `--prefix` flag to specify installation directory. For more meson options see [meson_options.txt](https://github.com/clitic/pkg-config/blob/main/meson_options.txt).

```bash
meson setup build --buildtype release --warnlevel 0 --default-library static --prefix c:/pkg-config -Dbuild-glib=true
```

4. Now install pkg-config using meson. The skipped subprojects are not needed at runtime if you still want to keep them, then remove `--skip-subprojects` flag.

```bash
meson install -C build --skip-subprojects "glib,libffi,pcre2,proxy-libintl,zlib"
```

5. Now pkg-config should be installed in your prefix directory. Now add `$PREFIX/bin` in your `PATH` environment variable. You can further read more information about building through meson from meson's quick [guide](https://mesonbuild.com/Quick-guide.html).
139 changes: 139 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
project(
'pkg-config',
'c',
version: '0.29.2',
license: 'GPL-2.0',
meson_version: '>=0.64.0'
)

cc = meson.get_compiler('c')
system = host_machine.system()

pkg_config_defines = []

system_include_path = get_option('system-include-path')

if system_include_path == 'auto' and system == 'windows'
pkg_config_defines += '-DPKG_CONFIG_SYSTEM_INCLUDE_PATH=""'
elif system_include_path == 'auto'
pkg_config_defines += '-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="/usr/include:/usr/local/include"'
else
pkg_config_defines += f'-DPKG_CONFIG_SYSTEM_INCLUDE_PATH="@system_include_path@"'
endif

system_library_path = get_option('system-library-path')

if system_library_path == 'auto' and system == 'windows'
pkg_config_defines += '-DPKG_CONFIG_SYSTEM_LIBRARY_PATH=""'
elif system_library_path == 'auto'
pkg_config_defines += '-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="/usr/lib:/usr/local/lib"'
else
pkg_config_defines += f'-DPKG_CONFIG_SYSTEM_LIBRARY_PATH="@system_library_path@"'
endif

pkg_config_defines += '-DENABLE_DEFINE_PREFIX=' + get_option('enable-define-prefix').to_int().to_string()
pkg_config_defines += '-DENABLE_INDIRECT_DEPS=' + get_option('enable-indirect-deps').to_int().to_string()

if cc.has_header('dirent.h')
pkg_config_defines += '-DHAVE_DIRENT_H'
endif

if cc.has_header('dlfcn.h')
pkg_config_defines += '-DHAVE_DLFCN_H'
endif

if cc.has_header('inttypes.h')
pkg_config_defines += '-DHAVE_INTTYPES_H'
endif

if cc.has_header('malloc.h')
pkg_config_defines += '-DHAVE_MALLOC_H'
endif

if cc.has_header('memory.h')
pkg_config_defines += '-DHAVE_MEMORY_H'
endif

if cc.has_header('stdint.h')
pkg_config_defines += '-DHAVE_STDINT_H'
endif

if cc.has_header('stdlib.h')
pkg_config_defines += '-DHAVE_STDLIB_H'
endif

if cc.has_header('strings.h')
pkg_config_defines += '-DHAVE_STRINGS_H'
endif

if cc.has_header('string.h')
pkg_config_defines += '-DHAVE_STRING_H'
endif

if cc.has_header('sys/stat.h')
pkg_config_defines += '-DHAVE_SYS_STAT_H'
endif

if cc.has_header('sys/types.h')
pkg_config_defines += '-DHAVE_SYS_TYPES_H'
endif

if cc.has_header('sys/wait.h')
pkg_config_defines += '-DHAVE_SYS_WAIT_H'
endif

if cc.has_header('unistd.h')
pkg_config_defines += '-DHAVE_UNISTD_H'
endif

pkg_config_defines += '-DLT_OBJDIR=".libs/"'
pkg_config_defines += '-DPACKAGE="@0@"'.format(meson.project_name())
pkg_config_defines += '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/pkg-config/pkg-config"'
pkg_config_defines += '-DPACKAGE_NAME="@0@"'.format(meson.project_name())
pkg_config_defines += '-DPACKAGE_STRING="@0@ @1@"'.format(meson.project_name(), meson.project_version())
pkg_config_defines += '-DPACKAGE_TARNAME="@0@-@1@"'.format(meson.project_name(), meson.project_version())
pkg_config_defines += '-DPACKAGE_URL="https://gitlab.freedesktop.org/pkg-config/pkg-config"'
pkg_config_defines += '-DPACKAGE_VERSION="@0@"'.format(meson.project_version())

if cc.has_header('stdlib.h')
pkg_config_defines += '-DSTDC_HEADERS'
endif

pkg_config_defines += '-DVERSION="@0@"'.format(meson.project_version())
pkg_config_defines += '-DDARWIN_USE_64_BIT_INODE=1'

libglib_dep = dependency('glib-2.0', required: false, static: get_option('static-glib'))

if not libglib_dep.found() or get_option('build-glib') == 'true'
glib = subproject('glib', default_options: ['tests=false'])
libglib_dep = glib.get_variable('libglib_dep')
endif

executable(
'pkg-config',
[
'pkg-config/pkg.h',
'pkg-config/pkg.c',
'pkg-config/parse.h',
'pkg-config/parse.c',
'pkg-config/rpmvercmp.c',
'pkg-config/rpmvercmp.h',
'pkg-config/main.c'
],
c_args: pkg_config_defines,
dependencies: libglib_dep,
install: true,
)

install_man('pkg-config/pkg-config.1')

install_data(
configure_file(
input: 'pkg-config/pkg.m4.in',
output: 'pkg.m4',
configuration: {
'VERSION': meson.project_version()
}
),
install_dir: get_option('datadir') / 'aclocal'
)
38 changes: 38 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
option(
'system-include-path',
type: 'string',
value: 'auto',
)

option(
'system-library-path',
type: 'string',
value: 'auto',
)

option(
'enable-define-prefix',
type: 'boolean',
value: true
)

option(
'enable-indirect-deps',
type: 'boolean',
value: true
)

option(
'build-glib',
type: 'combo',
choices: ['auto', 'true'],
value: 'auto',
description: 'build glib'
)

option(
'static-glib',
type: 'boolean',
value: false,
description: 'link pkg-config with static version of system glib'
)
1 change: 1 addition & 0 deletions pkg-config
Submodule pkg-config added at edf8e6
6 changes: 6 additions & 0 deletions subprojects/glib.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[wrap-git]
directory=glib
url=https://gitlab.gnome.org/GNOME/glib.git
push-url=ssh://git@gitlab.gnome.org:GNOME/glib.git
revision=2.75.0
depth=1

0 comments on commit 6088706

Please sign in to comment.