OpenWrt Build System on FreeBSD

I don't really like using Linux but sometimes you have to... the problem is which flavour?
it
I've come across OpenWrt over the last year and it seems nice and compact and it comes with a Build System for building the system as well as apps for it. I've managed to put together this build system on FreeBSD, but am unsure about how to test it.

Am I correct in thinking that FreeBSD can be used for building apps on other systems?

I've put together a simple script for installing the build system and will post it here if anyone is interested.
 
Do post it. Keep in mind that development environments vary with projects.

FreeBSD has a vast amount of packages for different build environments that's why you got the Openwrt's. You may also need interact with its developers say in the IRC network or mailing list for some more concise responses.
 
I've come across OpenWrt over the last year and it seems nice and compact and it comes with a Build System for building the system as well as apps for it. I've managed to put together this build system on FreeBSD, but am unsure about how to test it.
Here is a description how to build OpenWRT under FreeBSD. Don’t get to exited, it certainly won’t work in the present form with current FreeBSD versions. Informative is the shell script there. The script configures a proper environment to build with gnu tools natively under FreeBSD. It could serve as a guide for your build system. Even with proper environment, a successful or complete build may not be guaranteed. See last paragraph.

Wouldn’t it be easier to build on a standalone Linux installation or in a virtual machine, as recommend by OpenWRT?
 
Do post it. Keep in mind that development environments vary with projects.

Here it comes -

Code:
pkg bootstrap -y

#  Install required pkgs

cat <<EOF | xargs pkg install -y
git
bash
gmake
gtar
gcc
gawk
ncurses
findutils
patch
wget
getopt
coreutils
EOF

# Build and install GNU time
#
#wget https://ftp.gnu.org/gnu/time/time-1.9.tar.gz
#tar zxf time-1.9.tar.gz
#cd time-1.9
#./configure
#make
#make install
#mv /usr/local/bin/time /usr/local/bin/gtime

# Install OpenWrt Build System

mkdir ~/OpenWrt-BuildSystem
cd ~/OpenWrt-BuildSystem
git clone https://github.com/openwrt/openwrt.git
cd openwrt

# patch mkhash.c

wget 'https://bugs.openwrt.org/index.php?getfile=292' -O patchfile
patch scripts/mkhash.c -i patchfile -o scripts/mkhash.c

# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make  menuconfig

bear in mind it is fairly bareboned and could do with some refinement.

Building GNU time is commented out because it is no longer needed, but I've left it in to remind me how to build it should the need arise.

I'd be interested in any feedback...
 
Here is a description how to build OpenWRT under FreeBSD. Don’t get to exited, it certainly won’t work in the present form with current FreeBSD versions. Informative is the shell script there. The script configures a proper environment to build with gnu tools natively under FreeBSD. It could serve as a guide for your build system. Even with proper environment, a successful or complete build may not be guaranteed. See last paragraph.

Wouldn’t it be easier to build on a standalone Linux installation or in a virtual machine, as recommend by OpenWRT?

Thanks for the pointer to the page you mentioned. I notice that it was written six years ago, and as we all know, something which worked six years ago may well not work today.

I have managed to create the OpenWrt Build System on FreeBSD, but not really sure how to test it..

Of course it's easier to use Linux for this sort of thing, but I notice that you can't build this Build System on OpenWrt itself.
However I much prefer FreeBSD to Linux and don't like the idea of FreeBSD not being able to do something which Linux can.
 
Please tell me, now do you have a working configuration for building on FreeBSD?

Ogogon.
I've been out of the loop for over a year so have only just come across this post.

I'm trying to get things working because I have a problem getting an image for a TP-LINK Archer MR200 v4 which is misbehaving and source code is available for this model, but you have to build it yourself.

Surprisingly, the build script above almost worked in creating the build system. I'm looking into a couple of errors at the moment, but will update the script, as and when I sort them.
 
ogogon
Just use bhyve and a Debian VM, upstream pretty much doesn't care about anything else (OS X some love though) even though Alpine could be used at some point but is now broken again afaik.
 
After revisiting my script and updating FreeBSD to 13.0-RELEASE I am left with one outstanding error, namely:-

Checking 'getopt'... failed.
My updated script consists of:-
Bash:
pkg bootstrap -y

#  Install required pkgs

