mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-29 07:53:44 +02:00
Makefile: Make pkg-config mandatory to find libusb1
Use `make HAS_LIBUSB1=yes/no` to override the pkg-config detection and `CONFIG_LIBUSB1_CFLAGS` and `CONFIG_LIBUSB1_LDFLAGS` to set cflags and ldflags manually. Change-Id: I4f24be647d25dde24c41514f8964b7134205867c Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59049 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
82524f8411
commit
9469f81d8f
62
Makefile
62
Makefile
@ -189,6 +189,9 @@ CONFIG_LIB_NI845X_LDFLAGS := -L$(CONFIG_NI845X_LIBRARY_PATH) $(if NI854_X86_LIB
|
|||||||
CONFIG_LIBJAYLINK_CFLAGS := $(call dependency_cflags, libjaylink)
|
CONFIG_LIBJAYLINK_CFLAGS := $(call dependency_cflags, libjaylink)
|
||||||
CONFIG_LIBJAYLINK_LDFLAGS := $(call dependency_ldflags, libjaylink)
|
CONFIG_LIBJAYLINK_LDFLAGS := $(call dependency_ldflags, libjaylink)
|
||||||
|
|
||||||
|
CONFIG_LIBUSB1_CFLAGS := $(call dependency_cflags, libusb-1.0)
|
||||||
|
CONFIG_LIBUSB1_LDFLAGS := $(call dependency_ldflags, libusb-1.0)
|
||||||
|
|
||||||
# Determine the destination OS, architecture and endian
|
# Determine the destination OS, architecture and endian
|
||||||
# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
|
# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
|
||||||
# is ever used (of course), but should come after any lines setting CC because
|
# is ever used (of course), but should come after any lines setting CC because
|
||||||
@ -201,6 +204,7 @@ override ENDIAN := $(call c_macro_test, Makefile.d/endian_test.h)
|
|||||||
HAS_LIBFTDI1 := $(call find_dependency, libftdi1)
|
HAS_LIBFTDI1 := $(call find_dependency, libftdi1)
|
||||||
HAS_LIB_NI845X := no
|
HAS_LIB_NI845X := no
|
||||||
HAS_LIBJAYLINK := $(call find_dependency, libjaylink)
|
HAS_LIBJAYLINK := $(call find_dependency, libjaylink)
|
||||||
|
HAS_LIBUSB1 := $(call find_dependency, libusb-1.0)
|
||||||
|
|
||||||
HAS_FT232H := $(call c_compile_test, Makefile.d/ft232h_test.c, $(CONFIG_LIBFTDI1_CFLAGS))
|
HAS_FT232H := $(call c_compile_test, Makefile.d/ft232h_test.c, $(CONFIG_LIBFTDI1_CFLAGS))
|
||||||
HAS_UTSNAME := $(call c_compile_test, Makefile.d/utsname_test.c)
|
HAS_UTSNAME := $(call c_compile_test, Makefile.d/utsname_test.c)
|
||||||
@ -231,8 +235,6 @@ override CFLAGS += -Wno-format
|
|||||||
LIBS += -lgetopt
|
LIBS += -lgetopt
|
||||||
# Missing serial support.
|
# Missing serial support.
|
||||||
$(call mark_unsupported,$(DEPENDS_ON_SERIAL))
|
$(call mark_unsupported,$(DEPENDS_ON_SERIAL))
|
||||||
# Libraries not available for DOS
|
|
||||||
$(call mark_unsupported,$(DEPENDS_ON_LIBUSB1))
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), MinGW Cygwin))
|
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), MinGW Cygwin))
|
||||||
@ -267,8 +269,6 @@ $(call mark_unsupported,CONFIG_DUMMY)
|
|||||||
$(call mark_unsupported,CONFIG_ATAPROMISE)
|
$(call mark_unsupported,CONFIG_ATAPROMISE)
|
||||||
# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
|
# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
|
||||||
$(call mark_unsupported,CONFIG_BUSPIRATE_SPI CONFIG_SERPROG CONFIG_PONY_SPI)
|
$(call mark_unsupported,CONFIG_BUSPIRATE_SPI CONFIG_SERPROG CONFIG_PONY_SPI)
|
||||||
# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
|
|
||||||
$(call mark_unsupported,$(DEPENDS_ON_LIBUSB1))
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAS_LINUX_MTD), no)
|
ifeq ($(HAS_LINUX_MTD), no)
|
||||||
@ -305,6 +305,10 @@ ifeq ($(HAS_LIBJAYLINK), no)
|
|||||||
$(call mark_unsupported,$(DEPENDS_ON_LIBJAYLINK))
|
$(call mark_unsupported,$(DEPENDS_ON_LIBJAYLINK))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HAS_LIBUSB1), no)
|
||||||
|
$(call mark_unsupported,$(DEPENDS_ON_LIBUSB1))
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ENDIAN), little)
|
ifeq ($(ENDIAN), little)
|
||||||
FEATURE_CFLAGS += -D'__FLASHROM_LITTLE_ENDIAN__=1'
|
FEATURE_CFLAGS += -D'__FLASHROM_LITTLE_ENDIAN__=1'
|
||||||
endif
|
endif
|
||||||
@ -819,22 +823,11 @@ endif
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
NEED_LIBUSB1 := $(call filter_deps,$(DEPENDS_ON_LIBUSB1))
|
USE_LIBUSB1 := $(if $(call filter_deps,$(DEPENDS_ON_LIBUSB1)),yes,no)
|
||||||
ifneq ($(NEED_LIBUSB1), )
|
ifeq ($(USE_LIBUSB1), yes)
|
||||||
CHECK_LIBUSB1 = yes
|
override CFLAGS += $(CONFIG_LIBUSB1_CFLAGS)
|
||||||
PROGRAMMER_OBJS += usbdev.o usb_device.o
|
override LDFLAGS += $(CONFIG_LIBUSB1_LDFLAGS)
|
||||||
# FreeBSD and DragonflyBSD use a reimplementation of libusb-1.0 that is simply called libusb
|
PROGRAMMER_OBJS +=usbdev.o usb_device.o
|
||||||
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD DragonFlyBSD))
|
|
||||||
USB1LIBS += -lusb
|
|
||||||
else
|
|
||||||
ifeq ($(TARGET_OS),NetBSD)
|
|
||||||
override CPPFLAGS += -I/usr/pkg/include/libusb-1.0
|
|
||||||
USB1LIBS += -lusb-1.0
|
|
||||||
else
|
|
||||||
USB1LIBS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --libs libusb-1.0 || printf "%s" "-lusb-1.0")
|
|
||||||
override CPPFLAGS += $(call debug_shell,[ -n "$(PKG_CONFIG_LIBDIR)" ] && export PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"; $(PKG_CONFIG) --cflags-only-I libusb-1.0 || printf "%s" "-I/usr/include/libusb-1.0")
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
USE_LIBFTDI1 := $(if $(call filter_deps,$(DEPENDS_ON_LIBFTDI1)),yes,no)
|
USE_LIBFTDI1 := $(if $(call filter_deps,$(DEPENDS_ON_LIBFTDI1)),yes,no)
|
||||||
@ -884,7 +877,7 @@ ifeq ($(ARCH), x86)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
|
$(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
|
||||||
$(CC) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LDFLAGS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS) $(USB1LIBS)
|
$(CC) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LDFLAGS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS)
|
||||||
|
|
||||||
libflashrom.a: $(LIBFLASHROM_OBJS)
|
libflashrom.a: $(LIBFLASHROM_OBJS)
|
||||||
$(AR) rcs $@ $^
|
$(AR) rcs $@ $^
|
||||||
@ -963,28 +956,11 @@ ifeq ($(CHECK_LIBPCI), yes)
|
|||||||
rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
|
rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
|
||||||
@rm -f .test.c .test.o .test$(EXEC_SUFFIX)
|
@rm -f .test.c .test.o .test$(EXEC_SUFFIX)
|
||||||
endif
|
endif
|
||||||
ifeq ($(CHECK_LIBUSB1), yes)
|
@echo Dependency libusb1 found: $(HAS_LIBUSB1)
|
||||||
@printf "Checking for libusb-1.0 headers... " | tee -a $(BUILD_DETAILS_FILE)
|
@if [ $(HAS_LIBUSB1) = yes ]; then \
|
||||||
@echo "$$LIBUSB1_TEST" > .test.c
|
echo " CFLAGS: $(CONFIG_LIBUSB1_CFLAGS)"; \
|
||||||
@printf "\nexec: %s\n" "$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o" >>$(BUILD_DETAILS_FILE)
|
echo " LDFLAGS: $(CONFIG_LIBUSB1_LDFLAGS)"; \
|
||||||
@{ { { { { $(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >&2 && \
|
fi
|
||||||
echo "found." || { echo "not found."; echo; \
|
|
||||||
echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
|
|
||||||
echo "Please install libusb-1.0 headers or disable all features"; \
|
|
||||||
echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
|
|
||||||
echo "See README for more information."; echo; \
|
|
||||||
rm -f .test.c .test.o; exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
|
|
||||||
@printf "Checking if libusb-1.0 is usable... " | tee -a $(BUILD_DETAILS_FILE)
|
|
||||||
@printf "\nexec: %s\n" "$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS)" >>$(BUILD_DETAILS_FILE)
|
|
||||||
@{ { { { { $(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(USB1LIBS) >&2 && \
|
|
||||||
echo "yes." || { echo "no."; \
|
|
||||||
echo "The following features require libusb-1.0: $(NEED_LIBUSB1)."; \
|
|
||||||
echo "Please install libusb-1.0 or disable all features"; \
|
|
||||||
echo "mentioned above by specifying make CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no"; \
|
|
||||||
echo "See README for more information."; echo; \
|
|
||||||
rm -f .test.c .test.o .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
|
|
||||||
@rm -f .test.c .test.o .test$(EXEC_SUFFIX)
|
|
||||||
endif
|
|
||||||
@echo Dependency libjaylink found: $(HAS_LIBJAYLINK)
|
@echo Dependency libjaylink found: $(HAS_LIBJAYLINK)
|
||||||
@if [ $(HAS_LIBJAYLINK) = yes ]; then \
|
@if [ $(HAS_LIBJAYLINK) = yes ]; then \
|
||||||
echo " CFLAGS: $(CONFIG_LIBJAYLINK_CFLAGS)"; \
|
echo " CFLAGS: $(CONFIG_LIBJAYLINK_CFLAGS)"; \
|
||||||
|
@ -91,16 +91,3 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
endef
|
endef
|
||||||
export PCI_GET_DEV_TEST
|
export PCI_GET_DEV_TEST
|
||||||
|
|
||||||
define LIBUSB1_TEST
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <libusb.h>
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
(void)argc;
|
|
||||||
(void)argv;
|
|
||||||
libusb_init(NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
endef
|
|
||||||
export LIBUSB1_TEST
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user