meson.build 5.69 KB
Newer Older
Guido Gunther's avatar
Guido Gunther committed
1 2 3 4 5 6 7 8 9
libhandy_header_subdir = join_paths(package_subdir, 'libhandy-' + apiversion)
libhandy_header_dir = join_paths(get_option('includedir'), libhandy_header_subdir)
libhandy_resources = gnome.compile_resources(
   'hdy-resources',
   'handy.gresources.xml',

   c_name: 'hdy',
)

10
hdy_enum_headers = ['hdy-arrows.h',
11
                    'hdy-fold.h',
12 13
                    'hdy-leaflet.h',
                   ]
Guido Gunther's avatar
Guido Gunther committed
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

version_data = configuration_data()
version_data.set('HDY_MAJOR_VERSION', handy_version_major)
version_data.set('HDY_MINOR_VERSION', handy_version_minor)
version_data.set('HDY_MICRO_VERSION', handy_version_micro)
version_data.set('HDY_VERSION', meson.project_version())

hdy_version_h = configure_file(
           input: 'hdy-version.h.in',
          output: 'hdy-version.h',
     install_dir: libhandy_header_dir,
         install: true,
   configuration: version_data)

libhandy_generated_headers = [
]

install_headers(['handy.h'],
  subdir: libhandy_header_subdir)

# Filled out in the subdirs
libhandy_public_headers = []
libhandy_public_sources = []
libhandy_private_sources = []

39 40 41 42 43 44 45 46 47 48 49
hdy_enums = gnome.mkenums('hdy-enums',
      h_template: 'hdy-enums.h.in',
      c_template: 'hdy-enums.c.in',
         sources: hdy_enum_headers,
  install_header: true,
     install_dir: libhandy_header_dir,
)

libhandy_public_sources += [hdy_enums[0]]
libhandy_generated_headers += [hdy_enums[1]]

Guido Gunther's avatar
Guido Gunther committed
50
src_headers = [
Adrien Plazas's avatar
Adrien Plazas committed
51
  'hdy-action-row.h',
Guido Gunther's avatar
Guido Gunther committed
52
  'hdy-arrows.h',
Adrien Plazas's avatar
Adrien Plazas committed
53
  'hdy-column.h',
Adrien Plazas's avatar
Adrien Plazas committed
54
  'hdy-combo-row.h',
Guido Gunther's avatar
Guido Gunther committed
55
  'hdy-dialer-button.h',
Guido Gunther's avatar
Guido Gunther committed
56
  'hdy-dialer-cycle-button.h',
Guido Gunther's avatar
Guido Gunther committed
57
  'hdy-dialer.h',
58
  'hdy-dialog.h',
Adrien Plazas's avatar
Adrien Plazas committed
59
  'hdy-enum-value-object.h',
Adrien Plazas's avatar
Adrien Plazas committed
60
  'hdy-expander-row.h',
Adrien Plazas's avatar
Adrien Plazas committed
61
  'hdy-fold.h',
Adrien Plazas's avatar
Adrien Plazas committed
62
  'hdy-header-group.h',
Adrien Plazas's avatar
Adrien Plazas committed
63
  'hdy-leaflet.h',
64
  'hdy-list-box.h',
Guido Gunther's avatar
Guido Gunther committed
65
  'hdy-main.h',
Adrien Plazas's avatar
Adrien Plazas committed
66
  'hdy-search-bar.h',
67
  'hdy-string-utf8.h',
Adrien Plazas's avatar
Adrien Plazas committed
68
  'hdy-title-bar.h',
69
  'hdy-value-object.h',
Guido Gunther's avatar
Guido Gunther committed
70 71
]

72 73 74 75 76 77 78 79 80 81
sed = find_program('sed', required: true)
gen_public_types = find_program('gen-public-types.sh', required: true)

libhandy_init_public_types = custom_target('hdy-public-types.c',
  output : 'hdy-public-types.c',
  input : [src_headers, libhandy_generated_headers],
  command : [gen_public_types, '@INPUT@'],
  capture: true,
)

Guido Gunther's avatar
Guido Gunther committed
82
src_sources = [
Adrien Plazas's avatar
Adrien Plazas committed
83
  'gtkprogresstracker.c',
Adrien Plazas's avatar
Adrien Plazas committed
84
  'hdy-action-row.c',
Guido Gunther's avatar
Guido Gunther committed
85
  'hdy-arrows.c',
Adrien Plazas's avatar
Adrien Plazas committed
86
  'hdy-column.c',
Adrien Plazas's avatar
Adrien Plazas committed
87
  'hdy-combo-row.c',
Guido Gunther's avatar
Guido Gunther committed
88
  'hdy-dialer-button.c',
Guido Gunther's avatar
Guido Gunther committed
89
  'hdy-dialer-cycle-button.c',
Guido Gunther's avatar
Guido Gunther committed
90
  'hdy-dialer.c',
91
  'hdy-dialog.c',
Adrien Plazas's avatar
Adrien Plazas committed
92
  'hdy-enum-value-object.c',
Adrien Plazas's avatar
Adrien Plazas committed
93
  'hdy-expander-row.c',
Adrien Plazas's avatar
Adrien Plazas committed
94
  'hdy-fold.c',
Adrien Plazas's avatar
Adrien Plazas committed
95
  'hdy-header-group.c',
Adrien Plazas's avatar
Adrien Plazas committed
96
  'hdy-leaflet.c',
97
  'hdy-list-box.c',
Guido Gunther's avatar
Guido Gunther committed
98
  'hdy-main.c',
Adrien Plazas's avatar
Adrien Plazas committed
99
  'hdy-search-bar.c',
100
  'hdy-string-utf8.c',
Adrien Plazas's avatar
Adrien Plazas committed
101
  'hdy-title-bar.c',
102
  'hdy-value-object.c',
Guido Gunther's avatar
Guido Gunther committed
103 104 105 106 107
]

