Image builder not working correctly when using BIN_DIR variable

I'm using the latest image builder snapshot for my Banana Pi BPI-R4 from https://downloads.openwrt.org/snapshots/targets/mediatek/filogic/

When running the build normally make image PROFILE=bananapi_bpi-r4 I get the final images in the bin/targets/mediatek/filogic folder inside the image builder directory.

When running the build with make image PROFILE=bananapi_bpi-r4 BIN_DIR=firmware or ../firmware or ./firmware for that matter, I only get the profiles.json and sha256sums files in the firmware directory, but the images are missing. They are not mentioned in the sha256sums, neither are they in the default folder mentioned above.

Is that a bug with the Makefile of the Image Builder or did I not understand the purpose of the BIN_DIR variable correctly?

I've tried with 23.05.3 x86-64 IB and I can reproduce to an extent:

$ make image BIN_DIR=sometest
... some time later ...
$ find . -name "sometest"
./sometest
./target/linux/x86/image/sometest
$ ls -la ./sometest
total 16
drwxrwxr-x  2 4096 Apr 15 23:08 .
drwxr-xr-x 14 4096 Apr 15 23:07 ..
-rw-rw-r--  1 1692 Apr 15 23:08 profiles.json
-rw-rw-r--  1   80 Apr 15 23:08 sha256sums
$ ls -la ./target/linux/x86/image/sometest
total 37768
drwxrwxr-x 2     4096 Apr 15 23:08 .
drwxr-xr-x 3     4096 Apr 15 23:07 ..
-rw-rw-r-- 1 11634388 Apr 15 23:08 openwrt-23.05.3-x86-64-generic-ext4-combined-efi.img.gz
-rw-rw-r-- 1 11425568 Apr 15 23:08 openwrt-23.05.3-x86-64-generic-ext4-combined.img.gz
-rw-rw-r-- 1  5239616 Apr 15 23:08 openwrt-23.05.3-x86-64-generic-ext4-rootfs.img.gz
-rw-r--r-- 1  5636960 Apr 15 23:07 openwrt-23.05.3-x86-64-generic-kernel.bin
-rw-rw-r-- 1  4713814 Apr 15 23:07 openwrt-23.05.3-x86-64-generic-rootfs.tar.gz
-rw-rw-r-- 1     3294 Apr 15 23:08 openwrt-23.05.3-x86-64-generic.manifest

So in my case the images are available in ./target/linux/x86/image/sometest. Not sure if it's intentional or a bug.

Thanks for testing it. That at least confirms that I'm not alone with that issue.

I tried looking for the issue myself, but those .mk (i assume that's automake) files are a new level of unreadability for me. :sweat_smile:

I found multiple occurrences of the BIN_DIR variable, but could not make out the particular line that is responsible for copying to the output directory.