Skip to content

Commit 14c2a2f

Browse files
committed
sunxi-fel: find Homebrew libfdt on Darwin
Homebrew's dtc formula installs libfdt headers and libraries under the dtc prefix. The existing sunxi-fel link line only passed -lfdt, which leaves clang unable to find libfdt.h when the header is outside the default include path. Keep the default -lfdt behavior for systems that install libfdt in default search paths. On Darwin, add the Homebrew dtc include and library paths when that prefix is available. Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
1 parent 53f54d6 commit 14c2a2f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ ZLIB = zlib
134134
ZLIB_CFLAGS ?= `$(PKG_CONFIG) --cflags $(ZLIB)`
135135
ZLIB_LIBS ?= `$(PKG_CONFIG) --libs $(ZLIB)`
136136

137+
ifeq ($(OS),Darwin)
138+
DTC_PREFIX := $(shell brew --prefix dtc 2>/dev/null)
139+
ifneq ($(DTC_PREFIX),)
140+
LIBFDT_CFLAGS ?= -I$(DTC_PREFIX)/include
141+
LIBFDT_LIBS ?= -L$(DTC_PREFIX)/lib -lfdt
142+
endif
143+
endif
144+
145+
LIBFDT_CFLAGS ?=
146+
LIBFDT_LIBS ?= -lfdt
147+
137148
ifeq ($(OS),Windows_NT)
138149
# Windows lacks mman.h / mmap()
139150
DEFAULT_CFLAGS += -DNO_MMAP
@@ -149,8 +160,8 @@ FEL_LIB := fel_lib.c fel_lib.h
149160
SPI_FLASH:= fel-spiflash.c fel-spiflash.h fel-remotefunc-spi-data-transfer.h
150161

151162
sunxi-fel: fel.c fit_image.c thunks/fel-to-spl-thunk.h $(PROGRESS) $(SOC_INFO) $(FEL_LIB) $(SPI_FLASH)
152-
$(CC) $(HOST_CFLAGS) $(LIBUSB_CFLAGS) $(ZLIB_CFLAGS) $(LDFLAGS) -o $@ \
153-
$(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) $(ZLIB_LIBS) -lfdt
163+
$(CC) $(HOST_CFLAGS) $(LIBUSB_CFLAGS) $(ZLIB_CFLAGS) $(LIBFDT_CFLAGS) $(LDFLAGS) -o $@ \
164+
$(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) $(ZLIB_LIBS) $(LIBFDT_LIBS)
154165

155166
sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
156167
$(CC) $(HOST_CFLAGS) -c -o nand-part-main.o nand-part-main.c

0 commit comments

Comments
 (0)