Skip to content

Commit 46f3249

Browse files
committed
Build script updates.
1 parent 842f8b8 commit 46f3249

File tree

5 files changed

+192
-56
lines changed

5 files changed

+192
-56
lines changed

autogen.sh

+119-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,126 @@
11
#!/usr/bin/env bash
2+
#
3+
# Build Scripts
4+
# Copyright (C) 2002-2025 by Thomas Dreibholz
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
220

321
# Bash options:
4-
set -e
22+
set -eu
523

6-
# ------ Obtain number of cores ---------------------------------------------
7-
# Try Linux
8-
cores=`getconf _NPROCESSORS_ONLN 2>/dev/null || true`
9-
if [ "$cores" == "" ] ; then
10-
# Try FreeBSD
11-
cores=`sysctl -a | grep 'hw.ncpu' | cut -d ':' -f2 | tr -d ' '`
24+
25+
CMAKE_OPTIONS=""
26+
COMMAND=""
27+
CORES=
28+
29+
while [ $# -gt 0 ] ; do
30+
if [[ "$1" =~ ^(-|--)use-clang$ ]] ; then
31+
# Use these settings for CLang:
32+
export CXX=clang++
33+
export CC=clang
34+
elif [[ "$1" =~ ^(-|--)use-clang-scan-build$ ]] ; then
35+
# Use these settings for CLang:
36+
export CXX=clang++
37+
export CC=clang
38+
# Ensure build with CLang Static Analyzer
39+
mkdir -p scan-build-reports
40+
COMMAND="scan-build -o scan-build-reports"
41+
elif [[ "$1" =~ ^(-|--)use-gcc$ ]] ; then
42+
# Use these settings for GCC:
43+
export CXX=g++
44+
export CC=gcc
45+
elif [[ "$1" =~ ^(-|--)use-gcc-analyzer$ ]] ; then
46+
# Use these settings for GCC:
47+
export CXX=g++
48+
export CC=gcc
49+
export CFLAGS=-fanalyzer
50+
export CXXFLAGS=-fanalyzer
51+
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=ON"
52+
CORES=1 # The analyzer takes a *huge* amount of memory!
53+
elif [[ "$1" =~ ^(-|--)debug$ ]] ; then
54+
# Enable debugging build:
55+
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=Debug"
56+
elif [[ "$1" =~ ^(-|--)release$ ]] ; then
57+
# Enable debugging build:
58+
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=Release"
59+
elif [[ "$1" =~ ^(-|--)release-with-debinfo$ ]] ; then
60+
# Enable debugging build:
61+
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=RelWithDebInfo"
62+
elif [[ "$1" =~ ^(-|--)verbose$ ]] ; then
63+
# Enable verbose Makefile:
64+
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=ON"
65+
elif [[ "$1" =~ ^(-|--)cores ]] ; then
66+
if [[ ! "$2" =~ ^[0-9]*$ ]] ; then
67+
echo >&2 "ERROR: Number of cores must be an integer number!"
68+
exit 1
69+
fi
70+
CORES="$2"
71+
shift
72+
elif [ "$1" == "--" ] ; then
73+
shift
74+
break
75+
else
76+
echo >&2 "Usage: autogen.sh [--use-clang|--use-clang-scan-build|--use-gcc|--use-gcc-analyzer] [--debug|--release|--release-with-debinfo] [--cores N] [--verbose] -- (further CMake/Configure options)"
77+
exit 1
78+
fi
79+
shift
80+
done
81+
82+
if [ "$(uname)" != "FreeBSD" ] ; then
83+
installPrefix="/usr"
84+
else
85+
installPrefix="/usr/local"
1286
fi
13-
if [ "$cores" == "" ] ; then
14-
cores="1"
87+
88+
89+
# ====== Configure with CMake ===============================================
90+
if [ -e CMakeLists.txt ] ; then
91+
rm -f CMakeCache.txt
92+
if [ "$*" != "" ] ; then
93+
CMAKE_OPTIONS="${CMAKE_OPTIONS} $*"
94+
fi
95+
echo "CMake options:${CMAKE_OPTIONS} . -DCMAKE_INSTALL_PREFIX=\"${installPrefix}\""
96+
# shellcheck disable=SC2048,SC2086
97+
${COMMAND} cmake ${CMAKE_OPTIONS} . -DCMAKE_INSTALL_PREFIX="${installPrefix}"
98+
99+
# ====== Configure with AutoConf/AutoMake ===================================
100+
elif [ -e bootstrap ] ; then
101+
./bootstrap
102+
./configure $*
103+
104+
else
105+
echo >&2 "ERROR: Failed to configure with CMake or AutoMake/AutoConf!"
106+
exit 1
107+
fi
108+
109+
110+
# ====== Obtain number of cores =============================================
111+
# Try Linux
112+
if [ "${CORES}" == "" ] ; then
113+
CORES=$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)
114+
if [ "${CORES}" == "" ] ; then
115+
# Try FreeBSD
116+
CORES=$(sysctl -a | grep 'hw.ncpu' | cut -d ':' -f2 | tr -d ' ' || true)
117+
fi
118+
if [ "${CORES}" == "" ] ; then
119+
CORES="1"
120+
fi
121+
echo "This system has ${CORES} cores!"
15122
fi
16123

