Commit 3e140f9a authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Some changes to build the Python module on Mac OS X.

parent 4b2f6a77
......@@ -92,22 +92,50 @@ if(WIN32)
file(GLOB LINPHONE_DYNAMIC_LIBRARIES "${CMAKE_INSTALL_PREFIX}/bin/*.dll")
list(APPEND _BUILDS "exe" "msi" "zip" "wheel")
endif()
if(UNIX AND NOT APPLE)
set(LINPHONE_DYNAMIC_LIBRARIES
"${CMAKE_INSTALL_PREFIX}/lib/libavcodec.so.53"
"${CMAKE_INSTALL_PREFIX}/lib/libavutil.so.51"
"${CMAKE_INSTALL_PREFIX}/lib/libswscale.so.2"
)
if(UNIX)
set(LINPHONE_STATIC_LIBRARIES )
set(LINPHONE_DYNAMIC_LIBRARIES )
foreach(lib ${LINPHONE_LIBRARIES})
if(${lib} MATCHES "\\.a$")
list(APPEND LINPHONE_STATIC_LIBRARIES ${lib})
else()
list(APPEND LINPHONE_DYNAMIC_LIBRARIES ${lib})
endif()
endforeach()
find_program(LORDER_EXECUTABLE lorder)
if(NOT LORDER_EXECUTABLE)
message(FATAL_ERROR "lorder executable is needed.")
endif()
find_program(TSORT_EXECUTABLE tsort)
if(NOT TSORT_EXECUTABLE)
message(FATAL_ERROR "tsort executable is needed.")
endif()
execute_process(COMMAND ${LORDER_EXECUTABLE} ${LINPHONE_STATIC_LIBRARIES} OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lorder.out")
execute_process(COMMAND ${TSORT_EXECUTABLE} OUTPUT_VARIABLE LINPHONE_STATIC_LIBRARIES INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lorder.out")
separate_arguments(LINPHONE_STATIC_LIBRARIES UNIX_COMMAND "${LINPHONE_STATIC_LIBRARIES}")
if(APPLE)
set(LINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL
"${CMAKE_INSTALL_PREFIX}/lib/libavcodec.53.61.100.dylib"
"${CMAKE_INSTALL_PREFIX}/lib/libavutil.51.35.100.dylib"
"${CMAKE_INSTALL_PREFIX}/lib/libswscale.2.1.100.dylib"
)
else()
set(LINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL
"${CMAKE_INSTALL_PREFIX}/lib/libavcodec.so.53.61.100"
"${CMAKE_INSTALL_PREFIX}/lib/libavutil.so.51.35.100"
"${CMAKE_INSTALL_PREFIX}/lib/libswscale.so.2.1.100"
)
endif()
list(APPEND _BUILDS "zip" "wheel")
endif()
foreach(_BUILD ${_BUILDS})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.cmake" "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone/__init__.py")
if(UNIX AND NOT APPLE)
foreach(lib ${LINPHONE_DYNAMIC_LIBRARIES})
get_filename_component(libname ${lib} NAME)
file(GLOB reallib "${lib}.*")
if(UNIX)
foreach(reallib ${LINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL})
get_filename_component(libpath ${reallib} DIRECTORY)
get_filename_component(reallibname ${reallib} NAME)
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" libname ${reallibname})
file(COPY ${reallib} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone")
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone/${reallibname}" "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone/${libname}")
endforeach()
......
......@@ -17,6 +17,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
import re
import string
import sys
from setuptools import setup, Extension
......@@ -28,6 +29,8 @@ version = "@BUILD_VERSION@"
macros = "@LINPHONE_CPPFLAGS@"
include_dirs = "@LINPHONE_INCLUDE_DIRS@"
libraries = "@LINPHONE_LIBRARIES@"
static_libraries = "@LINPHONE_STATIC_LIBRARIES@"
dynamic_libraries = "@LINPHONE_DYNAMIC_LIBRARIES@"
data_files = "@LINPHONE_DATA_FILES@"
define_macros = []
......@@ -38,25 +41,32 @@ for macro in macros:
define_macros.append((macro, None))
include_dirs = list(set(include_dirs.split(';')))
libraries = libraries.split(';')
library_dirs = [os.path.dirname(item) for item in libraries if os.path.dirname(item) != '' and os.path.dirname(item) != lib_install_prefix]
if static_libraries != '':
static_libraries = static_libraries.split(';')
if dynamic_libraries != '':
dynamic_libraries = dynamic_libraries.split(';')
library_dirs = []
for l in [libraries, static_libraries, dynamic_libraries]:
library_dirs += [os.path.dirname(item) for item in l if os.path.dirname(item) != '' and os.path.dirname(item) != lib_install_prefix]
library_dirs = list(set(library_dirs))
library_dirs.insert(0, lib_install_prefix)
libraries = [os.path.basename(item) for item in libraries]
static_libraries = [os.path.basename(item) for item in static_libraries]
dynamic_libraries = [os.path.basename(item) for item in dynamic_libraries]
extra_compile_args = []
extra_link_args = []
if sys.platform.startswith("win32"):
libraries = [string.replace(item, '.lib', '') for item in libraries]
else:
libraries = [item[3:] for item in libraries]
static_libraries = [item for item in libraries if item.endswith('.a')]
dynamic_libraries = [item for item in libraries if '.so' in item]
static_libraries = [string.replace(item, '.a', '') for item in static_libraries]
dynamic_libraries = [string.replace(item, '.so', '') for item in dynamic_libraries]
extra_link_args.append("-Wl,--start-group")
extra_link_args += ['-l' + item for item in static_libraries]
extra_link_args.append("-Wl,--end-group")
extra_link_args.append("-Wl,-rpath=$ORIGIN")
libraries = dynamic_libraries
if sys.platform.startswith("darwin"):
dynext = '.dylib'
else:
dynext = '.so'
static_libraries = [re.search('lib(\w+).*', item).group(1) for item in static_libraries]
dynamic_libraries = [re.search('lib(\w+).*', item).group(1) for item in dynamic_libraries]
if sys.platform.startswith("linux"):
extra_link_args.append("-Wl,-rpath=$ORIGIN")
libraries = static_libraries + dynamic_libraries
if build_type == "Debug":
extra_compile_args = ["-O0"]
data_files = data_files.split(';')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment