Skip to content

Instantly share code, notes, and snippets.

@xsbchen
Last active April 4, 2025 04:26
Show Gist options
  • Save xsbchen/32a576c326e11618aba029e16d7e223a to your computer and use it in GitHub Desktop.
Save xsbchen/32a576c326e11618aba029e16d7e223a to your computer and use it in GitHub Desktop.
How to build openwrt in macOS

Tested in Macbook Pro M3 Pro with macOS Sonoma(14.4.1)

1. prepare disk

hdiutil create -size 30g -fs 'Case-sensitive HFS+' -type SPARSEBUNDLE -nospotlight -volname OpenWRTBuilder ~/OpenWRTBuilder
hdiutil attach -notremovable -nobrowse -mountpoint ~/OpenWRTBuilder ~/OpenWRTBuilder.sparsebundle

2. install dependencies

brew install coreutils findutils gettext gnu-tar gnu-sed gawk gnu-getopt grep libtool [email protected] diffutils wget xz openssl mercurial pkg-config ncurses swig

3. setup build environment

add these configs to your shell profile, such as ~/.zshrc or ~/.profile

PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gawk/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/[email protected]/libexec/bin:$PATH"
PATH="/opt/homebrew/opt/gnu-getopt/bin:$PATH"
PATH="/opt/homebrew/opt/diffutils/bin:$PATH"
PATH="/opt/homebrew/opt/ncurses/bin:$PATH"

4. clone source

git clone -b master --single-branch --filter=blob:none https://github.com/openwrt/openwrt

5. start build

cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment