You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
369 lines
14 KiB
369 lines
14 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<project name="Zabbix backend" default="build" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
|
|
|
|
<taskdef resource="net/sf/antcontrib/antlib.xml" />
|
|
|
|
<!-- oracle oci library has functions declarations without arguments: f() instead of f(void), so it triggers -Wstrict-prototypes warning -->
|
|
<property name="COMP_FLAGS_ORACLE" value="-g -std=gnu99 -pedantic -Wall -Wextra -Wunused -Wshadow -Wpointer-arith -Wno-maybe-uninitialized -Wformat -Wmissing-prototypes -Wunreachable-code -Wformat-extra-args -Wno-missing-field-initializers -Wno-missing-field-initializers -Wincompatible-pointer-types -Wnull-dereference -Wold-style-definition -Wmissing-declarations -Wunused-parameter -Winit-self -Wnested-externs -Wjump-misses-init -Wdangling-else -Wformat-signedness -Wfloat-conversion"/>
|
|
<property name="COMP_FLAGS" value="-Wstrict-prototypes ${COMP_FLAGS_ORACLE}"/>
|
|
<property name="ZBX_BASE_FLAGS" value="--enable-server --enable-agent --enable-proxy --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-libevent --with-ldap --with-libcurl"/>
|
|
|
|
<!-- Initialize database related options based on the database type -->
|
|
<switch value="${DBTYPE}" caseinsensitive="true">
|
|
<case value="POSTGRESQL">
|
|
<property name="with.db" value="--with-postgresql"/>
|
|
<property name="with.postgresql" value="true"/>
|
|
</case>
|
|
<case value="ORACLE">
|
|
<property name="with.db" value="--with-oracle"/>
|
|
<property name="with.oracle" value="true"/>
|
|
</case>
|
|
<default>
|
|
<property name="with.db" value="--with-mysql"/>
|
|
<property name="with.mysql" value="true"/>
|
|
</default>
|
|
</switch>
|
|
|
|
<!-- Zabbix various configuration parameters -->
|
|
<target name="init-conf-options">
|
|
<property name="conf1" value="--enable-agent"/>
|
|
<property name="conf2" value="--enable-server ${with.db}"/>
|
|
<property name="conf3" value="--enable-proxy ${with.db}"/>
|
|
<property name="conf4" value="--enable-server --enable-agent --enable-proxy ${with.db}"/>
|
|
<property name="conf6" value="${ZBX_BASE_FLAGS} ${with.db} --with-openipmi --with-openssl"/>
|
|
<property name="conf7" value="${ZBX_BASE_FLAGS} ${with.db} --with-openipmi --with-gnutls"/>
|
|
</target>
|
|
|
|
<!-- Additional Zabbix configuration parameters -->
|
|
<target name="init-conf-options-2">
|
|
<property name="conf8" value="--enable-agent2"/>
|
|
<property name="conf9" value="--enable-server --enable-agent --enable-proxy ${with.db} --with-ssh"/>
|
|
<property name="conf10" value="--enable-agent --with-libmodbus"/>
|
|
</target>
|
|
|
|
<!-- Cppcheck static analyzer target -->
|
|
<target name="cppcheck-static-analyzer">
|
|
<exec executable="./bootstrap.sh" failonerror="on"/>
|
|
<exec executable="scan-build" failonerror="on">
|
|
<arg line="./configure"/>
|
|
<arg line="--quiet"/>
|
|
<arg line="${ZBX_BASE_FLAGS} --with-mysql"/>
|
|
</exec>
|
|
<exec executable="cppcheck" error="${SCANFILE}" failonerror="on">
|
|
<arg line="--enable=all"/>
|
|
<arg line="-j5"/>
|
|
<arg line="-I/usr/include"/>
|
|
<arg line="-I/usr/local/include"/>
|
|
<arg line="-I./include/common"/>
|
|
<arg line="-I./include"/>
|
|
<!-- Exclude Duktape library from checking -->
|
|
<arg line="-isrc/libs/zbxembed/duk_config.h"/>
|
|
<arg line="-isrc/libs/zbxembed/duktape.c"/>
|
|
<arg line="-isrc/libs/zbxembed/duktape.h"/>
|
|
<arg line="--suppress=variableScope:*"/>
|
|
<arg line="--suppress=ConfigurationNotChecked:*"/>
|
|
<arg line="--inconclusive"/>
|
|
<arg line="--force"/>
|
|
<arg line="--xml"/>
|
|
<arg line="--xml-version=2"/>
|
|
<arg line="--cppcheck-build-dir=${CPPCHECK_BUILD_DIR}"/>
|
|
<arg line="."/>
|
|
</exec>
|
|
</target>
|
|
|
|
<!-- Clang Static Analyzer target with various configuration parameters -->
|
|
<target name="clang-static-analyzer" depends="init-conf-options">
|
|
<delete dir="clang-scan-build-reports"/>
|
|
<exec executable="./bootstrap.sh" failonerror="on"/>
|
|
<propertyselector property="conf.list" delimiter="," match="conf(\d+)"/>
|
|
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
|
|
<for list="${conf.list}" param="name" delimiter=",">
|
|
<sequential>
|
|
<exec executable="scan-build" failonerror="on">
|
|
<arg line="./configure"/>
|
|
<arg line="-q"/>
|
|
<arg line="${@{name}}"/>
|
|
</exec>
|
|
<trycatch>
|
|
<try>
|
|
<exec executable="scan-build" failonerror="on">
|
|
<arg line="-plist-html"/>
|
|
<arg line="-o"/>
|
|
<arg line="./clang-scan-build-reports"/>
|
|
<arg line="make"/>
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
</exec>
|
|
</try>
|
|
<finally>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="clean"/>
|
|
</exec>
|
|
</finally>
|
|
</trycatch>
|
|
</sequential>
|
|
</for>
|
|
</target>
|
|
|
|
<macrodef name="make">
|
|
<!-- Build Zabbix with the specified command line arguments -->
|
|
<attribute name="args"/>
|
|
<attribute name="cc" default="gcc"/>
|
|
<attribute name="target" default=""/>
|
|
<attribute name="post-action" default=""/>
|
|
<sequential>
|
|
<!-- initialize cflags depending on used compiler -->
|
|
<local name="common.cflags"/>
|
|
<local name="cc.cflags"/>
|
|
<property name="common.cflags" value="-O2 -g"/>
|
|
<switch value="@{cc}">
|
|
<case value="gcc">
|
|
<property name="cc.cflags" value="${COMP_FLAGS_ORACLE}"/>
|
|
</case>
|
|
<case value="clang">
|
|
<property name="cc.cflags" value=""/>
|
|
</case>
|
|
<default>
|
|
<fail>Unknown compiler type: @{cc}</fail>
|
|
</default>
|
|
</switch>
|
|
|
|
<!-- clean, configure and build -->
|
|
<exec executable="./configure" failonerror="on">
|
|
<env key="CC" value="@{cc}"/>
|
|
<arg line="@{args}"/>
|
|
<arg line="--prefix=$(pwd)/install"/>
|
|
<arg line="CFLAGS="${common.cflags} ${cc.cflags}""/>
|
|
</exec>
|
|
<trycatch>
|
|
<try>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="@{target}"/>
|
|
</exec>
|
|
<if>
|
|
<not >
|
|
<equals arg1="@{post-action}" arg2=""/>
|
|
</not>
|
|
<then>
|
|
<antcall target="@{post-action}"/>
|
|
</then>
|
|
</if>
|
|
</try>
|
|
<finally>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="clean"/>
|
|
</exec>
|
|
</finally>
|
|
</trycatch>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<target name="make-db-mysql" unless="${with.mysql}">
|
|
<!-- Build Zabbix with mysql database -->
|
|
<sequential>
|
|
<make args="${ZBX_BASE_FLAGS} --with-mysql --with-openipmi --with-openssl --enable-ipv6 --with-libmodbus"/>
|
|
</sequential>
|
|
</target>
|
|
|
|
<target name="make-db-postgresql" unless="${with.postgresql}">
|
|
<!-- Build Zabbix with postgresql database -->
|
|
<sequential>
|
|
<make args="${ZBX_BASE_FLAGS} --with-postgresql --with-openipmi --with-openssl"/>
|
|
</sequential>
|
|
</target>
|
|
|
|
<target name="make-db-oracle" unless="${with.oracle}">
|
|
<!-- Build Zabbix with oracle database -->
|
|
<sequential>
|
|
<make args="${ZBX_BASE_FLAGS} --with-oracle --with-openipmi --with-openssl --with-oracle-include=/usr/include/oracle/19.8/client64 --with-oracle-lib=/usr/lib/oracle/19.8/client64/lib"/>
|
|
</sequential>
|
|
</target>
|
|
|
|
<!-- Build Zabbix with all supported databases -->
|
|
<target name="make-db" depends="make-db-mysql,make-db-postgresql,make-db-oracle"/>
|
|
|
|
<target name="clean-tests">
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="clean"/>
|
|
</exec>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="-C"/>
|
|
<arg line="tests"/>
|
|
<arg line="clean"/>
|
|
</exec>
|
|
</target>
|
|
|
|
<macrodef name="make-tests">
|
|
<!-- Build Zabbix cmocka tests with the specified command line arguments -->
|
|
<attribute name="conf"/>
|
|
<attribute name="conf-name"/>
|
|
<sequential>
|
|
<!-- clean, configure and build -->
|
|
<exec executable="./configure" failonerror="on">
|
|
<arg line="@{conf}"/>
|
|
</exec>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="tests_build"/>
|
|
</exec>
|
|
<mkdir dir="tests_results/@{conf-name}"/>
|
|
<exec executable="tests/tests_run.pl" failonerror="off" output="tests_results/@{conf-name}/output.xml">
|
|
<arg line="-x @{conf-name}"/>
|
|
</exec>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<target name="init-cmocka-test-conf-options">
|
|
<!-- Zabbix various configuration parameters for cmocka tests -->
|
|
<!-- Configuration option name must consist of prefix 'cmocka-', configuration order number
|
|
and configuration title: cmocka-<number>-<title> -->
|
|
<property name="cmocka-1-default" value="-q CFLAGS='${COMP_FLAGS}' ${ZBX_BASE_FLAGS} --enable-ipv6 --with-mysql --with-openipmi --with-openssl --with-iconv --with-libpcre"/>
|
|
<property name="cmocka-2-agent-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-agent"/>
|
|
<property name="cmocka-3-server-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-server --with-mysql"/>
|
|
<property name="cmocka-4-proxy-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-proxy --with-sqlite3"/>
|
|
<property name="cmocka-5-sanitizer" value="CC=clang CFLAGS='${COMP_FLAGS} -Wenum-conversion -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q ${ZBX_BASE_FLAGS} --with-openssl --with-openipmi --enable-ipv6 --with-mysql --with-iconv --with-libpcre"/>
|
|
</target>
|
|
|
|
<target name="cmocka-tests" depends="init-cmocka-test-conf-options">
|
|
<!-- Build Zabbix with cmocka tests -->
|
|
<delete dir="tests_results"/>
|
|
<mkdir dir="tests_results"/>
|
|
<exec executable="./bootstrap.sh" failonerror="on">
|
|
<arg line="tests"/>
|
|
</exec>
|
|
<propertyselector property="conf.list" delimiter="," match="cmocka-(.*)" select="\1"/>
|
|
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
|
|
<for list="${conf.list}" param="name" delimiter=",">
|
|
<sequential>
|
|
<make-tests conf="${cmocka-@{name}}" conf-name="@{name}"/>
|
|
<antcall target="clean-tests"/>
|
|
</sequential>
|
|
</for>
|
|
</target>
|
|
|
|
<target name="init-cmocka-ora-test-conf-options">
|
|
<property name="ORA_INCLUDE" value="/usr/include/oracle/12.1/client64"/>
|
|
<property name="ORA_LIB" value="/usr/lib/oracle/12.1/client64/lib"/>
|
|
|
|
<!-- Zabbix various configuration parameters for cmocka Oracle tests -->
|
|
<!-- Configuration option name must consist of prefix 'cmocka-ora-', configuration order number
|
|
and configuration title: cmocka-<number>-<title> -->
|
|
<property name="cmocka-ora-1-default" value="-q CFLAGS='${COMP_FLAGS_ORACLE}' ${ZBX_BASE_FLAGS} --enable-ipv6 --with-openipmi --with-openssl --with-iconv --with-libpcre --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
|
|
<property name="cmocka-ora-2-server-only" value="-q CFLAGS='${COMP_FLAGS_ORACLE}' --enable-server --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
|
|
<property name="cmocka-ora-3-proxy-only" value="-q CFLAGS='${COMP_FLAGS_ORACLE}' --enable-proxy --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
|
|
<property name="cmocka-ora-4-sanitizer" value="CC=clang CFLAGS='${COMP_FLAGS_ORACLE} -Wenum-conversion -O2 -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q ${ZBX_BASE_FLAGS} --enable-ipv6 --with-openipmi --with-openssl --with-iconv --with-libpcre --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
|
|
</target>
|
|
|
|
<target name="cmocka-ora-tests" depends="init-cmocka-ora-test-conf-options">
|
|
<!-- Build Zabbix with cmocka Oracle tests -->
|
|
<delete dir="tests_results"/>
|
|
<mkdir dir="tests_results"/>
|
|
<exec executable="./bootstrap.sh" failonerror="on"/>
|
|
<propertyselector property="conf.list" delimiter="," match="cmocka-ora-(.*)" select="\1"/>
|
|
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
|
|
<for list="${conf.list}" param="name" delimiter=",">
|
|
<sequential>
|
|
<make-tests conf="${cmocka-ora-@{name}}" conf-name="@{name}"/>
|
|
<antcall target="clean-tests"/>
|
|
</sequential>
|
|
</for>
|
|
</target>
|
|
|
|
<target name="gen-test-coverage-report">
|
|
<!-- Generate Zabbix cmocka tests coverage report-->
|
|
<delete dir="tests_results"/>
|
|
<mkdir dir="tests_results"/>
|
|
<mkdir dir="tests_results/html"/>
|
|
<exec executable="lcov" failonerror="on">
|
|
<arg line="--directory"/>
|
|
<arg line="src"/>
|
|
<arg line="-zerocounters"/>
|
|
</exec>
|
|
<exec executable="./bootstrap.sh" failonerror="on">
|
|
<arg line="tests"/>
|
|
</exec>
|
|
<make-tests conf="CFLAGS='--coverage' -q --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-mysql" conf-name="gen-test-coverage-report"/>
|
|
<exec executable="lcov" failonerror="on">
|
|
<arg line="--directory"/>
|
|
<arg line="src"/>
|
|
<arg line="--capture"/>
|
|
<arg line="--output-file"/>
|
|
<arg line="tests_results/html/app.info"/>
|
|
</exec>
|
|
<exec executable="genhtml" failonerror="on">
|
|
<arg line="-p"/>
|
|
<arg line="${user.dir}"/>
|
|
<arg line="-o"/>
|
|
<arg line="tests_results/html"/>
|
|
<arg line="tests_results/html/app.info"/>
|
|
</exec>
|
|
<antcall target="clean-tests"/>
|
|
</target>
|
|
|
|
<target name="make-gcc" depends="init-conf-options,init-conf-options-2">
|
|
<!-- Build Zabbix with various configuration parameters -->
|
|
<propertyselector property="conf.list" delimiter="," match="conf(\d+)"/>
|
|
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
|
|
<for list="${conf.list}" param="name" delimiter=",">
|
|
<sequential>
|
|
<make args="${@{name}}"/>
|
|
</sequential>
|
|
</for>
|
|
</target>
|
|
|
|
<target name="build-dist" depends="make-gcc,make-db"/>
|
|
|
|
<target name="make-dist">
|
|
<!-- Create & build Zabbix distribution -->
|
|
<exec executable="./bootstrap.sh" failonerror="on"/>
|
|
<exec executable="./configure" failonerror="on">
|
|
<arg line="--quiet"/>
|
|
</exec>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="dbschema"/>
|
|
</exec>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="dist"/>
|
|
</exec>
|
|
<apply executable="tar">
|
|
<arg line="xzf"/>
|
|
<fileset dir="." includes="zabbix-*.tar.gz"/>
|
|
</apply>
|
|
<move tofile="sources">
|
|
<dirset dir="." includes="zabbix-*"/>
|
|
</move>
|
|
<ant antfile="../build-backend.xml" dir="sources" target="build-dist" inheritAll="true" inheritRefs="true"/>
|
|
</target>
|
|
|
|
<target name="agent2-tests">
|
|
<!-- Create, build & test agent2 -->
|
|
<exec executable="./bootstrap.sh" failonerror="on"/>
|
|
<exec executable="./configure" failonerror="on">
|
|
<arg line="--quiet"/>
|
|
<arg line="--enable-agent2"/>
|
|
</exec>
|
|
<exec executable="make" failonerror="on">
|
|
<arg line="-s"/>
|
|
<arg line="-j5"/>
|
|
<arg line="check"/>
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="build" depends="make-dist"/>
|
|
</project>
|