cat <<EOF | xargs pkg install -y
git
rsync
bash
gmake
gtar
gcc
gawk
ncurses
findutils
diffutils
patch
wget
getopt
coreutils
EOF


# Install OpenWrt Build System

mkdir ~/OpenWrt-BuildSystem2
cd ~/OpenWrt-BuildSystem2
git clone https://github.com/openwrt/openwrt.git
cd openwrt


# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make  menuconfig

After enquiring on the OpenWrt forum it was suggested that there is GNU getopt which is different to the one used by FreeBSD. Is this the case, and if so is the GNU version available?

I think the check for getopt consists of the following code

Code:
$(eval $(call SetupHostCommand,getopt, \
    Please install an extended getopt version that supports --long, \
    gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
    getopt -o t --long test -- --test | grep '^ *--test *--', \
    /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))

See https://forum.openwrt.org/t/anyone-using-freebsd/31320/20

Any advice would be welcomed.
 
install misc/getopt and rename the binary gnugetop or put /usr/local/bin in from of /usr/bin in PATH
misc/getopt was already installed, but I found that just renaming it to gnugetopt got around the problem....
I noticed that the info about FreeBSD's getopt says:-
Rewrite of getopt(1) with the following features:

* It can do anything that the GNU getopt(3) routines can do.
* It can cope with spaces and shell metacharacters within arguments.
* It can parse long parameters.
* It can shuffle parameters, so you can mix options and other parameters
on the command-line.
* It can be easily identified as an enhanced getopt(1) from within shell
scripts.
* It can report parse errors as coming from the shell script.
* It compiles cleanly with both libc-5 and glibc-2.

So it looks like this sort of error shouldn't occur.
 
it looks like it passes the above grep test
if you want to avoid the renaming trouble copy the binary in ~/bin and add ~/bin first in PATH while you run the failing script
 
Can someone translate the following code into English - it's not really clear to me what is being tested..

Bash:
$(eval $(call SetupHostCommand,getopt, \
        Please install an extended getopt version that supports --long, \
        gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
        getopt -o t --long test -- --test | grep '^ *--test *--', \
        /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))

Is there any way to change this so that a test for gnugetopt is made only if the getopt test fails?

At the moment, if I rename FreeBSD's getopt as gnugetopt the test passes.
 
Try setting a evaluation line for misc/getopt installed /usr/local/bin/gtopt to prereq-build.mk:
Code:
$(eval $(call SetupHostCommand,getopt, \
          ...
          /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
          /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
 
Then why did the evaluations of
Code:
        getopt -o t --long test -- --test | grep '^ *--test *--', \
returned Checking 'getopt'... failed. ?

getopt is in PATH, whereis getopt returns
Code:
getopt: /usr/bin/getopt /usr/share/man/man1/getopt.1.gz /usr/ports/misc/getopt
 
Then why did the evaluations of
Code:
        getopt -o t --long test -- --test | grep '^ *--test *--', \
returned Checking 'getopt'... failed. ?

getopt is in PATH, whereis getopt returns
Code:
getopt: /usr/bin/getopt /usr/share/man/man1/getopt.1.gz /usr/ports/misc/getopt
The first test uses FreeBSD's builtin getopt, which seems incompatible gnugetopt whereas misc/getopt works fine so I've created a patch which includes a test for /usr/local/bin/getopt. That seems to be the cleanest way of handling things.
 
Patch for using misc/getopt when trying to create an OpenWrt build system on FreeBSD:-
Bash:
--- include/prereq-build.mk     2021-12-03 21:03:44.406974000 +0000
+++ include/prereq-build.mk-FreeBSD-getopt      2021-12-03 21:56:19.603555000 +0000
@@ -130,6 +130,7 @@
        Please install an extended getopt version that supports --long, \
        gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
        getopt -o t --long test -- --test | grep '^ *--test *--', \
+       /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
        /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))

 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
 
After leaving this for a year, I thought I revisit things to see how well this build system works.

Here is my latest script which I run in a 13.1-RELEASE jail to make sure I have a clean environment.
Bash:
pkg bootstrap -y

#  Install required pkgs

cat <<EOF | xargs pkg install -y
git
rsync
bash
gmake
gtar
gcc
gawk
ncurses
findutils
diffutils
patch
wget
getopt
coreutils
EOF

# Install OpenWrt Build System

mkdir ~/OpenWrt-BuildSystem
cd ~/OpenWrt-BuildSystem
git clone https://github.com/openwrt/openwrt.git
cd openwrt

# amend prereq-build.mk

sed -E -i "" -e "/^.getopt/a\\
        \/usr\/local\/bin\/getopt -o t --long test -- --test \| grep '\^ \*--test \*--', \\\\" include/prereq-build.mk

# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make  menuconfig

Unfortunately I get the following error:

Code:
Installing package 'sipp' from telephony
Installing package 'siproxd' from telephony
Installing package 'sngrep' from telephony
Installing package 'yate' from telephony
gmake[1]: Entering directory '/root/OpenWrt-BuildSystem/openwrt'
make -s -C scripts/config mconf: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on
gmake[1]: *** [/root/OpenWrt-BuildSystem/openwrt/include/toplevel.mk:106: scripts/config/mconf] Error 1
gmake[1]: Leaving directory '/root/OpenWrt-BuildSystem/openwrt'
*** Error code 2

Stop.
make: stopped in /root/OpenWrt-BuildSystem/openwrt

Script done, output file is OpenWrt_Build-System-install_2211281717.log
      656.68 real       290.41 user        39.91 sys

Any pointers would be appreciated.
 
On further investigation, I get this error msg:-
Code:
gmake[4]: Entering directory '/root/OpenWrt-BuildSystem/openwrt/scripts/config'
; mkdir -p ./; trap "rm -f ./.mconf-cfg.tmp" EXIT; { /bin/sh mconf-cfg.sh; } > ./.mconf-cfg.tmp; if [ ! -r mconf-cfg ] || ! cmp -s mconf-cfg ./.mconf-cfg.tmp; then true '  UPD     mconf-cfg'; mv -f ./.mconf-cfg.tmp mconf-cfg; fi
*
* Unable to find the ncurses package.
* Install ncurses (ncurses-devel or libncurses-dev
* depending on your distribution).
*
* You may also need to install pkg-config to find the
* ncurses installed in a non-default location.

Any advice on which ncurses pkg I need to install?
 
Here's my latest effort:-
(it would be best to create a jail to run this in)

Code:
#!/bin/sh

pkg bootstrap -y

#  Install required pkgs

str="pkg install -y $(cat <<EOF)"
git
rsync
bash
gmake
gtar
gcc
gawk
ncurses
findutils
diffutils
patch
wget
getopt
coreutils
pkgconf
EOF

$str

# Install OpenWrt Build System

mkdir /OpenWrt-BuildSystem
cd /OpenWrt-BuildSystem
git clone https://github.com/openwrt/openwrt.git
cd openwrt

# patch prereq-build.mk

patch  <<EOF
--- include/prereq-build.mk    2023-08-26 09:03:31.437266000 +0100
+++ -
@@ -149,6 +149,7 @@
     Please install an extended getopt version that supports --long, \\
     gnugetopt -o t --long test -- --test | grep '^ *--test *--', \\
     getopt -o t --long test -- --test | grep '^ *--test *--', \\
+    /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \\
     /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \\
     /opt/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
EOF

pkg-config=ncurses

# Let's go!!!

./scripts/feeds update -a
./scripts/feeds install -a

make  menuconfig

If anyone tries this, please let me know if you get as far as opening an OpenWrt Configuration.
 
I've been working on a branch here. Would love some feedback, I can get past the config menu which is started by running `make menuconfig` and then I am also able to run `make download` which downloads all the packages necessary for building images. Now moving onto `make world` is where the trouble starts a bunch of packages had code that was not going to compile on FreeBSD (or any BSD for that matter I believe) and running with `make V=sc` I can see the following log:

