Commit c96d32c3 authored by Dimitris Lampridis's avatar Dimitris Lampridis

Merge branch '5-standardise-software-installation' into 'master'

Resolve "Standardise software installation"

Closes #5

See merge request be-cem-edl/fec/hardware-modules/rf-att-4cha!6
parents e4c55497 9e1a84c4
......@@ -20,19 +20,20 @@ cppcheck:
script:
- make -C software/lib cppcheck
build_software:
software_build:
extends: .build_fec_os_sw
variables:
EDL_CI_SW_PATHS: $CI_PROJECT_DIR/software
doxygen_build:
stage: build
image: gitlab-registry.cern.ch/be-cem-edl/evergreen/gitlab-ci/build-fec-sw:latest
interruptible: true
image: $EDL_IMAGE_BUILD_FEC_SW_FOR_PRODUCTION:latest
variables:
_DOXYGEN_DEST: $CI_PROJECT_DIR/$EDL_CI_EOS_OUTPUT_DIR/doc/developer_manual
before_script:
- yum install -q -y libftdi-devel systemd-devel which doxygen
script:
- make -C software
- make -C software/lib doc
- mkdir -p $_DOXYGEN_DEST
- cp -r software/lib/html/* $_DOXYGEN_DEST/
artifacts:
name: "$CI_COMMIT_TIMESTAMP-$CI_JOB_ID-$CI_COMMIT_SHORT_SHA-doxygen"
paths:
- $_DOXYGEN_DEST/*
......@@ -2,5 +2,5 @@
#
# SPDX-License-Identifier: LGPL-2.1-or-later
all clean:
all install clean:
make -C lib $@
......@@ -5,4 +5,7 @@
*.o
*.a
*.so
*.so.*
html/
build
pyoattnusb.egg-info
......@@ -4,34 +4,91 @@
-include Makefile.ftdi
OBJS = $(LIBNAME).o usb-enum.o eeprom.o
CFLAGS += -fPIC -g
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
GIT_VERSION = $(shell git describe --dirty --tags --long)
GIT_VERSION = $(shell git describe --dirty --long --tags --always | tr -d "v")
VER_MAJOR=$(word 1,$(subst ., ,$(GIT_VERSION)))
VER_MINOR=$(word 2,$(subst ., ,$(GIT_VERSION)))
VER_PATCH=$(word 1,$(subst -, ,$(word 3,$(subst ., ,$(GIT_VERSION)))))
VERSION=$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
SO_VERSION_XYZ=$(VERSION)
SO_VERSION_X=$(VER_MAJOR)
ifeq ($(SO_VERSION_X),)
SO_VERSION_X := 0
endif
DESTDIR ?=
prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
libdir ?= $(exec_prefix)/lib
includedir ?= $(prefix)/include
pythondir ?= $(libdir)/python
NAME = oattnusb
BINNAME = $(NAME)test
LIBNAME = lib$(NAME)
LIBSO = $(LIBNAME).so
LIBSO_XYZ = $(LIBSO).$(SO_VERSION_XYZ)
LIBSO_X = $(LIBSO).$(SO_VERSION_X)
LIB = $(LIBNAME).a
LOBJ = $(LIBNAME).o usb-enum.o eeprom.o
CFLAGS += -Wall -Werror -fPIC -g
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
CFLAGS += $(EXTRACFLAGS)
ARFLAGS = rcv
# intra2net does not seem to settle into any side of this
# dilemma, so we have to decide for them, see
# http://developer.intra2net.com/mailarchive/html/libftdi/2013/msg00372.html
#
LIBFTDI_CONFIG = $(shell command -v libftdi1-config)
ifeq ($(LIBFTDI_CONFIG),)
LIBFTDI_CONFIG = $(shell command -v libftdi-config)
endif
LIBFTDI_INC := $(shell $(LIBFTDI_CONFIG) --cflags)
LIBFTDI_LIBS := $(shell $(LIBFTDI_CONFIG) --libs)
CFLAGS += $(LIBFTDI_INC)
LDLIBS += $(LIBFTDI_LIBS)
LDLIBS += -ludev
CPPCHECK ?= cppcheck
all: lib doc
lib: $(LIBNAME).a $(LIBNAME).so
all: lib doc
lib: $(LIB) $(LIBSO) $(LIBSO_XYZ)
$(LIBNAME).a: $(OBJS)
ar rc $(LIBNAME).a $(OBJS)
$(LIBNAME).so: LDLIBS += -ludev
$(LIBNAME).so: $(OBJS)
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS) $(LDLIBS)
$(OBJS): $(LIBNAME).h $(LIBNAME)-i.h usb-enum.h
$(LIB): $(LOBJ)
$(AR) $(ARFLAGS) $@ $^
$(LIBSO_XYZ): $(LOBJ)
$(CC) -shared $^ -Wl,-soname,$(LIBSO_X) -o $@ $(LDFLAGS) $(LDLIBS)
$(LIBSO): $(LIBSO_XYZ)
ln -sf $< $@
doc:
doxygen oattn.doxy
clean:
rm -f *.a *.o *.so
rm -f $(LIB) $(LIBSO) $(LIBSO_XYZ) $(LOBJ) .depend *.a *.o *.so* *~
rm -rf html
rm -rf build pyoattnusb.egg-info
cppcheck:
$(CPPCHECK) -I. *.c *.h --error-exitcode=1 --suppress=missingIncludeSystem \
--enable=warning,style,performance,portability,information,missingInclude
-include Makefile.install
deploy deploy-$(LIBNAME): install
install: $(LIBSO) $(LIBSO_XYZ) $(LIB)
mkdir -m 0775 -p $(DESTDIR){$(libdir),$(includedir),$(pythondir),$(bindir)}
install -D -t $(DESTDIR)$(libdir) -m 0755 $(LIBSO_XYZ)
install -D -t $(DESTDIR)$(libdir) -m 0644 $(LIB)
install -D -t $(DESTDIR)$(includedir) -m 0644 $(LIBNAME).h usb-enum.h
cp -d $(LIBSO) $(DESTDIR)$(libdir)
install -D -t $(DESTDIR)$(bindir) -m 0755 $(BINNAME)
VERSION=$(VERSION) pip install . --target $(DESTDIR)$(pythondir)
.PHONY: install
# SPDX-FileCopyrightText: 2023 CERN (home.cern)
#
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# intra2net does not seem to settle into any side of this
# dilemma, so we have to decide for them, see
# http://developer.intra2net.com/mailarchive/html/libftdi/2013/msg00372.html
#
CONFIG = $(shell which libftdi1-config)
ifeq ($(CONFIG),)
CONFIG = $(shell which libftdi-config)
endif
LIBFTDI_INC := $(shell $(CONFIG) --cflags)
LIBFTDI_LIBS := $(shell $(CONFIG) --libs)
CFLAGS += $(LIBFTDI_INC)
LDLIBS += $(LIBFTDI_LIBS)
# SPDX-FileCopyrightText: 2023 CERN (home.cern)
#
# SPDX-License-Identifier: LGPL-2.1-or-later
VERSION = $(shell git describe --dirty --tags --long)
OATTN_ROOT = /acc/local/L867/drv/$(NAME)
INSTALL_ROOT = $(OATTN_ROOT)/$(VERSION)
install: $(LIBNAME).a $(LIBNAME).so $(NAME)test
install: $(LIBNAME).h usb-enum.h
install:
mkdir -p $(INSTALL_ROOT)/lib
mkdir -p $(INSTALL_ROOT)/include
mkdir -p $(INSTALL_ROOT)/bin
ln -sf . $(INSTALL_ROOT)/include/$(NAME)
install -m 0775 $(LIBNAME).a $(LIBNAME).so $(INSTALL_ROOT)/lib
install -m 0775 $(NAME)test $(INSTALL_ROOT)/bin
install -m 0775 $(LIBNAME).h usb-enum.h $(INSTALL_ROOT)/include
pip install . --target $(INSTALL_ROOT)/lib
......@@ -33,7 +33,7 @@ static void eeprom_backup(unsigned char *eeprom_raw, int sz)
gettimeofday(&tv, NULL);
snprintf(fname, sizeof(fname),
"/tmp/eeprom_dump-%10d%06d.bin", tv.tv_sec, tv.tv_usec);
"/tmp/eeprom_dump-%10ld%06ld.bin", tv.tv_sec, tv.tv_usec);
if ((f = fopen(fname, "wb")) != NULL) {
fprintf(stderr, "backing up EEPROM into %s\n", fname);
fwrite(eeprom_raw, sz, 1, f);
......
......@@ -3,4 +3,4 @@
#
# SPDX-License-Identifier: LGPL-2.1-or-later
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
PYTHONPATH=$SCRIPT_DIR/../lib python3 -m pyoattnusb
PYTHONPATH=$SCRIPT_DIR/../lib/python python3 -m pyoattnusb
......@@ -37,14 +37,13 @@ class Manager:
self._devices = self._get_devarray(self.VENDOR_ID, self.DEVICE_ID)
def _load_solib(self):
"""try to load attn dyn library from script dir or ../lib."""
"""try to find and load attn dyn library"""
solib = 'liboattnusb.so'
scriptdir = os.path.dirname(os.path.realpath(__file__))
rootdir = os.path.dirname(scriptdir)
paths = (solib,
os.path.join(rootdir, 'lib', solib),
os.path.join(rootdir, '..', 'lib', solib))
os.path.join(rootdir, '..', solib))
for p in paths:
try:
......
......@@ -3,16 +3,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
from setuptools import setup, find_packages
import subprocess
try:
version = subprocess.check_output(['git', 'describe', '--tags']).decode().strip()
except Exception:
version = '0.0.0'
import os
setup(
name='pyoattnusb',
version=version,
version=os.environ.get('VERSION', "0.0.0"),
packages=find_packages(),
author='Dimitris Lampridis',
author_email='dimitris.lampridis@cern.ch',
......
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