build: replace Perl ExtUtils::MakeMaker with pure CMake install

MakeMaker was only used to copy .pm files — no XS compilation, no binary
linking, no dependency resolution. Its hardcoded "Makefile" output name
conflicts with cmake's generated Makefile for in-source builds, and using
FIRST_MAKEFILE=MakefilePerl causes thousands of "uninitialized value"
warnings because MM.pm stats the wrong file.

Replace with native CMake install(DIRECTORY ... FILES_MATCHING PATTERN
"*.pm") directives. Perl module install path is auto-detected at configure
time via `perl -MConfig` (vendorlib on Linux, sitelib on FreeBSD),
overridable with -DZM_PERL_INSTALL_PATH=<path>.

What's removed:
- ExtUtils::MakeMaker as build dependency
- Three perl+make subprocesses at build time (zmperlmodules,
  zmonvifmodules, zmonvifproxy build targets)
- ~6000 auto-generated man3 pages from WSDL stubs
- MakeMaker scaffolding: Makefile.PL, MANIFEST, META.yml, Changes,
  README, and t/ZoneMinder.t test stub

What's preserved:
- configure_file() for .pm.in templates (same behavior)
- ZM_PERL_SEARCH_PATH (independent mechanism, unchanged)
- Section 8 man pages for .pl scripts (Pod2Man.cmake, unaffected)
- DESTDIR support (CMake install() handles natively)
- Installed file paths (perl -MConfig returns same paths MakeMaker used)

Verified: 3102 .pm files installed, 0 .pm.in files, 0 .3pm man pages,
no @VERSION@ markers in generated files, DESTDIR and user override work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pull/4617/head
Nic Boet 2026-02-10 21:08:44 -06:00
parent 08144613fc
commit c23869b6ac
16 changed files with 55 additions and 217 deletions

17
.gitignore vendored
View File

@ -40,37 +40,20 @@ node_modules/
onvif/CMakeFiles/
onvif/cmake_install.cmake
onvif/modules/CMakeFiles/
onvif/modules/MYMETA.json
onvif/modules/MYMETA.yml
onvif/modules/MakefilePerl
onvif/modules/cmake_install.cmake
onvif/modules/output/
onvif/modules/pm_to_blib
onvif/proxy/CMakeFiles/
onvif/proxy/MYMETA.json
onvif/proxy/MYMETA.yml
onvif/proxy/MakefilePerl
onvif/proxy/cmake_install.cmake
onvif/proxy/output/
onvif/proxy/pm_to_blib
onvif/scripts/CMakeFiles/
onvif/scripts/cmake_install.cmake
package.json
package-lock.json
scripts/CMakeFiles/
scripts/ZoneMinder/CMakeFiles/
scripts/ZoneMinder/MYMETA.json
scripts/ZoneMinder/MYMETA.yml
scripts/ZoneMinder/Makefile.old
scripts/ZoneMinder/MakefilePerl
scripts/ZoneMinder/blib
scripts/ZoneMinder/cmake_install.cmake
scripts/ZoneMinder/lib/ZoneMinder/Base.pm
scripts/ZoneMinder/lib/ZoneMinder/Config.pm
scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm
scripts/ZoneMinder/lib/ZoneMinder/Memory.pm
scripts/ZoneMinder/output/
scripts/ZoneMinder/pm_to_blib
scripts/cmake_install.cmake
scripts/zm
scripts/zmaudit.pl

View File

