Darling build

This commit is contained in:
Lubos Dolezel 2020-04-17 16:59:28 +02:00
parent def5435990
commit 3c541ad72a
3 changed files with 138 additions and 0 deletions

56
cctools/ar/CMakeLists.txt Normal file
View File

@ -0,0 +1,56 @@
project(ar)
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
add_compile_definitions(__arm64__)
endif()
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../include)
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../include/foreign)
add_definitions(-U__APPLE__
-D__STDC_LIMIT_MACROS=1
-D__STDC_CONSTANT_MACROS=1
-DHAVE_EXECINFO_H=1
-D__DARWIN_UNIX03
-U__APPLE__
-U_DARWIN_C_SOURCE
-U_POSIX_C_SOURCE
-DPROGRAM_PREFIX="x86_64-apple-darwin11-"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1
-Du_short=uint16_t -Du_int=uint32_t
-D__USE_MISC)
add_definitions(-DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_BCOPY=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1)
# i386 has a different CPU type/subtype, but Darling only supports x86_64
if (TARGET_x86_64 OR TARGET_i386)
add_definitions(
-DEMULATED_HOST_CPU_TYPE=16777223
-DEMULATED_HOST_CPU_SUBTYPE=3
)
elseif (TARGET_ARM64)
add_definitions(
-DEMULATED_HOST_CPU_TYPE=16777228
-DEMULATED_HOST_CPU_SUBTYPE=0
)
endif(TARGET_x86_64 OR TARGET_i386)
set(ar_sources
append.c
ar.c
archive.c
contents.c
delete.c
extract.c
misc.c
move.c
print.c
replace.c
../libstuff/unix_standard_mode.c
../libstuff/execute.c
../libstuff/port.c
../libstuff/fatals.c
../libstuff/allocate.c
)
add_executable(x86_64-apple-darwin11-ar ${ar_sources})

View File

@ -1,5 +1,7 @@
project(ld64)
add_definitions(-DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_BCOPY=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fblocks -std=c++11 -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
@ -42,6 +44,8 @@ set(ld64_sources
./ld/passes/compact_unwind.cpp
./ld/passes/code_dedup.cpp
./ld/passes/got.cpp
ld/passes/inits.cpp
ld/passes/thread_starts.cpp
./ld/passes/tlvp.cpp
./ld/passes/branch_shim.cpp
./ld/passes/dtrace_dof.cpp
@ -51,6 +55,7 @@ set(ld64_sources
./ld/passes/huge.cpp
./ld/passes/bitcode_bundle.cpp
./ld/passes/objc.cpp
ld/PlatformSupport.cpp
./3rd/md5.c
./3rd/strlcat.c
./3rd/BlocksRuntime/runtime.c
@ -59,6 +64,7 @@ set(ld64_sources
./3rd/strlcpy.c
./3rd/qsort_r.c
./3rd/eprintf.c
3rd/mkpath_np.c
./ld/debugline.c
)

View File

@ -0,0 +1,76 @@
project(misc)
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
add_compile_definitions(__arm64__)
endif()
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../include)
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../include/foreign)
add_definitions(-DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_BCOPY=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1)
add_definitions(-U__APPLE__
-D__STDC_LIMIT_MACROS=1
-D__STDC_CONSTANT_MACROS=1
-DHAVE_EXECINFO_H=1
-D__DARWIN_UNIX03
-U__APPLE__
-U_DARWIN_C_SOURCE
-U_POSIX_C_SOURCE
-DPROGRAM_PREFIX="x86_64-apple-darwin11-"
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1
-Du_short=uint16_t -Du_int=uint32_t
-DPACKAGE_NAME="lipo"
-DRANLIB
-DPACKAGE_VERSION="1.0")
# i386 has a different CPU type/subtype, but Darling only supports x86_64
if (TARGET_x86_64 OR TARGET_i386)
add_definitions(
-DEMULATED_HOST_CPU_TYPE=16777223
-DEMULATED_HOST_CPU_SUBTYPE=3
)
elseif (TARGET_ARM64)
add_definitions(
-DEMULATED_HOST_CPU_TYPE=16777228
-DEMULATED_HOST_CPU_SUBTYPE=0
)
endif(TARGET_x86_64 OR TARGET_i386)
add_library(stuff OBJECT
../libstuff/fatals.c
../libstuff/bytesex.c
../libstuff/allocate.c
../libstuff/errors.c
../libstuff/arch.c
../libstuff/arch_usage.c
../libstuff/port.c
../libstuff/apple_version.c
../libstuff/execute.c
../libstuff/rnd.c
../libstuff/ofile.c
../libstuff/ofile_error.c
../libstuff/unix_standard_mode.c
../libstuff/version_number.c
../libstuff/print.c
../libstuff/swap_headers.c
../libstuff/get_arch_from_host.c
../libstuff/set_arch_flag_name.c
../libstuff/get_toc_byte_sex.c
../libstuff/args.c
../libstuff/write64.c
)
set(lipo_sources
lipo.c
$<TARGET_OBJECTS:stuff>
)
add_executable(lipo ${lipo_sources})
target_link_libraries(lipo m)
set(ranlib_sources
libtool.c
$<TARGET_OBJECTS:stuff>
)
add_executable(ranlib ${ranlib_sources})