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' |
| 23 | conf_data.set('CONFIG_CHIPSET_INTEL', 1) |
| 24 | conf_data.set('CONFIG_CHIPSET_INTEL_LYNXPOINT_LP', 1) |
| 25 | conf_data.set('CONFIG_CHIPSET_INTEL_NM10', 1) |
| 26 | conf_data.set('CONFIG_CHIPSET_INTEL_SERIES6', 1) |
| 27 | conf_data.set('CONFIG_CROS_EC', 1) |
| 28 | conf_data.set('CONFIG_CROS_EC_LPC', 1) |
| 29 | conf_data.set('CONFIG_EC_ENE_KB932', 1) |
| 30 | conf_data.set('CONFIG_EC_ITE_IT8500', 1) |
| 31 | conf_data.set('CONFIG_EC_NUVOTON_NPCE781', 1) |
| 32 | conf_data.set('CONFIG_EC_SMSC_MEC1308', 1) |
| 33 | conf_data.set('CONFIG_EXPERIMENTAL_KIEV', 1) |
| 34 | conf_data.set('CONFIG_INTF_PORT_IO', 1) |
| 35 | conf_data.set('CONFIG_PLATFORM_ALEX', 1) |
| 36 | conf_data.set('CONFIG_PLATFORM_ARCH_X86', 1) |
| 37 | conf_data.set('CONFIG_PLATFORM_AURON', 1) |
| 38 | conf_data.set('CONFIG_PLATFORM_BELTINO', 1) |
| 39 | conf_data.set('CONFIG_PLATFORM_BUTTERFLY', 1) |
| 40 | conf_data.set('CONFIG_PLATFORM_CYAN', 1) |
| 41 | conf_data.set('CONFIG_PLATFORM_FIZZ', 1) |
| 42 | conf_data.set('CONFIG_PLATFORM_GLADOS', 1) |
| 43 | conf_data.set('CONFIG_PLATFORM_KAHLEE', 1) |
| 44 | conf_data.set('CONFIG_PLATFORM_LINK', 1) |
| 45 | conf_data.set('CONFIG_PLATFORM_LUMPY', 1) |
| 46 | conf_data.set('CONFIG_PLATFORM_MARIO', 1) |
C Shapiro | ed0a3af | 2018-04-16 17:12:00 -0600 | [diff] [blame] | 47 | conf_data.set('CONFIG_PLATFORM_OCTOPUS', 1) |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 48 | conf_data.set('CONFIG_PLATFORM_PARROT', 1) |
| 49 | conf_data.set('CONFIG_PLATFORM_RAMBI', 1) |
| 50 | conf_data.set('CONFIG_PLATFORM_REEF', 1) |
| 51 | conf_data.set('CONFIG_PLATFORM_SAMUS', 1) |
| 52 | conf_data.set('CONFIG_PLATFORM_SLIPPY', 1) |
| 53 | conf_data.set('CONFIG_PLATFORM_STOUT', 1) |
| 54 | conf_data.set('CONFIG_PLATFORM_STRAGO', 1) |
| 55 | conf_data.set('CONFIG_PLATFORM_STUMPY', 1) |
| 56 | conf_data.set('CONFIG_PLATFORM_ZGB', 1) |
| 57 | conf_data.set('CONFIG_SOC_INTEL_BAYTRAIL', 1) |
| 58 | conf_data.set('CONFIG_SOC_INTEL_BRASWELL', 1) |
| 59 | conf_data.set('CONFIG_STORAGE_SANDISK_U100', 1) |
| 60 | conf_data.set('CONFIG_SUPERIO_ITE_IT8772', 1) |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 61 | elif arch == 'mip' |
| 62 | conf_data.set('CONFIG_PLATFORM_ARCH_MIPSEL', 1) |
| 63 | elif arch == 'arm' |
| 64 | conf_data.set('CONFIG_CROS_EC', 1) |
| 65 | conf_data.set('CONFIG_CROS_EC_I2C', 1) |
| 66 | conf_data.set('CONFIG_PLATFORM_ARCH_ARMEL', 1) |
| 67 | conf_data.set('CONFIG_PLATFORM_CYCLONE', 1) |
| 68 | conf_data.set('CONFIG_PLATFORM_DAISY', 1) |
| 69 | conf_data.set('CONFIG_PLATFORM_GRU', 1) |
| 70 | conf_data.set('CONFIG_PLATFORM_NYAN', 1) |
| 71 | conf_data.set('CONFIG_PLATFORM_OAK', 1) |
| 72 | conf_data.set('CONFIG_PLATFORM_PEACH', 1) |
| 73 | conf_data.set('CONFIG_PLATFORM_PINKY', 1) |
| 74 | conf_data.set('CONFIG_PLATFORM_SKATE', 1) |
| 75 | conf_data.set('CONFIG_PLATFORM_SMAUG', 1) |
| 76 | conf_data.set('CONFIG_PLATFORM_SPRING', 1) |
| 77 | conf_data.set('CONFIG_PLATFORM_STORM', 1) |
| 78 | conf_data.set('CONFIG_SOC_NVIDIA', 1) |
| 79 | conf_data.set('CONFIG_SOC_NVIDIA_TEGRA124', 1) |
| 80 | conf_data.set('CONFIG_SOC_SAMSUNG', 1) |
| 81 | conf_data.set('CONFIG_SOC_SAMSUNG_EXYNOS5250', 1) |
| 82 | conf_data.set('CONFIG_SOC_SAMSUNG_EXYNOS5420', 1) |
| 83 | conf_data.set('CONFIG_TRACKPAD_CYPRESS_APA', 1) |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 84 | endif |
| 85 | |
| 86 | # Create the config header file and include it by default while compiling |
| 87 | configure_file( |
| 88 | output : 'config.h', |
| 89 | configuration : conf_data, |
| 90 | ) |
| 91 | add_global_arguments('-include', 'config.h', language: 'c') |
Jason D. Clinton | a7fd67d | 2018-04-17 13:34:08 -0600 | [diff] [blame^] | 92 | add_global_arguments('-std=gnu99', language : 'c') |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 93 | |
| 94 | # External libs used by Mosys |
| 95 | fmap_dep = dependency('fmap') |
| 96 | uuid_dep = dependency('uuid') |
| 97 | |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 98 | libmosys_src = files() |
| 99 | |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 100 | # Subdirs with source to link against |
| 101 | subdir('core') |
| 102 | subdir('drivers') |
| 103 | subdir('intf') |
| 104 | subdir('lib') |
| 105 | subdir('platform') |
| 106 | |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 107 | deps = [ |
| 108 | fmap_dep, |
| 109 | uuid_dep, |
| 110 | ] |
| 111 | link_whole = [] |
| 112 | |
| 113 | # Cros config is a special snowflake. |
| 114 | if use_cros_config |
| 115 | libmosys_src += mosys_lib_cros_config_src |
| 116 | fdt_dep = meson.get_compiler('c').find_library('fdt') |
| 117 | deps += fdt_dep |
| 118 | dtb_lib = static_library( |
| 119 | 'cros_config_dtb', |
| 120 | cros_config_dtb_src, |
| 121 | c_args: [ |
| 122 | '-Itools/vpd_encode', |
| 123 | '-D__ASSEMBLY__', |
| 124 | '-c', |
| 125 | ], |
| 126 | link_args: [ |
| 127 | '-znoexecstack', |
| 128 | '-r', |
| 129 | ], |
| 130 | ) |
| 131 | link_whole += dtb_lib |
| 132 | endif |
| 133 | |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 134 | # Lib momsys shared library target |
| 135 | libmosys = static_library( |
| 136 | 'mosys', |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 137 | libmosys_src, |
| 138 | dependencies: deps, |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 139 | include_directories: include_common, |
Jason D. Clinton | 3a2b39c | 2018-04-16 11:42:49 -0600 | [diff] [blame] | 140 | link_whole: link_whole, |
| 141 | pic: true, |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 142 | ) |
| 143 | |
| 144 | # Add static linking if static is set |
| 145 | link_args = [] |
Jason D. Clinton | a7fd67d | 2018-04-17 13:34:08 -0600 | [diff] [blame^] | 146 | if get_option('static') == true |
Alec Thilenius | f79f52b | 2017-12-22 12:10:17 -0700 | [diff] [blame] | 147 | link_args += '-static' |
| 148 | endif |
| 149 | |
| 150 | # Mosys dynamic executable |
| 151 | executable( |
| 152 | 'mosys', |
| 153 | ['mosys.c'], |
| 154 | include_directories: include_common, |
| 155 | link_args: link_args, |
| 156 | link_with: [libmosys], |
| 157 | install: true, |
| 158 | install_dir: '/usr/sbin', |
| 159 | ) |
| 160 | |
| 161 | # Mosys static executable. This will be removed by the ebuild if static is not |
| 162 | # set, but is always built and installed first. |
| 163 | executable( |
| 164 | 'mosys_s', |
| 165 | ['mosys.c'], |
| 166 | include_directories: include_common, |
| 167 | link_args: ['-static'], |
| 168 | link_with: [libmosys], |
| 169 | install: true, |
| 170 | install_dir: '/usr/sbin', |
| 171 | ) |