From fb480993ed5f8cdc5fc0255b21022b4908729513 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:40:33 +0200 Subject: [PATCH] Simplify Makefile --- collectors/Makefile | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/collectors/Makefile b/collectors/Makefile index de98eb6..b73d917 100644 --- a/collectors/Makefile +++ b/collectors/Makefile @@ -1,31 +1,33 @@ # LIKWID version -LIKWID_VERSION = 5.2.2 -LIKWID_INSTALLED_FOLDER=$(shell dirname $(shell which likwid-topology 2>/dev/null) 2>/dev/null) +LIKWID_VERSION := 5.2.2 +LIKWID_INSTALLED_FOLDER := $(shell dirname $$(which likwid-topology 2>/dev/null) 2>/dev/null) -LIKWID_FOLDER="$(shell pwd)/likwid" +LIKWID_FOLDER := $(CURDIR)/likwid -all: $(LIKWID_FOLDER)/likwid.h +all: likwid .ONESHELL: -.PHONY: $(LIKWID_FOLDER)/likwid.h -$(LIKWID_FOLDER)/likwid.h: - if [ "$(LIKWID_INSTALLED_FOLDER)" != "" ]; then \ - BASE="$(LIKWID_INSTALLED_FOLDER)/../include"; \ - mkdir -p $(LIKWID_FOLDER); \ - cp $$BASE/*.h $(LIKWID_FOLDER); \ - else \ - BUILD_FOLDER="$${PWD}/likwidbuild"; \ - if [ -d $(LIKWID_FOLDER) ]; then rm -r $(LIKWID_FOLDER); fi; \ - mkdir --parents --verbose $(LIKWID_FOLDER) $${BUILD_FOLDER}; \ - wget -P "$${BUILD_FOLDER}" http://ftp.rrze.uni-erlangen.de/mirrors/likwid/likwid-$(LIKWID_VERSION).tar.gz; \ - tar -C $${BUILD_FOLDER} -xf $${BUILD_FOLDER}/likwid-$(LIKWID_VERSION).tar.gz; \ - install -Dpm 0644 $${BUILD_FOLDER}/likwid-$(LIKWID_VERSION)/src/includes/likwid*.h $(LIKWID_FOLDER)/; \ - install -Dpm 0644 $${BUILD_FOLDER}/likwid-$(LIKWID_VERSION)/src/includes/bstrlib.h $(LIKWID_FOLDER)/; \ - rm -r $${BUILD_FOLDER}; \ +.PHONY: likwid +likwid: + if [ -n "$(LIKWID_INSTALLED_FOLDER)" ]; then + # Using likwid include files from system installation + INCLUDE_DIR="$(LIKWID_INSTALLED_FOLDER)/../include" + mkdir --parents --verbose "$(LIKWID_FOLDER)" + cp "$${INCLUDE_DIR}"/*.h "$(LIKWID_FOLDER)" + else + # Using likwid include files from downloaded tar archive + if [ -d "$(LIKWID_FOLDER)" ]; then + rm --recursive "$(LIKWID_FOLDER)" + fi + BUILD_FOLDER="$${PWD}/likwidbuild" + mkdir --parents --verbose "$${BUILD_FOLDER}" + wget --output-document=- http://ftp.rrze.uni-erlangen.de/mirrors/likwid/likwid-$(LIKWID_VERSION).tar.gz | + tar --directory="$${BUILD_FOLDER}" --extract --gz + install -D --verbose --preserve-timestamps --mode=0644 --target-directory="$(LIKWID_FOLDER)" "$${BUILD_FOLDER}/likwid-$(LIKWID_VERSION)/src/includes"/likwid*.h "$${BUILD_FOLDER}/likwid-$(LIKWID_VERSION)/src/includes"/bstrlib.h + rm --recursive "$${BUILD_FOLDER}" fi +.PHONY: clean clean: rm -rf likwid - -.PHONY: clean