diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 00000000..39251cab --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,599 @@ +# Makefile for "blink1-lib" and "blink1-tool" +# +# Works on Mac OS X, Windows, Linux, and other Linux-like systems. +# Type "make help" to see supported platforms. +# +# Build arguments: +# - "OS=macosx" -- build Mac version on Mac OS X +# - "OS=windows" -- build Windows version on Windows +# - "OS=linux" -- build Linux version on Linux +# +# Architecture is usually detected automatically, so normally just type "make". +# +# Dependencies: +# - hidapi (included), which uses libusb on Linux-like OSes +# +# Platform-specific notes: +# +# Mac OS X +# - Install XCode +# - In Terminal, "xcode-select --install" to install command-line tools +# - make +# +# Windows 10 using MSYS2 +# - Install Visual Studio 2015 +# - Install MSYS2 : https://github.com/msys2/msys2/wiki/MSYS2-installation +# - pacman -S base-devel make git zip unzip +# - pacman -S mingw-w64-x86_64-toolchain +# - add to PATH compiler and Windows linker: +# export PATH=${PATH}:/c/msys64/mingw64/bin +# export PATH=${PATH}:"/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin" +# - git clone https://github.com/todbot/blink1 +# - cd blink1/commandline +# - make +# +# Windows XP/7 +# - Install MinGW and MSYS (http://www.tdragon.net/recentgcc/ ) +# - make +# +# Linux (Ubuntu) +# - apt-get install build-essential pkg-config libusb-1.0-0-dev +# - make +# +# Linux (Fedora 18+) +# - yum install make gcc libusbx-devel +# - make +# +# Linux (Fedora 17) +# - yum install make gcc libusb1-static glibc-static +# - make +# +# FreeBSD +# - libusb is part of the OS so no pkg-config needed. +# - No -ldl on FreeBSD necessary. +# - For FreeBSD versions < 10, iconv is a package that needs to be installed; +# in this case it lives in /usr/local/lib/ +# - On FreeBSD 8.3, this command builds blink1-tool: +# - "cd blink1/commandline && USBLIB_TYPE=HIDDATA gmake" +# +# Linux Ubuntu 32-bit cross-compile on 64-bit +# To build 32-bit on 64-bit Ubuntu, try a chrooted build: +# (warning this will use up a lot of disk space) +# - sudo apt-get install ubuntu-dev-tools +# - pbuilder-dist oneiric i386 create +# - mkdir $HOME/i386 +# - cp -r blink1 $HOME/i386 +# - pbuilder-dist oneiric i386 login --bindmounts $HOME/i386 +# (now in the chrooted area) +# - apt-get install libusb-1.0-0 libusb-1.0-0-dev +# - cd $HOME/i386/blink1 +# - CFLAGS='-I/usr/include/libusb-1.0' LIBS='-lusb-1.0' make +# - exit +# +# Raspberry Pi +# - apt-get install build-essential pkg-config libusb-1.0.0-dev +# - make +# +# BeagleBone / BeagleBoard (on Angstrom Linux) +# - opkg install libusb-0.1-4-dev (FIXME: uses HIDAPI & libusb-1.0 now) +# - May need to symlink libusb +# cd /lib; ln -s libusb-0.1.so.4 libusb.so +# - make +# +# + +# Enable 'all' warnings, and treat them as errors. +CFLAGS = -Wall -Werror + +# deal with stupid Windows not having 'cc' +ifeq (default,$(origin CC)) + CC = gcc +endif + +# pick low-level implemenation style +# "HIDAPI" type is best for Mac, Windows, Linux Desktop, +# but has dependencies on iconv, libusb-1.0, pthread, dl +# +# "HIDAPI_HIDRAW" uses udev instead of libusb +# +# "HIDDATA" type is best for low-resource Linux, +# and the only dependencies it has is libusb-0.1 +# +# Try either on the commandline with: +# make USBLIB_TYPE=HIDDATA +# make USBLIB_TYPE=HIDAPI_HIDRAW +# + +USBLIB_TYPE ?= HIDAPI +#USBLIB_TYPE = HIDAPI_HIDRAW +#USBLIB_TYPE = HIDDATA + +# uncomment for debugging HID stuff +# or make with: CFLAGS=-DDEBUG_HID make +#CFLAGS += -DDEBUG_HID + + +# try to do some autodetecting +UNAME := $(shell uname -s) + +ifeq "$(UNAME)" "Darwin" + OS=macosx +endif + +ifeq "$(OS)" "Windows_NT" + OS=windows +endif + +ifeq "$(UNAME)" "Linux" + OS=linux +endif + +ifeq "$(UNAME)" "FreeBSD" + OS=freebsd +endif + +ifeq "$(UNAME)" "OpenBSD" + OS=openbsd +endif + +ifeq "$(UNAME)" "NetBSD" + OS=netbsd +endif + +# allow overriding of GIT_TAG & BLINK1_VERSION on commandline for automated builds + +MACH_TYPE:="$(strip $(shell uname -m))" +GIT_TAG?="$(strip $(shell git tag 2>&1 | tail -1 | cut -f1 -d' '))" +# deal with case of no git or no git tags, check for presence of "v" (i.e. "v1.93") +ifneq ($(findstring v,$(GIT_TAG)), v) + GIT_TAG:="v0" +endif + +BLINK1_VERSION?="$(GIT_TAG)-$(OS)-$(MACH_TYPE)" + + + +################# Mac OS X ################################################## +ifeq "$(OS)" "macosx" +LIBTARGET = libBlink1.dylib +CFLAGS += -mmacosx-version-min=10.8 +#CFLAGS += -mmacosx-version-min=10.6 +#CFLAGS += -fsanitize=address + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -arch i386 -arch x86_64 +# don't need pthread with clang +#CFLAGS += -pthread +CFLAGS += -O2 -D_THREAD_SAFE -MT MD -MP +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/mac/hid.o +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +OPT_HOME := /opt/local/bin +CFLAGS += `$(OPT_HOME)/libusb-config --cflags` +LIBS += `$(OPT_HOME)/libusb-config --libs` +endif + +LIBS += -framework IOKit -framework CoreFoundation + +EXEFLAGS = +#LIBFLAGS = -bundle -o $(LIBTARGET) -Wl,-search_paths_first $(LIBS) +LIBFLAGS = -dynamiclib -o $(LIBTARGET) -Wl,-search_paths_first $(LIBS) +EXE= + +INSTALL = install +PREFIX ?= /usr/local +EXELOCATION ?= $(PREFIX)/bin +LIBLOCATION ?= $(PREFIX)/lib +INCLOCATION ?= $(PREFIX)/include + +endif + +################# Windows ################################################## +ifeq "$(OS)" "windows" +LIBTARGET = blink1-lib.dll +#LIBS += -mwindows -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32 +#LIBS += -mwindows -lsetupapi -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32 +LIBS += -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++ +# needed for Mongoose & blink1-tiny-server +LIBS += -lws2_32 + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/windows/hid.o +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +endif + +EXEFLAGS = +#LIBFLAGS = -shared -o $(LIBTARGET) -Wl,--add-stdcall-alias -Wl,--export-all-symbols -Wl,--out-implib,$(LIBTARGET).a $(LIBS) +LIBFLAGS = -shared -o $(LIBTARGET) -Wl,--add-stdcall-alias -Wl,--export-all-symbols,--output-def,blink1-lib.def,--out-implib,blink1-lib.a +EXE= .exe + +# this generates a blink1-lib.lib for use with MSVC +LIB_EXTRA = lib /machine:i386 /def:blink1-lib.def + +INSTALL = cp +EXELOCATION ?= $(SystemRoot)/system32 +LIBLOCATION ?= $(SystemRoot)/system32 +# not sure where this really should point +INCLOCATION ?= $(SystemRoot)/system32 + +endif + +################# Linux #################################################### +ifeq "$(OS)" "linux" +LIBTARGET = libblink1.so +# was blink1-lib.so + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/libusb/hid.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC +LIBS += `pkg-config libusb-1.0 --libs` -lrt -lpthread -ldl +endif + +ifeq "$(USBLIB_TYPE)" "HIDAPI_HIDRAW" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/linux/hid.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC +LIBS += `pkg-config libusb-1.0 --libs` `pkg-config libudev --libs` -lrt +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +CFLAGS += `pkg-config libusb --cflags` -fPIC +LIBS += `pkg-config libusb --libs` +endif + +# static doesn't work on Ubuntu 13+ +#EXEFLAGS = -static +LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +INSTALL = install -D +PREFIX ?= /usr/local +EXELOCATION ?= $(PREFIX)/bin +LIBLOCATION ?= $(PREFIX)/lib +INCLOCATION ?= $(PREFIX)/include + +endif + +################ FreeBSD ################################################### +ifeq "$(OS)" "freebsd" +LIBTARGET = libblink1.so +# was blink1-lib.so + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/libusb/hid.o +CFLAGS += -I/usr/local/include -fPIC +LIBS += -lusb -lrt -lpthread +ifndef FBSD10 +LIBS += -L/usr/local/lib -liconv +endif +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +CFLAGS += -I/usr/local/include -fPIC +LIBS += -L/usr/local/lib -lusb +endif + +# Static binaries don't play well with the iconv implementation of FreeBSD 10 +ifndef FBSD10 +EXEFLAGS = -static +endif +LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +INSTALL = install -D +PREFIX ?= /usr/local +EXELOCATION ?= $(PREFIX)/bin +LIBLOCATION ?= $(PREFIX)/lib +INCLOCATION ?= $(PREFIX)/include + +endif + +################# OpenBSD ################################################### +ifeq "$(OS)" "openbsd" +LIBTARGET = libblink1.so +# was blink1-lib.so + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/libusb/hid.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -I/usr/local/include -fPIC +LIBS += `pkg-config libusb-1.0 --libs` -L/usr/local/lib -lpthread -liconv +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +CFLAGS += `pkg-config libusb --cflags` -fPIC +LIBS += `pkg-config libusb --libs` +endif + +LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +INSTALL = install +PREFIX ?= /usr/local +EXELOCATION ?= $(PREFIX)/bin +LIBLOCATION ?= $(PREFIX)/lib +INCLOCATION ?= $(PREFIX)/include + +endif + +################# NetBSD ################################################### +ifeq "$(OS)" "netbsd" +LIBTARGET = libblink1.so +# was blink1-lib.so + +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/libusb/hid.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -I/usr/pkg/include -fPIC +LIBS += `pkg-config libusb-1.0 --libs` -L/usr/pkg/lib -lpthread -liconv +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC +LIBS += `pkg-config libusb-1.0 --libs` +endif + +LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +INSTALL = install +PREFIX ?= /usr/local +EXELOCATION ?= $(PREFIX)/bin +LIBLOCATION ?= $(PREFIX)/lib +INCLOCATION ?= $(PREFIX)/include + +endif + +################# WRT Linux ################################################ +ifeq "$(OS)" "wrtlinux" +LIBTARGET = libblink1.so + +# HIDAPI build doesn't work, use HIDDATA instead +ifeq "$(USBLIB_TYPE)" "HIDAPI" +CFLAGS += -DUSE_HIDAPI +CFLAGS += -I./hidapi/hidapi +OBJS = ./hidapi/libusb/hid.o +CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC +LIBS += `pkg-config libusb-1.0 --libs` -lrt -lpthread -ldl +endif + +ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA $(COPT_FLAGS) +OBJS = ./hiddata.o +LIBS += $(LDOPT_FLAGS) +#LIBS += $(STAGING_DIR)/usr/lib/libusb.a +#can't build this static for some reason +LIBS += -lusb +endif + +#EXEFLAGS = -static +LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +endif + +############## Cross-compile WRT Linux for Arduino Yun ##################### +ifeq "$(OS)" "yun" +LIBTARGET = libblink1.so + +BLINK1_VERSION="$(GIT_TAG)-$(OS)-ar71xx" + +#ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o + +WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.6-linaro_uClibc-0.9.33.2 +WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) +WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) +STAGING_DIR=$(WRT_SDK_HOME)/staging_dir + +CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-gcc +LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-ld +CFLAGS += -I$(WRT_TARGET_ROOT)/usr/include +LIBS += -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 +export STAGING_DIR=$$(STAGING_DIR) + +#endif + +#EXEFLAGS = -static +LIBFLAGS = -o $(LIBTARGET) $(LIBS) +EXE= + +endif + +############## Cross-compile WRT Linux ##################################### +ifeq "$(OS)" "wrt" +LIBTARGET = libblink1.so + +BLINK1_VERSION="$(GIT_TAG)-$(OS)-brcm47xx" + +#ifeq "$(USBLIB_TYPE)" "HIDDATA" +CFLAGS += -DUSE_HIDDATA +OBJS = ./hiddata.o + +WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-brcm47xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2 +WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) +WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) +STAGING_DIR=$(WRT_SDK_HOME)/staging_dir + +CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips*-openwrt-linux-gcc +LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips*-openwrt-linux-ld +CFLAGS += -I$(WRT_TARGET_ROOT)/usr/include +LIBS += -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 +export STAGING_DIR=$$(STAGING_DIR) + +#endif + +EXEFLAGS = -static +#LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) +EXE= + +endif + + + +##################### Common ############################################### + + +#CFLAGS += -O -Wall -std=gnu99 -I ../hardware/firmware +CFLAGS += -std=gnu99 +CFLAGS += -g +CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\" + +OBJS += blink1-lib.o + + +PKGOS = $(BLINK1_VERSION) + +.PHONY: all install help blink1control-tool + +#all: msg blink1-tool blink1-server-simple +all: msg blink1-tool lib + +# symbolic targets: +help: + @echo "This Makefile works on multiple archs. Use one of the following:" + @echo "make ... autodetect platform and build appropriately" + @echo "make OS=windows ... build Windows blink1-lib and blink1-tool" + @echo "make OS=linux ... build Linux blink1-lib and blink1-tool" + @echo "make OS=freebsd ... build FreeBSD blink1-lib and blink1-tool" + @echo "make OS=openbsd ... build OpenBSD blink1-lib and blink1-tool" + @echo "make OS=netbsd ... build NetBSD blink1-lib and blink1-tool" + @echo "make OS=macosx ... build Mac OS X blink1-lib and blink1-tool" + @echo "make OS=wrt ... build OpenWrt blink1-lib and blink1-tool" + @echo "make OS=wrtcross... build for OpenWrt using cross-compiler" + @echo "make USBLIB_TYPE=HIDDATA OS=linux ... build using low-deps method" + @echo "make lib ... build blink1-lib shared library" + @echo "make blink1-tool... build blink1-tool program" + @echo "make blink1-tiny-server ... build tiny REST server" + @echo "make blink1control-tool ... build blink1control-tool (w/Blink1Control)" + @echo "make package ... zip up blink1-tool and blink1-lib " + @echo "make package-tiny-server ... package tiny REST server" + @echo "make package-all... package everything (and build everything first)" + @echo "make clean ... delete build products, leave binaries & libs" + @echo "make distclean ... delele binaries and libs too" + @echo + +msg: + @echo "Building blink1-tool for OS=$(OS) BLINK1_VERSION=$(BLINK1_VERSION) USBLIB_TYPE=$(USBLIB_TYPE)" + @echo "Type 'make help' for other build products" + + +$(OBJS): %.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +blink1-tool: $(OBJS) blink1-tool.o + $(CC) $(CFLAGS) -c blink1-tool.c -o blink1-tool.o + $(CC) $(CFLAGS) $(EXEFLAGS) -g $(OBJS) $(LIBS) blink1-tool.o -o blink1-tool$(EXE) $(LDFLAGS) + +blink1-tiny-server: $(OBJS) server/blink1-tiny-server.c +# $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c server/blink1-tiny-server.c -o blink1-tiny-server.o + $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c server/blink1-tiny-server.c -o blink1-tiny-server.o + $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c ./server/mongoose/mongoose.c -o ./server/mongoose/mongoose.o + $(CC) -g $(OBJS) $(EXEFLAGS) ./server/mongoose/mongoose.o $(LIBS) -lpthread blink1-tiny-server.o -o blink1-tiny-server$(EXE) $(LDFLAGS) + +$(LIBTARGET): $(OBJS) + $(CC) $(LIBFLAGS) $(CFLAGS) $(OBJS) $(LIBS) + $(LIB_EXTRA) + +lib: $(LIBTARGET) + +blink1control-tool: + $(MAKE) -C blink1control-tool + +package: lib blink1-tool + @echo "Packaging up blink1-tool and blink1-lib for '$(PKGOS)'" + zip blink1-tool-$(PKGOS).zip blink1-tool$(EXE) + zip blink1-lib-$(PKGOS).zip $(LIBTARGET) blink1-lib.h + +package-tiny-server: blink1-tiny-server + zip blink1-tiny-server-$(PKGOS).zip blink1-tiny-server$(EXE) + +package-blink1control-tool: blink1control-tool + zip -j blink1control-tool-$(PKGOS).zip blink1control-tool/blink1control-tool$(EXE) + +package-all: package package-tiny-server package-blink1control-tool + @mkdir -p builds + @mv blink1*$(PKGOS).zip builds + @echo "Look in 'builds' for zipfiles to publish" + +install-lib: + $(INSTALL) $(LIBTARGET) $(DESTDIR)$(LIBLOCATION)/$(LIBTARGET) + +install-dev: install-lib + $(INSTALL) blink1-lib.h $(DESTDIR)$(INCLOCATION)/blink1-lib.h + +install: all install-lib + $(INSTALL) blink1-tool$(EXE) $(DESTDIR)$(EXELOCATION)/blink1-tool$(EXE) + +uninstall-lib: + rm -f $(DESTDIR)$(LIBLOCATION)/$(LIBTARGET) + +uninstall-dev: uninstall-lib + rm -f $(DESTDIR)$(INCLOCATION)/blink2-lib.h + +uninstall: uninstall-lib + rm -f $(DESTDIR)$(EXELOCATION)/blink1-tool$(EXE) + +clean: + rm -f $(OBJS) + rm -f $(LIBTARGET) + rm -f blink1-tiny-server.o blink1-tool.o hiddata.o + rm -f server/mongoose/mongoose.o + rm -f blink1-tool$(EXE) blink1-tiny-server$(EXE) + $(MAKE) -C blink1control-tool clean + +distclean: clean + #rm -f blink1-tool$(EXE) + rm -f blink1-tiny-server$(EXE) + rm -f $(LIBTARGET) $(LIBTARGET).a + rm -f libblink1.so + rm -f blink1-tool + rm -f blink1-tool.exe + $(MAKE) -C blink1control-tool distclean + +# show shared library use +# in general we want minimal to no dependecies for blink1-tool + +# shows shared lib usage on Mac OS X +otool: + otool -L blink1-tool +# show shared lib usage on Linux +ldd: + ldd blink1-tool +# show shared lib usage on Windows +# FIXME: only works inside command prompt from +# Start->All Programs-> MS Visual Studio 2012 -> VS Tools -> Devel. Cmd Prompt +dumpbin: + dumpbin.exe /exports $(LIBTARGET) + dumpbin.exe /exports blink1-tool.exe + + +printvars: + @echo "OS=$(OS), CFLAGS=$(CFLAGS), LDFLAGS=$(LDFLAGS), LIBS=$(LIBS), LIBFLAGS=$(LIBFLAGS)" diff --git a/Makefile b/Makefile index 08f2e874..3d4c0f14 100644 --- a/Makefile +++ b/Makefile @@ -1,596 +1,5 @@ -# Makefile for "blink1-lib" and "blink1-tool" -# -# Works on Mac OS X, Windows, Linux, and other Linux-like systems. -# Type "make help" to see supported platforms. -# -# Build arguments: -# - "OS=macosx" -- build Mac version on Mac OS X -# - "OS=windows" -- build Windows version on Windows -# - "OS=linux" -- build Linux version on Linux -# -# Architecture is usually detected automatically, so normally just type "make". -# -# Dependencies: -# - hidapi (included), which uses libusb on Linux-like OSes -# -# Platform-specific notes: -# -# Mac OS X -# - Install XCode -# - In Terminal, "xcode-select --install" to install command-line tools -# - make -# -# Windows 10 using MSYS2 -# - Install Visual Studio 2015 -# - Install MSYS2 : https://github.com/msys2/msys2/wiki/MSYS2-installation -# - pacman -S base-devel make git zip unzip -# - pacman -S mingw-w64-x86_64-toolchain -# - add to PATH compiler and Windows linker: -# export PATH=${PATH}:/c/msys64/mingw64/bin -# export PATH=${PATH}:"/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin" -# - git clone https://github.com/todbot/blink1 -# - cd blink1/commandline -# - make -# -# Windows XP/7 -# - Install MinGW and MSYS (http://www.tdragon.net/recentgcc/ ) -# - make -# -# Linux (Ubuntu) -# - apt-get install build-essential pkg-config libusb-1.0-0-dev -# - make -# -# Linux (Fedora 18+) -# - yum install make gcc libusbx-devel -# - make -# -# Linux (Fedora 17) -# - yum install make gcc libusb1-static glibc-static -# - make -# -# FreeBSD -# - libusb is part of the OS so no pkg-config needed. -# - No -ldl on FreeBSD necessary. -# - For FreeBSD versions < 10, iconv is a package that needs to be installed; -# in this case it lives in /usr/local/lib/ -# - On FreeBSD 8.3, this command builds blink1-tool: -# - "cd blink1/commandline && USBLIB_TYPE=HIDDATA gmake" -# -# Linux Ubuntu 32-bit cross-compile on 64-bit -# To build 32-bit on 64-bit Ubuntu, try a chrooted build: -# (warning this will use up a lot of disk space) -# - sudo apt-get install ubuntu-dev-tools -# - pbuilder-dist oneiric i386 create -# - mkdir $HOME/i386 -# - cp -r blink1 $HOME/i386 -# - pbuilder-dist oneiric i386 login --bindmounts $HOME/i386 -# (now in the chrooted area) -# - apt-get install libusb-1.0-0 libusb-1.0-0-dev -# - cd $HOME/i386/blink1 -# - CFLAGS='-I/usr/include/libusb-1.0' LIBS='-lusb-1.0' make -# - exit -# -# Raspberry Pi -# - apt-get install build-essential pkg-config libusb-1.0.0-dev -# - make -# -# BeagleBone / BeagleBoard (on Angstrom Linux) -# - opkg install libusb-0.1-4-dev (FIXME: uses HIDAPI & libusb-1.0 now) -# - May need to symlink libusb -# cd /lib; ln -s libusb-0.1.so.4 libusb.so -# - make -# -# - -# deal with stupid Windows not having 'cc' -ifeq (default,$(origin CC)) - CC = gcc -endif - -# pick low-level implemenation style -# "HIDAPI" type is best for Mac, Windows, Linux Desktop, -# but has dependencies on iconv, libusb-1.0, pthread, dl -# -# "HIDAPI_HIDRAW" uses udev instead of libusb -# -# "HIDDATA" type is best for low-resource Linux, -# and the only dependencies it has is libusb-0.1 -# -# Try either on the commandline with: -# make USBLIB_TYPE=HIDDATA -# make USBLIB_TYPE=HIDAPI_HIDRAW -# - -USBLIB_TYPE ?= HIDAPI -#USBLIB_TYPE = HIDAPI_HIDRAW -#USBLIB_TYPE = HIDDATA - -# uncomment for debugging HID stuff -# or make with: CFLAGS=-DDEBUG_HID make -#CFLAGS += -DDEBUG_HID - - -# try to do some autodetecting -UNAME := $(shell uname -s) - -ifeq "$(UNAME)" "Darwin" - OS=macosx -endif - -ifeq "$(OS)" "Windows_NT" - OS=windows -endif - -ifeq "$(UNAME)" "Linux" - OS=linux -endif - -ifeq "$(UNAME)" "FreeBSD" - OS=freebsd -endif - -ifeq "$(UNAME)" "OpenBSD" - OS=openbsd -endif - -ifeq "$(UNAME)" "NetBSD" - OS=netbsd -endif - -# allow overriding of GIT_TAG & BLINK1_VERSION on commandline for automated builds - -MACH_TYPE:="$(strip $(shell uname -m))" -GIT_TAG?="$(strip $(shell git tag 2>&1 | tail -1 | cut -f1 -d' '))" -# deal with case of no git or no git tags, check for presence of "v" (i.e. "v1.93") -ifneq ($(findstring v,$(GIT_TAG)), v) - GIT_TAG:="v0" -endif - -BLINK1_VERSION?="$(GIT_TAG)-$(OS)-$(MACH_TYPE)" - - - -################# Mac OS X ################################################## -ifeq "$(OS)" "macosx" -LIBTARGET = libBlink1.dylib -CFLAGS += -mmacosx-version-min=10.8 -#CFLAGS += -mmacosx-version-min=10.6 -#CFLAGS += -fsanitize=address - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -arch i386 -arch x86_64 -# don't need pthread with clang -#CFLAGS += -pthread -CFLAGS += -O2 -D_THREAD_SAFE -MT MD -MP -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/mac/hid.o -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -OPT_HOME := /opt/local/bin -CFLAGS += `$(OPT_HOME)/libusb-config --cflags` -LIBS += `$(OPT_HOME)/libusb-config --libs` -endif - -LIBS += -framework IOKit -framework CoreFoundation - -EXEFLAGS = -#LIBFLAGS = -bundle -o $(LIBTARGET) -Wl,-search_paths_first $(LIBS) -LIBFLAGS = -dynamiclib -o $(LIBTARGET) -Wl,-search_paths_first $(LIBS) -EXE= - -INSTALL = install -PREFIX ?= /usr/local -EXELOCATION ?= $(PREFIX)/bin -LIBLOCATION ?= $(PREFIX)/lib -INCLOCATION ?= $(PREFIX)/include - -endif - -################# Windows ################################################## -ifeq "$(OS)" "windows" -LIBTARGET = blink1-lib.dll -#LIBS += -mwindows -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32 -#LIBS += -mwindows -lsetupapi -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32 -LIBS += -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -# needed for Mongoose & blink1-tiny-server -LIBS += -lws2_32 - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/windows/hid.o -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -endif - -EXEFLAGS = -#LIBFLAGS = -shared -o $(LIBTARGET) -Wl,--add-stdcall-alias -Wl,--export-all-symbols -Wl,--out-implib,$(LIBTARGET).a $(LIBS) -LIBFLAGS = -shared -o $(LIBTARGET) -Wl,--add-stdcall-alias -Wl,--export-all-symbols,--output-def,blink1-lib.def,--out-implib,blink1-lib.a -EXE= .exe - -# this generates a blink1-lib.lib for use with MSVC -LIB_EXTRA = lib /machine:i386 /def:blink1-lib.def - -INSTALL = cp -EXELOCATION ?= $(SystemRoot)/system32 -LIBLOCATION ?= $(SystemRoot)/system32 -# not sure where this really should point -INCLOCATION ?= $(SystemRoot)/system32 - -endif - -################# Linux #################################################### -ifeq "$(OS)" "linux" -LIBTARGET = libblink1.so -# was blink1-lib.so - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/libusb/hid.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC -LIBS += `pkg-config libusb-1.0 --libs` -lrt -lpthread -ldl -endif - -ifeq "$(USBLIB_TYPE)" "HIDAPI_HIDRAW" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/linux/hid.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC -LIBS += `pkg-config libusb-1.0 --libs` `pkg-config libudev --libs` -lrt -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -CFLAGS += `pkg-config libusb --cflags` -fPIC -LIBS += `pkg-config libusb --libs` -endif - -# static doesn't work on Ubuntu 13+ -#EXEFLAGS = -static -LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -INSTALL = install -D -PREFIX ?= /usr/local -EXELOCATION ?= $(PREFIX)/bin -LIBLOCATION ?= $(PREFIX)/lib -INCLOCATION ?= $(PREFIX)/include - -endif - -################ FreeBSD ################################################### -ifeq "$(OS)" "freebsd" -LIBTARGET = libblink1.so -# was blink1-lib.so - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/libusb/hid.o -CFLAGS += -I/usr/local/include -fPIC -LIBS += -lusb -lrt -lpthread -ifndef FBSD10 -LIBS += -L/usr/local/lib -liconv -endif -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -CFLAGS += -I/usr/local/include -fPIC -LIBS += -L/usr/local/lib -lusb -endif - -# Static binaries don't play well with the iconv implementation of FreeBSD 10 -ifndef FBSD10 -EXEFLAGS = -static -endif -LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -INSTALL = install -D -PREFIX ?= /usr/local -EXELOCATION ?= $(PREFIX)/bin -LIBLOCATION ?= $(PREFIX)/lib -INCLOCATION ?= $(PREFIX)/include - -endif - -################# OpenBSD ################################################### -ifeq "$(OS)" "openbsd" -LIBTARGET = libblink1.so -# was blink1-lib.so - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/libusb/hid.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -I/usr/local/include -fPIC -LIBS += `pkg-config libusb-1.0 --libs` -L/usr/local/lib -lpthread -liconv -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -CFLAGS += `pkg-config libusb --cflags` -fPIC -LIBS += `pkg-config libusb --libs` -endif - -LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -INSTALL = install -PREFIX ?= /usr/local -EXELOCATION ?= $(PREFIX)/bin -LIBLOCATION ?= $(PREFIX)/lib -INCLOCATION ?= $(PREFIX)/include - -endif - -################# NetBSD ################################################### -ifeq "$(OS)" "netbsd" -LIBTARGET = libblink1.so -# was blink1-lib.so - -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/libusb/hid.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -I/usr/pkg/include -fPIC -LIBS += `pkg-config libusb-1.0 --libs` -L/usr/pkg/lib -lpthread -liconv -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC -LIBS += `pkg-config libusb-1.0 --libs` -endif - -LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -INSTALL = install -PREFIX ?= /usr/local -EXELOCATION ?= $(PREFIX)/bin -LIBLOCATION ?= $(PREFIX)/lib -INCLOCATION ?= $(PREFIX)/include - -endif - -################# WRT Linux ################################################ -ifeq "$(OS)" "wrtlinux" -LIBTARGET = libblink1.so - -# HIDAPI build doesn't work, use HIDDATA instead -ifeq "$(USBLIB_TYPE)" "HIDAPI" -CFLAGS += -DUSE_HIDAPI -CFLAGS += -I./hidapi/hidapi -OBJS = ./hidapi/libusb/hid.o -CFLAGS += `pkg-config libusb-1.0 --cflags` -fPIC -LIBS += `pkg-config libusb-1.0 --libs` -lrt -lpthread -ldl -endif - -ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA $(COPT_FLAGS) -OBJS = ./hiddata.o -LIBS += $(LDOPT_FLAGS) -#LIBS += $(STAGING_DIR)/usr/lib/libusb.a -#can't build this static for some reason -LIBS += -lusb -endif - -#EXEFLAGS = -static -LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -endif - -############## Cross-compile WRT Linux for Arduino Yun ##################### -ifeq "$(OS)" "yun" -LIBTARGET = libblink1.so - -BLINK1_VERSION="$(GIT_TAG)-$(OS)-ar71xx" - -#ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o - -WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.6-linaro_uClibc-0.9.33.2 -WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) -WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) -STAGING_DIR=$(WRT_SDK_HOME)/staging_dir - -CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-gcc -LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-ld -CFLAGS += -I$(WRT_TARGET_ROOT)/usr/include -LIBS += -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 -export STAGING_DIR=$$(STAGING_DIR) - -#endif - -#EXEFLAGS = -static -LIBFLAGS = -o $(LIBTARGET) $(LIBS) -EXE= - -endif - -############## Cross-compile WRT Linux ##################################### -ifeq "$(OS)" "wrt" -LIBTARGET = libblink1.so - -BLINK1_VERSION="$(GIT_TAG)-$(OS)-brcm47xx" - -#ifeq "$(USBLIB_TYPE)" "HIDDATA" -CFLAGS += -DUSE_HIDDATA -OBJS = ./hiddata.o - -WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-brcm47xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2 -WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) -WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) -STAGING_DIR=$(WRT_SDK_HOME)/staging_dir - -CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips*-openwrt-linux-gcc -LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips*-openwrt-linux-ld -CFLAGS += -I$(WRT_TARGET_ROOT)/usr/include -LIBS += -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 -export STAGING_DIR=$$(STAGING_DIR) - -#endif - -EXEFLAGS = -static -#LIBFLAGS = -shared -o $(LIBTARGET) $(LIBS) -EXE= - -endif - - - -##################### Common ############################################### - - -#CFLAGS += -O -Wall -std=gnu99 -I ../hardware/firmware -CFLAGS += -std=gnu99 -CFLAGS += -g -CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\" - -OBJS += blink1-lib.o - - -PKGOS = $(BLINK1_VERSION) - -.PHONY: all install help blink1control-tool - -#all: msg blink1-tool blink1-server-simple -all: msg blink1-tool lib - -# symbolic targets: -help: - @echo "This Makefile works on multiple archs. Use one of the following:" - @echo "make ... autodetect platform and build appropriately" - @echo "make OS=windows ... build Windows blink1-lib and blink1-tool" - @echo "make OS=linux ... build Linux blink1-lib and blink1-tool" - @echo "make OS=freebsd ... build FreeBSD blink1-lib and blink1-tool" - @echo "make OS=openbsd ... build OpenBSD blink1-lib and blink1-tool" - @echo "make OS=netbsd ... build NetBSD blink1-lib and blink1-tool" - @echo "make OS=macosx ... build Mac OS X blink1-lib and blink1-tool" - @echo "make OS=wrt ... build OpenWrt blink1-lib and blink1-tool" - @echo "make OS=wrtcross... build for OpenWrt using cross-compiler" - @echo "make USBLIB_TYPE=HIDDATA OS=linux ... build using low-deps method" - @echo "make lib ... build blink1-lib shared library" - @echo "make blink1-tool... build blink1-tool program" - @echo "make blink1-tiny-server ... build tiny REST server" - @echo "make blink1control-tool ... build blink1control-tool (w/Blink1Control)" - @echo "make package ... zip up blink1-tool and blink1-lib " - @echo "make package-tiny-server ... package tiny REST server" - @echo "make package-all... package everything (and build everything first)" - @echo "make clean ... delete build products, leave binaries & libs" - @echo "make distclean ... delele binaries and libs too" - @echo - -msg: - @echo "Building blink1-tool for OS=$(OS) BLINK1_VERSION=$(BLINK1_VERSION) USBLIB_TYPE=$(USBLIB_TYPE)" - @echo "Type 'make help' for other build products" - - -$(OBJS): %.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -blink1-tool: $(OBJS) blink1-tool.o - $(CC) $(CFLAGS) -c blink1-tool.c -o blink1-tool.o - $(CC) $(CFLAGS) $(EXEFLAGS) -g $(OBJS) $(LIBS) blink1-tool.o -o blink1-tool$(EXE) $(LDFLAGS) - -blink1-tiny-server: $(OBJS) server/blink1-tiny-server.c -# $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c server/blink1-tiny-server.c -o blink1-tiny-server.o - $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c server/blink1-tiny-server.c -o blink1-tiny-server.o - $(CC) $(CFLAGS) -DMG_ENABLE_THREADS -I. -I./server/mongoose -c ./server/mongoose/mongoose.c -o ./server/mongoose/mongoose.o - $(CC) -g $(OBJS) $(EXEFLAGS) ./server/mongoose/mongoose.o $(LIBS) -lpthread blink1-tiny-server.o -o blink1-tiny-server$(EXE) $(LDFLAGS) - -$(LIBTARGET): $(OBJS) - $(CC) $(LIBFLAGS) $(CFLAGS) $(OBJS) $(LIBS) - $(LIB_EXTRA) - -lib: $(LIBTARGET) - -blink1control-tool: - make -C blink1control-tool - -package: lib blink1-tool - @echo "Packaging up blink1-tool and blink1-lib for '$(PKGOS)'" - zip blink1-tool-$(PKGOS).zip blink1-tool$(EXE) - zip blink1-lib-$(PKGOS).zip $(LIBTARGET) blink1-lib.h - -package-tiny-server: blink1-tiny-server - zip blink1-tiny-server-$(PKGOS).zip blink1-tiny-server$(EXE) - -package-blink1control-tool: blink1control-tool - zip -j blink1control-tool-$(PKGOS).zip blink1control-tool/blink1control-tool$(EXE) - -package-all: package package-tiny-server package-blink1control-tool - @mkdir -p builds - @mv blink1*$(PKGOS).zip builds - @echo "Look in 'builds' for zipfiles to publish" - -install-lib: - $(INSTALL) $(LIBTARGET) $(DESTDIR)$(LIBLOCATION)/$(LIBTARGET) - -install-dev: install-lib - $(INSTALL) blink1-lib.h $(DESTDIR)$(INCLOCATION)/blink1-lib.h - -install: all install-lib - $(INSTALL) blink1-tool$(EXE) $(DESTDIR)$(EXELOCATION)/blink1-tool$(EXE) - -uninstall-lib: - rm -f $(DESTDIR)$(LIBLOCATION)/$(LIBTARGET) - -uninstall-dev: uninstall-lib - rm -f $(DESTDIR)$(INCLOCATION)/blink2-lib.h - -uninstall: uninstall-lib - rm -f $(DESTDIR)$(EXELOCATION)/blink1-tool$(EXE) - -clean: - rm -f $(OBJS) - rm -f $(LIBTARGET) - rm -f blink1-tiny-server.o blink1-tool.o hiddata.o - rm -f server/mongoose/mongoose.o - rm -f blink1-tool$(EXE) blink1-tiny-server$(EXE) - make -C blink1control-tool clean - -distclean: clean - #rm -f blink1-tool$(EXE) - rm -f blink1-tiny-server$(EXE) - rm -f $(LIBTARGET) $(LIBTARGET).a - rm -f libblink1.so - rm -f blink1-tool - rm -f blink1-tool.exe - make -C blink1control-tool distclean - -# show shared library use -# in general we want minimal to no dependecies for blink1-tool - -# shows shared lib usage on Mac OS X -otool: - otool -L blink1-tool -# show shared lib usage on Linux -ldd: - ldd blink1-tool -# show shared lib usage on Windows -# FIXME: only works inside command prompt from -# Start->All Programs-> MS Visual Studio 2012 -> VS Tools -> Devel. Cmd Prompt -dumpbin: - dumpbin.exe /exports $(LIBTARGET) - dumpbin.exe /exports blink1-tool.exe - - -printvars: - @echo "OS=$(OS), CFLAGS=$(CFLAGS), LDFLAGS=$(LDFLAGS), LIBS=$(LIBS), LIBFLAGS=$(LIBFLAGS)" +USEGNU=gmake $* +all: + @$(USEGNU) +.DEFAULT: + @$(USEGNU) diff --git a/blink1-mini-tool/GNUmakefile b/blink1-mini-tool/GNUmakefile new file mode 100644 index 00000000..a584f67f --- /dev/null +++ b/blink1-mini-tool/GNUmakefile @@ -0,0 +1,162 @@ +# +# blink1-mini-tool -- minimal blink(1) controller +# for embedded Linuxes or other minimal systems +# +# Arduino Yun +# - Download Linino SDK from: http://download.linino.org/linino-utils/ +# - Unzip tarball +# - Set WRT_SDK_HOME environment variable to resulting directory +# - Do "cd ${WRT_SDK_HOME} && make" to setup SDK +# - Do "make OS=yun" to build +# +# OpenWrt / DD-WRT +# - Download & unzip the OpenWrt SDK for Linux +# - Set WRT_SDK_HOME environment variable to resulting directory +# - Do "cd ${WRT_SDK_HOME} && make" to setup SDK +# - Do "make OS=wrt" to build +# - note: "apt-get install lib32stdc++6 lib32z1" if using 32bit SDK on 64bit system +# - note: if your OpenWrt device is ar71xx-based, try 'make OS=yun' build instead +# +# BeagleBone / BeagleBoard (on Angstrom Linux) +# - Install USB dev support +# "opkg install libusb-0.1-4-dev" +# - May need to symlink libusb +# "cd /lib; ln -s libusb-0.1.so.4 libusb.so" +# +# Mac OS X +# - Install Xcode and command-line dev tools +# - Install MacPorts +# - sudo port install libusb-legacy +# +# Linux (Ubuntu) +# - apt-get install gcc-avr avr-libc avrdude java librxtx-java +# +# +# +# + +TARGET=blink1-mini-tool + +#CC=gcc + +# try to do some autodetecting +UNAME := $(shell uname -s) + +# assume linux +ifeq "$(OS)" "" + OS = linux +endif + +ifeq "$(UNAME)" "Darwin" + OS = macosx +endif + +#GIT_TAG="$(strip $(shell git tag | tail -1))" + + +################# Mac OSx ################################################### +ifeq "$(OS)" "macosx" +OPT_HOME := /opt/local/bin +USBFLAGS = `$(OPT_HOME)/libusb-config --cflags` +USBLIBS = `$(OPT_HOME)/libusb-config --libs` +#USBFLAGS = `$(OPT_HOME)/libusb-legacy-config --cflags` +# get just the path to the static lib +#USBLIBS = `$(OPT_HOME)/libusb-legacy-config --libs | cut -d' ' -f1 | cut -c3- `/libusb-legacy.a +# get everything else in --libs +#USBLIBS += `$(OPT_HOME)/libusb-legacy-config --libs | cut -d' ' -f 3- ` + +endif + +################# Linux ################################################### +ifeq "$(OS)" "linux" +USBFLAGS = `libusb-config --cflags` +USBLIBS = `libusb-config --libs` +endif + +################# Yun OpenWrt ######################################### +ifeq "$(OS)" "yun" + +WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.6-linaro_uClibc-0.9.33.2 +WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) +WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) +STAGING_DIR=$(WRT_SDK_HOME)/staging_dir + +CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-gcc +LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-ld +USBFLAGS= -I$(WRT_TARGET_ROOT)/usr/include +USBLIBS = -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 +export STAGING_DIR=$$(STAGING_DIR) + +endif + +################# OpenWrt / DD-WRT ######################################### +ifeq "$(OS)" "wrt" + +WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-brcm47xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2 +WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) +WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) +STAGING_DIR=$(WRT_SDK_HOME)/staging_dir +# STAGING_DIR used by mipsel-openwrt-linux-gcc + +CC = $(WRT_TOOLCHAIN_ROOT)/bin/mip*-openwrt-linux-gcc +LD = $(WRT_TOOLCHAIN_ROOT)/bin/mip*-openwrt-linux-ld +USBFLAGS= -I$(WRT_TARGET_ROOT)/usr/include +USBLIBS = -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 +export STAGING_DIR=$$(STAGING_DIR) + +#WRT_SDK_HOME := $(HOME)/OpenWrt-SDK-Linux-i686-1 +#CC = $(WRT_SDK_HOME)/staging_dir_mipsel/bin/mipsel-linux-gcc +#LD = $(WRT_SDK_HOME)/staging_dir_mipsel/bin/mipsel-linux-ld +#USBFLAGS = "-I$(WRT_SDK_HOME)/staging_dir_mipsel/usr/include" +#USBLIBS = "$(WRT_SDK_HOME)/staging_dir_mipsel/usr/lib/libusb.a" + +LDFLAGS += -static + +endif + + +##################### Common ############################################### + +CFLAGS= $(OS_CFLAGS) -O -Wall -std=gnu99 $(USBFLAGS) +LIBS= $(OS_LIBS) $(USBLIBS) $(LDFLAGS) + +OBJ= $(TARGET).o hiddata.o + +PROGRAM= $(TARGET)$(EXE_SUFFIX) + +all: msg $(PROGRAM) + +msg: + @echo "building for OS=$(OS)" + +# symbolic targets: +help: + @echo "This Makefile works on multiple archs. Use one of the following:" + @echo "make OS=linux ... build for Linux" + @echo "make OS=macosx ... build for Mac OS X " + @echo "make clean ..... to delete objects and hex file" + @echo + +test: + @echo "WRT_TOOLCHAIN_ROOT=$(WRT_TOOLCHAIN_ROOT)" + @echo "WRT_TARGET_ROOT=$(WRT_TARGET_ROOT)" + +$(PROGRAM): $(OBJ) + $(CC) -o $(PROGRAM) $(OBJ) $(LIBS) + + +strip: $(PROGRAM) + strip $(PROGRAM) + +clean: + rm -f $(OBJ) $(PROGRAM) + +.c.o: + $(CC) $(ARCH_COMPILE) $(CFLAGS) -c $*.c -o $*.o + +# shows shared lib usage on Mac OS X +otool: + otool -L $(TARGET) + +foo: + @echo "OS=$(OS), USBFLAGS=$(USBFLAGS)" diff --git a/blink1-mini-tool/Makefile b/blink1-mini-tool/Makefile index a584f67f..3d4c0f14 100644 --- a/blink1-mini-tool/Makefile +++ b/blink1-mini-tool/Makefile @@ -1,162 +1,5 @@ -# -# blink1-mini-tool -- minimal blink(1) controller -# for embedded Linuxes or other minimal systems -# -# Arduino Yun -# - Download Linino SDK from: http://download.linino.org/linino-utils/ -# - Unzip tarball -# - Set WRT_SDK_HOME environment variable to resulting directory -# - Do "cd ${WRT_SDK_HOME} && make" to setup SDK -# - Do "make OS=yun" to build -# -# OpenWrt / DD-WRT -# - Download & unzip the OpenWrt SDK for Linux -# - Set WRT_SDK_HOME environment variable to resulting directory -# - Do "cd ${WRT_SDK_HOME} && make" to setup SDK -# - Do "make OS=wrt" to build -# - note: "apt-get install lib32stdc++6 lib32z1" if using 32bit SDK on 64bit system -# - note: if your OpenWrt device is ar71xx-based, try 'make OS=yun' build instead -# -# BeagleBone / BeagleBoard (on Angstrom Linux) -# - Install USB dev support -# "opkg install libusb-0.1-4-dev" -# - May need to symlink libusb -# "cd /lib; ln -s libusb-0.1.so.4 libusb.so" -# -# Mac OS X -# - Install Xcode and command-line dev tools -# - Install MacPorts -# - sudo port install libusb-legacy -# -# Linux (Ubuntu) -# - apt-get install gcc-avr avr-libc avrdude java librxtx-java -# -# -# -# - -TARGET=blink1-mini-tool - -#CC=gcc - -# try to do some autodetecting -UNAME := $(shell uname -s) - -# assume linux -ifeq "$(OS)" "" - OS = linux -endif - -ifeq "$(UNAME)" "Darwin" - OS = macosx -endif - -#GIT_TAG="$(strip $(shell git tag | tail -1))" - - -################# Mac OSx ################################################### -ifeq "$(OS)" "macosx" -OPT_HOME := /opt/local/bin -USBFLAGS = `$(OPT_HOME)/libusb-config --cflags` -USBLIBS = `$(OPT_HOME)/libusb-config --libs` -#USBFLAGS = `$(OPT_HOME)/libusb-legacy-config --cflags` -# get just the path to the static lib -#USBLIBS = `$(OPT_HOME)/libusb-legacy-config --libs | cut -d' ' -f1 | cut -c3- `/libusb-legacy.a -# get everything else in --libs -#USBLIBS += `$(OPT_HOME)/libusb-legacy-config --libs | cut -d' ' -f 3- ` - -endif - -################# Linux ################################################### -ifeq "$(OS)" "linux" -USBFLAGS = `libusb-config --cflags` -USBLIBS = `libusb-config --libs` -endif - -################# Yun OpenWrt ######################################### -ifeq "$(OS)" "yun" - -WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.6-linaro_uClibc-0.9.33.2 -WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) -WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) -STAGING_DIR=$(WRT_SDK_HOME)/staging_dir - -CC = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-gcc -LD = $(WRT_TOOLCHAIN_ROOT)/bin/mips-openwrt-linux-ld -USBFLAGS= -I$(WRT_TARGET_ROOT)/usr/include -USBLIBS = -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 -export STAGING_DIR=$$(STAGING_DIR) - -endif - -################# OpenWrt / DD-WRT ######################################### -ifeq "$(OS)" "wrt" - -WRT_SDK_HOME := $(HOME)/openwrt/OpenWrt-SDK-brcm47xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2 -WRT_TOOLCHAIN_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/toolchain-* | tail -1)) -WRT_TARGET_ROOT=$(strip $(shell ls -d $(WRT_SDK_HOME)/staging_dir/target-* | tail -1)) -STAGING_DIR=$(WRT_SDK_HOME)/staging_dir -# STAGING_DIR used by mipsel-openwrt-linux-gcc - -CC = $(WRT_TOOLCHAIN_ROOT)/bin/mip*-openwrt-linux-gcc -LD = $(WRT_TOOLCHAIN_ROOT)/bin/mip*-openwrt-linux-ld -USBFLAGS= -I$(WRT_TARGET_ROOT)/usr/include -USBLIBS = -L$(WRT_TARGET_ROOT)/usr/lib -lusb -lusb-1.0 -export STAGING_DIR=$$(STAGING_DIR) - -#WRT_SDK_HOME := $(HOME)/OpenWrt-SDK-Linux-i686-1 -#CC = $(WRT_SDK_HOME)/staging_dir_mipsel/bin/mipsel-linux-gcc -#LD = $(WRT_SDK_HOME)/staging_dir_mipsel/bin/mipsel-linux-ld -#USBFLAGS = "-I$(WRT_SDK_HOME)/staging_dir_mipsel/usr/include" -#USBLIBS = "$(WRT_SDK_HOME)/staging_dir_mipsel/usr/lib/libusb.a" - -LDFLAGS += -static - -endif - - -##################### Common ############################################### - -CFLAGS= $(OS_CFLAGS) -O -Wall -std=gnu99 $(USBFLAGS) -LIBS= $(OS_LIBS) $(USBLIBS) $(LDFLAGS) - -OBJ= $(TARGET).o hiddata.o - -PROGRAM= $(TARGET)$(EXE_SUFFIX) - -all: msg $(PROGRAM) - -msg: - @echo "building for OS=$(OS)" - -# symbolic targets: -help: - @echo "This Makefile works on multiple archs. Use one of the following:" - @echo "make OS=linux ... build for Linux" - @echo "make OS=macosx ... build for Mac OS X " - @echo "make clean ..... to delete objects and hex file" - @echo - -test: - @echo "WRT_TOOLCHAIN_ROOT=$(WRT_TOOLCHAIN_ROOT)" - @echo "WRT_TARGET_ROOT=$(WRT_TARGET_ROOT)" - -$(PROGRAM): $(OBJ) - $(CC) -o $(PROGRAM) $(OBJ) $(LIBS) - - -strip: $(PROGRAM) - strip $(PROGRAM) - -clean: - rm -f $(OBJ) $(PROGRAM) - -.c.o: - $(CC) $(ARCH_COMPILE) $(CFLAGS) -c $*.c -o $*.o - -# shows shared lib usage on Mac OS X -otool: - otool -L $(TARGET) - -foo: - @echo "OS=$(OS), USBFLAGS=$(USBFLAGS)" +USEGNU=gmake $* +all: + @$(USEGNU) +.DEFAULT: + @$(USEGNU) diff --git a/blink1control-tool/GNUmakefile b/blink1control-tool/GNUmakefile new file mode 100644 index 00000000..9a650e9e --- /dev/null +++ b/blink1control-tool/GNUmakefile @@ -0,0 +1,169 @@ +# +# Makefile for blink1control-tool +# + +# On Mac: +# % wget http://curl.haxx.se/download/curl-7.37.1.tar.gz +# % tar xvzf curl-7.37.1.tar.gz +# % cd curl-7.37.1 +# % ./configure --prefix `pwd`/../curl-mac --disable-shared --disable-ldap --without-zlib --without-libssh2 --without-ssl --disable-crypto-auth +# % make && make install +# % cd .. +# % gcc -static -o curl-simple curl-simple.c `curl-mac/bin/curl-config --cflags` `curl-mac/bin/curl-config --static-libs` +# +# On Win: +# % wget http://curl.haxx.se/download/curl-7.37.1.tar.gz +# % tar xvzf curl-7.37.1.tar.gz +# % cd curl-7.37.1 +# # In the file libcurl.pc.in add -DCURL_STATICLIB to Cflags. +# % ./configure --prefix `pwd`/../curl-win --disable-shared --disable-ldap --without-zlib --without-libssh2 +# % make && make install +# % cd .. +# % gcc -static -o curl-simple curl-simple.c `curl-win2/bin/curl-config --cflags` `curl-win2/bin/curl-config --static-libs` + + + +# try to do some autodetecting +UNAME := $(shell uname -s) + +ifeq "$(UNAME)" "Darwin" + OS=macosx +endif + +ifeq "$(OS)" "Windows_NT" + OS=windows +endif + +ifeq "$(UNAME)" "Linux" + OS=linux +endif + +ifeq "$(UNAME)" "FreeBSD" + OS=freebsd +endif + +# allow overriding of GIT_TAG & BLINK1_VERSION on commandline for automated builds + +MACH_TYPE:="$(strip $(shell uname -m))" +GIT_TAG?="$(strip $(shell git tag 2>&1 | tail -1 | cut -f1 -d' '))" +# deal with case of no git or no git tags, check for presence of "v" (i.e. "v1.93") +ifneq ($(findstring v,$(GIT_TAG)), v) + GIT_TAG:="v0" +endif + +BLINK1_VERSION="$(GIT_TAG)-$(OS)-$(MACH_TYPE)" + +PKGOS = $(BLINK1_VERSION) + +# force this? +CC=gcc + +################# Mac OS X ################################################## +ifeq "$(OS)" "macosx" + +CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` + +EXE= + +endif + +################# Windows ################################################## +ifeq "$(OS)" "windows" + +CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` + +EXE=.exe + +endif + +################# Linux #################################################### +ifeq "$(OS)" "linux" + +CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` + + +EXE= + +#INSTALL = install -D +#EXELOCATION ?= /usr/local/bin +#LIBLOCATION ?= /usr/local/lib +#INCLOCATION ?= /usr/local/include + +endif + + +##################### Common ############################################### + +CFLAGS += -Wall +#CFLAGS += -Werror +CFLAGS += -std=gnu99 +#CFLAGS += -std=c99 +CFLAGS += -g + +CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\" + +CFLAGS += -lm +# to fix usleep() not being found on Ubuntu14 +CFLAGS += -D_BSD_SOURCE + +#CFLAGS += -I jsmn-example +#JSFILES=jsmn-example/jsmn.c jsmn-example/json.c jsmn-example/buf.c jsmn-example/log.c + +CFLAGS += -Wno-pointer-to-int-cast +CFLAGS += -I json-parser +JSFILES = json-parser/json.c + +#$(OBJS): %.o: %.c +# $(CC) $(CFLAGS) -c $< -o $@ + +#all: bjsmn blink1control-tool +all: msg depcheck blink1control-tool + +msg: +# @echo "Be sure to 'make curl-setup' and 'make json-parser-setup' if you have not already" + @echo "Building blink1control-tool for OS=$(OS) BLINK1_VERSION=$(BLINK1_VERSION)" + +curl-setup: + @echo "setting up curl..." + #wget http://curl.haxx.se/download/curl-7.37.1.tar.gz + tar xvzf curl-7.37.1.tar.gz + cd curl-7.37.1 && ./configure --prefix=`pwd`/../curl-$(OS) --disable-shared --disable-ldap --without-zlib --without-libssh2 --without-ssl --disable-crypto-auth && make && make install + +json-parser-setup: + @echo "setting up json-parser" + unzip json-parser.zip + +depcheck: + @echo "Checking if curl and json-parser are setup" + @if [ ! -d curl-7.37.1 ] ; then \ + $(MAKE) curl-setup; \ + else \ + echo " curl set up"; \ + fi + + @if [ ! -d json-parser ] ; then \ + $(MAKE) json-parser-setup; \ + else \ + echo " json-parser set up"; \ + fi + + +blink1control-tool: blink1control-tool.c + $(CC) -o blink1control-tool$(EXE) blink1control-tool.c $(JSFILES) $(CFLAGS) + +package: blink1control-tool + @echo "Packaging up blink1control-tool for '$(PKGOS)'" + zip blink1control-tool-$(PKGOS).zip blink1control-tool$(EXE) + @#mkdir -f ../builds && cp blink1control-tool-$(PKGOKS).zip ../builds + +clean: + rm -f $(OBJS) + rm -f *.o + rm -f blink1control-tool$(EXE) + +distclean: + $(MAKE) clean + rm -rf curl-7.37.1 + rm -rf json-parser + +FORCE: diff --git a/blink1control-tool/Makefile b/blink1control-tool/Makefile index a71a10b8..3d4c0f14 100644 --- a/blink1control-tool/Makefile +++ b/blink1control-tool/Makefile @@ -1,169 +1,5 @@ -# -# Makefile for blink1control-tool -# - -# On Mac: -# % wget http://curl.haxx.se/download/curl-7.37.1.tar.gz -# % tar xvzf curl-7.37.1.tar.gz -# % cd curl-7.37.1 -# % ./configure --prefix `pwd`/../curl-mac --disable-shared --disable-ldap --without-zlib --without-libssh2 --without-ssl --disable-crypto-auth -# % make && make install -# % cd .. -# % gcc -static -o curl-simple curl-simple.c `curl-mac/bin/curl-config --cflags` `curl-mac/bin/curl-config --static-libs` -# -# On Win: -# % wget http://curl.haxx.se/download/curl-7.37.1.tar.gz -# % tar xvzf curl-7.37.1.tar.gz -# % cd curl-7.37.1 -# # In the file libcurl.pc.in add -DCURL_STATICLIB to Cflags. -# % ./configure --prefix `pwd`/../curl-win --disable-shared --disable-ldap --without-zlib --without-libssh2 -# % make && make install -# % cd .. -# % gcc -static -o curl-simple curl-simple.c `curl-win2/bin/curl-config --cflags` `curl-win2/bin/curl-config --static-libs` - - - -# try to do some autodetecting -UNAME := $(shell uname -s) - -ifeq "$(UNAME)" "Darwin" - OS=macosx -endif - -ifeq "$(OS)" "Windows_NT" - OS=windows -endif - -ifeq "$(UNAME)" "Linux" - OS=linux -endif - -ifeq "$(UNAME)" "FreeBSD" - OS=freebsd -endif - -# allow overriding of GIT_TAG & BLINK1_VERSION on commandline for automated builds - -MACH_TYPE:="$(strip $(shell uname -m))" -GIT_TAG?="$(strip $(shell git tag 2>&1 | tail -1 | cut -f1 -d' '))" -# deal with case of no git or no git tags, check for presence of "v" (i.e. "v1.93") -ifneq ($(findstring v,$(GIT_TAG)), v) - GIT_TAG:="v0" -endif - -BLINK1_VERSION="$(GIT_TAG)-$(OS)-$(MACH_TYPE)" - -PKGOS = $(BLINK1_VERSION) - -# force this? -CC=gcc - -################# Mac OS X ################################################## -ifeq "$(OS)" "macosx" - -CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` - -EXE= - -endif - -################# Windows ################################################## -ifeq "$(OS)" "windows" - -CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` - -EXE=.exe - -endif - -################# Linux #################################################### -ifeq "$(OS)" "linux" - -CFLAGS += `curl-$(OS)/bin/curl-config --static-libs` `curl-$(OS)/bin/curl-config --cflags` - - -EXE= - -#INSTALL = install -D -#EXELOCATION ?= /usr/local/bin -#LIBLOCATION ?= /usr/local/lib -#INCLOCATION ?= /usr/local/include - -endif - - -##################### Common ############################################### - -CFLAGS += -Wall -#CFLAGS += -Werror -CFLAGS += -std=gnu99 -#CFLAGS += -std=c99 -CFLAGS += -g - -CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\" - -CFLAGS += -lm -# to fix usleep() not being found on Ubuntu14 -CFLAGS += -D_BSD_SOURCE - -#CFLAGS += -I jsmn-example -#JSFILES=jsmn-example/jsmn.c jsmn-example/json.c jsmn-example/buf.c jsmn-example/log.c - -CFLAGS += -Wno-pointer-to-int-cast -CFLAGS += -I json-parser -JSFILES = json-parser/json.c - -#$(OBJS): %.o: %.c -# $(CC) $(CFLAGS) -c $< -o $@ - -#all: bjsmn blink1control-tool -all: msg depcheck blink1control-tool - -msg: -# @echo "Be sure to 'make curl-setup' and 'make json-parser-setup' if you have not already" - @echo "Building blink1control-tool for OS=$(OS) BLINK1_VERSION=$(BLINK1_VERSION)" - -curl-setup: - @echo "setting up curl..." - #wget http://curl.haxx.se/download/curl-7.37.1.tar.gz - tar xvzf curl-7.37.1.tar.gz - cd curl-7.37.1 && ./configure --prefix=`pwd`/../curl-$(OS) --disable-shared --disable-ldap --without-zlib --without-libssh2 --without-ssl --disable-crypto-auth && make && make install - -json-parser-setup: - @echo "setting up json-parser" - unzip json-parser.zip - -depcheck: - @echo "Checking if curl and json-parser are setup" - @if [ ! -d curl-7.37.1 ] ; then \ - make curl-setup; \ - else \ - echo " curl set up"; \ - fi - - @if [ ! -d json-parser ] ; then \ - make json-parser-setup; \ - else \ - echo " json-parser set up"; \ - fi - - -blink1control-tool: blink1control-tool.c - $(CC) -o blink1control-tool$(EXE) blink1control-tool.c $(JSFILES) $(CFLAGS) - -package: blink1control-tool - @echo "Packaging up blink1control-tool for '$(PKGOS)'" - zip blink1control-tool-$(PKGOS).zip blink1control-tool$(EXE) - @#mkdir -f ../builds && cp blink1control-tool-$(PKGOKS).zip ../builds - -clean: - rm -f $(OBJS) - rm -f *.o - rm -f blink1control-tool$(EXE) - -distclean: - make clean - rm -rf curl-7.37.1 - rm -rf json-parser - -FORCE: +USEGNU=gmake $* +all: + @$(USEGNU) +.DEFAULT: + @$(USEGNU) diff --git a/blink1raw/GNUmakefile b/blink1raw/GNUmakefile new file mode 100644 index 00000000..e3fddc56 --- /dev/null +++ b/blink1raw/GNUmakefile @@ -0,0 +1,8 @@ + + +CC=gcc + +blink1raw: + $(CC) -o blink1raw blink1raw.c + +all: blink1raw diff --git a/blink1raw/Makefile b/blink1raw/Makefile index e3fddc56..3d4c0f14 100644 --- a/blink1raw/Makefile +++ b/blink1raw/Makefile @@ -1,8 +1,5 @@ - - -CC=gcc - -blink1raw: - $(CC) -o blink1raw blink1raw.c - -all: blink1raw +USEGNU=gmake $* +all: + @$(USEGNU) +.DEFAULT: + @$(USEGNU) diff --git a/hidapi/libusb/hid.c b/hidapi/libusb/hid.c index 6c1d2471..26fd7701 100644 --- a/hidapi/libusb/hid.c +++ b/hidapi/libusb/hid.c @@ -250,27 +250,6 @@ static int get_usage(uint8_t *report_descriptor, size_t size, } #endif /* INVASIVE_GET_USAGE */ -#ifdef __FreeBSD__ -/* The FreeBSD version of libusb doesn't have this funciton. In mainline - libusb, it's inlined in libusb.h. This function will bear a striking - resemblence to that one, because there's about one way to code it. - - Note that the data parameter is Unicode in UTF-16LE encoding. - Return value is the number of bytes in data, or LIBUSB_ERROR_*. - */ -static inline int libusb_get_string_descriptor(libusb_device_handle *dev, - uint8_t descriptor_index, uint16_t lang_id, - unsigned char *data, int length) -{ - return libusb_control_transfer(dev, - LIBUSB_ENDPOINT_IN | 0x0, /* Endpoint 0 IN */ - LIBUSB_REQUEST_GET_DESCRIPTOR, - (LIBUSB_DT_STRING << 8) | descriptor_index, - lang_id, data, (uint16_t) length, 1000); -} - -#endif - /* Get the first language the device says it reports. This comes from USB string #0. */ @@ -333,11 +312,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx) size_t inbytes; size_t outbytes; size_t res; -#ifdef __FreeBSD__ - const char *inptr; -#else char *inptr; -#endif char *outptr; /* Determine which language to use. */ diff --git a/hidapi/testgui/copy_to_bundle.sh b/hidapi/testgui/copy_to_bundle.sh index f0fc767a..3d3a4e29 100755 --- a/hidapi/testgui/copy_to_bundle.sh +++ b/hidapi/testgui/copy_to_bundle.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash #### Configuration: # The name of the executable. It is assumed diff --git a/hidapi/testgui/start.sh b/hidapi/testgui/start.sh index 980635d9..3247f164 100755 --- a/hidapi/testgui/start.sh +++ b/hidapi/testgui/start.sh @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash xterm -e /Users/alan/work/hidapi/testgui/TestGUI.app/Contents/MacOS/tg diff --git a/scripts/blink1-moodlight.sh b/scripts/blink1-moodlight.sh index 1edf969a..22b17e76 100755 --- a/scripts/blink1-moodlight.sh +++ b/scripts/blink1-moodlight.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Fade to random colors # diff --git a/scripts/blink1-rainbow.sh b/scripts/blink1-rainbow.sh index d69b62db..33699b09 100755 --- a/scripts/blink1-rainbow.sh +++ b/scripts/blink1-rainbow.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # play an infinite shifing rainbow #