Commit ef1914b4 authored by mz-fuzzy's avatar mz-fuzzy

Linux library name backward compatibilty using simlink

Linux library name and symlinks adaptations
Linux library version taken from library.properties (including python lib installation)
ldconfig bugfixing
Linux makefile cleanup
Minor configure/makefile fixes
parent 46824af3
......@@ -33,36 +33,36 @@ all: $(LIBNAME)
# Make the library
$(LIBNAME): $(OBJECTS)
@echo "[Linking]"
${CC} ${SHARED_LINKER_FLAGS} ${CFLAGS} -o ${LIBNAME} $^
$(CC) $(SHARED_LINKER_FLAGS) $(CFLAGS) -o $(LIBNAME) $^
# Library parts
RF24.o: RF24.cpp
${CXX} -Wall -fPIC ${CFLAGS} -c $^
$(CXX) -Wall -fPIC $(CFLAGS) -c $^
bcm2835.o: $(DRIVER_DIR)/bcm2835.c
${CC} -Wall -fPIC ${CFLAGS} -c $^
$(CC) -Wall -fPIC $(CFLAGS) -c $^
spi.o: $(DRIVER_DIR)/spi.cpp
${CXX} -Wall -fPIC ${CFLAGS} -c $^
$(CXX) -Wall -fPIC $(CFLAGS) -c $^
compatibility.o: $(DRIVER_DIR)/compatibility.c
${CC} -Wall -fPIC ${CFLAGS} -c $(DRIVER_DIR)/compatibility.c
$(CC) -Wall -fPIC $(CFLAGS) -c $(DRIVER_DIR)/compatibility.c
gpio.o: $(DRIVER_DIR)/gpio.cpp
${CXX} -Wall -fPIC ${CFLAGS} -c $(DRIVER_DIR)/gpio.cpp
$(CXX) -Wall -fPIC $(CFLAGS) -c $(DRIVER_DIR)/gpio.cpp
interrupt.o: $(DRIVER_DIR)/interrupt.c
${CXX} -Wall -fPIC ${CFLAGS} -c $(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
rm -rf $(CONFIG_FILE) utility/includes.h
# clear build files
clean:
@echo "[Cleaning]"
rm -rf *.o ${LIBNAME}.*
rm -rf *.o $(LIBNAME).*
$(CONFIG_FILE):
@echo "[Running configure]"
......@@ -73,39 +73,52 @@ upload: all upload-libs upload-headers
# Install the library to LIBPATH
install-libs:
@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}
@echo "[Installing Libs to $(LIB_DIR)]"
@if ( test ! -d $(LIB_DIR) ); then mkdir -p $(LIB_DIR); fi
@install -m 0755 $(LIBNAME) $(LIB_DIR)
@orig=$(LIBNAME) && \
for sl in $(LIBSYMLINKS); do \
ln -sf $(LIB_DIR)/$${orig} $(LIB_DIR)/$${sl}; \
orig=$${sl}; \
done && \
if [ "$(LIBDEPRECATE)" ]; then ln -sf $(LIB_DIR)/$${orig} $(LIB_DIR)/$(LIBDEPRECATE); fi
ifneq ($(LDCONFIG),)
@$(LDCONFIG)
endif
upload-libs:
@echo "[Uploading Libs to ${REMOTE}:${REMOTE_LIB_DIR}]"
@echo "[Uploading Libs to $(REMOTE):$(REMOTE_LIB_DIR)]"
ifeq ($(REMOTE),)
@echo "${REMOTE_ERROR}"
@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"
@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) &&" \
" orig=$(LIBNAME) && for sl in $(LIBSYMLINKS); do sudo ln -sf $(REMOTE_LIB_DIR)/\$${orig} $(REMOTE_LIB_DIR)/\$${sl}; orig=\$${sl}; done &&" \
" if [ "$(LIBDEPRECATE)" ]; then ln -sf $(REMOTE_LIB_DIR)/\$${orig} $(REMOTE_LIB_DIR)/$(LIBDEPRECATE); fi &&" \
" rm /tmp/$(LIBNAME)"
ifneq ($(REMOTE_LDCONFIG),)
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo $(REMOTE_LDCONFIG)"
endif
install-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}
@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}:${REMOTE_HEADER_DIR}]"
@echo "[Uploading Headers to $(REMOTE):$(REMOTE_HEADER_DIR)]"
ifeq ($(REMOTE),)
@echo "${REMOTE_ERROR}"
@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
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0644 /tmp/RF24/*.h ${REMOTE_HEADER_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0644 /tmp/RF24/${DRIVER_DIR}/*.h ${REMOTE_HEADER_DIR}/${DRIVER_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "sudo install -m 0644 /tmp/RF24/${ARCH_DIR}/*.h ${REMOTE_HEADER_DIR}/${ARCH_DIR}"
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "rm -rf /tmp/RF24"
@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
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/*.h $(REMOTE_HEADER_DIR)"
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/$(DRIVER_DIR)/*.h $(REMOTE_HEADER_DIR)/$(DRIVER_DIR)"
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/$(ARCH_DIR)/*.h $(REMOTE_HEADER_DIR)/$(ARCH_DIR)"
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "rm -rf /tmp/RF24"
......@@ -40,7 +40,7 @@ Cross-compilation options:
--remote=<USER@HOST> Remote ssh host identification for installation [REMOTE_USER@REMOTE_HOST]
--remote-prefix=<RPREFIX> Remote host installation prefix path. [/usr/local]
--remote-lib-dir=<DIR> Remote library target installation directory [RPREFIX/lib]
--remote-header-dir=<DIR> Remote header files target installation directory. [RPREFIX/include]
--remote-header-dir=<DIR> Remote header files target installation directory. [RPREFIX/include]
--remote-ldconfig=<RLDCON> Remote ldconfig binary filename. Can be set to '' to skip ldconfig call. [ldconfig]
--remote-examples-dir=<DIR> Example files remote installation directory. Default: [REMOTE_PREFIX/bin]
......@@ -162,7 +162,23 @@ function detect_driver {
echo $result
}
params="OS SOC DRIVER CPUFLAGS CFLAGS PREFIX REMOTE_PREFIX LIB LIBNAME CC CXX LIB_DIR REMOTE_LIB_DIR HEADER_DIR REMOTE_HEADER_DIR DRIVER_DIR ARCH_DIR REMOTE REMOTE_HOST REMOTE_USER REMOTE_PORT SHARED_LINKER_FLAGS LDCONFIG REMOTE_LDCONFIG EXAMPLES_DIR REMOTE_EXAMPLES_DIR"
function gen_symlink_names {
base_name="$1"
version="$2"
IFS='.' read -r -a ver <<< "$version"
versions=""
for index in "${!ver[@]}" ; do
verstr=""
for ind in `seq 0 $(expr $index - 1)` ; do
verstr="${verstr}.${ver[$ind]}"
done
versions="${base_name}${verstr} $versions"
done
echo ${versions}
}
params="OS SOC DRIVER CPUFLAGS CFLAGS PREFIX REMOTE_PREFIX LIB LIBNAME LIB_VERSION LIBSYMLINKS LIBDEPRECATE CC CXX LIB_DIR REMOTE_LIB_DIR HEADER_DIR REMOTE_HEADER_DIR DRIVER_DIR ARCH_DIR REMOTE REMOTE_HOST REMOTE_USER REMOTE_PORT SHARED_LINKER_FLAGS LDCONFIG REMOTE_LDCONFIG EXAMPLES_DIR REMOTE_EXAMPLES_DIR"
for opt do
if [ "$opt" = "-h" ] || [ "$opt" = "--help" ]; then
......@@ -312,9 +328,12 @@ HEADER_DIR=${HEADER_DIR:-${PREFIX}/include/RF24}
REMOTE_HEADER_DIR=${REMOTE_HEADER_DIR:-${REMOTE_PREFIX}/include/RF24}
EXAMPLES_DIR=${EXAMPLES_DIR:-${PREFIX}/bin}
REMOTE_EXAMPLES_DIR=${REMOTE_EXAMPLES_DIR:-${REMOTE_PREFIX}/bin}
LDCONFIG=${LDCONFIG:-ldconfig}
REMOTE_LDCONFIG=${REMOTE_LDCONFIG:-/sbin/ldconfig}
LDCONFIG=${LDCONFIG-ldconfig}
REMOTE_LDCONFIG=${REMOTE_LDCONFIG-/sbin/ldconfig}
LIB=${LIB:-rf24}
LIB_VERSION=${LIB_VERSION:-$(awk -F "=" '/version/ {print $2}' library.properties)}
LIB_DEPRECATE_NAME=${LIB_DEPRECATE_NAME:-"rf24-bcm"}
LIB_DEPRECATE_VERSION=${LIB_DEPRECATE_VERSION:-""}
CC=${CC:-gcc}
CXX=${CXX:-g++}
ARCH_DIR=${ARCH_DIR:-utility}
......@@ -386,7 +405,14 @@ DARWIN)
esac
LIBNAME=${LIBNAME:-lib${LIB}.${DYN_SUFFIX}}
LIBNAME=${LIBNAME:-lib${LIB}.${DYN_SUFFIX}.${LIB_VERSION}}
LIBSYMLINKS="${LIBSYMLINKS:-$(gen_symlink_names lib${LIB}.${DYN_SUFFIX} ${LIB_VERSION})}"
if [ "${LIB_DEPRECATE_NAME}" ]; then
LIBDEPRECATE="${LIBDEPRECATE:-lib${LIB_DEPRECATE_NAME}.${DYN_SUFFIX}}"
if [ "${LIB_DEPRECATE_VERSION}" ]; then
LIBDEPRECATE="${LIBDEPRECATE}.${LIB_DEPRECATE_VERSION}"
fi
fi
DRIVER_DIR=${DRIVER_DIR:-${ARCH_DIR}/${DRIVER}}
CFLAGS="$CPUFLAGS -O2 -Wall -g $CFLAGS"
......@@ -397,7 +423,7 @@ echo "[SECTION] Saving configuration."
echo -n "" > Makefile.inc
for param in ${params}; do
if [[ ${!param} ]]; then
echo ${param}=${!param} >> Makefile.inc
echo "${param}=${!param}" >> Makefile.inc
fi
done
......
......@@ -11,12 +11,13 @@
# use make all and make install to install the examples
#
SOURCES = ${PROGRAMS:=.cpp}
BINARY_PREFIX = rf24
SOURCES = $(PROGRAMS:=.cpp)
all: ${PROGRAMS}
all: $(PROGRAMS)
${PROGRAMS}: ${SOURCES}
${CXX} ${CFLAGS} -I${HEADER_DIR}/.. -I.. -L${LIB_DIR} -l${LIB} $@.cpp -o $@
$(PROGRAMS): $(SOURCES)
$(CXX) $(CFLAGS) -I$(HEADER_DIR)/.. -I.. -L$(LIB_DIR) -l$(LIB) $@.cpp -o $@
clean:
@echo "[Cleaning]"
......@@ -26,21 +27,21 @@ install: all
@echo "[Installing examples to $(EXAMPLES_DIR)]"
@mkdir -p $(EXAMPLES_DIR)
@for prog in $(PROGRAMS); do \
install -m 0755 $$prog $(EXAMPLES_DIR); \
install -m 0755 $${prog} $(EXAMPLES_DIR)/$(BINARY_PREFIX)-$${prog}; \
done
upload: all
@echo "[Uploading examples to ${REMOTE}:${REMOTE_EXAMPLES_DIR}]"
@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
@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}"; \
ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0755 /tmp/RF24_examples/$${prog} $(REMOTE_EXAMPLES_DIR)/$(BINARY_PREFIX)-$${prog}"; \
done
@ssh -q -t -p ${REMOTE_PORT} ${REMOTE} "rm -rf /tmp/RF24_examples"
@ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "rm -rf /tmp/RF24_examples"
.PHONY: install upload
......@@ -2,16 +2,19 @@
import os
import sys
# import distutils.core
import setuptools
import crossunixccompiler
version = ''
def process_configparams():
global version
with open('../Makefile.inc') as f:
config_lines = f.readlines()
config_lines = f.read().splitlines()
cflags=os.getenv("CFLAGS", "")
cflags = os.getenv("CFLAGS", "")
for line in config_lines:
identifier, value = line.split('=', 1)
if identifier == "CPUFLAGS":
......@@ -20,6 +23,8 @@ def process_configparams():
cflags += " -I" + os.path.dirname(value)
elif identifier == "LIB_DIR":
cflags += " -L" + value
elif identifier == "LIB_VERSION":
version = value
elif identifier in ("CC", "CXX"):
os.environ[identifier] = value
......@@ -34,14 +39,10 @@ else:
process_configparams()
crossunixccompiler.register()
# module_RF24 = distutils.core.Extension('RF24',
module_RF24 = setuptools.Extension('RF24',
libraries=['rf24', BOOST_LIB],
sources=['pyRF24.cpp']
)
libraries=['rf24', BOOST_LIB],
sources=['pyRF24.cpp'])
# distutils.core.setup(name='RF24',
setuptools.setup(name='RF24',
version='1.1',
ext_modules=[module_RF24]
)
version=version,
ext_modules=[module_RF24])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment