Skip to content

Commit cfa6df8

Browse files
Rafael Palomarjcfr
authored andcommitted
cmake: Support building nis module on system having libtirpc
glibc has removed Sun RPC. Use replacement libtirpc headers and library in nis moduleupdated path for rpc.h for systems using libtirpc See python/cpython#5137 This closes python-cmake-buildsystem#224 Co-authored-by: Jean-Christophe Fillion-Robin <[email protected]>
1 parent f5fd65c commit cfa6df8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

cmake/ConfigureChecks.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ endif()
107107
find_path(SQLITE3_INCLUDE_PATH sqlite3.h)
108108
find_library(SQLITE3_LIBRARY sqlite3)
109109

110+
find_path(TIRPC_RPC_INCLUDE_PATH rpc.h PATHS "/usr/include/tirpc/rpc")
111+
find_library(TIRPC_LIBRARY tirpc)
112+
110113
if(WIN32)
111114
set(M_LIBRARIES )
112115
set(HAVE_LIBM 1)
@@ -2495,3 +2498,4 @@ endif()
24952498
if(CMAKE_SYSTEM MATCHES Windows)
24962499
set(PY_PLATFORM win32)
24972500
endif()
2501+

cmake/extensions/CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,23 @@ endif()
147147
# UNIX-only extensions
148148
add_python_extension(fcntl REQUIRES UNIX SOURCES fcntlmodule.c)
149149
add_python_extension(grp REQUIRES UNIX SOURCES grpmodule.c)
150-
add_python_extension(nis REQUIRES UNIX HAVE_LIBNSL SOURCES nismodule.c LIBRARIES ${HAVE_LIBNSL})
150+
151+
set(nis_REQUIRES UNIX HAVE_LIBNSL)
152+
set(nis_LIBRARIES ${HAVE_LIBNSL})
153+
set(nis_INCLUDEDIRS )
154+
if(TIRPC_LIBRARY AND TIRPC_RPC_INCLUDE_PATH)
155+
# if rpc.h is provided by libtirpc (instead of being provided by glibc). See python/cpython#5137
156+
list(APPEND nis_REQUIRES )
157+
list(APPEND nis_LIBRARIES ${TIRPC_LIBRARY})
158+
list(APPEND nis_INCLUDEDIRS ${TIRPC_RPC_INCLUDE_PATH}/../)
159+
endif()
160+
add_python_extension(nis
161+
REQUIRES ${nis_REQUIRES}
162+
SOURCES nismodule.c
163+
LIBRARIES ${nis_LIBRARIES}
164+
INCLUDEDIRS ${nis_INCLUDEDIRS}
165+
)
166+
151167
add_python_extension(posix REQUIRES UNIX BUILTIN SOURCES posixmodule.c)
152168
add_python_extension(pwd REQUIRES UNIX BUILTIN SOURCES pwdmodule.c) # this is needed to find out the user's home dir if $HOME is not set
153169
add_python_extension(resource REQUIRES UNIX SOURCES resource.c)

0 commit comments

Comments
 (0)