/ CMakeLists.txt
CMakeLists.txt
  1  project(darling-libsystem_init)
  2  
  3  cmake_minimum_required(VERSION 3.13)
  4  
  5  if(COMMAND cmake_policy)
  6  	cmake_policy(SET CMP0003 NEW)
  7  endif(COMMAND cmake_policy)
  8  
  9  
 10  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
 11  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-bind_at_load")
 12  
 13  add_definitions(-DHAVE_STDINT_H=1 -DHAVE_SYSTEM_CORESERVICES)
 14  
 15  # Hide warnings
 16  add_definitions(
 17  	-w
 18  	-nostdinc
 19  )
 20  
 21  set(libsystem_sources
 22  	init.c
 23  	darling/src/dummy.c
 24  	CompatibilityHacks.c
 25  )
 26  
 27  set_source_files_properties(init.c PROPERTIES
 28  	COMPILE_FLAGS " -DPRIVATE=1"
 29  )
 30  
 31  set(DYLIB_INSTALL_NAME "/usr/lib/libSystem.B.dylib")
 32  set(DYLIB_CURRENT_VERSION "1281.0.0")
 33  add_circular(system FAT
 34  	SOURCES
 35  		${libsystem_sources}
 36  	OBJECTS
 37  		$<TARGET_OBJECTS:kqueue>
 38  
 39  	SIBLINGS
 40  
 41  	system_malloc
 42  )
 43  
 44  function(libsystem_reexport)
 45  	while(ARGN)
 46  		list(GET ARGN 0 sublib)
 47  		list(GET ARGN 1 sublib_path)
 48  
 49  		add_dependencies(system ${sublib})
 50  		set_property(TARGET system APPEND_STRING PROPERTY LINK_FLAGS
 51                  " -Wl,-reexport_library -Wl,${CMAKE_BINARY_DIR}/${sublib_path} ")
 52  
 53  		list(REMOVE_AT ARGN 0 1)
 54  	endwhile(ARGN)
 55  endfunction(libsystem_reexport)
 56  
 57  libsystem_reexport(
 58  	system_sandbox src/sandbox/libsystem_sandbox.dylib
 59  	system_quarantine src/quarantine/libquarantine.dylib
 60  	removefile src/external/removefile/libremovefile.dylib
 61  	system_copyfile src/external/copyfile/libcopyfile.dylib
 62  	system_coreservices src/libsystem_coreservices/libsystem_coreservices.dylib
 63  	system_coretls src/external/coretls/libsystem_coretls.dylib
 64  	system_malloc src/external/libmalloc/libsystem_malloc.dylib
 65  	system_c src/external/libc/libsystem_c.dylib
 66  	system_kernel src/external/xnu/darling/src/libsystem_kernel/libsystem_kernel.dylib
 67  	system_trace src/external/libtrace/libsystem_trace.dylib
 68  	keymgr src/external/keymgr/libkeymgr.dylib
 69  	system_m src/libm/libsystem_m.dylib
 70  	system_info src/external/Libinfo/libsystem_info.dylib
 71  	system_notify src/external/libnotify/libsystem_notify.dylib
 72  	libdispatch_shared src/external/libdispatch/libdispatch.dylib
 73  	launch src/launchd/liblaunch/liblaunch.dylib
 74  	compiler_rt src/external/compiler-rt/lib/builtins/libcompiler_rt.dylib
 75  	system_dyld src/external/dyld/libdyld.dylib
 76  	macho src/external/cctools/libmacho/libmacho.dylib
 77  	system_pthread src/external/libpthread/src/libsystem_pthread.dylib
 78  	platform src/external/libplatform/libsystem_platform.dylib
 79  	system_asl src/external/syslog/libsystem_asl.tproj/libsystem_asl.dylib
 80  	system_duct src/duct/src/libsystem_duct.dylib
 81  	system_blocks src/external/libclosure/libsystem_blocks.dylib
 82  	xpc src/external/libxpc/libxpc.dylib
 83  	corecrypto src/external/corecrypto/libcorecrypto.dylib
 84  	commonCrypto src/external/commoncrypto/libcommonCrypto.dylib
 85  	system_dnssd src/lib/system/dnssd/libsystem_dnssd.dylib
 86  	system_networkextension src/networkextension/libsystem_networkextension.dylib
 87  	unwind src/external/libunwind/libunwind.dylib
 88  	system_darwin src/external/libc/libdarwin/libsystem_darwin.dylib
 89  	libcache src/libcache/libcache.dylib
 90  	system_configuration src/external/configd/libsystem_configuration.dylib
 91  )
 92  
 93  add_dependencies(system system_malloc system_m)
 94  
 95  set_target_properties(system PROPERTIES OUTPUT_NAME "System.B")
 96  
 97  make_fat(system)
 98  
 99  install(TARGETS system DESTINATION libexec/darling/usr/lib)
100  
101  InstallSymlink("libSystem.B.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libSystem.dylib")
102  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libc.dylib")
103  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libdbm.dylib")
104  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libdl.dylib")
105  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libinfo.dylib")
106  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libdl.dylib")
107  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libm.dylib")
108  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libmx.A.dylib")
109  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libmx.dylib")
110  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libpoll.dylib")
111  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libproc.dylib")
112  InstallSymlink("libSystem.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libpthread.dylib")