blob: 4d780143496fd7ca20bcc8ce5d4d08f8824dfb89 [file] [log] [blame]
Michal Vaskob725ee82019-12-20 15:20:51 +01001set(PACKAGE "libyang")
2set(CPP_PACKAGE "libyang-cpp")
Michal Vasko8daccd62019-12-20 15:52:17 +01003set(PYTHON_PACKAGE "python3-yang")
Martin Winter7fbed082020-07-15 16:41:48 +02004set(TOOLS_PACKAGE "libyang-tools")
Michal Vaskob725ee82019-12-20 15:20:51 +01005
6find_program(DEB_BUILDER NAMES debuild)
7find_program(RPM_BUILDER NAMES rpmbuild)
8
9# setup package build
10configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.spec.in ${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.spec)
11configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.dsc.in ${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.dsc)
12configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY)
13configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules)
Michal Vasko143f4182020-01-27 10:38:27 +010014configure_file(${PROJECT_SOURCE_DIR}/packages/debian.compat
15 ${PROJECT_BINARY_DIR}/build-packages/debian.compat COPYONLY)
Michal Vasko10542002020-07-29 09:59:11 +020016configure_file(${PROJECT_SOURCE_DIR}/packages/debian.copyright
17 ${PROJECT_BINARY_DIR}/build-packages/debian.copyright COPYONLY)
Michal Vaskob725ee82019-12-20 15:20:51 +010018configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.rpmlintrc
19 ${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.rpmlintrc COPYONLY)
Michal Vaskob725ee82019-12-20 15:20:51 +010020configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PACKAGE}.install
Michal Vasko10542002020-07-29 09:59:11 +020021 ${PROJECT_BINARY_DIR}/build-packages/debian.${PACKAGE}${LIBYANG_MAJOR_SOVERSION}.install COPYONLY)
Michal Vaskob725ee82019-12-20 15:20:51 +010022configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PACKAGE}-dev.install
23 ${PROJECT_BINARY_DIR}/build-packages/debian.${PACKAGE}-dev.install COPYONLY)
24configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}.install
Michal Vasko10542002020-07-29 09:59:11 +020025 ${PROJECT_BINARY_DIR}/build-packages/debian.${CPP_PACKAGE}${LIBYANG_MAJOR_SOVERSION}.install COPYONLY)
Michal Vaskob725ee82019-12-20 15:20:51 +010026configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}-dev.install
27 ${PROJECT_BINARY_DIR}/build-packages/debian.${CPP_PACKAGE}-dev.install COPYONLY)
Michal Vasko143f4182020-01-27 10:38:27 +010028# no python package for Debian because there is only SWIG 3.10 on Debian 9 :-/
29#configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PYTHON_PACKAGE}.install
Michal Vasko10542002020-07-29 09:59:11 +020030# ${PROJECT_BINARY_DIR}/build-packages/debian.${PYTHON_PACKAGE}${LIBYANG_MAJOR_SOVERSION}.install COPYONLY)
Michal Vaskob725ee82019-12-20 15:20:51 +010031
Michal Vasko2b677b82020-02-03 09:17:11 +010032if(NOT DEB_BUILDER)
Michal Vaskob725ee82019-12-20 15:20:51 +010033 message(STATUS "Missing tools (devscripts, debhelper package) for building DEB package.")
Michal Vasko2b677b82020-02-03 09:17:11 +010034else()
Michal Vaskob725ee82019-12-20 15:20:51 +010035 # target for local build deb package
36 message(STATUS "To build local DEB package, use \"build-deb\" target.")
37 add_custom_target(build-deb
38 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
39 COMMAND build-packages/local-deb.sh
40 )
41 configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY)
42endif()
43
Michal Vasko2b677b82020-02-03 09:17:11 +010044if(NOT RPM_BUILDER)
Michal Vaskob725ee82019-12-20 15:20:51 +010045 message(STATUS "Missing tools (rpm package) for building RPM package.")
Michal Vasko2b677b82020-02-03 09:17:11 +010046else()
Michal Vaskob725ee82019-12-20 15:20:51 +010047 # target for local build rpm package
48 message(STATUS "To build local RPM package, use \"build-rpm\" target.")
49 string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})
50 add_custom_target(build-rpm
51 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
52 COMMAND build-packages/local-rpm.sh
53 )
54 configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY)
55endif()