config-flexisip-rpm.cmake 7.24 KB
Newer Older
1
############################################################################
Ghislain MARY's avatar
Ghislain MARY committed
2
# config-flexisip-rpm.cmake
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22
#
############################################################################

23
include(GNUInstallDirs)
24
include(${CMAKE_SOURCE_DIR}/cmake/FindLinuxPlatform.cmake)
25

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
# Check if we have everything to compile correctly

FUNCTION(CHECK_PROGRAM progname)
	find_program(${progname}_PROGRAM
		NAMES ${progname}
	)
	if(NOT ${progname}_PROGRAM)
		message(FATAL_ERROR "Could not find the ${progname} program, which is needed for RPMBuild")
	else()
		message(STATUS "Found ${progname} : ${${progname}_PROGRAM}.")
	endif()
ENDFUNCTION()

FUNCTION(CHECK_LIBRARY libname)
	find_library(${libname}_LIBRARY
		NAMES ${libname}
42
		PATHS /usr/lib/mysql/
43 44 45 46 47 48 49 50 51 52 53 54
	)
	if(NOT ${libname}_LIBRARY)
		message(FATAL_ERROR "Could not find the ${libname} library, which is needed for RPMBuild of flexisip")
	else()
		message(STATUS "Found ${libname} : ${${libname}_LIBRARY}.")
	endif()
ENDFUNCTION()

# Doxygen can be found through CMake
find_package(Doxygen REQUIRED)

# the rest will be checked manually
55
FOREACH(PROGNAME rpmbuild bison)
56 57 58
	CHECK_PROGRAM(${PROGNAME})
ENDFOREACH()

59

60 61
set(FLEXISIP_LIBDEPS ssl mysqlclient_r mysqlclient)
if(PLATFORM STREQUAL "Debian")
62
	set(DEFAULT_VALUE_ENABLE_SOCI_BUILD ON)
63 64 65
endif()

FOREACH(LIBNAME ${FLEXISIP_LIBDEPS})
66 67 68 69
	CHECK_LIBRARY(${LIBNAME})
ENDFOREACH()


Ghislain MARY's avatar
Ghislain MARY committed
70
# Define default values for the flexisip builder options
71
set(DEFAULT_VALUE_DISABLE_BC_ANTLR ON)
jehan's avatar
jehan committed
72
set(DEFAULT_VALUE_ENABLE_ODBC OFF)
73
set(DEFAULT_VALUE_ENABLE_PUSHNOTIFICATION ON)
Ghislain MARY's avatar
Ghislain MARY committed
74
set(DEFAULT_VALUE_ENABLE_REDIS ON)
75
set(DEFAULT_VALUE_ENABLE_SOCI ON)
76
set(DEFAULT_VALUE_ENABLE_UNIT_TESTS OFF)
Ghislain MARY's avatar
Ghislain MARY committed
77
set(DEFAULT_VALUE_CMAKE_LINKING_TYPE "-DENABLE_STATIC=NO")
jehan's avatar
jehan committed
78
set(DEFAULT_VALUE_ENABLE_BC_HIREDIS ON)
79 80 81 82

# Global configuration
set(LINPHONE_BUILDER_HOST "")

83 84
set(RPM_INSTALL_PREFIX "/opt/belledonne-communications")

85 86
# Adjust PKG_CONFIG_PATH to include install directory
if(UNIX)
87 88 89
	set(LINPHONE_BUILDER_PKG_CONFIG_PATH "${RPM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:$ENV{PKG_CONFIG_PATH}:/usr/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:/usr/${CMAKE_INSTALL_LIBDIR}/x86_64-linux-gnu/pkgconfig/:/usr/share/pkgconfig/:/usr/local/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:/opt/local/${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
	message(STATUS "PKG CONFIG PATH: ${LINPHONE_BUILDER_PKG_CONFIG_PATH}")
	message(STATUS "LIBDIR: ${LIBDIR}")
90 91 92 93
else() # Windows
	set(LINPHONE_BUILDER_PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/")
endif()

94
# needed *before* the include
95 96 97
lcb_builder_linking_type(ortp "--enable-static")
lcb_builder_use_autogen(ms2 YES)
lcb_builder_configure_options(ms2 "--disable-video")
98
#required to use autotools
99 100
lcb_builder_use_autogen(bellesip YES)
set(EP_flexisip_FORCE_AUTOTOOLS TRUE)
101

102 103
# we can override the bctoolbox build method before including builders because it doesn't define it.
set(EP_bctoolbox_BUILD_METHOD "rpm")
104 105
lcb_builder_cmake_options(bctoolbox "-DENABLE_TESTS=NO")
lcb_builder_cmake_options(bctoolbox "-DENABLE_TESTS_COMPONENT=NO")
106

107
set(EP_ortp_BUILD_METHOD     "rpm")
108 109 110
# Include builders
include(builders/CMakeLists.txt)

111 112
set(EP_bellesip_LINKING_TYPE "--enable-static")

113
set(EP_bellesip_BUILD_METHOD "rpm")
114 115
set(EP_sofiasip_BUILD_METHOD "rpm")
set(EP_flexisip_BUILD_METHOD "rpm")
116
set(EP_odb_BUILD_METHOD      "custom")
117
set(EP_ms2_BUILD_METHOD "rpm")
118

119
set(EP_ms2_SPEC_PREFIX     "${RPM_INSTALL_PREFIX}")
120
set(EP_ortp_SPEC_PREFIX     "${RPM_INSTALL_PREFIX}")
121
set(EP_bellesip_SPEC_PREFIX "${RPM_INSTALL_PREFIX}")
122 123 124
set(EP_sofiasip_SPEC_PREFIX "${RPM_INSTALL_PREFIX}")
set(EP_flexisip_SPEC_PREFIX "${RPM_INSTALL_PREFIX}")

125
set(EP_flexisip_CONFIGURE_OPTIONS "--enable-redis" "--enable-libodb=no" "--enable-libodb-mysql=no")
126

127

128 129
set(EP_ortp_RPMBUILD_OPTIONS      "--with bc")
set(EP_ms2_RPMBUILD_OPTIONS       "--with bc --without video")
130
set(EP_unixodbc_RPMBUILD_OPTIONS  "--with bc")
131
set(EP_myodbc_RPMBUILD_OPTIONS    "--with bc")
132
set(EP_sofiasip_RPMBUILD_OPTIONS  "--with bc --without glib")
133
set(EP_hiredis_RPMBUILD_OPTIONS   "--with bc" )
134 135 136 137 138 139 140
if (ENABLE_TRANSCODER)
	set(EP_flexisip_RPMBUILD_OPTIONS  "--with bc --with push")
else()
	list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--disable-transcoder")
	set(EP_flexisip_RPMBUILD_OPTIONS  "--with bc --without transcoder --with push")
endif()

141 142 143 144 145 146
set(EP_bellesip_RPMBUILD_OPTIONS  "--with bc ")

if (ENABLE_PRESENCE)
	set(EP_flexisip_RPMBUILD_OPTIONS "${EP_flexisip_RPMBUILD_OPTIONS} --with presence")
	list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--enable-presence")
endif()
147

148
if (ENABLE_SOCI)
149
	set(EP_flexisip_RPMBUILD_OPTIONS "${EP_flexisip_RPMBUILD_OPTIONS} --with soci")
150 151 152
	list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--enable-soci")
endif()

153 154 155 156 157
if (ENABLE_SNMP)
	set(EP_flexisip_RPMBUILD_OPTIONS "${EP_flexisip_RPMBUILD_OPTIONS} --with snmp")
	list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--enable-snmp")
endif()

Ghislain MARY's avatar
Ghislain MARY committed
158
if(ENABLE_BC_ODBC)
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
159 160 161 162 163 164
	set(EP_unixodbc_BUILD_METHOD       "rpm")
	set(EP_myodbc_BUILD_METHOD         "rpm")
	set(EP_unixodbc_SPEC_PREFIX        "${RPM_INSTALL_PREFIX}")
	set(EP_myodbc_SPEC_PREFIX          "${RPM_INSTALL_PREFIX}")
	set(EP_myodbc_CONFIGURE_OPTIONS    "--with-unixODBC=${RPM_INSTALL_PREFIX}")
	set(EP_flexisip_RPMBUILD_OPTIONS   "${EP_flexisip_RPMBUILD_OPTIONS} --with bcodbc")
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
165
	list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--with-odbc=${RPM_INSTALL_PREFIX}")
166
endif()
167

168
set(LINPHONE_BUILDER_RPMBUILD_PACKAGE_PREFIX "bc-")
169

170 171
# prepare the RPMBUILD options that we need to pass

172
set(RPMBUILD_OPTIONS "--define '_mandir %{_prefix}'")
173

jehan's avatar
jehan committed
174 175 176 177 178
# bc-redis  will be installed in the prefix, but we have to pass it through a special flag to the RPM build, since there
# is no pkgconfig
list(APPEND EP_flexisip_CONFIGURE_OPTIONS "--with-redis=${CMAKE_INSTALL_PREFIX}")
set(EP_flexisip_RPMBUILD_OPTIONS "${EP_flexisip_RPMBUILD_OPTIONS} --define 'hiredisdir ${RPM_INSTALL_PREFIX}'")

179
if(PLATFORM STREQUAL "Debian")
180
	# dependencies cannot be checked by rpmbuild in debian
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
181
	set(RPMBUILD_OPTIONS "${RPMBUILD_OPTIONS} --nodeps")
182

183
	# dist is not defined in debian for rpmbuild..
184 185
	set(RPMBUILD_OPTIONS "${RPMBUILD_OPTIONS} --define 'dist .deb'")

186
	# debian has multi-arch lib dir instead of lib and lib64
187 188
	set(RPMBUILD_OPTIONS "${RPMBUILD_OPTIONS} --define '_libdir %{_prefix}/${CMAKE_INSTALL_LIBDIR}'")

189 190
	# some debians are using dash as shell, which doesn't support "export -n", so we override and use bash
	set(RPMBUILD_OPTIONS "${RPMBUILD_OPTIONS} --define '_buildshell /bin/bash'")
191

192 193
	CHECK_PROGRAM(alien)
	CHECK_PROGRAM(fakeroot)
194 195
endif()

196
set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTION ${RPMBUILD_OPTIONS})