Skip to content

Commit

Permalink
makefile: 'configure' target added
Browse files Browse the repository at this point in the history
makefile: upload actions announce error when remote machine not set
makefile: report destination directories when installing/uploading
synchronizing makefiles for linux examples
RF24_config.h - changed detection of makefile build
minor configure/makefile improvements
  • Loading branch information
martin-mat committed Mar 26, 2016
1 parent 87b5545 commit 46824af
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 168 deletions.
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
# use make all and make install to install the library
#

ifeq ($(wildcard Makefile.inc), )
$(error Configuration not found. Run ./configure first)
endif
CONFIG_FILE=Makefile.inc
REMOTE_ERROR="[ERROR] Remote machine not configured. Run configure with respective arguments."

include Makefile.inc
include $(CONFIG_FILE)

# Objects to compile
OBJECTS=RF24.o
Expand Down Expand Up @@ -55,37 +54,54 @@ gpio.o: $(DRIVER_DIR)/gpio.cpp
interrupt.o: $(DRIVER_DIR)/interrupt.c
${CXX} -Wall -fPIC ${CFLAGS} -c $(DRIVER_DIR)/interrupt.c

# clear configuration files
cleanconfig:
@echo "[Cleaning configuration]"
rm -rf ${CONFIG_FILE} utility/includes.h

# clear build files
clean:
@echo "[Cleaning]"
rm -rf *.o ${LIBNAME}.*

$(CONFIG_FILE):
@echo "[Running configure]"
@./configure

install: all install-libs install-headers
upload: all upload-libs upload-headers

# Install the library to LIBPATH
install-libs:
@echo "[Installing Libs]"
@if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
@echo "[Installing Libs to ${LIB_DIR}]"
@if ( test ! -d ${LIB_DIR} ) ; then mkdir -p $(LIB_DIR) ; fi
@install -m 0755 ${LIBNAME} ${LIB_DIR}
@ln -sf ${LIB_DIR}/${LIBNAME} ${LIB_DIR}/${LIBNAME}.1
@${LDCONFIG}

upload-libs:
@echo "[Uploading Libs to ${REMOTE}]"
@echo "[Uploading Libs to ${REMOTE}:${REMOTE_LIB_DIR}]"
ifeq ($(REMOTE),)
@echo "${REMOTE_ERROR}"
@exit 1
endif
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p ${REMOTE_LIB_DIR}"
@scp -q -P ${REMOTE_PORT} ${LIBNAME} ${REMOTE}:/tmp
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0755 /tmp/${LIBNAME} ${REMOTE_LIB_DIR} && rm /tmp/${LIBNAME} && sudo ln -sf ${REMOTE_LIB_DIR}/${LIBNAME} ${REMOTE_LIB_DIR}/${LIBNAME}.1 && sudo ldconfig"

install-headers:
@echo "[Installing Headers]"
@echo "[Installing Headers to ${HEADER_DIR}]"
@mkdir -p ${HEADER_DIR}/${DRIVER_DIR}
@install -m 0644 *.h ${HEADER_DIR}
@install -m 0644 ${DRIVER_DIR}/*.h ${HEADER_DIR}/${DRIVER_DIR}
@install -m 0644 ${ARCH_DIR}/*.h ${HEADER_DIR}/${ARCH_DIR}

upload-headers:
@echo "[Uploading Headers to ${REMOTE}]"
@echo "[Uploading Headers to ${REMOTE}:${REMOTE_HEADER_DIR}]"
ifeq ($(REMOTE),)
@echo "${REMOTE_ERROR}"
@exit 1
endif
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo mkdir -p ${REMOTE_HEADER_DIR}/${DRIVER_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p /tmp/RF24 && rm -rf /tmp/RF24/*"
@rsync -a --include="*.h" --include="*/" --exclude="*" -e "ssh -p ${REMOTE_PORT}" . ${REMOTE}:/tmp/RF24
Expand Down
68 changes: 0 additions & 68 deletions Makefile.littlewire

This file was deleted.

10 changes: 4 additions & 6 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
#define RF24_SPI_TRANSACTIONS
#endif

//Generic Linux/ARM and //http://iotdk.intel.com/docs/master/mraa/
//#if ( defined (__linux) || defined (LINUX) ) && defined( __arm__ ) || defined(MRAA) // BeagleBone Black running GNU/Linux or any other ARM-based linux device
#if ( defined (__linux) || defined (LINUX) ) || defined(LITTLEWIRE) || defined(MRAA) // BeagleBone Black running GNU/Linux or any other ARM-based linux device
#if ( !defined (ARDUINO) ) // Any non-arduino device is handled via configure/Makefile

// The Makefile checks for bcm2835 (RPi) and copies the correct includes.h file to /utility/includes.h (Default is spidev config)
// This behavior can be overridden by calling 'make RF24_SPIDEV=1' or 'make RF24_MRAA=1'
// The includes.h file defines either RF24_RPi, MRAA or RF24_BBB and includes the correct RF24_arch_config.h file
// The configure script detects device and copies the correct includes.h file to /utility/includes.h
// This behavior can be overridden by calling configure with respective parameters
// The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
#include "utility/includes.h"

//ATTiny
Expand Down
10 changes: 5 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ if [ "${REMOTE}" ]; then
if [[ "$(execute_check 'echo ok 2>/dev/null' 2>/dev/null)" ]]; then
echo " [OK] Remote machine ssh passwordless login configured fine."
else
die "Remote machine ssh and/or passwordless login check failed." 1
die "Remote machine ssh and/or passwordless login check failed." 4
fi
if [[ $(execute_check "sudo echo ok 2>/dev/null") ]]; then
echo " [OK] Remote machine sudo configured fine."
else
die "Remote machine sudo test failed." 1
die "Remote machine sudo test failed." 5
fi
fi

Expand Down Expand Up @@ -340,7 +340,7 @@ if [ -z "${DRIVER}" ]; then
echo "[SECTION] Detecting DRIVER"
DRIVER=$(detect_driver)
if [ -z "${DRIVER}" ]; then
die "No supported driver detected. Run configure with --driver=<driver> to set a driver explicitly."
die "No supported driver detected. Run configure with --driver=<driver> to set a driver explicitly." 1
fi
echo " [OK] DRIVER detected:${DRIVER}."
fi
Expand All @@ -358,7 +358,7 @@ LittleWire)
SHARED_LINKER_FLAGS+=" -llittlewire-spi"
;;
*)
die "Unsupported DRIVER: ${DRIVER}." 1
die "Unsupported DRIVER: ${DRIVER}." 2
;;
esac

Expand All @@ -381,7 +381,7 @@ DARWIN)
SHARED_LINKER_FLAGS+=" -dynamiclib -install_name ${LIB_DIR}/lib${LIB}.${DYN_SUFFIX}"
;;
*)
die "Unsupported OS: ${OS}." 1
die "Unsupported OS: ${OS}." 3
;;
esac

Expand Down
27 changes: 1 addition & 26 deletions examples_linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,5 @@ include ../Makefile.inc

# define all programs
PROGRAMS = gettingstarted gettingstarted_call_response transfer pingpair_dyn
SOURCES = ${PROGRAMS:=.cpp}

all: ${PROGRAMS}

${PROGRAMS}: ${SOURCES}
${CXX} ${CFLAGS} -I${HEADER_DIR}/.. -I.. -L${LIB_DIR} -lrf24 $@.cpp -o $@

clean:
rm -rf $(PROGRAMS)

install: all
mkdir -p $(EXAMPLES_DIR)
for prog in $(PROGRAMS); do \
install -m 0755 $$prog $(EXAMPLES_DIR); \
done

