From 3430e95de7a007a05640be343f60e3bb9019e900 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 26 Dec 2019 21:38:49 +0000 Subject: [PATCH 1/3] Don't install testfilter. --- tools/library/filter/testfilter/testfilter.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/library/filter/testfilter/testfilter.pro b/tools/library/filter/testfilter/testfilter.pro index 06418b1c1..7361c5f0f 100644 --- a/tools/library/filter/testfilter/testfilter.pro +++ b/tools/library/filter/testfilter/testfilter.pro @@ -11,3 +11,5 @@ HEADERS += \ INCLUDEPATH += \ .. + +target.CONFIG += no_default_install From 0a2a934934507a1b529485e12c0e4b6eb0fc761b Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 26 Dec 2019 21:59:07 +0000 Subject: [PATCH 2/3] Configurable installation prefix for the tools. There's no standard for this in qmake, but PREFIX seems to be a common name in other projects. --- tools/ld-analyse/ld-analyse.pro | 8 +++++--- tools/ld-chroma-decoder/encoder/encoder.pro | 8 +++++--- tools/ld-chroma-decoder/ld-chroma-decoder.pro | 8 +++++--- tools/ld-diffdod/ld-diffdod.pro | 10 +++++----- tools/ld-discmap/ld-discmap.pro | 10 +++++----- tools/ld-dropout-correct/ld-dropout-correct.pro | 10 +++++----- tools/ld-lds-converter/ld-lds-converter.pro | 9 +++++---- tools/ld-process-efm/ld-process-efm.pro | 8 +++++--- tools/ld-process-vbi/ld-process-vbi.pro | 11 +++++------ 9 files changed, 45 insertions(+), 37 deletions(-) diff --git a/tools/ld-analyse/ld-analyse.pro b/tools/ld-analyse/ld-analyse.pro index 29b1abef3..1d3bc74b3 100644 --- a/tools/ld-analyse/ld-analyse.pro +++ b/tools/ld-analyse/ld-analyse.pro @@ -97,9 +97,11 @@ INCLUDEPATH += ../library/filter INCLUDEPATH += ../library/tbc INCLUDEPATH += ../ld-chroma-decoder -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target RESOURCES += \ diff --git a/tools/ld-chroma-decoder/encoder/encoder.pro b/tools/ld-chroma-decoder/encoder/encoder.pro index bf67c3a87..a56cb3fcd 100644 --- a/tools/ld-chroma-decoder/encoder/encoder.pro +++ b/tools/ld-chroma-decoder/encoder/encoder.pro @@ -32,7 +32,9 @@ HEADERS += \ INCLUDEPATH += ../../library/filter INCLUDEPATH += ../../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target diff --git a/tools/ld-chroma-decoder/ld-chroma-decoder.pro b/tools/ld-chroma-decoder/ld-chroma-decoder.pro index 4d392367e..3c637ee86 100644 --- a/tools/ld-chroma-decoder/ld-chroma-decoder.pro +++ b/tools/ld-chroma-decoder/ld-chroma-decoder.pro @@ -62,9 +62,11 @@ HEADERS += \ INCLUDEPATH += ../library/filter INCLUDEPATH += ../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target # Additional include paths to support MacOS compilation diff --git a/tools/ld-diffdod/ld-diffdod.pro b/tools/ld-diffdod/ld-diffdod.pro index b73eaf4f6..334ec0e08 100644 --- a/tools/ld-diffdod/ld-diffdod.pro +++ b/tools/ld-diffdod/ld-diffdod.pro @@ -38,9 +38,9 @@ HEADERS += \ INCLUDEPATH += ../library/filter INCLUDEPATH += ../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target - - diff --git a/tools/ld-discmap/ld-discmap.pro b/tools/ld-discmap/ld-discmap.pro index 4338127fe..7b2efa853 100644 --- a/tools/ld-discmap/ld-discmap.pro +++ b/tools/ld-discmap/ld-discmap.pro @@ -34,9 +34,9 @@ HEADERS += \ # Add external includes to the include path INCLUDEPATH += ../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target - - diff --git a/tools/ld-dropout-correct/ld-dropout-correct.pro b/tools/ld-dropout-correct/ld-dropout-correct.pro index de1027dcf..b6b6fee55 100644 --- a/tools/ld-dropout-correct/ld-dropout-correct.pro +++ b/tools/ld-dropout-correct/ld-dropout-correct.pro @@ -36,9 +36,9 @@ HEADERS += \ INCLUDEPATH += ../library/filter INCLUDEPATH += ../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target - - diff --git a/tools/ld-lds-converter/ld-lds-converter.pro b/tools/ld-lds-converter/ld-lds-converter.pro index 8d96bf79d..0952344f0 100644 --- a/tools/ld-lds-converter/ld-lds-converter.pro +++ b/tools/ld-lds-converter/ld-lds-converter.pro @@ -21,8 +21,9 @@ SOURCES += \ HEADERS += \ dataconverter.h -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target - diff --git a/tools/ld-process-efm/ld-process-efm.pro b/tools/ld-process-efm/ld-process-efm.pro index 7d2c6a5e4..b887d0dd7 100644 --- a/tools/ld-process-efm/ld-process-efm.pro +++ b/tools/ld-process-efm/ld-process-efm.pro @@ -86,9 +86,11 @@ FORMS += \ aboutdialog.ui \ mainwindow.ui -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target RESOURCES += \ diff --git a/tools/ld-process-vbi/ld-process-vbi.pro b/tools/ld-process-vbi/ld-process-vbi.pro index f6542dcf3..4ff1112e1 100644 --- a/tools/ld-process-vbi/ld-process-vbi.pro +++ b/tools/ld-process-vbi/ld-process-vbi.pro @@ -38,10 +38,9 @@ HEADERS += \ # Add external includes to the include path INCLUDEPATH += ../library/tbc -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/local/bin/ +# Rules for installation +isEmpty(PREFIX) { + PREFIX = /usr/local +} +unix:!android: target.path = $$PREFIX/bin/ !isEmpty(target.path): INSTALLS += target - - - From e0c278756a886e5fe5e7474a31862c464c0a2ce6 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 26 Dec 2019 22:04:19 +0000 Subject: [PATCH 3/3] Make the top-level Makefile build/install all of ld-decode. This tries to cover building and installation for typical users, and supports GNU-style prefix and DESTDIR variables for installing in custom prefixes and package staging dirs. Variables are provided to override qmake and python3 because some systems have different names for these (qmake-5, python3.7, ...). --- .github/workflows/tests.yml | 16 +++----- Makefile | 78 ++++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7f44079f..767b203bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,17 +25,13 @@ jobs: # This list is from: https://github.com/happycube/ld-decode/wiki/Installation sudo apt-get install -y --no-install-recommends clang libopencv-dev libfann-dev python3-numpy python3-scipy python3-matplotlib git qt5-default libqwt-qt5-dev libfftw3-dev python3-tk python3-pandas python3-numba libavformat-dev libavcodec-dev libavutil-dev ffmpeg openssl pv - - name: Build toplevel - timeout-minutes: 5 - run: | - make - - - name: Build tools + - name: Build timeout-minutes: 15 - run: | - cd tools - qmake -recursive - make + run: make prefix=/usr + + - name: Install + timeout-minutes: 5 + run: make install prefix=/usr DESTDIR=/tmp/staging - name: Run testfilter timeout-minutes: 5 diff --git a/Makefile b/Makefile index 4bd04a4ec..10c8fe310 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,75 @@ -# Makefile for the Software Decode of Laserdiscs project +### Top-level Makefile for ld-decode ### -# Note: Targets do not include auto-generated .h files, which means -# that make clean will not remove them. -TARGETS=ld-ldf-reader +# Prefix into which ld-decode will be installed. +# This must be set both at build and install time. If you're using a +# non-default directory here, make sure that Python knows to look in there for +# modules (e.g. by setting PYTHONPATH in your environment). +prefix ?= /usr/local -CFLAGS=-g -O2 -fno-omit-frame-pointer -march=native -Itools/library/filter +# Staging dir for building distribution packages. +# If you're building packages, it may make more sense to build the Python and +# Qt parts using your distribution's tools, rather than using this Makefile +# (but don't forget the helpers!). +DESTDIR = -all: $(TARGETS) +# Tools you might want to override +PYTHON3 ?= python3 +QMAKE ?= qmake -clean: - rm -f $(TARGETS) +### Targets for users to invoke ### -install: - cp ld-ldf-reader /usr/local/bin +all: build-helpers build-python build-tools +install: install-helpers install-python install-tools +clean: clean-helpers clean-python clean-tools -tools/library/filter/deemp.h: scripts/filtermaker - python3 scripts/filtermaker >$@ +.PHONY: all build-helpers build-python build-tools +.PHONY: install install-helpers install-python install-tools +.PHONY: clean clean-helpers clean-python clean-tools + +### Helper programs used by ld-decode ### + +helpers = ld-ldf-reader + +build-helpers: $(helpers) ld-ldf-reader: ld-ldf-reader.c - clang -o ld-ldf-reader ld-ldf-reader.c -Wno-deprecated-declarations -lavcodec -lavutil -lavformat -O2 + $(CC) -O2 -Wno-deprecated-declarations -o $@ $< -lavcodec -lavutil -lavformat + +install-helpers: + install -d "$(DESTDIR)$(prefix)/bin" + install -m755 $(helpers) "$(DESTDIR)$(prefix)/bin" + +clean-helpers: + rm -f $(helpers) + +### Python modules and scripts ### + +build-python: + $(PYTHON3) setup.py build +install-python: + if [ -z "$(DESTDIR)" ]; then \ + $(PYTHON3) setup.py install --prefix="$(prefix)"; \ + else \ + $(PYTHON3) setup.py install --root="$(DESTDIR)" --prefix="$(prefix)"; \ + fi +clean-python: + $(PYTHON3) setup.py clean -a + +### Qt-based tools ### + +build-tools: + cd tools && $(QMAKE) -recursive PREFIX="$(prefix)" + $(MAKE) -C tools + +install-tools: + $(MAKE) -C tools install INSTALL_ROOT="$(DESTDIR)" + +clean-tools: + $(MAKE) -C tools clean + +### Generated files, not updated automatically ### + +tools/library/filter/deemp.h: scripts/filtermaker + $(PYTHON3) scripts/filtermaker >$@