Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on FreeBSD #14

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
599 changes: 599 additions & 0 deletions GNUmakefile

Large diffs are not rendered by default.

601 changes: 5 additions & 596 deletions Makefile

Large diffs are not rendered by default.

162 changes: 162 additions & 0 deletions blink1-mini-tool/GNUmakefile
Original file line number Diff line number Diff line change
@@ -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)"
167 changes: 5 additions & 162 deletions blink1-mini-tool/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Loading