@ -89,7 +89,7 @@ mark_as_advanced(
ZM_MYSQL_ENGINE
ZM_NO_MMAP
CMAKE_INSTALL_FULL_BINDIR
ZM_PERL_MM_PARMS
ZM_PERL_INSTALL_PATH
ZM_PERL_SEARCH_PATH
ZM_TARGET_DISTRO
ZM_PATH_MAP
@ -206,16 +206,10 @@ set(ZM_NO_RTSPSERVER "OFF" CACHE BOOL
"Set to ON to skip building ZM with rtsp server support. default: OFF")
set(ZM_NO_MQTT "OFF" CACHE BOOL
"Set to ON to skip MQTT (Mosquitto) checks and force building ZM without MQTT support. default: OFF")
set(ZM_PERL_MM_PARMS INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 CACHE STRING
"By default, ZoneMinder's Perl modules are installed into the Vendor folders,
as defined by your installation of Perl. You can change that here. Consult Perl's
MakeMaker documentation for a definition of acceptable parameters. If you set this
to something that causes the modules to be installed outside Perl's normal search
path, then you will also need to set ZM_PERL_SEARCH_PATH accordingly.")
set(ZM_PERL_SEARCH_PATH "" CACHE PATH
"Use to add a folder to your Perl's search path. This will need to be set in cases
where ZM_PERL_MM_PARMS has been modified such that ZoneMinder's Perl modules are
installed outside Perl's default search path.")
where ZM_PERL_INSTALL_PATH has been overridden such that ZoneMinder's Perl modules
are installed outside Perl's default search path.")
set(ZM_TARGET_DISTRO "" CACHE STRING
"Build ZoneMinder for a specific distribution. Currently, valid names are: fc, el, OS13, FreeBSD")
set(ZM_DETECT_SYSTEMD "ON" CACHE BOOL
@ -278,17 +272,12 @@ elseif(ZM_TARGET_DISTRO STREQUAL "FreeBSD")
set(ZM_CONFIG_SUBDIR "/usr/local/etc/zm/conf.d")
set(ZM_WEBDIR "/usr/local/share/zoneminder/www")
set(ZM_CGIDIR "/usr/local/libexec/zoneminder/cgi-bin")
set(ZM_PERL_MM_PARMS "INSTALLDIRS=site")
endif()
if(BUILD_MAN)
message(STATUS "Building man pages: Yes (default)")
set(ZM_PERL_MM_PARMS_FULL ${ZM_PERL_MM_PARMS})
else()
message(STATUS "Building man pages: No")
list(APPEND ZM_PERL_MM_PARMS_FULL ${ZM_PERL_MM_PARMS}
"INSTALLMAN1DIR=none"
"INSTALLMAN3DIR=none")
endif()
# Required for certain checks to work
@ -642,13 +631,38 @@ if(NOT PERL_FOUND)
message(FATAL_ERROR "ZoneMinder requires Perl 5.6.0 or newer but it was not found on your system")
endif()
# Detect Perl module installation path
# Prefer vendorlib (standard for distro packages), fall back to sitelib
# (used on FreeBSD and systems without vendorlib configured)
execute_process(
COMMAND ${PERL_EXECUTABLE} -MConfig -e "print \$Config{vendorlib}"
OUTPUT_VARIABLE _perl_lib_default
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _perl_result)
if(NOT _perl_result EQUAL 0 OR _perl_lib_default STREQUAL "")
execute_process(
COMMAND ${PERL_EXECUTABLE} -MConfig -e "print \$Config{sitelib}"
OUTPUT_VARIABLE _perl_lib_default
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _perl_result)
if(NOT _perl_result EQUAL 0 OR _perl_lib_default STREQUAL "")
message(FATAL_ERROR
"Could not detect Perl vendorlib or sitelib path. "
"Set ZM_PERL_INSTALL_PATH manually.")
endif()
message(STATUS "Perl vendorlib not configured, using sitelib")
endif()
set(ZM_PERL_INSTALL_PATH "${_perl_lib_default}" CACHE PATH
"Install path for ZoneMinder Perl modules. Override for non-standard locations (also set ZM_PERL_SEARCH_PATH).")
message(STATUS "Perl module install path: ${ZM_PERL_INSTALL_PATH}")
# Checking for perl modules requires FindPerlModules.cmake
# Check all required modules at once
# TODO: Add checking for the optional modules
find_package(
PerlModules COMPONENTS Sys::Syslog DBI DBD::mysql
Getopt::Long Time::HiRes Date::Manip LWP::UserAgent
ExtUtils::MakeMaker ${ZM_MMAP_PERLPACKAGE})
${ZM_MMAP_PERLPACKAGE})
if(NOT PERLMODULES_FOUND)
message(WARNING "Not all required perl modules were found on your system")
endif()

View File

@ -1,2 +1 @@
usr/share/man/man3
usr/share/perl5

View File

@ -64,7 +64,6 @@ BuildRequires: perl(Archive::Tar)
BuildRequires: perl(Archive::Zip)
BuildRequires: perl(Date::Manip)
BuildRequires: perl(DBD::mysql)
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(LWP::UserAgent)
BuildRequires: perl(MIME::Entity)
BuildRequires: perl(MIME::Lite)

View File

@ -1,2 +1 @@
usr/share/man/man3
usr/share/perl5

View File

@ -1,18 +1,5 @@
# CMakeLists.txt for the ZoneMinder ONVIF modules.
# If this is an out-of-source build, copy the files we need to the binary directory
if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.PL" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lib" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN "*.in" EXCLUDE)
endif()
# MAKEMAKER_NOECHO_COMMAND previously defined in /scripts/zoneminder/CMakeLists.txt
# Add build target for the perl modules
add_custom_target(zmonvifmodules ALL "${PERL_EXECUTABLE}" Makefile.PL ${ZM_PERL_MM_PARMS_FULL} FIRST_MAKEFILE=MakefilePerl DESTDIR="${CMAKE_CURRENT_BINARY_DIR}/output" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make -f MakefilePerl pure_install COMMENT "Building ZoneMinder perl ONVIF proxy module")
# Add install target for the perl modules
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/" DESTINATION "/")
# Add additional files and directories to make clean
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "output;blib;pm_to_blib;MakefilePerl")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib/"
DESTINATION "${ZM_PERL_INSTALL_PATH}"
FILES_MATCHING PATTERN "*.pm")

