From a2608b1947c02af386763b759728a092ad67378c Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Thu, 2 Jan 2020 21:52:40 +0100 Subject: [PATCH] macOS: Explicit Makefile.osx using static linking Instead of using pkg-config and assuming Homebrew or similar package management is present, use explicit manually built static libraries for libusb and libftdi. This makefile was used to generate portable ujprog in: https://github.com/emard/ulx3s-bin/commit/0f782d92267fa4faa3ee --- ujprog/Makefile.osx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ujprog/Makefile.osx b/ujprog/Makefile.osx index f61ddb2..09c0acf 100644 --- a/ujprog/Makefile.osx +++ b/ujprog/Makefile.osx @@ -1,13 +1,24 @@ -CFLAGS += -Wall `pkg-config --cflags libusb libftdi` -LDFLAGS += `pkg-config --libs libusb libftdi` +# build libusb, libftdi and adjust paths below accordingly +# NOTE: static libraries are preferred, so produced binaries are portable -# Install libusb-compat, libftdi0, pkg-config with 'brew install libusb-compat libftdi0 pkg-config' +# location of libftdi built with CMake in build/ sub-folder +# downloaded from https://www.intra2net.com/en/developer/libftdi/ +FTINC = ../../src/libftdi1-1.4/src +FTLIB = ../../src/libftdi1-1.4/build/src/libftdi1.a + +# location of libusb built with ./configure --disable-shared --enable-static +# downloaded from https://libusb.info +USBINC = ../../src/libusb-1.0.22/libusb +USBLIB = ../../src/libusb-1.0.22/libusb/.libs/libusb-1.0.a + +CFLAGS += -Wall -I${FTINC} -I${USBINC} +LDFLAGS += ${FTLIB} ${USBLIB} -framework IOKit -framework Foundation ujprog: ujprog.c ${CC} ${CFLAGS} $^ ${LDFLAGS} -o $@ flash: ft232r_flash.c - ${CC} ${CFLAGS} $^ ${LDFLAGS} -lusb -o $@ + ${CC} ${CFLAGS} $^ ${LDFLAGS} -o $@ install: ujprog install -m 4755 ujprog /usr/local/bin