From 669d53024d860ec4365db64b9083e82fc0746b3e Mon Sep 17 00:00:00 2001 From: Mathias Krause Date: Mon, 28 Aug 2023 14:09:01 +0200 Subject: [PATCH 1/2] Makefile: try to find the python wrapper on our own Not all distributions ship a version-agnostic python wrapper any more, making a simple 'make' fail and require the user to provide the proper python interpreter through the PYTHON make variable. Instead try to find a matching python wrapper automatically by probing the ones we do support. Signed-off-by: Mathias Krause --- Makefile | 2 +- tools/ci/get-python.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 tools/ci/get-python.sh diff --git a/Makefile b/Makefile index 29d388d2..d448cd4c 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ endif LD := ld NM := nm -PYTHON := python +PYTHON := $(shell tools/ci/get-python.sh) SHELL := bash RM := rm LN := ln diff --git a/tools/ci/get-python.sh b/tools/ci/get-python.sh new file mode 100755 index 00000000..4aa8927c --- /dev/null +++ b/tools/ci/get-python.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Not all systems ship a 'python' wrapper, try version specific ones if we +# fail to find the version-agnostic one. +# +# Copyright (c) 2023 Open Source Security, Inc. + +try_python() { + if $1 -c 'exit' 2>/dev/null; then + echo "$1" + exit 0 + fi +} + +try_python python +try_python python3 +try_python python2 + +echo "error: python interpreter not found!" >&2 +exit 1 From 44e9971507bfba5e18da166f1e241e49419d8e03 Mon Sep 17 00:00:00 2001 From: Mathias Krause Date: Mon, 28 Aug 2023 14:13:06 +0200 Subject: [PATCH 2/2] Makefile: ctags support Add 'tags' and 'TAGS' targets to generate corresponding ctags files. Signed-off-by: Mathias Krause --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index d448cd4c..281e8f9b 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ endif LD := ld NM := nm +CTAGS := ctags PYTHON := $(shell tools/ci/get-python.sh) SHELL := bash RM := rm @@ -230,6 +231,7 @@ clean: $(VERBOSE) find $(KTF_ROOT) -name \*.img -delete $(VERBOSE) find $(KTF_ROOT) -name \*.xz -delete $(VERBOSE) find $(KTF_ROOT) -name cscope.\* -delete + $(VERBOSE) find $(KTF_ROOT) -maxdepth 1 \( -name tags -or -name TAGS \) -delete $(VERBOSE) find $(KTF_ROOT) -name $(ASM_OFFSETS_S) -delete $(VERBOSE) find $(KTF_ROOT) -name $(ASM_OFFSETS_H) -delete $(VERBOSE) find $(PFMLIB_DIR) -mindepth 1 ! -name $(PFMLIB_NAME)-$(PFMLIB_VER).tar.gz -delete @@ -315,6 +317,10 @@ cscope: $(VERBOSE) $(all_sources) > cscope.files $(VERBOSE) cscope -b -q -k +tags TAGS: $(SOURCES) $(HEADERS) $(ASM_SOURCES) + @echo "TAGS ($@)" + $(VERBOSE) $(CTAGS) -o $@ $+ + .PHONY: style style: @echo "STYLE"