Yosemite에서 Synergy 직접 빌드하여 사용하기

2014년 10월 27일
|
#apple #os-x #synergy #trouble-shooting

멀티플랫폼간 마우스 및 키보드를 공유해주는 유명한 프로그램인 Synergy가 어느새 유료화되었습니다. 다운로드 페이지로 가보면, 1인당 5달러를 결재하면 평생 사용할 수 있다... 라고는 합니다.

하지만 원래 Synergy는 오픈소스 프로젝트 입니다. 그것도 GNU 라이센스가 적용되어 있는 프로젝트입니다. 이는 Synergy의 Github 페이지로 가보면 확인할 수 있습니다. 따라서 그냥 Github에 공개된 코드를 직접 빌드하여 사용하기로 했습니다. 작업한 환경은 OS X 10.10 Yosemite입니다.

http://synergy-project.org/wiki/Compiling 에 가보면 환경별 컴파일 방법이 간단하게 설명되어 있습니다. 따라서 저는 해당 내용을 따라서 Synergy를 컴파일해서 사용해 보기로 했습니다.

일단 필요한 의존성 모듈을 설치해야 합니다. 저는 brew를 이용해서 cmake, qt를 설치했습니다.

$ brew install cmake
$ brew install qt

의존성 모듈을 설치한 후에, 공식 문서에 나와있는 것과 같이 수행합니다.

$ ./hm.sh conf -g1
Mapping command: conf -> configure
Running setup...
Setup complete.
Error: Arg missing: --mac-sdk <version>

그럼 위와 같은 오류가 발생합니다. mac sdk 옵션이 없어서 발생하는 오류인 듯 싶어 옵션을 주어 실행해봤습니다.

$ ./hm.sh conf -g1 --mac-sdk 10.10
Mapping command: conf -> configure
Error: Arg missing: --mac-identity <name>

이번에는 mac identity 옵션이 없다고 합니다. 그럼 줘봅니다. 일단 test라고 주었습니다.

$ ./hm.sh conf -g1 --mac-sdk 10.10 --mac-identity test
Mapping command: conf -> configure
cmake version 3.0.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
Creating dir: build/release
Entering dir: build/release
CMake command: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../..
-- The C compiler identification is AppleClang 6.0.0.6000054
-- The CXX compiler identification is AppleClang 6.0.0.6000054
(중간 생략)
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found CURL: /usr/lib/libcurl.dylib (found version "7.37.1")
-- OSX_TARGET_MAJOR=
-- OSX_TARGET_MINOR=
CMake Error at CMakeLists.txt:168 (message):
Mac OS X target must be 10.x
-- Configuring incomplete, errors occurred!
See also "/Users/nesswit/Downloads/synergy-master/build/release/CMakeFiles/CMakeOutput.log".
Going back to: /Users/nesswit/Downloads/synergy-master
Error: CMake encountered error: 256

색다른 오류가 저를 반겼습니다. 보아하니 OSX_TARGET_MAJOROSX_TARGET_MINOR 옵션이 적용이 되지 않은듯 합니다.

이를 해결하기 위한 간단한 patch 파일을 작성했습니다. 자세한 내용은 아래와 같습니다.

--- ./ext/toolchain/commands1.py    2014-10-27 15:53:52.000000000 +0900
+++ ./ext/toolchain/commands1-new.py    2014-10-28 17:51:52.000000000 +0900
@@ -451,15 +451,16 @@
            cmake_args += ' -DCMAKE_BUILD_TYPE=' + target.capitalize()

        elif sys.platform == "darwin":
-           macSdkMatch = re.match("(d+).(d+)", self.macSdk)
-           if not macSdkMatch:
-               raise Exception("unknown osx version: " + self.macSdk)
-
            sdkDir = self.getMacSdkDir()
            cmake_args += " -DCMAKE_OSX_SYSROOT=" + sdkDir
            cmake_args += " -DCMAKE_OSX_DEPLOYMENT_TARGET=" + self.macSdk
-           cmake_args += " -DOSX_TARGET_MAJOR=" + macSdkMatch.group(1)
-           cmake_args += " -DOSX_TARGET_MINOR=" + macSdkMatch.group(2)
+
+       macSdkMatch = re.match("(d+).(d+)", self.macSdk)
+       if not macSdkMatch:
+           raise Exception("unknown osx version: " + self.macSdk)
+
+       cmake_args += " -DOSX_TARGET_MAJOR=" + macSdkMatch.group(1)
+       cmake_args += " -DOSX_TARGET_MINOR=" + macSdkMatch.group(2)

        # if not visual studio, use parent dir
        sourceDir = generator.getSourceDir()
@@ -485,10 +486,10 @@
        if generator.cmakeName.find('Eclipse') != -1:
            self.fixCmakeEclipseBug()

-       # only on osx 10.9 mavericks.
+       # only on osx 10.9 mavericks and 10.10 yosemite.
        # manually change .xcodeproj to add code sign for
        # synmacph project and specify its info.plist
-       if self.macSdk == "10.9" and generator.cmakeName.find('Xcode') != -1:
+       if (self.macSdk == "10.9" or self.macSdk == "10.10") and generator.cmakeName.find('Xcode') != -1:
            self.fixXcodeProject(target)

        if err != 0:
@@ -577,7 +578,8 @@
        if os.path.exists(sdkPath):
            return sdkPath

-       return "/Developer/SDKs/" + sdkDirName + ".sdk"
+       return os.popen('xcodebuild -version -sdk macosx' + self.macSdk + ' Path').read().strip()
+       # return "/Developer/SDKs/" + sdkDirName + ".sdk"

    # http://tinyurl.com/cs2rxxb
    def fixCmakeEclipseBug(self):

해당 패치를 적용하고 실행한 결과는 아래와 같습니다.

$ ./hm.sh conf -g1 --mac-sdk 10.10 --mac-identity test
Mapping command: conf -> configure
cmake version 3.0.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
Entering dir: build/release
CMake command: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DOSX_TARGET_MAJOR=10 -DOSX_TARGET_MINOR=10 ../..
-- OSX_TARGET_MAJOR=10
-- OSX_TARGET_MINOR=10
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/nesswit/Downloads/synergy-master/build/release
Going back to: /Users/nesswit/Downloads/synergy-master
QMake command: qmake gui.pro -r -spec macx-g++ "MACX_LIBS=-framework ApplicationServices -framework Security -framework cocoa -framework ServiceManagement" QMAKE_MACOSX_DEPLOYMENT_TARGET=10.10 QMAKE_MAC_SDK=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
Entering dir: src/gui
Going back to: /Users/nesswit/Downloads/synergy-master

생각대로 잘 동작합니다. 이대로 빌드를 진행합니다.

$ ./hm.sh build
Entering dir: build/release
Scanning dependencies of target arch
[ 0%] Building CXX object src/lib/arch/CMakeFiles/arch.dir/Arch.cpp.o
(중간 생략)
Log: Deploying plugins from "/usr/local/plugins"
Log: Created configuration file: "Synergy.app/Contents/Resources/qt.conf"
Log: This file sets the plugin search path to "Synergy.app/Contents/PlugIns"
Going back to: /Users/nesswit/Downloads/synergy-master
Error: [Errno 2] No such file or directory: '/Library/Frameworks/QtCore.framework/Contents/Info.plist'

제가 설치한 qt는 brew로 설치했기 때문에 /Library/Frameworks/ 아래에 있지 않습니다. 따라서 해당 경로를 수정해야 합니다.

이는 아까 패치파일을 적용한 ext/toolchain/commands1.py 파일의 826번째 줄 쯤에 있습니다. 해당 코드를 아래와 같이 수정합니다.

            (qMajor, qMinor, qRev) = self.getQmakeVersion()
            # if qMajor <= 4:
            #   frameworkRootDir = "/Library/Frameworks"
            # else:
            #   # TODO: auto-detect, qt can now be installed anywhere.
            #   frameworkRootDir = "/Developer/Qt5.2.1/5.2.1/clang_64/lib"
            frameworkRootDir = "/usr/local/Cellar/qt/4.8.6/Frameworks"

이후, clean한 후 root 권한으로 다시 빌드해봅니다.

$ ./hm.sh clean
(생략)
```shell
$ sudo ./hm.sh build
Entering dir: build/release
[ 0%] Building CXX object src/lib/arch/CMakeFiles/arch.dir/Arch.cpp.o
(중간 생략)
WARNING: Plugins = PlugIns
Going back to: /Users/nesswit/Downloads/synergy-master

경고... 가 뜨지만 더 이상은 그냥 무시하기로 했습니다.

그럼, 정상적으로 생성된 Synergy.app 파일을 bin 폴더에서 확인할 수 있습니다.