1# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; version 2 of the License. 6# 7# This program is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU General Public License for more details. 11# 12# You should have received a copy of the GNU General Public License 13# along with this program; if not, write to the Free Software 14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA 15 16# Produce meaningful package name for the binary package 17# The logic is rather involved with special cases for different OSes 18INCLUDE(CheckTypeSize) 19CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) 20MACRO(GET_PACKAGE_FILE_NAME Var) 21IF(NOT VERSION) 22 MESSAGE(FATAL_ERROR 23 "Variable VERSION needs to be set prior to calling GET_PACKAGE_FILE_NAME") 24 ENDIF() 25 IF(NOT SYSTEM_NAME_AND_PROCESSOR) 26 SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 1) 27 SET(DEFAULT_PLATFORM ${CMAKE_SYSTEM_NAME}) 28 SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR}) 29 IF(SIZEOF_VOIDP EQUAL 8) 30 SET(64BIT 1) 31 ENDIF() 32 33 IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64") 34 SET(DEFAULT_MACHINE "mips") 35 ENDIF() 36 37 IF(CMAKE_SYSTEM_NAME MATCHES "Windows") 38 SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0) 39 SET(DEFAULT_PLATFORM "win") 40 IF(64BIT) 41 SET(DEFAULT_MACHINE "x64") 42 ELSE() 43 SET(DEFAULT_MACHINE "32") 44 ENDIF() 45 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux") 46 IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") 47 SET(DEFAULT_MACHINE "i686") 48 ENDIF() 49 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") 50 # SunOS 5.10=> solaris10 51 STRING(REPLACE "5." "" VER "${CMAKE_SYSTEM_VERSION}") 52 SET(DEFAULT_PLATFORM "solaris${VER}") 53 IF(64BIT) 54 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") 55 SET(DEFAULT_MACHINE "x86_64") 56 ELSE() 57 SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") 58 ENDIF() 59 ENDIF() 60 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX") 61 STRING(REPLACE "B." "" VER "${CMAKE_SYSTEM_VERSION}") 62 SET(DEFAULT_PLATFORM "hpux${VER}") 63 IF(64BIT) 64 SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") 65 ENDIF() 66 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "AIX") 67 SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}5.${CMAKE_SYSTEM_VERSION}") 68 IF(64BIT) 69 SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") 70 ENDIF() 71 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 72 STRING(REGEX MATCH "[0-9]+\\.[0-9]+" VER "${CMAKE_SYSTEM_VERSION}") 73 SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}${VER}") 74 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64") 75 SET(DEFAULT_MACHINE "x86_64") 76 IF(NOT 64BIT) 77 SET(DEFAULT_MACHINE "i386") 78 ENDIF() 79 ENDIF() 80 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "GNU") 81 SET(DEFAULT_PLATFORM "GNU") 82 SET(DEFAULT_MACHINE "i386") 83 ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin") 84 IF(CMAKE_OSX_DEPLOYMENT_TARGET) 85 SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}") 86 ELSE() 87 SET(VER "${CMAKE_SYSTEM_VERSION}") 88 STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VER "${VER}") 89 # Subtract 4 from Darwin version to get correct osx10.X 90 MATH(EXPR VER "${VER} -4") 91 SET(DEFAULT_PLATFORM "osx10.${VER}") 92 ENDIF() 93 94 IF(CMAKE_OSX_ARCHITECTURES) 95 LIST(LENGTH CMAKE_OSX_ARCHITECTURES LEN) 96 IF(LEN GREATER 1) 97 SET(DEFAULT_MACHINE "universal") 98 ELSE() 99 SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}") 100 ENDIF() 101 ELSE() 102 IF(64BIT) 103 SET(DEFAULT_MACHINE "x86_64") 104 ELSE() 105 SET(DEFAULT_MACHINE "i386") 106 ENDIF() 107 ENDIF() 108 109 IF(DEFAULT_MACHINE MATCHES "i386") 110 SET(DEFAULT_MACHINE "x86") 111 ENDIF() 112 ENDIF() 113 114 IF(NOT DEFAULT_MACHINE MATCHES "64" AND 64BIT) 115 SET(DEFAULT_MACHINE "${DEFAULT_MACHINE}-64bit") 116 ENDIF() 117 118 IF(NOT PLATFORM) 119 SET(PLATFORM ${DEFAULT_PLATFORM}) 120 ENDIF() 121 IF(NOT MACHINE) 122 SET(MACHINE ${DEFAULT_MACHINE}) 123 ENDIF() 124 125 IF(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE) 126 SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}-${MACHINE}") 127 ELSE() 128 SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}${MACHINE}") 129 ENDIF() 130 ENDIF() 131 132 IF(SHORT_PRODUCT_TAG) 133 SET(PRODUCT_TAG "-${SHORT_PRODUCT_TAG}") 134 ELSEIF(MYSQL_SERVER_SUFFIX) 135 SET(PRODUCT_TAG "${MYSQL_SERVER_SUFFIX}") # Already has a leading dash 136 ELSE() 137 SET(PRODUCT_TAG) 138 ENDIF() 139 140 SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}") 141 142 MESSAGE_ONCE(package_name "Packaging as: ${package_name}") 143 144 # Sometimes package suffix is added (something like "-icc-glibc23") 145 IF(PACKAGE_SUFFIX) 146 SET(package_name "${package_name}${PACKAGE_SUFFIX}") 147 ENDIF() 148 STRING(TOLOWER ${package_name} package_name) 149 SET(${Var} ${package_name}) 150ENDMACRO() 151