17-
# ------ Configure and build ------------------------------------------------
18-
./bootstrap
19-
./configure --enable-static --enable-shared --enable-maintainer-mode --enable-sctp-over-udp $@
20-
make -j${cores}
124+
125+
# ====== Build ==============================================================
126+
${COMMAND} make -j"${CORES}"

ci/build-tool

+67-38
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
#
44
# Unified Build Tool
5-
# Copyright (C) 2021-2025 by Thomas Dreibholz
5+
# Copyright (C) 2021-2024 by Thomas Dreibholz
66
#
77
# This program is free software: you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
@@ -370,10 +370,12 @@ def readRPMPackagingInformation():
370370
rpm_spec_names = glob.glob('rpm/*.spec')
371371
if len(rpm_spec_names) == 1:
372372
packageInfo['rpm_spec_name'] = rpm_spec_names[0]
373+
packageInfo['rpm_packages'] = [ ]
373374

374375
re_rpm_name = re.compile(r'^(Name:[ \t]*)(\S+)')
375376
re_rpm_version = re.compile(r'^(Version:[ \t]*)(\d+)\.(\d+)\.(\d+)(.*|)')
376377
re_rpm_release = re.compile(r'^(Release:[ \t]*)(\d+)')
378+
re_rpm_package = re.compile(r'^(%package[ \t]+)([a-zA-Z0-9+-]+)')
377379
try:
378380
rpmSpecFile = open(packageInfo['rpm_spec_name'], 'r', encoding='utf-8')
379381
rpmSpecFileContents = rpmSpecFile.readlines()
@@ -397,17 +399,32 @@ def readRPMPackagingInformation():
397399
match = re_rpm_name.match(line)
398400
if match != None:
399401
packageInfo['rpm_package_name'] = match.group(2)
402+
else:
403+
match = re_rpm_package.match(line)
404+
if match != None:
405+
packageInfo['rpm_packages'].append(
406+
packageInfo['rpm_package_name'] + '-' + \
407+
match.group(2) + '-' + \
408+
packageInfo['rpm_version_string'] + '-' + \
409+
str(packageInfo['rpm_version_packaging']))
410+
400411
rpmSpecFile.close()
401412

402413
except Exception as e:
403414
sys.stderr.write('ERROR: Unable to read ' + packageInfo['rpm_spec_name'] + ': ' + str(e) + '\n')
404415
sys.exit(1)
405416

406417
# ====== Check whether information is complete ========================
407-
if ( (not 'rpm_package_name' in packageInfo) or
408-
(not 'rpm_version_packaging' in packageInfo) ):
418+
if ( (not 'rpm_package_name' in packageInfo) or
419+
(not 'rpm_version_packaging' in packageInfo) or
420+
(not 'rpm_version_string' in packageInfo) ):
409421
sys.stderr.write('ERROR: Cannot find required package versioning details in ' + packageInfo['rpm_spec_name'] + '!\n')
410422
sys.exit(1)
423+
packageInfo['rpm_packages'].append(
424+
packageInfo['rpm_package_name'] + '-' +
425+
packageInfo['rpm_version_string'] + '-' +
426+
str(packageInfo['rpm_version_packaging']))
427+
print(packageInfo['rpm_packages'])
411428

