aboutsummaryrefslogtreecommitdiff
path: root/libpkgconf/buildfile
blob: a2f9427dfb94613c655c3d0fb8dc8dfebfaf8a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# file      : libpkgconf/buildfile
# copyright : Copyright (c) 2016-2017 Code Synthesis Ltd
# license   : ISC; see accompanying COPYING file

lib{pkgconf}: {h c}{* -version} {h}{version}

# See bootstrap.build for details.
#
if $version.pre_release
  lib{pkgconf}: bin.lib.version = @"-$version.project_id"
else
  lib{pkgconf}: bin.lib.version = @"-$release_num"

# The version file is an internal one (it is only included from config.h) so we
# don't distribute nor install it (see below).
#
h{version}: in{version} $src_root/file{manifest}

tclass = $c.target.class
tsys   = $c.target.system

# Define the PKG_DEFAULT_PATH, SYSTEM_INCLUDEDIR and SYSTEM_LIBDIR macros.
# The whole idea feels utterly broken (hello cross-compilation) so we will
# just do bare minimum and wait and see.
#
# @@ We should probably allow to configure these macros via configuration
#    variables config.pkgconfig.pkg_default_path and alike.
#
if ($tclass == "windows")
{
  inc_dirs = ""
  lib_dirs = ""

  # Note that on Windows PKG_DEFAULT_PATH macros is internally redefined as
  # "../lib/pkgconfig;../share/pkgconfig" and is used as a fallback. Normally
  # the default path is relative to the program's (that link the library)
  # directory and has the following format:
  #
  # <dir>/../lib/pkgconfig;<dir>/../share/pkgconfig
  #
  # So we keep it empty.
  #
  def_paths = ""
}
else
{
  inc_dirs = "/usr/include"
  lib_dirs = "/usr/lib"

  def_dirs = ($install.root != [null] \
              ? "$install.resolve($install.pkgconfig)" \
              : "")
}

c.poptions += -DPKG_DEFAULT_PATH=\"$def_dirs\" \
              -DSYSTEM_INCLUDEDIR=\"$inc_dirs\"  \
              -DSYSTEM_LIBDIR=\"$lib_dirs\"

# Disable warnings.
#
if ($tsys == "win32-msvc")
  c.coptions += /wd4996 /wd4267

if ($tclass == "windows")
{
  # See libpkgconf/libpkgconf-api.h for details.
  #
  objs{*}: c.poptions += -DLIBPKGCONF_EXPORT
  obja{*}: c.poptions += -DPKGCONFIG_IS_STATIC

  if ($tsys == "mingw32")
    c.libs += -ladvapi32
  else
    c.libs += advapi32.lib
}

c.poptions =+ "-I$out_root" "-I$src_root"

lib{pkgconf}:  cc.export.poptions = "-I$src_root"
liba{pkgconf}: cc.export.poptions += -DPKGCONFIG_IS_STATIC

# In the original package the source files are compiled with -std=gnu99 option
# to allow some GNU deviations from the ISO C99 standard. We will compile with
# -std=c9x option (is implied by c.std=99 in root.build) and define _GNU_SOURCE
# for the source files that require such deviations.
#
# We will also re-enable definitions of POSIX macros (specifically PATH_MAX)
# that are disabled by -std=c9x.
#
if ($tclass != "windows")
{
  # On FreeBSD and MacOS -D_POSIX_C_SOURCE disables declarations of strndup(),
  # strlcpy() and alike, that are not POSIX. Not very consistent given that
  # they are also not C99. Luckily, -std=c9x doesn't disable PATH_MAX on these
  # OSes, so we just don't define the macro for them.
  #
  # @@ It all becomes a bit hairy. Should we just undefine the corresponding
  #    HAVE_* macros in config.h, so the custom function implementations are
  #    picked up? Alternatively, can we stop specifying the C standard and
  #    defining _POSIX_C_SOURCE macro altogether?
  #
  if ($tclass != "bsd" && $tclass != "macos")
    c.poptions += -D_POSIX_C_SOURCE=200112L

  obj{client fragment path pkg queue tuple}: c.poptions += -D_GNU_SOURCE
}

# Install into the pkgconf/libpkgconf/ subdirectory of, say, /usr/include/.
# Also make sure Cflags is properly set in .pc files to pkgconfig/.
#
{h}{*}: install = include/$project/
install.include = $install.include/pkgconf/

# For the original package config.h is generated during the configuration
# phase. We distribute a custom one with a minimal set of macro definitions
# required to build the project. Note that the file is an internal one (is
# only included from C files) and so is not installed.
#
h{config}@./: install = false

# Internal header (see above).
#
h{version}: install = false

# Implementation details.
#
h{stdinc}@./:     install = false
h{win-dirent}@./: install = false