upload: all
@echo "[Uploading examples to ${REMOTE}:${REMOTE_EXAMPLES_DIR}]"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p ${REMOTE_EXAMPLES_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p /tmp/RF24_examples"
@scp -q -P ${REMOTE_PORT} ${PROGRAMS} ${REMOTE}:/tmp/RF24_examples
for prog in $(PROGRAMS); do \
ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0755 /tmp/RF24_examples/$${prog} ${REMOTE_EXAMPLES_DIR}"; \
done
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "rm -rf /tmp/RF24_examples"

.PHONY: install upload
include Makefile.examples
46 changes: 46 additions & 0 deletions examples_linux/Makefile.examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#############################################################################
#
# Makefile for librf24 examples on Linux
#
# License: GPL (General Public License)
# Author: gnulnulf <arco@appeltaart.mine.nu>
# Date: 2013/02/07 (version 1.0)
#
# Description:
# ------------
# use make all and make install to install the examples
#

SOURCES = ${PROGRAMS:=.cpp}

all: ${PROGRAMS}

${PROGRAMS}: ${SOURCES}
${CXX} ${CFLAGS} -I${HEADER_DIR}/.. -I.. -L${LIB_DIR} -l${LIB} $@.cpp -o $@

clean:
@echo "[Cleaning]"
rm -rf $(PROGRAMS)

install: all
@echo "[Installing examples to $(EXAMPLES_DIR)]"
@mkdir -p $(EXAMPLES_DIR)
@for prog in $(PROGRAMS); do \
install -m 0755 $$prog $(EXAMPLES_DIR); \
done

upload: all
@echo "[Uploading examples to ${REMOTE}:${REMOTE_EXAMPLES_DIR}]"
ifeq ($(REMOTE),)
@echo "[ERROR] Remote machine not configured. Run configure with respective arguments."
@exit 1
endif
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p ${REMOTE_EXAMPLES_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "mkdir -p /tmp/RF24_examples"
@scp -q -P ${REMOTE_PORT} ${PROGRAMS} ${REMOTE}:/tmp/RF24_examples
@for prog in $(PROGRAMS); do \
ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0755 /tmp/RF24_examples/$${prog} ${REMOTE_EXAMPLES_DIR}"; \
done
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "rm -rf /tmp/RF24_examples"

.PHONY: install upload
29 changes: 4 additions & 25 deletions examples_linux/extra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,14 @@
# use make all and make install to install the examples
# You can change the install directory by editing the prefix line
#
prefix := /usr/local

ARCH=armv6zk
ifeq "$(shell uname -m)" "armv7l"
ARCH=armv7-a
ifeq ($(wildcard ../../Makefile.inc), )
$(error Configuration not found. Run ./configure first)
endif

# The recommended compiler flags for the Raspberry Pi
CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=$(ARCH) -mtune=arm1176jzf-s
#CCFLAGS=
include ../../Makefile.inc

# define all programs
PROGRAMS = rpi-hub scanner

SOURCES = ${PROGRAMS:=.cpp}

all: ${PROGRAMS}

${PROGRAMS}: ${SOURCES}
g++ ${CCFLAGS} -Wall -I../ -lrf24-bcm $@.cpp -o $@

clean:
rm -rf $(PROGRAMS)

install: all
test -d $(prefix) || mkdir $(prefix)
test -d $(prefix)/bin || mkdir $(prefix)/bin
for prog in $(PROGRAMS); do \
install -m 0755 $$prog $(prefix)/bin; \
done

.PHONY: install
include ../Makefile.examples
33 changes: 4 additions & 29 deletions examples_linux/interrupts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,14 @@
# use make all and make install to install the examples
# You can change the install directory by editing the prefix line
#
prefix := /usr/local

ARCH=armv6zk
ifeq "$(shell uname -m)" "armv7l"
ARCH=armv7-a
ifeq ($(wildcard ../../Makefile.inc), )
$(error Configuration not found. Run ./configure first)
endif

# Detect the Raspberry Pi by the existence of the bcm_host.h file
BCMLOC=/opt/vc/include/bcm_host.h

ifneq ("$(wildcard $(BCMLOC))","")
# The recommended compiler flags for the Raspberry Pi
CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=$(ARCH) -mtune=arm1176jzf-s
endif
include ../../Makefile.inc

# define all programs
#PROGRAMS = scanner pingtest gettingstarted
PROGRAMS = gettingstarted_call_response_int gettingstarted_call_response_int2 transfer_interrupt pingpair_dyn_int
SOURCES = ${PROGRAMS:=.cpp}

all: ${PROGRAMS}

${PROGRAMS}: ${SOURCES}
g++ ${CCFLAGS} -Wall -I../ -lrf24-bcm $@.cpp -o $@

clean:
rm -rf $(PROGRAMS)

install: all
test -d $(prefix) || mkdir $(prefix)
test -d $(prefix)/bin || mkdir $(prefix)/bin
for prog in $(PROGRAMS); do \
install -m 0755 $$prog $(prefix)/bin; \
done

.PHONY: install
include ../Makefile.examples

1 comment on commit 46824af

@martin-mat
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.