View File

@ -1,13 +0,0 @@
use 5.006;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'ONVIF',
# VERSION_FROM => 'lib/ZoneMinder/Base.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
# No need to specify perl modules. MakeMaker will find them automatically
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(#ABSTRACT_FROM => 'lib/ZoneMinder.pm', # retrieve abstract from module
AUTHOR => 'Jan Hochstein') : ()),
);

View File

@ -1,18 +1,5 @@
# CMakeLists.txt for the ZoneMinder ONVIF proxy module.
# If this is an out-of-source build, copy the files we need to the binary directory
if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.PL" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lib" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN "*.in" EXCLUDE)
endif()
# MAKEMAKER_NOECHO_COMMAND previously defined in /scripts/zoneminder/CMakeLists.txt
# Add build target for the perl modules
add_custom_target(zmonvifproxy ALL "${PERL_EXECUTABLE}" Makefile.PL ${ZM_PERL_MM_PARMS_FULL} FIRST_MAKEFILE=MakefilePerl DESTDIR=${CMAKE_CURRENT_BINARY_DIR}/output ${MAKEMAKER_NOECHO_COMMAND} COMMAND make -f MakefilePerl pure_install COMMENT "Building ZoneMinder perl ONVIF proxy module")
# Add install target for the perl modules
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/" DESTINATION "/")
# Add additional files and directories to make clean
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "output;blib;pm_to_blib;MakefilePerl")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib/"
DESTINATION "${ZM_PERL_INSTALL_PATH}"
FILES_MATCHING PATTERN "*.pm")

View File

@ -1,13 +0,0 @@
use 5.006;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'ONVIF',
# VERSION_FROM => 'lib/ZoneMinder/Base.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
# No need to specify perl modules. MakeMaker will find them automatically
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(#ABSTRACT_FROM => 'lib/ZoneMinder.pm', # retrieve abstract from module
AUTHOR => 'Jan Hochstein') : ()),
);

View File