Code:
gmake[1]: Entering directory '/root/openwrt'
gmake[2]: Entering directory '/root/openwrt'
gmake[3]: Entering directory '/root/openwrt'
gmake[3]: Leaving directory '/root/openwrt'
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a build dependency on 'libpam', which does not exist
gmake[3]: Entering directory '/root/openwrt/scripts/config'
gmake[3]: 'conf' is up to date.
gmake[3]: Leaving directory '/root/openwrt/scripts/config'
gmake[3]: Entering directory '/root/openwrt'
gmake[3]: Leaving directory '/root/openwrt'
gmake[2]: Leaving directory '/root/openwrt'
gmake[2]: Entering directory '/root/openwrt'
gmake[3]: Entering directory '/root/openwrt'
+ mkdir -p /root/openwrt/staging_dir/target-x86_64_musl
+ cd /root/openwrt/staging_dir/target-x86_64_musl
+ mkdir -p bin lib stamp usr/include usr/lib
mkdir -p /root/openwrt/build_dir/target-x86_64_musl/stamp
touch /root/openwrt/staging_dir/target-x86_64_musl/.prepared
+ mkdir -p /root/openwrt/staging_dir/host
+ cd /root/openwrt/staging_dir/host
+ mkdir -p bin lib stamp usr/include usr/lib
mkdir -p /root/openwrt/build_dir/host/stamp /root/openwrt/staging_dir/host/include/sys
install -m0644 /root/openwrt/tools/include/*.h /root/openwrt/staging_dir/host/include/
install -m0644 /root/openwrt/tools/include/sys/*.h /root/openwrt/staging_dir/host/include/sys/
mkdir -p /root/openwrt/staging_dir/host/include/asm
install -m0644 /root/openwrt/tools/include/asm/*.h /root/openwrt/staging_dir/host/include/asm/
ln -snf lib /root/openwrt/staging_dir/host/lib64
touch /root/openwrt/staging_dir/host/.prepared
gmake[4]: Entering directory '/root/openwrt/tools/flock'
gmake[4]: Leaving directory '/root/openwrt/tools/flock'
time: tools/flock/compile#0.00#0.03#0.05
gmake[4]: Entering directory '/root/openwrt/tools/xz'
gmake[4]: Leaving directory '/root/openwrt/tools/xz'
time: tools/xz/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/sed'
gmake[4]: Leaving directory '/root/openwrt/tools/sed'
time: tools/sed/compile#0.02#0.06#0.07
gmake[4]: Entering directory '/root/openwrt/tools/libdeflate'
gmake[4]: Leaving directory '/root/openwrt/tools/libdeflate'
time: tools/libdeflate/compile#0.00#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/patch'
gmake[4]: Leaving directory '/root/openwrt/tools/patch'
time: tools/patch/compile#0.03#0.01#0.03
gmake[4]: Entering directory '/root/openwrt/tools/tar'
gmake[4]: Leaving directory '/root/openwrt/tools/tar'
time: tools/tar/compile#0.02#0.02#0.04
gmake[4]: Entering directory '/root/openwrt/tools/m4'
gmake[4]: Leaving directory '/root/openwrt/tools/m4'
time: tools/m4/compile#0.03#0.01#0.04
gmake[4]: Entering directory '/root/openwrt/tools/autoconf'
gmake[4]: Leaving directory '/root/openwrt/tools/autoconf'
time: tools/autoconf/compile#0.01#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/autoconf-archive'
gmake[4]: Leaving directory '/root/openwrt/tools/autoconf-archive'
time: tools/autoconf-archive/compile#0.00#0.04#0.03
gmake[4]: Entering directory '/root/openwrt/tools/ninja'
gmake[4]: Leaving directory '/root/openwrt/tools/ninja'
time: tools/ninja/compile#0.03#0.01#0.04
gmake[4]: Entering directory '/root/openwrt/tools/meson'
gmake[4]: Leaving directory '/root/openwrt/tools/meson'
time: tools/meson/compile#0.01#0.01#0.02
gmake[4]: Entering directory '/root/openwrt/tools/pkgconf'
gmake[4]: Leaving directory '/root/openwrt/tools/pkgconf'
time: tools/pkgconf/compile#0.00#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/automake'
gmake[4]: Leaving directory '/root/openwrt/tools/automake'
time: tools/automake/compile#0.00#0.05#0.05
gmake[4]: Entering directory '/root/openwrt/tools/gnulib'
gmake[4]: Leaving directory '/root/openwrt/tools/gnulib'
time: tools/gnulib/compile#0.05#0.04#0.07
gmake[4]: Entering directory '/root/openwrt/tools/missing-macros'
gmake[4]: Leaving directory '/root/openwrt/tools/missing-macros'
time: tools/missing-macros/compile#0.01#0.01#0.03
gmake[4]: Entering directory '/root/openwrt/tools/libtool'
gmake[4]: Leaving directory '/root/openwrt/tools/libtool'
time: tools/libtool/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/flex'
gmake[4]: Leaving directory '/root/openwrt/tools/flex'
time: tools/flex/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/bison'
gmake[4]: Leaving directory '/root/openwrt/tools/bison'
time: tools/bison/compile#0.01#0.02#0.04
gmake[4]: Entering directory '/root/openwrt/tools/bc'
gmake[4]: Leaving directory '/root/openwrt/tools/bc'
time: tools/bc/compile#0.02#0.01#0.03
gmake[4]: Entering directory '/root/openwrt/tools/libressl'
gmake[4]: Leaving directory '/root/openwrt/tools/libressl'
time: tools/libressl/compile#0.02#0.02#0.04
gmake[4]: Entering directory '/root/openwrt/tools/expat'
gmake[4]: Leaving directory '/root/openwrt/tools/expat'
time: tools/expat/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/zlib'
gmake[4]: Leaving directory '/root/openwrt/tools/zlib'
time: tools/zlib/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/zstd'
gmake[4]: Leaving directory '/root/openwrt/tools/zstd'
time: tools/zstd/compile#0.02#0.01#0.03
gmake[4]: Entering directory '/root/openwrt/tools/cmake'
gmake[4]: Leaving directory '/root/openwrt/tools/cmake'
time: tools/cmake/compile#0.06#0.11#0.11
gmake[4]: Entering directory '/root/openwrt/tools/cpio'
gmake[4]: Leaving directory '/root/openwrt/tools/cpio'
time: tools/cpio/compile#0.01#0.03#0.04
gmake[4]: Entering directory '/root/openwrt/tools/dosfstools'
gmake[4]: Leaving directory '/root/openwrt/tools/dosfstools'
time: tools/dosfstools/compile#0.01#0.02#0.04
gmake[4]: Entering directory '/root/openwrt/tools/e2fsprogs'
gmake[4]: Leaving directory '/root/openwrt/tools/e2fsprogs'
time: tools/e2fsprogs/compile#0.03#0.02#0.05
gmake[4]: Entering directory '/root/openwrt/tools/elfutils'
gmake[4]: Leaving directory '/root/openwrt/tools/elfutils'
time: tools/elfutils/compile#0.01#0.03#0.04
gmake[4]: Entering directory '/root/openwrt/tools/fakeroot'
[CMD]

[PORT][/PORT]

[/CMD]
gmake[4]: Leaving directory '/root/openwrt/tools/fakeroot'
time: tools/fakeroot/compile#0.02#0.01#0.03
gmake[4]: Entering directory '/root/openwrt/tools/findutils'
gmake[4]: Leaving directory '/root/openwrt/tools/findutils'
time: tools/findutils/compile#0.02#0.02#0.04
gmake[4]: Entering directory '/root/openwrt/tools/firmware-utils'
gmake[4]: Leaving directory '/root/openwrt/tools/firmware-utils'
time: tools/firmware-utils/compile#0.02#0.02#0.03
gmake[4]: Entering directory '/root/openwrt/tools/gengetopt'
gmake[4]: Leaving directory '/root/openwrt/tools/gengetopt'
time: tools/gengetopt/compile#0.04#0.00#0.04
gmake[4]: Entering directory '/root/openwrt/tools/lzma'
gmake[4]: Leaving directory '/root/openwrt/tools/lzma'
time: tools/lzma/compile#0.00#0.05#0.06
gmake[4]: Entering directory '/root/openwrt/tools/make-ext4fs'
gmake[4]: Leaving directory '/root/openwrt/tools/make-ext4fs'
time: tools/make-ext4fs/compile#0.01#0.02#0.05
gmake[4]: Entering directory '/root/openwrt/tools/mkimage'
/usr/local/bin/gmake -C /root/openwrt/build_dir/host/u-boot-2023.10 HOSTCFLAGS="-O2 -I/root/openwrt/staging_dir/host/include " HOSTLDFLAGS="-L/root/openwrt/staging_dir/host/lib " PKG_CONFIG_EXTRAARGS="--static" V=1 tools-only
gmake[5]: Entering directory '/root/openwrt/build_dir/host/u-boot-2023.10'
/usr/local/bin/gmake -f ./Makefile syncconfig
/usr/local/bin/gmake -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
/usr/local/bin/gmake -f ./scripts/Makefile.build obj=scripts/kconfig syncconfig
scripts/kconfig/conf  --syncconfig Kconfig
/usr/local/bin/gmake -f ./scripts/Makefile.autoconf || \
    { rm -f include/config/auto.conf; false; }
set -e; mkdir -p include/;     (echo "/* Automatically generated - do not edit */"; echo \#define CFG_BOARDDIR board/sandbox; echo \#include \<configs/"sandbox".h\>; echo \#include \<asm/config.h\>; echo \#include \<linux/kconfig.h\>; echo \#include \<config_fallbacks.h\>;) < scripts/Makefile.autoconf > include/config.h.tmp; if [ -r include/config.h ] && cmp -s include/config.h include/config.h.tmp; then rm -f include/config.h.tmp; else : '  UPD     include/config.h'; mv -f include/config.h.tmp include/config.h; fi
  gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing     -no-integrated-as -fno-PIE -fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign -Wno-array-bounds -fmacro-prefix-map=./= -gdwarf-4 -fstack-usage -Wno-format-nonliteral -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=date-time  -D__KERNEL__ -D__UBOOT__ -D__SANDBOX__ -U_FORTIFY_SOURCE -fPIC -pipe -Iinclude  -I./arch/sandbox/include -include ./include/linux/kconfig.h -nostdinc -isystem /usr/lib/clang/16/include  -DDO_DEPS_ONLY -dM ./include/common.h > u-boot.cfg.tmp && { grep 'define CONFIG_' u-boot.cfg.tmp | sed '/define CONFIG_IS_ENABLED(/d;/define CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > u-boot.cfg; rm u-boot.cfg.tmp; } || { rm u-boot.cfg.tmp; false; }
In file included from ./include/common.h:18:
In file included from include/time.h:7:
include/linux/types.h:8:10: fatal error: 'stdbool.h' file not found
#include <stdbool.h>
         ^~~~~~~~~~~
1 error generated.
gmake[6]: *** [scripts/Makefile.autoconf:82: u-boot.cfg] Error 1
/usr/local/bin/gmake -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
gmake[5]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'.  Stop.
gmake[5]: Leaving directory '/root/openwrt/build_dir/host/u-boot-2023.10'
gmake[4]: *** [Makefile:54: /root/openwrt/build_dir/host/u-boot-2023.10/.built] Error 2
gmake[4]: Leaving directory '/root/openwrt/tools/mkimage'
time: tools/mkimage/compile#0.24#0.18#0.42
    ERROR: tools/mkimage failed to build.
gmake[3]: *** [tools/Makefile:228: tools/mkimage/compile] Error 1
gmake[3]: Leaving directory '/root/openwrt'
gmake[2]: *** [tools/Makefile:224: /root/openwrt/staging_dir/host/stamp/.tools_compile_nyyynyynnnyyyynynyyyyyyynyyynnynyynnynnyyyyyynyyyyyyyyyyynynnyyyyyyy] Error 2
gmake[2]: Leaving directory '/root/openwrt'
gmake[1]: *** [/root/openwrt/include/toplevel.mk:232: world] Error 2
gmake[1]: Leaving directory '/root/openwrt'
*** Error code 2

Stop.
make: stopped in /root/openwrt

The error is really weird as I can see stdbool.h present:

Code:
root@openwrt-jail:~/openwrt # find /usr -name stdbool.h
/usr/src/include/stdbool.h

For reference this is the makefile for the mkimage tool.
 
Here is a description how to build OpenWRT under FreeBSD. Don’t get to exited, it certainly won’t work in the present form with current FreeBSD versions. Informative is the shell script there. The script configures a proper environment to build with gnu tools natively under FreeBSD. It could serve as a guide for your build system. Even with proper environment, a successful or complete build may not be guaranteed. See last paragraph.

Wouldn’t it be easier to build on a standalone Linux installation or in a virtual machine, as recommend by OpenWRT?
I just noticed the script referenced in this website, it seems like mtd-utils and e2fsprogs (although e2fsprogs compiles now) hadn't worked then, it's a shame because we wont be able to get ext images out of it. Once I took care of it, the "tools" part of the build process looks to be done. The next roadblock seems to be binutils, since openwrt uses musl libc it tries to build one and without the patches for freebsd it'll just fail it shouldn't be too hard to port over the patches from freebsd into the openwrt toolchain patch folder
 
Back
Top