Skip to content

Commit 2b75353

Browse files
committed
build: Fix compilation errors on FreeBSD.
Another pass of fixing compiler warnings/errors on FreeBSD.
1 parent 46ba8d4 commit 2b75353

File tree

10 files changed

+80
-32
lines changed

10 files changed

+80
-32
lines changed

.github/workflows/main.yml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ jobs:
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
19-
- name: Build LBBS
19+
- name: Install prereqs
2020
run: |
2121
sudo sed -i 's/azure\.//' /etc/apt/sources.list
2222
sudo ./scripts/install_prereq.sh
23+
- name: Build LBBS
24+
run: |
2325
sudo make modcheck
2426
sudo make -j$(nproc)
2527
sudo make install
@@ -40,10 +42,12 @@ jobs:
4042
steps:
4143
- name: Checkout
4244
uses: actions/checkout@v4
43-
- name: Build LBBS
45+
- name: Install prereqs
4446
run: |
4547
sudo sed -i 's/azure\.//' /etc/apt/sources.list
4648
sudo ./scripts/install_prereq.sh
49+
- name: Build LBBS
50+
run: |
4751
sudo make modcheck
4852
sudo make -j$(nproc)
4953
sudo make install
@@ -64,11 +68,13 @@ jobs:
6468
steps:
6569
- name: Checkout
6670
uses: actions/checkout@v4
67-
- name: Build LBBS
71+
- name: Install prereqs
6872
run: |
6973
sudo sed -i 's/azure\.//' /etc/apt/sources.list
70-
sudo sed -i 's/-O3/-O0/' Makefile
7174
sudo ./scripts/install_prereq.sh
75+
- name: Build LBBS
76+
run: |
77+
sudo sed -i 's/-O3/-O0/' Makefile
7278
sudo make modcheck
7379
sudo make -j$(nproc)
7480
sudo make install
@@ -84,9 +90,11 @@ jobs:
8490
container: debian:12
8591
steps:
8692
- uses: actions/checkout@v4
87-
- name: Build LBBS
93+
- name: Install prereqs
8894
run: |
8995
./scripts/install_prereq.sh
96+
- name: Build LBBS
97+
run: |
9098
make modcheck
9199
make -j$(nproc)
92100
make install
@@ -101,9 +109,11 @@ jobs:
101109
container: debian:11
102110
steps:
103111
- uses: actions/checkout@v4
104-
- name: Build LBBS
112+
- name: Install prereqs
105113
run: |
106114
./scripts/install_prereq.sh
115+
- name: Build LBBS
116+
run: |
107117
make modcheck
108118
make -j$(nproc)
109119
make install
@@ -118,9 +128,11 @@ jobs:
118128
container: debian:10
119129
steps:
120130
- uses: actions/checkout@v4
121-
- name: Build LBBS
131+
- name: Install prereqs
122132
run: |
123133
./scripts/install_prereq.sh
134+
- name: Build LBBS
135+
run: |
124136
make modcheck
125137
make -j$(nproc)
126138
make install
@@ -135,9 +147,11 @@ jobs:
135147
container: alpine:latest
136148
steps:
137149
- uses: actions/checkout@v4
138-
- name: Build LBBS
150+
- name: Install prereqs
139151
run: |
140152
./scripts/install_prereq.sh
153+
- name: Build LBBS
154+
run: |
141155
make modcheck
142156
make modconfig
143157
make -j$(nproc)
@@ -150,9 +164,11 @@ jobs:
150164
container: fedora:42
151165
steps:
152166
- uses: actions/checkout@v4
153-
- name: Build LBBS
167+
- name: Install prereqs
154168
run: |
155169
INSTALL_LIBOPENARC=0 ./scripts/install_prereq.sh
170+
- name: Build LBBS
171+
run: |
156172
make modcheck
157173
make modconfig
158174
make -j$(nproc)
@@ -168,9 +184,11 @@ jobs:
168184
container: fedora:40
169185
steps:
170186
- uses: actions/checkout@v4
171-
- name: Build LBBS
187+
- name: Install prereqs
172188
run: |
173189
INSTALL_LIBOPENARC=0 ./scripts/install_prereq.sh
190+
- name: Build LBBS
191+
run: |
174192
make modcheck
175193
make modconfig
176194
make -j$(nproc)
@@ -186,9 +204,11 @@ jobs:
186204
container: rockylinux:9.3
187205
steps:
188206
- uses: actions/checkout@v4
189-
- name: Build LBBS
207+
- name: Install prereqs
190208
run: |
191209
INSTALL_LIBOPENARC=0 ./scripts/install_prereq.sh
210+
- name: Build LBBS
211+
run: |
192212
make modcheck
193213
make modconfig
194214
make -j$(nproc)
@@ -204,9 +224,11 @@ jobs:
204224
container: rockylinux:8.9
205225
steps:
206226
- uses: actions/checkout@v4
207-
- name: Build LBBS
227+
- name: Install prereqs
208228
run: |
209229
INSTALL_LIBOPENARC=0 ./scripts/install_prereq.sh
230+
- name: Build LBBS
231+
run: |
210232
make modcheck
211233
make modconfig
212234
make -j$(nproc)
@@ -222,9 +244,11 @@ jobs:
222244
container: opensuse/tumbleweed
223245
steps:
224246
- uses: actions/checkout@v4
225-
- name: Build LBBS
247+
- name: Install prereqs
226248
run: |
227249
INSTALL_LIBETPAN=0 ./scripts/install_prereq.sh
250+
- name: Build LBBS
251+
run: |
228252
make modcheck
229253
make modconfig
230254
make -j$(nproc)
@@ -240,9 +264,11 @@ jobs:
240264
container: archlinux:latest
241265
steps:
242266
- uses: actions/checkout@v4
243-
- name: Build LBBS
267+
- name: Install prereqs
244268
run: |
245269
INSTALL_LIBOPENARC=0 ./scripts/install_prereq.sh
270+
- name: Build LBBS
271+
run: |
246272
make modcheck
247273
make modconfig
248274
make -j$(nproc)
@@ -257,20 +283,22 @@ jobs:
257283
name: FreeBSD
258284
steps:
259285
- uses: actions/checkout@v4
260-
- name: Build LBBS
286+
- name: Install prereqs and build LBBS
261287
uses: vmactions/freebsd-vm@v1
262288
with:
263289
usesh: true
290+
copyback: false
264291
run: |
265-
./scripts/install_prereq.sh
292+
INSTALL_LIBDISCORD=0 ./scripts/install_prereq.sh
266293
gmake modcheck
267294
gmake modconfig
268-
gmake bbs
269-
gmake doors
270-
gmake io
271-
gmake modules
272-
gmake nets
295+
gmake -j$(nproc) bbs
296+
gmake -j$(nproc) doors
297+
gmake -j$(nproc) io
298+
gmake -j$(nproc) modules
299+
gmake -j$(nproc) nets
273300
gmake -j$(nproc)
274301
gmake install
275302
gmake samples
276-
gmake tests
303+
gmake tests
304+
gmake install

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ scripts :
149149
fi
150150
cp scripts/*.sh /var/lib/lbbs/scripts
151151
cp scripts/*.sql /var/lib/lbbs/scripts
152-
cp -n scripts/*.php /var/lib/lbbs/scripts
152+
# On FreeBSD, cp -n returns 1 if it already exists, ignore that
153+
cp -n scripts/*.php /var/lib/lbbs/scripts || :
153154
chmod +x /var/lib/lbbs/scripts/*
154155

155156
templates :

bbs/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ ALPINE_LINUX := $(shell ls /etc/alpine-release 2>/dev/null | wc -l)
88
# the include directory is in the parent
99
INC = -I..
1010

11-
LIBS = -lrt -lm -ldl
11+
LIBS = -lrt -lm -ldl -lcrypt -rdynamic
1212

1313
# -lcrypto needed for SHA1_Init in hash.c
14-
LIBS += -lcrypt -lcrypto -rdynamic
14+
# XXX Would be nice to move hash.c out into a module (mod_hash)
15+
# The only users of hash.h are mod_http and auth.c, one call each.
16+
LIBS += -lcrypto
1517

1618
# -lbfd and friends
1719
# On SUSE, the remaining libraries are needed to link successfully

bbs/string.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,14 @@ int bbs_quoted_printable_decode(char *restrict s, size_t *restrict len, int prin
620620
if (!printonly || isprint((char) hex)) { /* XXX isprint check only works for single-byte UTF-8 characters */
621621
*d++ = (char) hex;
622622
*len += 1;
623+
#ifdef __linux__
623624
bbs_debug(10, "Decoded quoted printable[%lu] %s -> %d (%c)\n", index, hexcode, hex, isprint(hex) ? hex : '.');
625+
#endif
624626
} else {
625627
/* Don't add invalid UTF-8 characters in the first place */
628+
#ifdef __linux__
626629
bbs_warning("Invalid quoted printable[%lu] %s -> %d (%c)\n", index, hexcode, hex, isprint(hex) ? hex : '.');
630+
#endif
627631
}
628632
}
629633
s++;

bbs/system.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ int __bbs_execvpe(struct bbs_node *node, struct bbs_exec_params *e, const char *
707707
int fdin = e->fdin, fdout = e->fdout;
708708
int fd = fdout;
709709
int res = -1;
710-
int pfd[2], procpipe[2];
710+
int pfd[2] = { -1, -1 }, procpipe[2] = { -1, -1 }; /* Compiler complains could be used uninitialized on FreeBSD */
711711
char fullpath[256] = "", fullterm[32] = "";
712712
#ifdef ISOEXEC_SUPPORTED
713713
/* Only needed if isoexec is supported */

bbs/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ ssize_t bbs_splice(int fd_in, int fd_out, size_t len)
976976
return written;
977977
#else
978978
off_t offset = 0;
979-
return bbs_sendfile(fd_out, fd_in, &offset, lenq);
979+
return bbs_sendfile(fd_out, fd_in, &offset, len);
980980
#endif
981981
}
982982

modules/mod_mailscript.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#if defined(linux) && !defined(__GLIBC__)
2929
#include <libgen.h> /* use non-GNU basename */
30+
#elif defined(__FreeBSD__)
31+
#include <libgen.h> /* use basename */
3032
#endif
3133

3234
#include "include/module.h"
@@ -387,7 +389,7 @@ static int exec_cmd(struct smtp_msg_process *mproc, char *s)
387389
}
388390

