2
# Copyright (C) 2003-2010 Sebastien Helleu <flashcode@flashtux.org>
3
# Copyright (C) 2009 Julien Louis <ptitlouis@sysif.net>
5
# This file is part of WeeChat, the extensible chat client.
7
# WeeChat is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
12
# WeeChat is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
22
# This module finds if Python is installed and determines where the include files
23
# and libraries are. It also determines what the name of the library is. This
24
# code sets the following variables:
26
# PYTHON_EXECUTABLE = full path to the python binary
27
# PYTHON_INCLUDE_PATH = path to where python.h can be found
28
# PYTHON_LIBRARY = path to where libpython.so* can be found
29
# PYTHON_LFLAGS = python compiler options for linking
32
# Already in cache, be silent
33
SET(PYTHON_FIND_QUIETLY TRUE)
36
FIND_PROGRAM(PYTHON_EXECUTABLE
37
NAMES python python2.6 python2.5 python2.4 python2.3 python2.2
38
PATHS /usr/bin /usr/local/bin /usr/pkg/bin
43
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('CONFINCLUDEPY')"
44
OUTPUT_VARIABLE PYTHON_INC_DIR
48
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LIBPL')"
49
OUTPUT_VARIABLE PYTHON_POSSIBLE_LIB_PATH
53
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_config_var('LINKFORSHARED')"
54
OUTPUT_VARIABLE PYTHON_LFLAGS
57
# remove the new lines from the output by replacing them with empty strings
58
STRING(REPLACE "\n" "" PYTHON_INC_DIR "${PYTHON_INC_DIR}")
59
STRING(REPLACE "\n" "" PYTHON_POSSIBLE_LIB_PATH "${PYTHON_POSSIBLE_LIB_PATH}")
60
STRING(REPLACE "\n" "" PYTHON_LFLAGS "${PYTHON_LFLAGS}")
62
FIND_PATH(PYTHON_INCLUDE_PATH
64
PATHS ${PYTHON_INC_DIR}
67
FIND_LIBRARY(PYTHON_LIBRARY
68
NAMES python python2.6 python2.5 python2.4 python2.3 python2.2
69
PATHS ${PYTHON_POSSIBLE_LIB_PATH}
72
IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
73
SET(PYTHON_FOUND TRUE)
74
ENDIF(PYTHON_LIBRARY AND PYTHON_INCLUDE_PATH)
83
ENDIF(PYTHON_EXECUTABLE)