1 # Build settings based on the upstream Xcode project.
2 # See: https://github.com/apple-oss-distributions/system_cmds/blob/main/system_cmds.xcodeproj/project.pbxproj
6 project('system_cmds', 'c', version : '@version@')
8 if host_machine.system() != 'linux'
9 add_project_arguments('-D__FreeBSD__', language : 'c')
12 sdk_version = get_option('sdk_version')
16 cc = meson.get_compiler('c')
17 # Upstream uses awk to process `.gperf` files instead of gperf, which can’t process them.
18 fake_gperf = find_program('awk', required : true)
21 core_foundation = dependency('appleframeworks', modules : 'CoreFoundation')
22 core_symbolication = dependency('appleframeworks', modules : 'CoreSymbolication')
23 directory_service = dependency('appleframeworks', modules : 'DirectoryService')
24 iokit = dependency('appleframeworks', modules : 'IOKit')
25 kernel = declare_dependency(include_directories : '@kernel@/Library/Frameworks/Kernel.framework/Headers')
26 open_directory = dependency('appleframeworks', modules : 'OpenDirectory')
29 cfopen_directory = declare_dependency(
30 dependencies : declare_dependency(
31 compile_args :[ '-iframework', '@opendirectory@/Library/Frameworks/OpenDirectory.framework/Frameworks' ],
33 include_directories : '@opendirectory_private@/include',
35 libc_private = declare_dependency(include_directories : '@libc_private@/include')
36 libmalloc_private = declare_dependency(include_directories : '@libmalloc_private@/include')
40 '@xnu@/include/libkern',
41 '@xnu@/include/iokit',
42 '@xnu@/include/osfmk',
43 '@xnu_private@/include'
45 if sdk_version.version_compare('>=10.13')
46 xnu_include_dirs += '@xnu@/include/san'
48 xnu_private = declare_dependency(
50 # Suppresses suffixing symbols with '$UNIX2003', which causes link failures.
51 '-D__DARWIN_ONLY_UNIX_CONFORMANCE=1',
52 # Make sure Darwin is correctly detected as macOS
53 '-DPLATFORM_MacOSX=1',
54 # Access private definitions
57 include_directories : xnu_include_dirs
61 ncurses = dependency('ncurses')
62 openbsm = cc.find_library('bsm')
63 pam = cc.find_library('pam')
66 if sdk_version.version_compare('<12')
67 add_project_arguments('-DkIOMainPortDefault=kIOMasterPortDefault', language : 'c')
68 add_project_arguments('-DIOMainPort=IOMasterPort', language : 'c')
75 arguments : [ '-f', meson.source_root() + '/getconf/fake-gperf.awk', '@INPUT@' ],
77 output : '@BASENAME@.gperf.c'
82 executable('ac', install : true, sources : 'ac/ac.c')
83 install_man('ac/ac.8')
85 executable('accton', install : true, sources : 'accton/accton.c')
86 install_man('accton/accton.8')
90 build_by_default : sdk_version.version_compare('>=11'),
91 dependencies : [ core_foundation ],
92 install : sdk_version.version_compare('>=11'),
93 sources : 'arch/arch.c'
105 '-DDEFAULT_AT_QUEUE=\'a\'',
106 '-DDEFAULT_BATCH_QUEUE=\'b\'',
107 '-DPERM_PATH="/usr/lib/cron"',
117 install_man('at/at.1')
121 c_args : [ '-DDAEMON_UID=1', '-DDAEMON_GID=1' ],
122 include_directories : 'at',
129 install_man('atrun/atrun.8')
133 c_args : '-DUSE_PAM',
134 dependencies : [ core_foundation, open_directory, pam ],
137 'chkpasswd/file_passwd.c',
138 'chkpasswd/nis_passwd.c',
139 'chkpasswd/od_passwd.c',
140 'chkpasswd/pam_passwd.c',
141 'chkpasswd/passwd.c',
142 'chkpasswd/stringops.c'
145 install_man('chkpasswd/chkpasswd.8')
149 dependencies : [ core_foundation, cfopen_directory, directory_service, open_directory ],
155 'chpass/open_directory.c',
160 install_man('chpass/chpass.1')
162 executable('cpuctl', install : true, sources : 'cpuctl/cpuctl.c')
163 install_man('cpuctl/cpuctl.8')
165 executable('dmesg', install : true, sources : 'dmesg/dmesg.c')
166 install_man('dmesg/dmesg.8')
170 c_args : '-DNO_DIRECT_RPC',
172 sources : 'dynamic_pager/dynamic_pager.c'
174 install_man('dynamic_pager/dynamic_pager.8')
178 # Requires 'ktrace/session.h'
179 build_by_default : false,
181 sources : 'fs_usage/fs_usage.c'
183 # install_man('fs_usage/fs_usage.1')
187 # Requires XPC private APIs
188 build_by_default : false and sdk_version.version_compare('>=11'),
189 install : false and sdk_version.version_compare('>=11'),
194 'gcore/dyld_shared_cache.c',
203 # install_man('gcore/gcore-internal.1', 'gcore/gcore.1')
207 c_args : '-DAPPLE_GETCONF_UNDERSCORE',
208 include_directories : 'getconf',
214 'getconf/confstr.gperf',
215 'getconf/limits.gperf',
216 'getconf/unsigned_limits.gperf',
217 'getconf/progenv.gperf',
218 'getconf/sysconf.gperf',
219 'getconf/pathconf.gperf'
223 install_man('getconf/getconf.1')
241 executable('hostinfo', install : true, sources : 'hostinfo/hostinfo.c')
242 install_man('hostinfo/hostinfo.8')
246 dependencies : [ core_foundation, iokit ],
247 include_directories : 'at',
249 sources : 'iosim/iosim.c'
251 install_man('iosim/iosim.1')
255 dependencies : [ core_foundation, iokit ],
257 sources : 'iostat/iostat.c'
259 install_man('iostat/iostat.8')
263 dependencies : [ xnu_private ],
265 sources : 'kpgo/kpgo.c'
267 # No man pages for `kpgo`
271 build_by_default : sdk_version.version_compare('>=12'),
272 dependencies : ncurses,
273 install : sdk_version.version_compare('>=12'),
274 sources : 'latency/latency.c'
276 if sdk_version.version_compare('>=12')
277 install_man('latency/latency.1')
282 # Requires SoftLinking/WeakLinking.h and end-point security entitlements
283 build_by_default : false,
284 c_args : '-DUSE_BSM_AUDIT=1',
285 dependencies : [ openbsm, xnu_private ],
289 'login/login_audit.c'
292 # install_man('login/login.1')
296 build_by_default : sdk_version.version_compare('>=12'),
297 install : sdk_version.version_compare('>=12'),
298 sources : 'lskq/lskq.c'
300 if sdk_version.version_compare('>=12')
301 install_man('lskq/lskq.1')
306 build_by_default : sdk_version.version_compare('>=12'),
307 install : sdk_version.version_compare('>=12'),
310 'lsmp/port_details.c',
311 'lsmp/task_details.c'
314 if sdk_version.version_compare('>=12')
315 install_man('lsmp/lsmp.1')
321 sources : 'ltop/ltop.c'
323 install_man('ltop/ltop.1')
325 executable('mean', install : true, sources : 'mean/mean.c')
326 # No man pages for `mean`.
330 dependencies : [ xnu_private ],
332 sources : 'memory_pressure/memory_pressure.c'
334 install_man('memory_pressure/memory_pressure.1')
336 executable('mkfile', install : true, sources : 'mkfile/mkfile.c')
337 install_man('mkfile/mkfile.8')
341 build_by_default : sdk_version.version_compare('>=10.13'),
342 dependencies : [ libmalloc_private ],
343 install : sdk_version.version_compare('>=10.13'),
344 sources : 'mslutil/mslutil.c'
346 if sdk_version.version_compare('>=10.13')
347 install_man('mslutil/mslutil.1')
350 executable('newgrp', install : true, sources : 'newgrp/newgrp.c')
351 install_man('newgrp/newgrp.1')
353 executable('nologin', install : true, sources : 'nologin/nologin.c')
361 c_args : '-DTARGET_OS_BRIDGE=0',
362 dependencies : [ core_foundation, iokit, libc_private, xnu_private ],
364 sources : 'nvram/nvram.c'
366 install_man('nvram/nvram.8')
370 command : [ 'cp', '@INPUT@', '@OUTPUT@' ],
372 install_dir : get_option('bindir'),
373 install_mode : 'r-xr-xr-x',
374 input : 'pagesize/pagesize.sh',
377 install_man('pagesize/pagesize.1')
381 dependencies : [ core_foundation, cfopen_directory, directory_service, open_directory, pam ],
384 'passwd/file_passwd.c',
385 'passwd/nis_passwd.c',
386 'passwd/od_passwd.c',
387 'passwd/pam_passwd.c',
391 install_man('passwd/passwd.1')
396 sources : 'proc_uuid_policy/proc_uuid_policy.c'
398 install_man('proc_uuid_policy/proc_uuid_policy.1')
400 executable('purge', install : true, sources : 'purge/purge.c')
401 install_man('purge/purge.8')
405 c_args : [ '-D_PW_NAME_LEN=MAXLOGNAME', '-D_PW_YPTOKEN="__YP!"' ],
408 'pwd_mkdb/pw_scan.c',
409 'pwd_mkdb/pwd_mkdb.c'
412 install_man('pwd_mkdb/pwd_mkdb.8')
416 # Requires IOKitUser kext APIs
417 build_by_default : false,
419 sources : 'reboot/reboot.c'
421 # install_man('reboot/reboot.8')
434 install_man('sa/sa.8')
438 build_by_default : sdk_version.version_compare('>=12'),
439 dependencies : ncurses,
440 install : sdk_version.version_compare('>=12'),
441 sources : 'sc_usage/sc_usage.c'
443 if sdk_version.version_compare('>=12')
444 install_man('sc_usage/sc_usage.1')
447 executable('shutdown',
448 # Requires IOKitUser kext APIs
449 build_by_default : false,
451 sources : 'shutdown/shutdown.c'
453 # install_man('shutdown/shutdown.8')
457 build_by_default : sdk_version.version_compare('>=10.13'),
458 dependencies : [ xnu_private ],
459 install : sdk_version.version_compare('>=10.13'),
460 sources : 'stackshot/stackshot.c'
462 # No man pages for `stackshot`.
464 executable('sync', install : true, sources : 'sync/sync.c')
465 # No man pages for `sync`.
467 executable('sysctl', install : true, sources : 'sysctl/sysctl.c')
470 'sysctl/sysctl.conf.5'
475 build_by_default : sdk_version.version_compare('>=11'),
476 dependencies : [ xnu_private ],
477 install : sdk_version.version_compare('>=11'),
478 sources : 'taskpolicy/taskpolicy.c'
480 if sdk_version.version_compare('>=11')
481 install_man('taskpolicy/taskpolicy.8')
484 executable('vifs', install : true, sources : 'vifs/vifs.c')
485 install_man('vifs/vifs.8')
495 install_man('vipw/vipw.8')
497 executable('vm_purgeable_stat',
498 build_by_default : sdk_version.version_compare('>=11'),
499 install : sdk_version.version_compare('>=11'),
500 sources : 'vm_purgeable_stat/vm_purgeable_stat.c'
502 if sdk_version.version_compare('>=11')
503 install_man('vm_purgeable_stat/vm_purgeable_stat.1')
506 executable('vm_stat', install : true, sources : 'vm_stat/vm_stat.c')
507 install_man('vm_stat/vm_stat.1')
509 executable('wait4path', install : true, sources : 'wait4path/wait4path.c')
510 install_man('wait4path/wait4path.1')
512 executable('wordexp-helper', install : true, sources : 'wordexp-helper/wordexp-helper.c')
513 # No man pages for `wordexp-helper`.
515 executable('zdump', include_directories : 'zic', install : true, sources : 'zdump/zdump.c')
516 install_man('zdump/zdump.8')
518 executable('zic', install : true, sources : 'zic/zic.c')
519 install_man('zic/zic.8')
523 build_by_default : sdk_version.version_compare('>=11'),
524 c_args : '-DKERN_NOT_FOUND=56',
525 dependencies : [ core_foundation, core_symbolication ],
526 install : sdk_version.version_compare('>=11'),
528 'zlog/SymbolicationHelper.c',
532 if sdk_version.version_compare('>=11')
533 install_man('zlog/zlog.1')
538 # Requires IOKitUser kext APIs
539 build_by_default : false,
540 dependencies: [ kernel ],
542 sources : 'zprint/zprint.c'
544 # install_man('zprint/zprint.1')