389391
/* Calculate the path of the temp file we are going to create */
390-
#if defined(linux) && !defined(__GLIBC__)
392+
#if !defined(linux) || !defined(__GLIBC__)
391393
#pragma GCC diagnostic push
392394
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
393395
#pragma GCC diagnostic ignored "-Wcast-qual"

scripts/evergreen.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/bin/sh
22

33
set -e
4+
5+
OS=$( uname -s )
6+
MAKE=make
7+
if [ "$OS" = "FreeBSD" ]; then
8+
MAKE=gmake
9+
fi
10+
411
cd /usr/local/src
512
if [ ! -d evergreen ]; then
613
git clone https://github.com/InterLinked1/evergreen.git
@@ -10,5 +17,5 @@ else
1017
git stash
1118
git pull
1219
fi
13-
make
14-
make install
20+
$MAKE
21+
$MAKE install

scripts/install_prereq.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PACKAGES_FEDORA="$PACKAGES_FEDORA autoconf automake pkg-config libtool m4"
2424
PACKAGES_SUSE="$PACKAGES_SUSE autoconf automake pkg-config libtool m4"
2525
PACKAGES_ARCH="$PACKAGES_ARCH autoconf automake pkg-config libtool m4"
2626
PACKAGES_ALPINE="$PACKAGES_ALPINE autoconf automake pkgconf libtool m4"
27+
PACKAGES_FREEBSD="$PACKAGES_FREEBSD autoconf automake pkgconf libtool m4"
2728

2829
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev" # ncurses
2930
PACKAGES_DEBIAN="$PACKAGES_DEBIAN ncurses-base ncurses-term" # full/extended terminal definitions
@@ -285,7 +286,10 @@ scripts/libwss.sh
285286
scripts/libslackrtm.sh
286287

287288
# libdiscord (mod_discord)
288-
scripts/libdiscord.sh
289+
if [ "$INSTALL_LIBDISCORD" != "0" ]; then
290+
# Makefile doesn't add the proper LDFLAGS on BSD and doesn't seem to obey LDFLAGS when passed in...
291+
scripts/libdiscord.sh
292+
fi
289293

290294
# libetpan fails to build successfully on Fedora-based distros,
291295
# so need to be able to skip that for now using an env var.

scripts/libcami.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ else
1010
git stash
1111
git pull
1212
fi
13-
make
13+
make library
1414
make install

0 commit comments

Comments
 (0)