libhandy_public_headers += files(src_headers)
libhandy_public_sources += files(src_sources)

108
install_headers(src_headers, subdir: libhandy_header_subdir)
Guido Gunther's avatar
Guido Gunther committed
109 110 111 112 113 114 115


libhandy_sources = [
  libhandy_generated_headers,
  libhandy_public_sources,
  libhandy_private_sources,
  libhandy_resources,
116
  libhandy_init_public_types,
Guido Gunther's avatar
Guido Gunther committed
117 118
]

119 120
glib_min_version = '>= 2.44'

Guido Gunther's avatar
Guido Gunther committed
121
libhandy_deps = [
122 123 124
  dependency('glib-2.0', version: glib_min_version),
  dependency('gio-2.0', version: glib_min_version),
  dependency('gmodule-2.0', version: glib_min_version),
125
  dependency('gtk+-3.0', version: '>= 3.24.1'),
Guido Gunther's avatar
Guido Gunther committed
126 127 128 129
  cc.find_library('m', required: false),
  cc.find_library('rt', required: false),
]

130
libhandy_c_args = []
131
libhandy_link_args = []
132
libhandy_symbols_file = 'libhandy.syms'
133 134 135

# Check linker flags
ld_version_script_arg = '-Wl,--version-script,@0@/@1@'.format(meson.source_root(),
136
                                                              libhandy_symbols_file)
137 138 139
if cc.links('int main() { return 0; }', args : ld_version_script_arg, name : 'ld_supports_version_script')
  libhandy_link_args += [ld_version_script_arg]
endif
140

141 142 143 144 145 146 147
static = get_option('static')
if static
  libtype = 'static_library'
else
  libtype = 'shared_library'
endif

148 149 150 151 152 153 154
# set default libdir on win32 for libhandy target to keep MinGW compatibility
if target_system == 'windows'
  handy_libdir = [true]
else
  handy_libdir = libdir
endif

155
libhandy = build_target(
Guido Gunther's avatar
Guido Gunther committed
156 157 158 159
  'handy-' + apiversion,
  libhandy_sources,

            soversion: 0,
160
               c_args: libhandy_c_args,
Guido Gunther's avatar
Guido Gunther committed
161 162 163
         dependencies: libhandy_deps,
  include_directories: [ root_inc, src_inc ],
              install: true,
164
            link_args: libhandy_link_args,
165
          install_dir: handy_libdir,
166
          target_type: libtype,
Guido Gunther's avatar
Guido Gunther committed
167 168 169
)

libhandy_dep = declare_dependency(
170
              sources: libhandy_generated_headers,
Guido Gunther's avatar
Guido Gunther committed
171 172 173 174 175
         dependencies: libhandy_deps,
            link_with: libhandy,
  include_directories: include_directories('.'),
)

176
if introspection
Guido Gunther's avatar
Guido Gunther committed
177 178 179 180 181

   libhandy_gir = gnome.generate_gir(libhandy,
                 sources: libhandy_generated_headers + libhandy_public_headers + libhandy_public_sources,
               nsversion: apiversion,
               namespace: 'Handy',
182
               export_packages: 'libhandy-0.0',
Guido Gunther's avatar
Guido Gunther committed
183 184 185 186 187 188 189
           symbol_prefix: 'hdy',
       identifier_prefix: 'Hdy',
               link_with: libhandy,
                includes: ['Gio-2.0', 'Gtk-3.0'],
                 install: true,
         install_dir_gir: girdir,
     install_dir_typelib: typelibdir,
190
              extra_args: [ '--c-include=handy.h', '--quiet' ],
Guido Gunther's avatar
Guido Gunther committed
191 192
   )

193
   if get_option('vapi')
Guido Gunther's avatar
Guido Gunther committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

     libhandy_vapi = gnome.generate_vapi('libhandy-' + apiversion,
             sources: libhandy_gir[0],
            packages: [ 'gio-2.0', 'gtk+-3.0' ],
             install: true,
         install_dir: vapidir,
       metadata_dirs: [ meson.current_source_dir() ],
     )

   endif
endif

pkgg = import('pkgconfig')

pkgg.generate(
    libraries: [libhandy],
      subdirs: libhandy_header_subdir,
      version: meson.project_version(),
         name: 'Handy',
     filebase: 'libhandy-@0@'.format(apiversion),
  description: 'Handy Mobile widgets',
     requires: 'gtk+-3.0',
  install_dir: join_paths(libdir, 'pkgconfig'),
)