diff --git a/cmake/darling_lib.cmake b/cmake/darling_lib.cmake index 87292aa4f..47eaaa2e3 100644 --- a/cmake/darling_lib.cmake +++ b/cmake/darling_lib.cmake @@ -26,6 +26,14 @@ FUNCTION(add_darling_library name) set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-dylib_install_name,${DYLIB_INSTALL_NAME} ") endif (DYLIB_INSTALL_NAME) + if (DYLIB_COMPAT_VERSION) + set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-compatibility_version,${DYLIB_COMPAT_VERSION} ") + endif (DYLIB_COMPAT_VERSION) + if (DYLIB_CURRENT_VERSION) + set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-current_version,${DYLIB_CURRENT_VERSION} ") + endif (DYLIB_CURRENT_VERSION) use_ld64(${name}) ENDFUNCTION(add_darling_library) diff --git a/src/AudioUnit/AUComponent.h b/src/AudioUnit/AUComponent.h index 6a68353ae..3d08ffe77 100644 --- a/src/AudioUnit/AUComponent.h +++ b/src/AudioUnit/AUComponent.h @@ -1,6 +1,6 @@ #ifndef AUCOMPONENT_H #define AUCOMPONENT_H -#include +#include #include #include diff --git a/src/AudioUnit/AudioUnit.h b/src/AudioUnit/AudioUnit.h index b25df9ca8..cc2b88b83 100644 --- a/src/AudioUnit/AudioUnit.h +++ b/src/AudioUnit/AudioUnit.h @@ -1,6 +1,6 @@ #ifndef AUDIOUNIT_H #define AUDIOUNIT_H -#include +#include #include #include "AUComponent.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 032684a25..e190173bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,9 +118,8 @@ add_subdirectory(external/liblzma) add_subdirectory(external/pcre) add_subdirectory(external/sqlite) add_subdirectory(external/openpam) -#add_subdirectory(CFF) #add_subdirectory(SystemConfiguration) -#add_subdirectory(CoreServices) +add_subdirectory(CoreServices) #add_subdirectory(ApplicationServices) #add_subdirectory(VideoDecodeAcceleration) #add_subdirectory(DiskArbitration) @@ -147,33 +146,31 @@ add_subdirectory(external/file/file) add_subdirectory(external/libxpc) add_subdirectory(external/openssl_certificates) -if (NOT DARLING_NO_EXECUTABLES) - add_subdirectory(external/shell_cmds) - add_subdirectory(external/file_cmds) - add_subdirectory(external/text_cmds) - add_subdirectory(external/adv_cmds) -# add_subdirectory(external/network_cmds) - add_subdirectory(external/bash) - add_subdirectory(external/less) - add_subdirectory(external/grep) - add_subdirectory(external/awk) - add_subdirectory(external/groff) - add_subdirectory(external/nano) - add_subdirectory(external/man) - add_subdirectory(external/bc) - add_subdirectory(external/zip/zip/zip30) - add_subdirectory(external/zip/unzip/unzip-5.52) -# add_subdirectory(tools) -# add_subdirectory(external/installer) - add_subdirectory(external/gnutar/gnutar) - add_subdirectory(external/gpatch) - add_subdirectory(external/gnudiff) -# add_subdirectory(launchd/src) -# add_subdirectory(launchd/support) - add_subdirectory(external/openssh) -# add_subdirectory(external/top) -# add_subdirectory(external/perl) -endif (NOT DARLING_NO_EXECUTABLES) +add_subdirectory(external/shell_cmds) +add_subdirectory(external/file_cmds) +add_subdirectory(external/text_cmds) +add_subdirectory(external/adv_cmds) +#add_subdirectory(external/network_cmds) +add_subdirectory(external/bash) +add_subdirectory(external/less) +add_subdirectory(external/grep) +add_subdirectory(external/awk) +add_subdirectory(external/groff) +add_subdirectory(external/nano) +add_subdirectory(external/man) +add_subdirectory(external/bc) +add_subdirectory(external/zip/zip/zip30) +add_subdirectory(external/zip/unzip/unzip-5.52) +#add_subdirectory(tools) +add_subdirectory(external/installer) +add_subdirectory(external/gnutar/gnutar) +add_subdirectory(external/gpatch) +add_subdirectory(external/gnudiff) +#add_subdirectory(launchd/src) +#add_subdirectory(launchd/support) +add_subdirectory(external/openssh) +#add_subdirectory(external/top) +#add_subdirectory(external/perl) ###################### # libc++ & libc++abi # diff --git a/src/CoreAudio/CoreAudioTypes.h b/src/CoreAudio/CoreAudioTypes.h index 400d42a5c..307eae9e7 100644 --- a/src/CoreAudio/CoreAudioTypes.h +++ b/src/CoreAudio/CoreAudioTypes.h @@ -1,6 +1,6 @@ #ifndef COREAUDIOTYPES_H #define COREAUDIOTYPES_H -#include +#include struct AudioStreamBasicDescription { diff --git a/src/CoreServices/CMakeLists.txt b/src/CoreServices/CMakeLists.txt index 7a55bd2c8..375a0afeb 100644 --- a/src/CoreServices/CMakeLists.txt +++ b/src/CoreServices/CMakeLists.txt @@ -5,28 +5,19 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) -#if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") -# message(FATAL_ERROR "Clang is the only supported compiler.") -#endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -nostdinc -nostdinc++") -#configure_file(config.h.in config.h) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -nostdinc -nostdinc++ -ggdb -O0") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${DARLING_TOP_DIRECTORY}/darwin.map -nostdlib -Bsymbolic") -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${DARLING_TOP_DIRECTORY}/platform-include) -include_directories(${DARLING_TOP_DIRECTORY}/src/external/libcxx/include) -include_directories(${DARLING_TOP_DIRECTORY}/src/libc/include/FreeBSD) -include_directories(${DARLING_TOP_DIRECTORY}/src/libiconv/include) -include_directories(${DARLING_TOP_DIRECTORY}/src/external/icu/icuSources/common) -include_directories(${DARLING_TOP_DIRECTORY}/src/external/icu/icuSources/i18n) -include_directories(${DARLING_TOP_DIRECTORY}/src/external/corefoundation/Headers) -include_directories(${DARLING_TOP_DIRECTORY}/src/external/foundation/Headers) -include_directories(${CMAKE_BINARY_DIR}/src/external/corefoundation/Headers) -include_directories(${CMAKE_BINARY_DIR}) -# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../util) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/external/libcxx/include + ${CMAKE_SOURCE_DIR}/src/libc/include/FreeBSD + ${CMAKE_SOURCE_DIR}/src/libiconv/include + ${CMAKE_SOURCE_DIR}/src/external/icu/icuSources/common + ${CMAKE_SOURCE_DIR}/src/external/icu/icuSources/i18n + ${CMAKE_SOURCE_DIR}/src/external/corefoundation + ${CMAKE_SOURCE_DIR}/src/external/foundation/include + ${CMAKE_SOURCE_DIR}/src/external/libclosure +) set(CoreServices_SRCS CoreEndian.cpp @@ -49,21 +40,29 @@ set(CoreServices_SRCS OpenTransport.cpp Timer.cpp CoreServicesPriv.cpp - ../external/libcxx/src/dso_handle.c + #../external/libcxx/src/dso_handle.c ) if (WITH_COREAUDIO) set(EXTRA_LIBS AudioUnit) endif (WITH_COREAUDIO) -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/darling") -#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags") -SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - -add_library(CoreServices SHARED ${CoreServices_SRCS}) -target_link_libraries(CoreServices icucore system ${EXTRA_LIBS} CFF cxx iconv) +set(DYLIB_COMPAT_VERSION "1.0.0") +set(DYLIB_CURRENT_VERSION "1.0.0") +add_framework(CoreServices + FAT + CURRENT_VERSION + VERSION "A" + SOURCES + ${CoreServices_SRCS} + DEPENDENCIES + icucore + system + CoreFoundation + cxx + iconv + ${EXTRA_LIBS} +) -install(TARGETS CoreServices DESTINATION "${CMAKE_INSTALL_LIBDIR}/darling") install(FILES SystemVersion.plist DESTINATION "libexec/darling/System/Library/CoreServices") diff --git a/src/CoreServices/Components.cpp b/src/CoreServices/Components.cpp index ab7aa193d..2d9f6edea 100644 --- a/src/CoreServices/Components.cpp +++ b/src/CoreServices/Components.cpp @@ -5,7 +5,9 @@ #include #include #include -#include + +#define TRACE1(x) +#define TRACE2(x,y) Component FindNextComponent(Component prev, ComponentDescription* desc) { @@ -59,7 +61,7 @@ OSErr OpenAComponent(Component comp, ComponentInstance* out) ComponentInstance OpenComponent(Component comp) { - TRACE1(comp); + // TRACE1(comp); ComponentInstance inst; OpenAComponent(comp, &inst); @@ -68,7 +70,7 @@ ComponentInstance OpenComponent(Component comp) OSErr CloseComponent(ComponentInstance inst) { - TRACE1(inst); + // TRACE1(inst); delete inst; return noErr; diff --git a/src/CoreServices/Components.h b/src/CoreServices/Components.h index 68e7fb038..df89d30c8 100644 --- a/src/CoreServices/Components.h +++ b/src/CoreServices/Components.h @@ -1,6 +1,6 @@ #ifndef COMPONENTS_H #define COMPONENTS_H -#include +#include #ifdef __cplusplus class CarbonComponent; diff --git a/src/CoreServices/CoreEndian.cpp b/src/CoreServices/CoreEndian.cpp index aba509ea2..d332f8a2e 100644 --- a/src/CoreServices/CoreEndian.cpp +++ b/src/CoreServices/CoreEndian.cpp @@ -62,6 +62,18 @@ template <> int64_t bswap(int64_t value) return __builtin_bswap64(value); } +#ifdef __i386__ +template <> long bswap(long value) +{ + return __builtin_bswap32(value); +} + +template <> unsigned long bswap(unsigned long value) +{ + return __builtin_bswap32(value); +} +#endif + template T LtoN(T value) { #if TARGET_RT_LITTLE_ENDIAN diff --git a/src/CoreServices/CoreEndian.h b/src/CoreServices/CoreEndian.h index d483614fc..39b7c9e3b 100644 --- a/src/CoreServices/CoreEndian.h +++ b/src/CoreServices/CoreEndian.h @@ -19,7 +19,8 @@ along with Darling. If not, see . #ifndef COREENDIAN_H #define COREENDIAN_H -#include "MacTypes.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/CoreServices/FileManager.cpp b/src/CoreServices/FileManager.cpp index 8d03d95db..3f08854ef 100644 --- a/src/CoreServices/FileManager.cpp +++ b/src/CoreServices/FileManager.cpp @@ -35,11 +35,12 @@ along with Darling. If not, see . #include #include #include +#include #include "DateTimeUtils.h" -#include -#include #include +#define STUB() // TODO + // Doesn't resolve the last symlink // Mallocates a new buffer static char* realpath_ns(const char* path); @@ -48,6 +49,36 @@ static bool FSRefParamMakePath(const FSRefParam* param, std::string& out); // Is the current user member of the specified group? static bool hasgid(gid_t gid); +static bool string_endsWith(const std::string& str, const std::string& what) +{ + if (str.size() < what.size()) + return false; + else + return str.compare(str.size()-what.size(), what.size(), what) == 0; +} + +static std::vector string_explode(const std::string& str, char delim, bool keepEmpty) +{ + std::vector rv; + size_t start = 0, end; + + do + { + std::string substr; + + end = str.find(delim, start); + substr = str.substr(start, (end != std::string::npos) ? end-start : std::string::npos); + + if (keepEmpty || !substr.empty()) + rv.push_back(substr); + + start = end+1; + } + while (end != std::string::npos); + + return rv; +} + OSStatus FSPathMakeRef(const uint8_t* path, FSRef* fsref, Boolean* isDirectory) { return FSPathMakeRefWithOptions(path, kFSPathMakeRefDoNotFollowLeafSymlink, fsref, isDirectory); diff --git a/src/CoreServices/LaunchServices.cpp b/src/CoreServices/LaunchServices.cpp index 29075babf..4a4136a15 100644 --- a/src/CoreServices/LaunchServices.cpp +++ b/src/CoreServices/LaunchServices.cpp @@ -10,7 +10,7 @@ #include #include "UniChar.h" -extern char** __darwin_environ; +extern char** environ; namespace { @@ -102,12 +102,12 @@ int execvpe(const char* name, char** argv, char** envp) char** orig_env; int ret; - orig_env = __darwin_environ; - __darwin_environ = envp; + orig_env = environ; + environ = envp; ret = execvp(name, argv); - __darwin_environ = orig_env; + environ = orig_env; return ret; } diff --git a/src/CoreServices/MacLocales.cpp b/src/CoreServices/MacLocales.cpp index c490af16b..0b3b656b4 100644 --- a/src/CoreServices/MacLocales.cpp +++ b/src/CoreServices/MacLocales.cpp @@ -27,11 +27,11 @@ along with Darling. If not, see . #include #include #include -#include "../util/mutex.h" +#include static std::map g_mapLocaleString; static std::map g_mapLocaleStringRev; -static Darling::Mutex g_mapLocaleStringMutex; +static pthread_mutex_t g_mapLocaleStringMutex = PTHREAD_MUTEX_INITIALIZER; namespace Darling { @@ -43,12 +43,12 @@ int getLocaleUID(const std::string& str) return it->second; else { - g_mapLocaleStringMutex.lock(); + pthread_mutex_lock(&g_mapLocaleStringMutex); size_t id = g_mapLocaleString.size()+1; g_mapLocaleString[str] = id; g_mapLocaleStringRev[id] = str; - g_mapLocaleStringMutex.unlock(); + pthread_mutex_unlock(&g_mapLocaleStringMutex); return id; } diff --git a/src/CoreServices/MacTypes.h b/src/CoreServices/MacTypes.h deleted file mode 100644 index 0ce66dfa4..000000000 --- a/src/CoreServices/MacTypes.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef MACTYPES_H -#define MACTYPES_H -#include -#include - -#ifdef __cplusplus -class _StringHandle; -#endif - -#if 0 // declared in CFBase.h -typedef int8_t SInt8; -typedef uint8_t UInt8; -typedef int16_t SInt16; -typedef uint16_t UInt16; -typedef int32_t SInt32; -typedef uint32_t UInt32; -typedef int64_t SInt64; -typedef uint64_t UInt64; -typedef float Float32; -typedef double Float64; - -typedef Fixed* FixedPtr; -typedef Fract* FractPtr; -typedef UnsignedFixed* UnsignedFixedPtr; -typedef short ShortFixed; -typedef ShortFixed * ShortFixedPtr; // 8/8 -#endif -//typedef int64_t wide; -//typedef uint64_t UnsignedWide; -//typedef uint64_t AbsoluteTime; -typedef uint8_t Boolean; - -// Pascal strings -typedef unsigned char Str255[256]; -typedef unsigned char Str63[64]; -typedef unsigned char Str32[33]; -typedef unsigned char Str31[32]; -typedef unsigned char Str27[28]; -typedef unsigned char Str15[16]; - -typedef unsigned char* StringPtr; -typedef unsigned char** StringHandle; -typedef char* Ptr; -typedef char** Handle; - -typedef int16_t OSErr; - -enum { - kDurationImmediate = 0, - kDurationForever = 0x7FFFFFFF, - kDurationMillisecond = 1, - kDurationMicrosecond = -1 -}; - -#endif - diff --git a/src/CoreServices/Math64.h b/src/CoreServices/Math64.h index 51bc7acaa..20c0502be 100644 --- a/src/CoreServices/Math64.h +++ b/src/CoreServices/Math64.h @@ -20,7 +20,8 @@ along with Darling. If not, see . #ifndef MATH64_H #define MATH64_H -#include "MacTypes.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/CoreServices/Multiprocessing.h b/src/CoreServices/Multiprocessing.h index 37bee5d00..887718b80 100644 --- a/src/CoreServices/Multiprocessing.h +++ b/src/CoreServices/Multiprocessing.h @@ -6,6 +6,13 @@ extern "C" { #endif +enum { + kDurationImmediate = 0, + kDurationForever = 0x7FFFFFFF, + kDurationMillisecond = 1, + kDurationMicrosecond = -1 +}; + typedef void* MPCriticalRegionID; Boolean _MPIsFullyInitialized(); diff --git a/src/CoreServices/OpenTransport.h b/src/CoreServices/OpenTransport.h index ff482ce47..93671edb7 100644 --- a/src/CoreServices/OpenTransport.h +++ b/src/CoreServices/OpenTransport.h @@ -1,6 +1,7 @@ #ifndef OPENTRANSPORT_H #define OPENTRANSPORT_H -#include "MacTypes.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/CoreServices/Processes.cpp b/src/CoreServices/Processes.cpp index e9b5ba326..4056e291c 100644 --- a/src/CoreServices/Processes.cpp +++ b/src/CoreServices/Processes.cpp @@ -6,9 +6,15 @@ #include #include #include -#include #include #include +#include +#include + +#define STUB() // TODO +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif // CFStringRef kCFBundleExecutableKey = CFSTR("kCFBundleExecutableKey"); // CFStringRef kCFBundleNameKey = CFSTR("kCFBundleNameKey"); diff --git a/src/CoreServices/UnicodeUtilities.cpp b/src/CoreServices/UnicodeUtilities.cpp index 84fee08b4..c1703fc4a 100644 --- a/src/CoreServices/UnicodeUtilities.cpp +++ b/src/CoreServices/UnicodeUtilities.cpp @@ -25,7 +25,6 @@ along with Darling. If not, see . #include #include "UniChar.h" #include "MacErrors.h" -#include "util/log.h" namespace Darling { diff --git a/src/external/installer b/src/external/installer index 1aeae2571..f7451eb3d 160000 --- a/src/external/installer +++ b/src/external/installer @@ -1 +1 @@ -Subproject commit 1aeae2571e621f32650fe8ecf635fede14b9f29e +Subproject commit f7451eb3db471bd1d728c897846f69ad613e8887 diff --git a/src/libiconv/CMakeLists.txt b/src/libiconv/CMakeLists.txt index 94c8793bd..279100384 100644 --- a/src/libiconv/CMakeLists.txt +++ b/src/libiconv/CMakeLists.txt @@ -51,6 +51,8 @@ set(iconv_SRCS #libcharset/src/relocatable.c ) +set(DYLIB_COMPAT_VERSION "7.0.0") +set(DYLIB_CURRENT_VERSION "7.0.0") set(DYLIB_INSTALL_NAME "/usr/lib/libiconv.2.dylib") add_darling_library(iconv SHARED ${iconv_SRCS}) make_fat(iconv) diff --git a/src/ncurses/CMakeLists.txt b/src/ncurses/CMakeLists.txt index 83d957bb7..3b91cb887 100644 --- a/src/ncurses/CMakeLists.txt +++ b/src/ncurses/CMakeLists.txt @@ -23,6 +23,9 @@ add_definitions( -Wno-format-security ) +set(DYLIB_COMPAT_VERSION "5.4.0") +set(DYLIB_CURRENT_VERSION "5.4.0") + add_subdirectory(ncurses) add_subdirectory(menu) add_subdirectory(panel)