@ -1,34 +1,23 @@
# CMakeLists.txt for the ZoneMinder perl module.
# CMakeLists.txt for the ZoneMinder Perl modules.
# If this is an out-of-source build, copy the files we need to the binary directory
if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/Changes" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.PL" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/META.yml" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/README" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/t" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lib" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN "*.in" EXCLUDE)
endif()
# Create configured .pm files from .pm.in templates
configure_file(lib/ZoneMinder/Base.pm.in
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Base.pm" @ONLY)
configure_file(lib/ZoneMinder/Config.pm.in
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm" @ONLY)
configure_file(lib/ZoneMinder/Memory.pm.in
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm" @ONLY)
configure_file(lib/ZoneMinder/ConfigData.pm.in
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm" @ONLY)
configure_file(lib/ZoneMinder/ONVIF.pm.in
"${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ONVIF.pm" @ONLY)
# Create files from the .in files
configure_file(lib/ZoneMinder/Base.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Base.pm" @ONLY)
configure_file(lib/ZoneMinder/Config.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm" @ONLY)
configure_file(lib/ZoneMinder/Memory.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm" @ONLY)
configure_file(lib/ZoneMinder/ConfigData.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm" @ONLY)
configure_file(lib/ZoneMinder/ONVIF.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ONVIF.pm" @ONLY)
# Install static .pm files from source tree
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib/"
DESTINATION "${ZM_PERL_INSTALL_PATH}"
FILES_MATCHING PATTERN "*.pm")
if(CMAKE_VERBOSE_MAKEFILE)
set(MAKEMAKER_NOECHO_COMMAND "")
else()
set(MAKEMAKER_NOECHO_COMMAND "NOECHO=\"1>/dev/null\"")
endif()
# Add build target for the perl modules
add_custom_target(zmperlmodules ALL "${PERL_EXECUTABLE}" Makefile.PL ${ZM_PERL_MM_PARMS_FULL} FIRST_MAKEFILE=MakefilePerl DESTDIR="${CMAKE_CURRENT_BINARY_DIR}/output" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make -f MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules")
# Add install target for the perl modules
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/" DESTINATION "/")
# Add additional files and directories to make clean
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "output;blib;pm_to_blib;MakefilePerl")
# Install configured .pm files from build tree
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib/"
DESTINATION "${ZM_PERL_INSTALL_PATH}"
FILES_MATCHING PATTERN "*.pm")

View File

@ -1,6 +0,0 @@
Revision history for Perl extension ZoneMinder.
0.01 Thu Dec 15 17:22:29 2005
- original version; created by h2xs 1.23 with options
-XA -b 5.6.0 -n ZoneMinder

View File

@ -1,7 +0,0 @@
Changes
Makefile.PL
MANIFEST
README
t/ZoneMinder.t
lib/ZoneMinder.pm
META.yml Module meta-data (added by MakeMaker)

View File

@ -1,10 +0,0 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: ZoneMinder
version: 1.23.2
version_from: lib/ZoneMinder/Base.pm
installdirs: site
requires:
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

View File

@ -1,13 +0,0 @@
use 5.006;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'ZoneMinder',
VERSION_FROM => 'lib/ZoneMinder/Base.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
# No need to specify perl modules. MakeMaker will find them automatically
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/ZoneMinder.pm', # retrieve abstract from module
AUTHOR => 'Philip Coombes <philip.coombes@zoneminder.com>') : ()),
);

View File

@ -1,40 +0,0 @@
ZoneMinder version 0.01
=======================
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
A README file is required for CPAN modules since CPAN extracts the
README file from a module distribution so that people browsing the
archive can use it get an idea of the modules uses. It is usually a
good idea to provide version information here so that people can
decide whether fixes for the module are worth downloading.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules and libraries:
blah blah blah
COPYRIGHT AND LICENCE
Put the correct copyright and licence information here.
Copyright (C) 2005 by Philip Coombes
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.

View File

@ -1,17 +0,0 @@
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl ZoneMinder.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test;
BEGIN { plan tests => 1 };
use ZoneMinder;
ok(1); # If we made it this far, we're ok.
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.