412429
elif len(rpm_spec_names) > 1:
413430
sys.stderr.write('ERROR: More than one spec file found: ' + str(rpm_spec_names) + '!\n')
@@ -1607,19 +1624,20 @@ def buildRPM(packageInfo, releases, architectures, skipPackageSigning, summaryFi
16071624
for buildArchitecture in architectures:
16081625
for release in releases:
16091626

1610-
printSubsection('Creating binary RPM package for ' + release + '/' + buildArchitecture)
1627+
printSubsection('Creating binary RPM package(s) for ' + release + '/' + buildArchitecture)
16111628

16121629
# ====== Check for mock configuration file =========================
16131630
configuration = release + '-' + buildArchitecture
16141631
if not os.path.isfile('/etc/mock/' + configuration + '.cfg'):
16151632
sys.stderr.write('ERROR: Configuration ' + '/etc/mock/' + configuration + '.cfg does not exist!\n')
16161633
sys.exit(1)
16171634

1618-
# ====== Delete old RPM ============================================
1619-
rpmFile = '/var/lib/mock/' + configuration + '/result/' + \
1620-
packageInfo['rpm_package_name'] + '-' + \
1621-
packageInfo['rpm_version_string'] + '-' + str(packageInfo['rpm_version_packaging']) + '.' + \
1622-
buildArchitecture + '.rpm'
1635+
# ====== Delete old RPMs ===========================================
1636+
for rpmFilePrefix in packageInfo['rpm_packages']:
1637+
for architecture in [ 'noarch', buildArchitecture ]:
1638+
rpmFile = '/var/lib/mock/' + configuration + '/result/' + \
1639+
rpmFilePrefix + '.' + \
1640+
architecture + '.rpm'
16231641
try:
16241642
os.unlink(rpmFile)
16251643
except FileNotFoundError:
@@ -1642,38 +1660,49 @@ def buildRPM(packageInfo, releases, architectures, skipPackageSigning, summaryFi
16421660
sys.exit(1)
16431661

16441662
# ------ Check resulting RPM =======================================
1645-
if not os.path.isfile(rpmFile):
1646-
sys.stderr.write('ERROR: RPM ' + rpmFile + ' not found!\n')
1647-
sys.exit(1)
1648-
1649-
# ====== Sign SRPM =================================================
1650-
if skipPackageSigning == False:
1651-
rpmsign = [ 'rpmsign',
1652-
'--define', '_gpg_name ' + packageInfo['packaging_maintainer_key'],
1653-
'--addsign', rpmFile ]
1654-
print(rpmsign)
1655-
try:
1656-
subprocess.run(rpmsign, check = True)
1657-
except Exception as e:
1658-
sys.stderr.write('ERROR: RPMSign run failed: ' + str(e) + '\n')
1663+
for rpmFilePrefix in packageInfo['rpm_packages']:
1664+
rpmArchitecture = None
1665+
found = False
1666+
for architecture in [ 'noarch', buildArchitecture ]:
1667+
rpmFile = '/var/lib/mock/' + configuration + '/result/' + \
1668+
rpmFilePrefix + '.' + \
1669+
architecture + '.rpm'
1670+
if os.path.isfile(rpmFile):
1671+
rpmArchitecture = architecture
1672+
found = True
1673+
break
1674+
if not found:
1675+
sys.stderr.write('ERROR: RPM ' + rpmFile + ' not found!\n')
16591676
sys.exit(1)
16601677

1661-
# ====== Run RPM Lint ==============================================
1662-
if shutil.which('rpmlint') != None:
1663-
rpmlintCommand = 'rpmlint -P ' + rpmFile
1664-
printSubsection('Running RPM Lint')
1665-
print('=> ' + rpmlintCommand)
1666-
try:
1667-
subprocess.run(rpmlintCommand, check=False, shell=True)
1668-
except Exception as e:
1669-
sys.stderr.write('ERROR: RPM Lint run failed: ' + str(e) + '\n')
1670-
sys.exit(1)
1671-
else:
1672-
sys.stderr.write('NOTE: RPM Lint is not installed -> checks skipped!\n')
1678+
# ====== Sign SRPM ==============================================
1679+
if skipPackageSigning == False:
1680+
rpmsign = [ 'rpmsign',
1681+
'--define', '_gpg_name ' + packageInfo['packaging_maintainer_key'],
1682+
'--addsign', rpmFile ]
1683+
print(rpmsign)
1684+
try:
1685+
subprocess.run(rpmsign, check = True)
1686+
except Exception as e:
1687+
sys.stderr.write('ERROR: RPMSign run failed: ' + str(e) + '\n')
1688+
sys.exit(1)
1689+
1690+
# ====== Run RPM Lint ===========================================
1691+
if shutil.which('rpmlint') != None:
1692+
rpmlintCommand = 'rpmlint -P ' + rpmFile
1693+
printSubsection('Running RPM Lint')
1694+
print('=> ' + rpmlintCommand)
1695+
try:
1696+
subprocess.run(rpmlintCommand, check=False, shell=True)
1697+
except Exception as e:
1698+
sys.stderr.write('ERROR: RPM Lint run failed: ' + str(e) + '\n')
1699+
sys.exit(1)
1700+
else:
1701+
sys.stderr.write('NOTE: RPM Lint is not installed -> checks skipped!\n')
16731702

1674-
# ====== Add RPM file to summary ===================================
1675-
if summaryFile != None:
1676-
summaryFile.write('rpmFile: ' + rpmFile + ' ' + release + ' ' + buildArchitecture + '\n')
1703+
# ====== Add RPM file to summary ================================
1704+
if summaryFile != None:
1705+
summaryFile.write('rpmFile: ' + rpmFile + ' ' + release + ' ' + rpmArchitecture + '\n')
16771706

16781707

16791708

configure.ac

+4-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ fi
6868

6969
# ###### Options ############################################################
7070
AC_ARG_ENABLE([sctp-over-udp],
71-
[ --enable-sctp-over-udp enable SCTP over UDP mode ],
72-
AC_DEFINE(SCTP_OVER_UDP, 1, "Define to 1 if you want SCTP over UDP"), )
71+
[ --enable-sctp-over-udp enable SCTP over UDP mode ]
72+
[default=yes]],enable_sctp_over_udp=$enableval,enable_sctp_over_udp=yes)
7373

7474
if test "$enable_sctp_over_udp" = "yes" ; then
75+
AC_DEFINE(SCTP_OVER_UDP, 1, "Define to 1 if you want SCTP over UDP")
7576
AC_MSG_CHECKING([port number for SCTP over UDP])
7677
AC_ARG_WITH(sctp_over_udp_port,AS_HELP_STRING([--with-sctp-over-udp-port=FLAGS],[SCTP over UDO port (default: 9899).]),
7778
sctp_over_udp_port="$withval", sctp_over_udp_port="9899")
@@ -86,7 +87,7 @@ fi
8687

8788
AC_ARG_ENABLE([maintainer-mode],
8889
[ --enable-maintainer-mode enable maintainer mode ]
89-
[default=no]],enable_maintainer_mode=$enableval,enable_maintainer_mode=no)
90+
[default=yes]],enable_maintainer_mode=$enableval,enable_maintainer_mode=yes)
9091

9192
AC_ARG_ENABLE(ipv6,
9293
[ --disable-ipv6 turn off IPv6 support ])

debian/rules

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
66
dh $@ --parallel
77

88
override_dh_auto_configure:
9-
dh_auto_configure -- --enable-sctp-over-udp
9+
dh_auto_configure -- --enable-sctp-over-udp --disable-maintainer-mode
1010

1111
override_dh_installchangelogs:
1212
dh_installchangelogs -k ChangeLog

rpm/sctplib.spec

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ asynchronous interprocess communication.
4444
%build
4545
autoreconf -i
4646

47-
%configure --prefix=/usr --enable-static --enable-shared --enable-sctp-over-udp
47+
%configure --prefix=/usr --enable-sctp-over-udp --disable-maintainer-mode
4848
make %{?_smp_mflags}
4949

5050
%install

0 commit comments

Comments
 (0)