Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 1 | project('mosys', 'c') |
| 2 | |
| 3 | # Include common. This is passed to all subdir build files as well |
| 4 | include_common = include_directories(['include']) |
| 5 | |
| 6 | # Config data used for creating a config header and including it |
| 7 | conf_data = configuration_data() |
| 8 | |
| 9 | # Set for all platforms |
| 10 | conf_data.set('PROGRAM', '"mosys"') |
| 11 | conf_data.set('VERSION', '"1.2.03"') |
| 12 | conf_data.set('CONFIG_LITTLE_ENDIAN', 1) |
| 13 | conf_data.set('CONFIG_LOGLEVEL', 4) |
| 14 | conf_data.set('CONFIG_PLATFORM_EXPERIMENTAL', 1) |
Jason D. Clinton | a7fd67d | 2018-04-17 13:34:08 -0600 | [diff] [blame] | 15 | use_cros_config = get_option('use_cros_config') == true |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 16 | if use_cros_config |
| 17 | conf_data.set('CONFIG_CROS_CONFIG', 1) |
| 18 | endif |
| 19 | |
| 20 | # Setting on a per-arch basis |
| 21 | arch = get_option('arch') |
| 22 | if arch == 'x86' or arch == 'x86_64' or arch == 'amd64' |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 23 | conf_data.set('CONFIG_PLATFORM_ARCH_X86', 1) |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 24 | elif arch == 'mip' |
| 25 | conf_data.set('CONFIG_PLATFORM_ARCH_MIPSEL', 1) |
Paul Kocialkowski | 8cc37a3 | 2018-06-02 22:18:00 +0200 | [diff] [blame] | 26 | elif arch == 'arm' or arch == 'arm64' |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 27 | conf_data.set('CONFIG_PLATFORM_ARCH_ARMEL', 1) |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 28 | endif |
| 29 | |
| 30 | # Create the config header file and include it by default while compiling |
| 31 | configure_file( |
| 32 | output : 'config.h', |
| 33 | configuration : conf_data, |
| 34 | ) |
| 35 | add_global_arguments('-include', 'config.h', language: 'c') |
Jason D. Clinton | a7fd67d | 2018-04-17 13:34:08 -0600 | [diff] [blame] | 36 | add_global_arguments('-std=gnu99', language : 'c') |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 37 | |
Brian Norris | e11e08f | 2018-04-30 10:46:48 -0700 | [diff] [blame] | 38 | cc = meson.get_compiler('c') |
| 39 | if (cc.has_argument('-Wno-address-of-packed-member')) |
| 40 | add_global_arguments(['-Wno-address-of-packed-member'], language: 'c') |
| 41 | endif |
Jason D. Clinton | 4f88fa3 | 2018-08-29 15:34:26 -0600 | [diff] [blame^] | 42 | add_global_arguments('-Wall', language : 'c') |
Brian Norris | 402d832 | 2018-04-30 14:22:51 -0700 | [diff] [blame] | 43 | add_global_arguments('-Werror', language : 'c') |
Jason D. Clinton | 4f88fa3 | 2018-08-29 15:34:26 -0600 | [diff] [blame^] | 44 | add_global_arguments('-Wstrict-prototypes', language : 'c') |
| 45 | add_global_arguments('-Wundef', language : 'c') |
Brian Norris | e11e08f | 2018-04-30 10:46:48 -0700 | [diff] [blame] | 46 | |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 47 | # External libs used by Mosys |
| 48 | fmap_dep = dependency('fmap') |
| 49 | uuid_dep = dependency('uuid') |
| 50 | |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 51 | libmosys_src = files() |
| 52 | |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 53 | # Subdirs with source to link against |
| 54 | subdir('core') |
| 55 | subdir('drivers') |
| 56 | subdir('intf') |
| 57 | subdir('lib') |
| 58 | subdir('platform') |
| 59 | |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 60 | deps = [ |
| 61 | fmap_dep, |
| 62 | uuid_dep, |
| 63 | ] |
| 64 | link_whole = [] |
Jason D. Clinton | a236cdf | 2018-04-22 18:32:02 -0600 | [diff] [blame] | 65 | objects = [] |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 66 | |
| 67 | # Cros config is a special snowflake. |
| 68 | if use_cros_config |
| 69 | libmosys_src += mosys_lib_cros_config_src |
| 70 | fdt_dep = meson.get_compiler('c').find_library('fdt') |
| 71 | deps += fdt_dep |
| 72 | dtb_lib = static_library( |
| 73 | 'cros_config_dtb', |
| 74 | cros_config_dtb_src, |
| 75 | c_args: [ |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 76 | '-D__ASSEMBLY__', |
| 77 | '-c', |
| 78 | ], |
| 79 | link_args: [ |
| 80 | '-znoexecstack', |
| 81 | '-r', |
| 82 | ], |
| 83 | ) |
| 84 | link_whole += dtb_lib |
Jason D. Clinton | a236cdf | 2018-04-22 18:32:02 -0600 | [diff] [blame] | 85 | objects = dtb_lib.extract_all_objects() |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 86 | endif |
| 87 | |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 88 | # Lib momsys shared library target |
| 89 | libmosys = static_library( |
| 90 | 'mosys', |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 91 | libmosys_src, |
| 92 | dependencies: deps, |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 93 | include_directories: include_common, |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 94 | link_whole: link_whole, |
Jason D. Clinton | a236cdf | 2018-04-22 18:32:02 -0600 | [diff] [blame] | 95 | objects: objects, |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 96 | pic: true, |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 97 | ) |