diff --git a/CMakeLists.txt b/CMakeLists.txt index dee09ae..b751d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.0) project(openFPGALoader VERSION 0.1 LANGUAGES CXX) option(BUILD_STATIC "Whether or not to build with static libraries" OFF) +option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON) ## specify the C++ standard set(CMAKE_CXX_STANDARD 11) @@ -23,7 +24,16 @@ add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\") find_package(PkgConfig REQUIRED) pkg_check_modules(LIBFTDI REQUIRED libftdi1) pkg_check_modules(LIBUSB REQUIRED libusb-1.0) -pkg_check_modules(LIBUDEV REQUIRED libudev) + +if(ENABLE_UDEV) + pkg_check_modules(LIBUDEV libudev) + if (LIBUDEV_FOUND) + add_definitions(-DUSE_UDEV) + else() + message("libudev not found, disabling udev support and -d parameter") + set(ENABLE_UDEV OFF) + endif() +endif() # for non glibc, argp-standalone is required and must be # explicitly linked. This code will fail for others libc @@ -92,17 +102,21 @@ add_executable(openFPGALoader ${OPENFPGALOADER_HEADERS} ) -include_directories(${LIBUDEV_INCLUDE_DIRS} +include_directories( ${LIBUSB_INCLUDE_DIRS} ${LIBFTDI_INCLUDE_DIRS} ) target_link_libraries(openFPGALoader - ${LIBUDEV_LIBRARIES} ${LIBUSB_LIBRARIES} ${LIBFTDI_LIBRARIES} ) +if(ENABLE_UDEV) +include_directories(${LIBUDEV_INCLUDE_DIRS}) +target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES}) +endif() + if(NOT HAVE_ARGP) target_link_libraries(openFPGALoader /usr/lib/libargp.a) endif() diff --git a/INSTALL.md b/INSTALL.md index ce44661..4780f7e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,6 +6,7 @@ $ mkdir build $ cd build $ cmake ../ # add -DBUILD_STATIC=ON to build a static version + # add -DENABLE_UDEV=OFF to disable udev support and -d /dev/xxx $ cmake --build . or $ make -j$(nproc) diff --git a/README.md b/README.md index 610dde1..15deb98 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ depending of the distribution, headers too) ```bash apt-get install libftdi1-2 libftdi1-dev libudev-dev cmake ``` +**libudev-dev** is optional, may be replaced by **eudev-dev** or just not installed. + +By default, **(e)udev** support is enabled (used to open a device by his */dev/xx* +node). If you don't want this option, use: + +```-DENABLE_UDEV=OFF``` For distributions using non-glibc (musl, uClibc) **argp-standalone** must be installed. @@ -47,6 +53,7 @@ To build the app: $ mkdir build $ cd build $ cmake ../ # add -DBUILD_STATIC=ON to build a static version + # add -DENABLE_UDEV=OFF to disable udev support and -d /dev/xxx $ cmake --build . or $ make -j$(nproc) diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index 85c49d6..c157826 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -7,7 +7,9 @@ #include +#ifdef USE_UDEV #include +#endif #include #include "ftdipp_mpsse.hpp" @@ -346,6 +348,7 @@ int FTDIpp_MPSSE::mpsse_read(unsigned char *rx_buff, int len) return num_read; } +#ifdef USE_UDEV unsigned int FTDIpp_MPSSE::udevstufftoint(const char *udevstring, int base) { char *endp; @@ -436,3 +439,16 @@ bool FTDIpp_MPSSE::search_with_dev(const string &device) return true; } +#else +unsigned int FTDIpp_MPSSE::udevstufftoint(const char *udevstring, int base) +{ + (void)udevstring; + (void)base; + return 0; +} +bool FTDIpp_MPSSE::search_with_dev(const string &device) +{ + (void)device; + return false; +} +#endif diff --git a/src/main.cpp b/src/main.cpp index 122d520..5a2a381 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,7 +67,9 @@ static struct argp_option options[] = { {"list-cables", LIST_CABLE, 0, 0, "list all supported cables"}, {"board", 'b', "BOARD", 0, "board name, may be used instead of cable"}, {"list-boards", LIST_BOARD, 0, 0, "list all supported boards"}, +#ifdef USE_UDEV {"device", 'd', "DEVICE", 0, "device to use (/dev/ttyUSBx)"}, +#endif {"list-fpga", LIST_FPGA, 0, 0, "list all supported FPGA"}, {"detect", DETECT, 0, 0, "detect FPGA"}, {"write-flash", 'f', 0, 0, @@ -215,9 +217,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 'r': arguments->reset = true; break; +#ifdef USE_UDEV case 'd': arguments->device = arg; break; +#endif case 'v': arguments->verbose = true; break;