1 # Build settings based on the upstream Xcode project.
2 # See: https://github.com/apple-oss-distributions/file_cmds/blob/main/file_cmds.xcodeproj/project.pbxproj
5 project('file_cmds', 'c', version : '@version@')
7 '-DTARGET_OS_BRIDGE=0',
12 cc = meson.get_compiler('c')
14 core_foundation = dependency('appleframeworks', modules : 'CoreFoundation')
16 libbsd = dependency('libbsd-overlay', required : false)
17 bzip2 = dependency('bzip2')
18 xz = dependency('liblzma')
19 libxo = dependency('libxo')
20 zlib = dependency('zlib')
22 copyfile = cc.find_library('copyfile')
23 removefile = cc.find_library('removefile')
24 libutil = cc.find_library('util')
32 int main(int argc, char* argv[]) {
33 return utimensat(AT_FDCWD, NULL, NULL, 0);
39 int main(int argc, char* argv[]) {
44 has_utimensat = cc.compiles(utimensat_test, name : 'supports utimensat')
45 utimensat_c_args = has_utimensat ? [ ] : [ '-include', 'time_compat.h', '-I' + meson.source_root() + '/compat' ]
46 utimensat_sources = has_utimensat ? [ ] : [ 'compat/time_compat.c' ]
48 has_rpmatch = cc.compiles(rpmatch_test, name : 'supports rpmatch')
49 rpmatch_c_args = has_rpmatch ? [ ] : [ '-include', 'rpmatch_compat.h', '-I' + meson.source_root() + '/compat' ]
50 rpmatch_sources = has_rpmatch ? [ ] : [ 'compat/rpmatch_compat.c' ]
52 compat_link_args = not (has_utimensat and has_rpmatch) ? [ '-Wl,-undefined,dynamic_lookup' ] : [ ]
59 sources: [ 'chflags/chflags.c' ],
61 install_man('chflags/chflags.1')
71 install_man('chmod/chmod.1')
76 sources: [ 'chown/chown.c' ],
78 install_man('chown/chown.8')
82 install_dir : get_option('bindir'),
83 pointing_to : 'chown',
85 install_man('chown/chgrp.1')
99 install_man('cksum/cksum.1')
103 install_dir : get_option('bindir'),
104 pointing_to : 'cksum',
106 install_man('cksum/sum.1')
110 c_args : [ utimensat_c_args, rpmatch_c_args ],
112 link_args : compat_link_args,
114 'compress/compress.c',
120 install_man('compress/compress.1')
124 install_dir : get_option('bindir'),
125 pointing_to : 'compress',
127 install_man('compress/uncompress.1')
129 install_man('compress/zopen.3')
137 dependencies : [ copyfile ],
139 link_args : compat_link_args,
147 install_man('cp/cp.1')
151 dependencies : [ libutil ],
158 # 'dd/gen.c', # Not compiled in the Xcode project. Building it causes a duplicate symbol error when linking.
163 install_man('dd/dd.1')
167 dependencies : [ libutil, libxo ],
169 sources: [ 'df/df.c' ],
171 install_man('df/df.1')
175 dependencies : [ libutil ],
177 sources: [ 'du/du.c' ],
179 install_man('du/du.1')
183 c_args : [ '-DGZIP_APPLE_VERSION="@version@"' ],
184 dependencies : [ bzip2, copyfile, xz, zlib ],
189 # Apple only builds with gzip support
194 # 'gzip/zuncompress.c',
197 install_man('gzip/gzip.1')
199 foreach cmd : [ 'gzexe', 'zdiff', 'zforce', 'zmore', 'znew' ]
202 install_dir : get_option('bindir'),
203 install_mode : 'r-xr-xr-x',
205 install_man(f'gzip/@cmd@.1')
210 install_dir : get_option('bindir'),
211 pointing_to : 'zmore',
215 'install-bin', # Meson reserves the name “install”, so use a different name and rename in install phase.
216 c_args : utimensat_c_args,
217 dependencies : [ copyfile ],
219 link_args : compat_link_args,
221 'install/xinstall.c',
225 install_man('install/install.1')
230 sources: [ 'ipcrm/ipcrm.c' ],
232 install_man('ipcrm/ipcrm.1')
237 sources: [ 'ipcs/ipcs.c' ],
239 install_man('ipcs/ipcs.1')
244 sources: [ 'ln/ln.c' ],
246 install_man('ln/ln.1')
250 install_dir : get_option('bindir'),
253 install_man('ln/link.1')
255 install_man(f'ln/symlink.7')
260 # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/stat.h#L520
261 '-DSF_DATALESS=0x40000000',
263 dependencies : [ libbsd, libutil ],
272 install_man('ls/ls.1')
277 sources: [ 'mkdir/mkdir.c' ],
279 install_man('mkdir/mkdir.1')
284 sources: [ 'mkfifo/mkfifo.c' ],
286 install_man('mkfifo/mkfifo.1')
296 install_man('mknod/mknod.8')
300 # Define these flags for the 10.12 SDK assuming that users on older systems can’t encounter dataless files.
302 # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/stat.h#L520
303 '-DSF_DATALESS=0x40000000',
304 # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/resource.h#L598
305 '-DIOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES=3',
306 # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/resource.h#L640
307 '-DIOPOL_MATERIALIZE_DATALESS_FILES_OFF=1',
308 # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/attr.h#L562
309 '-DATTR_CMNEXT_LINKID=0x00000010',
311 dependencies : [ core_foundation, removefile ],
315 'mtree/commoncrypto.c',
327 install_man('mtree/mtree.8')
331 c_args : [ utimensat_c_args, rpmatch_c_args ],
332 dependencies : [ copyfile ],
334 link_args : compat_link_args,
341 install_man('mv/mv.1')
346 sources: [ 'pathchk/pathchk.c' ],
348 install_man('pathchk/pathchk.1')
352 dependencies : [ copyfile ],
374 install_man('pax/pax.1')
378 c_args : rpmatch_c_args,
379 dependencies : [ removefile ],
381 link_args : compat_link_args,
387 install_man('rm/rm.1')
391 install_dir : get_option('bindir'),
394 install_man('rm/unlink.1')
399 sources: [ 'rmdir/rmdir.c' ],
401 install_man('rmdir/rmdir.1')
405 install_dir : get_option('bindir'),
406 install_mode : 'r-xr-xr-x',
409 install_man('shar/shar.1')
414 sources: [ 'stat/stat.c' ],
416 install_man('stat/stat.1')
420 install_dir : get_option('bindir'),
421 pointing_to : 'stat',
423 install_man('stat/readlink.1')
427 c_args : utimensat_c_args,
429 link_args : compat_link_args,
435 install_man('touch/touch.1')
439 dependencies : [ libutil ],
441 sources: [ 'truncate/truncate.c' ],
443 install_man('truncate/truncate.1')
448 sources: [ 'xattr/xattr.c' ],
450 install_man('xattr/xattr.1')