Skip to content

FreeBSD support (only 3 changes needed) #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LukaszMoskala opened this issue Sep 25, 2022 · 0 comments
Closed

FreeBSD support (only 3 changes needed) #650

LukaszMoskala opened this issue Sep 25, 2022 · 0 comments

Comments

@LukaszMoskala
Copy link

Description

There are 3 changes needed to get ebusd to compile on FreeBSD. Tested with current source from git (commit c3935d494619203dac308a197e3554786098fa01).

In src/lib/knx/knxnet.h, we need to change endian.h to machine/endian.h. We can use ifdef here:

#ifdef __FreeBSD__
#include <machine/endian.h>
#else
#include <endian.h>
#endif

Also, in ebusd::main, variable environ is undefined, and we need to pass it from main as an argument. So main is now:

int main(int argc, char* argv[], char* envp[]) {
  return ebusd::main(argc, argv, envp);
}

And we need to change definition of ebusd::main to:

int main(int argc, char* argv[], char* environ[]) {

I don't know if on Linux environ is global variable or where it's supposed to come from. I can confirm that code with this change still compiles on archlinux.

I have not yet tested if it actually works, it compilled and I can run ebusd --help. I don't yet have my ebus adapter to check if it's working.

Complete steps to compile on FreeBSD:

#as root:
pkg install autogen cmake argp-standalone mosquitto
#as normal user:
cat - > patch.txt <<EOF
diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp
index 7b69cde..e7fb7c6 100644
--- a/src/ebusd/main.cpp
+++ b/src/ebusd/main.cpp
@@ -1332,7 +1332,7 @@ bool parseMessage(const string& arg, bool onlyMasterSlave, MasterSymbolString* m
  * @param argv the command line arguments.
  * @return the exit code.
  */
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[], char* environ[]) {
   struct argp aargp = { argpoptions, parse_opt, nullptr, argpdoc, datahandler_getargs(), nullptr, nullptr };
   setenv("ARGP_HELP_FMT", "no-dup-args-note", 0);
 
@@ -1553,6 +1553,6 @@ int main(int argc, char* argv[]) {
 
 }  // namespace ebusd
 
-int main(int argc, char* argv[]) {
-  return ebusd::main(argc, argv);
+int main(int argc, char* argv[], char* envp[]) {
+  return ebusd::main(argc, argv, envp);
 }
diff --git a/src/lib/knx/knxnet.h b/src/lib/knx/knxnet.h
index 578ee98..ff57fca 100644
--- a/src/lib/knx/knxnet.h
+++ b/src/lib/knx/knxnet.h
@@ -31,7 +31,11 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
+#ifdef __FreeBSD__
+#include <machine/endian.h>
+#else
 #include <endian.h>
+#endif
 #include <string>
 #include <cstdio>
 #include <ctime>
EOF

git clone https://github.com/john30/ebusd.git

patch -d ebusd  < patch.txt

mkdir ebusd-build
env CXXFLAGS='-I/usr/local/include' LDFLAGS='-L/usr/local/lib' cmake -S ebusd -B ebusd-build

cd ebusd-build
make

It'd be nice to have those changes included in next releases. If not, maybe it'd be usefull to someone to have those steps on wiki page.

Thank you for maintaining this project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants