blob: 811743574b25892cd5cb591d24975117b5ea4c69 [file] [log] [blame]
Alec Thileniusf79f52b2017-12-22 12:10:17 -07001project('mosys', 'c')
2
3# Include common. This is passed to all subdir build files as well
4include_common = include_directories(['include'])
5
6# Config data used for creating a config header and including it
7conf_data = configuration_data()
8
9# Set for all platforms
10conf_data.set('PROGRAM', '"mosys"')
11conf_data.set('VERSION', '"1.2.03"')
12conf_data.set('CONFIG_LITTLE_ENDIAN', 1)
13conf_data.set('CONFIG_LOGLEVEL', 4)
14conf_data.set('CONFIG_PLATFORM_EXPERIMENTAL', 1)
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060015use_cros_config = get_option('use_cros_config') == true
Alec Thileniusf79f52b2017-12-22 12:10:17 -070016if use_cros_config
17 conf_data.set('CONFIG_CROS_CONFIG', 1)
18endif
19
20# Setting on a per-arch basis
21arch = get_option('arch')
22if arch == 'x86' or arch == 'x86_64' or arch == 'amd64'
Alec Thileniusf79f52b2017-12-22 12:10:17 -070023 conf_data.set('CONFIG_PLATFORM_ARCH_X86', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070024elif arch == 'mip'
25 conf_data.set('CONFIG_PLATFORM_ARCH_MIPSEL', 1)
26elif arch == 'arm'
Alec Thileniusf79f52b2017-12-22 12:10:17 -070027 conf_data.set('CONFIG_PLATFORM_ARCH_ARMEL', 1)
Alec Thileniusf79f52b2017-12-22 12:10:17 -070028endif
29
30# Create the config header file and include it by default while compiling
31configure_file(
32 output : 'config.h',
33 configuration : conf_data,
34)
35add_global_arguments('-include', 'config.h', language: 'c')
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060036add_global_arguments('-std=gnu99', language : 'c')
Alec Thileniusf79f52b2017-12-22 12:10:17 -070037
Brian Norrise11e08f2018-04-30 10:46:48 -070038cc = meson.get_compiler('c')
39if (cc.has_argument('-Wno-address-of-packed-member'))
40 add_global_arguments(['-Wno-address-of-packed-member'], language: 'c')
41endif
Brian Norris402d8322018-04-30 14:22:51 -070042add_global_arguments('-Werror', language : 'c')
Brian Norrise11e08f2018-04-30 10:46:48 -070043
Alec Thileniusf79f52b2017-12-22 12:10:17 -070044# External libs used by Mosys
45fmap_dep = dependency('fmap')
46uuid_dep = dependency('uuid')
47
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060048libmosys_src = files()
49
Alec Thileniusf79f52b2017-12-22 12:10:17 -070050# Subdirs with source to link against
51subdir('core')
52subdir('drivers')
53subdir('intf')
54subdir('lib')
55subdir('platform')
56
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060057deps = [
58 fmap_dep,
59 uuid_dep,
60]
61link_whole = []
Jason D. Clintona236cdf2018-04-22 18:32:02 -060062objects = []
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060063
64# Cros config is a special snowflake.
65if use_cros_config
66 libmosys_src += mosys_lib_cros_config_src
67 fdt_dep = meson.get_compiler('c').find_library('fdt')
68 deps += fdt_dep
69 dtb_lib = static_library(
70 'cros_config_dtb',
71 cros_config_dtb_src,
72 c_args: [
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060073 '-D__ASSEMBLY__',
74 '-c',
75 ],
76 link_args: [
77 '-znoexecstack',
78 '-r',
79 ],
80 )
81 link_whole += dtb_lib
Jason D. Clintona236cdf2018-04-22 18:32:02 -060082 objects = dtb_lib.extract_all_objects()
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060083endif
84
Alec Thileniusf79f52b2017-12-22 12:10:17 -070085# Lib momsys shared library target
86libmosys = static_library(
87 'mosys',
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060088 libmosys_src,
89 dependencies: deps,
Alec Thileniusf79f52b2017-12-22 12:10:17 -070090 include_directories: include_common,
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060091 link_whole: link_whole,
Jason D. Clintona236cdf2018-04-22 18:32:02 -060092 objects: objects,
Jason D. Clinton3a2b39c2018-04-16 11:42:49 -060093 pic: true,
Alec Thileniusf79f52b2017-12-22 12:10:17 -070094)
95
96# Add static linking if static is set
97link_args = []
Jason D. Clintona7fd67d2018-04-17 13:34:08 -060098if get_option('static') == true
Alec Thileniusf79f52b2017-12-22 12:10:17 -070099 link_args += '-static'
100endif
101
102# Mosys dynamic executable
103executable(
104 'mosys',
105 ['mosys.c'],
106 include_directories: include_common,
107 link_args: link_args,
108 link_with: [libmosys],
109 install: true,
110 install_dir: '/usr/sbin',
111)
112
113# Mosys static executable. This will be removed by the ebuild if static is not
114# set, but is always built and installed first.
115executable(
116 'mosys_s',
117 ['mosys.c'],
118 include_directories: include_common,
119 link_args: ['-static'],
120 link_with: [libmosys],
121 install: true,
122 install_dir: '/usr/sbin',
123)