2023-05-25 22:53:58 +02:00
#* Btop++ makefile v1.6
2021-08-22 16:04:01 +02:00
2023-06-28 01:49:43 +02:00
BANNER = \n \0 33[ 38; 5; 196m██████\0 33[ 38; 5; 240m╗ \0 33[ 38; 5; 196m████████\0 33[ 38; 5; 240m╗ \0 33[ 38; 5; 196m██████\0 33[ 38; 5; 240m╗ \0 33[ 38; 5; 196m██████\0 33[ 38; 5; 240m╗\n \0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╔══\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╗╚══\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╔══╝\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╔═══\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╗\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╔══\0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╗ \0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╗ \0 33[ 38; 5; 160m██\0 33[ 38; 5; 239m╗\n \0 33[ 38; 5; 124m██████\0 33[ 38; 5; 238m╔╝ \0 33[ 38; 5; 124m██\0 33[ 38; 5; 238m║ \0 33[ 38; 5; 124m██\0 33[ 38; 5; 238m║ \0 33[ 38; 5; 124m██\0 33[ 38; 5; 238m║\0 33[ 38; 5; 124m██████\0 33[ 38; 5; 238m╔╝ \0 33[ 38; 5; 124m██████\0 33[ 38; 5; 238m╗\0 33[ 38; 5; 124m██████\0 33[ 38; 5; 238m╗\n \0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m╔══\0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m╗ \0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m║ \0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m║ \0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m║\0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m╔═══╝ ╚═\0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m╔═╝╚═\0 33[ 38; 5; 88m██\0 33[ 38; 5; 237m╔═╝\n \0 33[ 38; 5; 52m██████\0 33[ 38; 5; 236m╔╝ \0 33[ 38; 5; 52m██\0 33[ 38; 5; 236m║ ╚\0 33[ 38; 5; 52m██████\0 33[ 38; 5; 236m╔╝\0 33[ 38; 5; 52m██\0 33[ 38; 5; 236m║ ╚═╝ ╚═╝\n \0 33[ 38; 5; 235m╚═════╝ ╚═╝ ╚═════╝ ╚═╝ \0 33[ 1; 3; 38; 5; 240mMakefile v1.6\0 33[ 0m
2021-08-22 16:04:01 +02:00
2021-09-01 21:40:13 +02:00
override BTOP_VERSION : = $( shell head -n 100 src /btop .cpp 2>/dev /null | grep "Version =" | cut -f 2 -d "\"" || echo " unknown ")
override TIMESTAMP : = $( shell date +%s 2>/dev /null || echo "0")
2022-02-14 22:01:21 +01:00
override DATESTAMP : = $( shell date '+%Y -%m -%d %H :%M :%S ' || echo "5 minutes ago ")
2021-11-13 21:19:18 +01:00
i f e q ( $( shell command -v gdate >/dev /null ; echo $ $ ?) , 0 )
DATE_CMD := gdate
e l s e
DATE_CMD := date
e n d i f
2021-08-22 16:04:01 +02:00
2021-09-21 18:57:16 +02:00
i f n e q ( $( QUIET ) , t r u e )
override QUIET := false
e n d i f
2022-10-10 12:29:32 +02:00
OLDCXX := $( CXXFLAGS)
OLDLD := $( LDFLAGS)
2021-05-06 20:32:03 +02:00
PREFIX ?= /usr/local
2021-10-18 20:55:06 +02:00
#? Detect PLATFORM and ARCH from uname/gcc if not set
PLATFORM ?= $( shell uname -s || echo unknown)
2021-11-13 21:19:18 +01:00
i f n e q ( $( filter unknown Darwin , $ ( PLATFORM ) ) , )
2021-10-18 20:55:06 +02:00
override PLATFORM := $( shell $( CXX) -dumpmachine | awk -F"-" '{ print (NF==4) ? $$3 : $$2 }' )
2021-11-13 21:19:18 +01:00
ifeq ( $( PLATFORM) ,apple)
override PLATFORM := macos
endif
e n d i f
i f e q ( $( shell uname -v | grep ARM 64 >/dev /null 2>&1; echo $ $ ?) , 0 )
ARCH ?= arm64
e l s e
ARCH ?= $( shell $( CXX) -dumpmachine | cut -d "-" -f 1)
2021-10-18 20:55:06 +02:00
e n d i f
2021-10-16 15:15:56 +02:00
override PLATFORM_LC : = $( shell echo $ ( PLATFORM ) | tr '[:upper :]' '[:lower :]')
2021-09-01 21:40:13 +02:00
2023-05-25 22:53:58 +02:00
#? Compiler and Linker
i f e q ( $( shell $ ( CXX ) --version | grep clang >/dev /null 2>&1; echo $ $ ?) , 0 )
override CXX_IS_CLANG := true
e n d i f
override CXX_VERSION : = $( shell $ ( CXX ) -dumpfullversion -dumpversion || echo 0)
override CXX_VERSION_MAJOR : = $( shell echo $ ( CXX_VERSION ) | cut -d '.' -f 1)
CLANG_WORKS = false
GCC_WORKS = false
#? Supported is Clang 16.0.0 and later
i f e q ( $( CXX_IS_CLANG ) , t r u e )
ifneq ( $( shell test $( CXX_VERSION_MAJOR) -lt 16; echo $$ ?) ,0)
CLANG_WORKS := true
endif
e n d i f
i f e q ( $( CLANG_WORKS ) , f a l s e )
#? Try to find a newer GCC version
2023-08-26 20:29:43 +02:00
ifeq ( $( shell command -v g++-13 >/dev/null; echo $$ ?) ,0)
CXX := g++-13
else ifeq ( $( shell command -v g++13 >/dev/null; echo $$ ?) ,0)
CXX := g++13
else ifeq ( $( shell command -v g++-12 >/dev/null; echo $$ ?) ,0)
2023-05-25 22:53:58 +02:00
CXX := g++-12
2023-06-26 23:48:44 +02:00
else ifeq ( $( shell command -v g++12 >/dev/null; echo $$ ?) ,0)
CXX := g++12
2023-05-25 22:53:58 +02:00
else ifeq ( $( shell command -v g++-11 >/dev/null; echo $$ ?) ,0)
CXX := g++-11
else ifeq ( $( shell command -v g++11 >/dev/null; echo $$ ?) ,0)
CXX := g++11
else ifeq ( $( shell command -v g++ >/dev/null; echo $$ ?) ,0)
CXX := g++
2023-06-26 23:48:44 +02:00
else
GCC_NOT_FOUND := true
2023-05-25 22:53:58 +02:00
endif
2023-06-26 23:48:44 +02:00
ifndef GCC_NOT_FOUND
override CXX_VERSION := $( shell $( CXX) -dumpfullversion -dumpversion || echo 0)
override CXX_VERSION_MAJOR := $( shell echo $( CXX_VERSION) | cut -d '.' -f 1)
ifneq ( $( shell test $( CXX_VERSION_MAJOR) -lt 10; echo $$ ?) ,0)
GCC_WORKS := true
endif
2023-05-25 22:53:58 +02:00
endif
e n d i f
i f e q ( $( CLANG_WORKS ) , f a l s e )
ifeq ( $( GCC_WORKS) ,false)
$(error $(shell printf "\033[1;91mERROR : \033[97mCompiler too old . (Requires Clang 16.0.0, GCC 10.1.0)\033[0m "))
endif
e n d i f
2021-10-21 08:16:52 +02:00
#? Any flags added to TESTFLAGS must not contain whitespace for the testing to work
2021-11-13 21:19:18 +01:00
override TESTFLAGS : = -fexceptions -fstack -clash -protection -fcf -protection
i f n e q ( $( PLATFORM ) $( ARCH ) , m a c o s a r m 6 4 )
override TESTFLAGS += -fstack-protector
e n d i f
2021-09-01 21:40:13 +02:00
2021-09-18 02:13:35 +02:00
i f e q ( $( STATIC ) , t r u e )
2023-08-26 20:29:43 +02:00
ifeq ( $( CXX_IS_CLANG) $( CLANG_WORKS) ,true true )
2023-05-25 22:53:58 +02:00
ifeq ( $( shell $( CXX) -print-target-triple | grep gnu >/dev/null; echo $$ ?) ,0)
$(error $(shell printf "\033[1;91mERROR : \033[97m $( CXX ) can 't statically link glibc \033[0m "))
endif
else
override ADDFLAGS += -static-libgcc -static-libstdc++
endif
2023-08-26 20:29:43 +02:00
ifeq ( $( PLATFORM_LC) ,linux)
2021-11-16 07:16:55 +01:00
override ADDFLAGS += -DSTATIC_BUILD -static -Wl,--fatal-warnings
2023-08-26 20:29:43 +02:00
else ifeq ( $( PLATFORM_LC) ,freebsd)
override ADDFLAGS += -DSTATIC_BUILD
2021-11-16 07:16:55 +01:00
endif
2021-10-16 15:15:56 +02:00
e n d i f
i f e q ( $( STRIP ) , t r u e )
2021-10-24 01:16:15 +02:00
override ADDFLAGS += -s
2021-09-18 02:13:35 +02:00
e n d i f
2022-10-10 13:02:07 +02:00
i f e q ( $( VERBOSE ) , t r u e )
2022-10-10 12:29:32 +02:00
override VERBOSE := false
2022-10-10 13:02:07 +02:00
e l s e
override VERBOSE := true
2022-10-10 12:29:32 +02:00
e n d i f
2021-09-12 15:58:23 +02:00
#? Pull in platform specific source files and get thread count
2021-10-16 15:15:56 +02:00
i f e q ( $( PLATFORM_LC ) , l i n u x )
2021-09-12 15:58:23 +02:00
PLATFORM_DIR := linux
THREADS := $( shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
2021-11-13 21:25:08 +01:00
SU_GROUP := root
2021-10-16 15:15:56 +02:00
e l s e i f e q ( $( PLATFORM_LC ) , f r e e b s d )
2021-09-12 15:58:23 +02:00
PLATFORM_DIR := freebsd
THREADS := $( shell getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)
2022-01-16 14:19:31 +01:00
SU_GROUP := wheel
2023-08-26 20:29:43 +02:00
override ADDFLAGS += -lm -lkvm -ldevstat -Wl,-rpath= /usr/local/lib/gcc$( CXX_VERSION_MAJOR)
ifneq ( $( STATIC) ,true)
override ADDFLAGS += -lstdc++
endif
2021-11-13 21:25:08 +01:00
export MAKE = gmake
e l s e i f e q ( $( PLATFORM_LC ) , m a c o s )
2021-09-12 15:58:23 +02:00
PLATFORM_DIR := osx
THREADS := $( shell sysctl -n hw.ncpu || echo 1)
2021-11-13 21:25:08 +01:00
override ADDFLAGS += -framework IOKit -framework CoreFoundation -Wno-format-truncation
SU_GROUP := wheel
2021-09-12 15:58:23 +02:00
e l s e
$(error $(shell printf "\033[1;91mERROR : \033[97mUnsupported platform ($( PLATFORM ) )\033[0m "))
e n d i f
2021-08-23 17:35:27 +02:00
#? Use all CPU cores (will only be set if using Make 4.3+)
2021-10-21 08:16:52 +02:00
MAKEFLAGS := --jobs= $( THREADS)
2021-09-01 21:40:13 +02:00
i f e q ( $( THREADS ) , 1 )
override THREADS := auto
e n d i f
2021-06-19 14:57:27 +02:00
2023-05-25 22:53:58 +02:00
#? LTO command line
i f e q ( $( CLANG_WORKS ) , t r u e )
LTO := thin
e l s e
LTO := $( THREADS)
e n d i f
2021-08-22 16:04:01 +02:00
#? The Directories, Source, Includes, Objects and Binary
2021-06-19 14:57:27 +02:00
SRCDIR := src
2023-05-23 15:10:36 +02:00
INCDIRS := include $( wildcard lib/**/include)
2021-06-19 14:57:27 +02:00
BUILDDIR := obj
TARGETDIR := bin
SRCEXT := cpp
DEPEXT := d
OBJEXT := o
2021-10-21 08:16:52 +02:00
#? Filter out unsupported compiler flags
override GOODFLAGS : = $( foreach flag ,$ ( TESTFLAGS ) ,$ ( strip $ ( shell echo "int main ( ) {}" | $ ( CXX ) -o /dev /null $ ( flag ) -x c ++ - >/dev /null 2>&1 && echo $ ( flag ) || true ) ) )
2021-08-22 16:04:01 +02:00
#? Flags, Libraries and Includes
2021-09-01 21:40:13 +02:00
override REQFLAGS : = -std =c ++20
2021-09-17 14:25:54 +02:00
WARNFLAGS := -Wall -Wextra -pedantic
2023-05-25 22:53:58 +02:00
OPTFLAGS := -O2 -ftree-vectorize -flto= $( LTO)
2023-05-23 15:21:45 +02:00
LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE= 2 -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS= 64 $( GOODFLAGS) $( ADDFLAGS)
2023-06-01 16:42:02 +02:00
o v e r r i d e CXXFLAGS += $( REQFLAGS) $( LDCXXFLAGS) $( OPTFLAGS) $( WARNFLAGS)
2023-06-02 15:44:44 +02:00
o v e r r i d e LDFLAGS += $( LDCXXFLAGS) $( OPTFLAGS) $( WARNFLAGS)
2023-05-25 13:53:18 +02:00
INC := $( foreach incdir,$( INCDIRS) ,-isystem $( incdir) ) -I$( SRCDIR)
2021-08-22 16:04:01 +02:00
SU_USER := root
2021-06-19 14:57:27 +02:00
2022-01-12 00:04:26 +01:00
i f d e f D E B U G
override OPTFLAGS := -O0 -g
e n d i f
2022-02-13 03:51:13 +01:00
SOURCES := $( sort $( shell find $( SRCDIR) -maxdepth 1 -type f -name *.$( SRCEXT) ) )
2021-08-23 22:52:52 +02:00
2022-02-13 03:51:13 +01:00
SOURCES += $( sort $( shell find $( SRCDIR) /$( PLATFORM_DIR) -type f -name *.$( SRCEXT) ) )
2021-09-01 21:40:13 +02:00
2022-02-14 22:01:21 +01:00
#? Setup percentage progress
2022-02-10 08:46:39 +01:00
SOURCE_COUNT := $( words $( SOURCES) )
2021-08-23 22:52:52 +02:00
OBJECTS := $( patsubst $( SRCDIR) /%,$( BUILDDIR) /%,$( SOURCES:.$( SRCEXT) = .$( OBJEXT) ) )
2021-06-19 14:57:27 +02:00
2022-02-14 22:21:50 +01:00
i f e q ( $( shell find $ ( BUILDDIR ) -type f -newermt "$ ( DATESTAMP ) " -name *.o >/dev /null 2>&1; echo $ $ ?) , 0 )
2022-02-14 22:19:26 +01:00
ifneq ( $( wildcard $( BUILDDIR) /.*) ,)
SKIPPED_SOURCES := $( foreach fname,$( SOURCES) ,$( shell find $( BUILDDIR) -type f -newer $( fname) -name *.o | grep " $( basename $( notdir $( fname) ) ) .o " 2>/dev/null) )
override SOURCE_COUNT := $( shell expr $( SOURCE_COUNT) - $( words $( SKIPPED_SOURCES) ) )
ifeq ( $( SOURCE_COUNT) ,0)
override SOURCE_COUNT = $( words $( SOURCES) )
endif
2022-02-14 22:01:21 +01:00
endif
2022-02-14 22:19:26 +01:00
PROGRESS = expr $$ ( find $( BUILDDIR) -type f -newermt " $( DATESTAMP) " -name *.o | wc -l || echo 1) '*' 90 / $( SOURCE_COUNT) | cut -c1-2
e l s e
PROGRESS = expr $$ ( find $( BUILDDIR) -type f -name *.o | wc -l || echo 1) '*' 90 / $( SOURCE_COUNT) | cut -c1-2
2022-02-14 22:01:21 +01:00
e n d i f
2022-02-10 08:46:39 +01:00
P := %%
2023-06-01 19:37:53 +02:00
i f e q ( $( VERBOSE ) , t r u e )
override SUPPRESS := 1>/dev/null
e l s e
override SUPPRESS :=
e n d i f
2021-08-22 16:04:01 +02:00
#? Default Make
2023-06-01 19:37:53 +02:00
.ONESHELL :
all : | info rocm_smi info -quiet directories btop
2021-08-22 16:04:01 +02:00
2023-06-01 19:37:53 +02:00
i f n e q ( $( QUIET ) , t r u e )
2021-09-21 18:57:16 +02:00
info :
2021-08-22 16:04:01 +02:00
@printf " $( BANNER) \n "
2023-05-12 19:34:47 +02:00
@printf " \033[1;92mPLATFORM \033[1;93m?| \033[0m $( PLATFORM) \n "
@printf " \033[1;96mARCH \033[1;93m?| \033[0m $( ARCH) \n "
@printf " \033[1;93mCXX \033[1;93m?| \033[0m $( CXX) \033[1;93m(\033[97m $( CXX_VERSION) \033[93m)\n "
@printf " \033[1;94mTHREADS \033[1;94m:| \033[0m $( THREADS) \n "
@printf " \033[1;92mREQFLAGS \033[1;91m!| \033[0m $( REQFLAGS) \n "
@printf " \033[1;91mWARNFLAGS \033[1;94m:| \033[0m $( WARNFLAGS) \n "
@printf " \033[1;94mOPTFLAGS \033[1;94m:| \033[0m $( OPTFLAGS) \n "
@printf " \033[1;93mLDCXXFLAGS \033[1;94m:| \033[0m $( LDCXXFLAGS) \n "
2023-06-01 16:42:02 +02:00
@printf " \033[1;95mCXXFLAGS \033[1;92m+| \033[0;37m\$ $( \0 33[ 92mREQFLAGS\0 33[ 37m) \$ $( \0 33[ 93mLDCXXFLAGS\0 33[ 37m) \$ $( \0 33[ 94mOPTFLAGS\0 33[ 37m) \$ $( \0 33[ 91mWARNFLAGS\0 33[ 37m) $( OLDCXX) \n "
2023-06-02 15:44:44 +02:00
@printf " \033[1;95mLDFLAGS \033[1;92m+| \033[0;37m\$ $( \0 33[ 93mLDCXXFLAGS\0 33[ 37m) \$ $( \0 33[ 94mOPTFLAGS\0 33[ 37m) \$ $( \0 33[ 91mWARNFLAGS\0 33[ 37m) $( OLDLD) \n "
2023-06-01 19:37:53 +02:00
e l s e
info :
@true
e n d i f
2021-09-01 21:40:13 +02:00
2023-06-01 19:37:53 +02:00
info-quiet : | info rocm_smi
2021-09-21 18:57:16 +02:00
@printf " \n\033[1;92mBuilding btop++ \033[91m(\033[97mv $( BTOP_VERSION) \033[91m) \033[93m $( PLATFORM) \033[96m $( ARCH) \033[0m\n "
2021-08-22 16:04:01 +02:00
help :
2021-09-18 02:13:35 +02:00
@printf " $( BANNER) \n "
2021-08-22 16:04:01 +02:00
@printf "\033[1;97mbtop++ makefile\033[0m\n"
@printf "usage: make [argument]\n\n"
@printf "arguments:\n"
@printf " all Compile btop (default argument)\n"
@printf " clean Remove built objects\n"
@printf " distclean Remove built objects and binaries\n"
2021-09-18 02:13:35 +02:00
@printf " install Install btop++ to \$ $PREFIX ( $( PREFIX) )\n "
@printf " setuid Set installed binary owner/group to \$ $SU_USER /\$ $SU_GROUP ( $( SU_USER) / $( SU_GROUP) ) and set SUID bit\n "
2021-08-22 16:04:01 +02:00
@printf " uninstall Uninstall btop++ from \$ $PREFIX \n "
2021-10-04 20:57:15 +02:00
@printf " info Display information about Environment,compiler and linker flags\n"
2021-08-22 16:04:01 +02:00
#? Make the Directories
2021-06-19 14:57:27 +02:00
directories :
2022-12-15 17:42:07 +01:00
@$( VERBOSE) || printf " mkdir -p $( TARGETDIR) \n "
2021-06-19 14:57:27 +02:00
@mkdir -p $( TARGETDIR)
2022-12-15 17:42:07 +01:00
@$( VERBOSE) || printf " mkdir -p $( BUILDDIR) / $( PLATFORM_DIR) \n "
2021-09-01 21:40:13 +02:00
@mkdir -p $( BUILDDIR) /$( PLATFORM_DIR)
2021-06-19 14:57:27 +02:00
2021-08-22 16:04:01 +02:00
#? Clean only Objects
2021-06-19 14:57:27 +02:00
clean :
2021-08-22 16:04:01 +02:00
@printf "\033[1;91mRemoving: \033[1;97mbuilt objects...\033[0m\n"
2021-06-19 14:57:27 +02:00
@rm -rf $( BUILDDIR)
2021-08-22 16:04:01 +02:00
#? Clean Objects and Binaries
2021-06-30 22:28:12 +02:00
distclean : clean
2021-08-22 16:04:01 +02:00
@printf "\033[1;91mRemoving: \033[1;97mbuilt binaries...\033[0m\n"
2021-06-19 14:57:27 +02:00
@rm -rf $( TARGETDIR)
2021-05-06 20:32:03 +02:00
install :
2021-08-22 16:04:01 +02:00
@printf " \033[1;92mInstalling binary to: \033[1;97m $( DESTDIR) $( PREFIX) /bin/btop\n "
2021-05-06 20:32:03 +02:00
@mkdir -p $( DESTDIR) $( PREFIX) /bin
2021-07-04 01:18:48 +02:00
@cp -p $( TARGETDIR) /btop $( DESTDIR) $( PREFIX) /bin/btop
2021-05-06 20:32:03 +02:00
@chmod 755 $( DESTDIR) $( PREFIX) /bin/btop
2021-08-22 16:04:01 +02:00
@printf " \033[1;92mInstalling doc to: \033[1;97m $( DESTDIR) $( PREFIX) /share/btop\n "
@mkdir -p $( DESTDIR) $( PREFIX) /share/btop
@cp -p README.md $( DESTDIR) $( PREFIX) /share/btop
2021-09-21 22:05:03 +02:00
@printf " \033[1;92mInstalling themes to: \033[1;97m $( DESTDIR) $( PREFIX) /share/btop/themes\033[0m\n "
2021-08-22 16:04:01 +02:00
@cp -pr themes $( DESTDIR) $( PREFIX) /share/btop
2022-05-08 13:37:48 +02:00
@printf " \033[1;92mInstalling desktop entry to: \033[1;97m $( DESTDIR) $( PREFIX) /share/applications/btop.desktop\n "
@mkdir -p $( DESTDIR) $( PREFIX) /share/applications/
@cp -p btop.desktop $( DESTDIR) $( PREFIX) /share/applications/btop.desktop
@printf " \033[1;92mInstalling PNG icon to: \033[1;97m $( DESTDIR) $( PREFIX) /share/icons/hicolor/48x48/apps/btop.png\n "
@mkdir -p $( DESTDIR) $( PREFIX) /share/icons/hicolor/48x48/apps
@cp -p Img/icon.png $( DESTDIR) $( PREFIX) /share/icons/hicolor/48x48/apps/btop.png
@printf " \033[1;92mInstalling SVG icon to: \033[1;97m $( DESTDIR) $( PREFIX) /share/icons/hicolor/scalable/apps/btop.svg\n "
@mkdir -p $( DESTDIR) $( PREFIX) /share/icons/hicolor/scalable/apps
@cp -p Img/icon.svg $( DESTDIR) $( PREFIX) /share/icons/hicolor/scalable/apps/btop.svg
2021-05-06 20:32:03 +02:00
2022-01-12 00:04:26 +01:00
2021-09-01 21:40:13 +02:00
#? Set SUID bit for btop as $SU_USER in $SU_GROUP
2021-08-22 16:04:01 +02:00
setuid :
@printf " \033[1;97mFile: $( DESTDIR) $( PREFIX) /bin/btop\n "
@printf " \033[1;92mSetting owner \033[1;97m $( SU_USER) : $( SU_GROUP) \033[0m\n "
@chown $( SU_USER) :$( SU_GROUP) $( DESTDIR) $( PREFIX) /bin/btop
@printf "\033[1;92mSetting SUID bit\033[0m\n"
@chmod u+s $( DESTDIR) $( PREFIX) /bin/btop
2021-06-30 22:28:12 +02:00
2021-05-06 20:32:03 +02:00
uninstall :
2021-08-22 16:04:01 +02:00
@printf " \033[1;91mRemoving: \033[1;97m $( DESTDIR) $( PREFIX) /bin/btop\033[0m\n "
2021-05-06 20:32:03 +02:00
@rm -rf $( DESTDIR) $( PREFIX) /bin/btop
2021-08-22 16:04:01 +02:00
@printf " \033[1;91mRemoving: \033[1;97m $( DESTDIR) $( PREFIX) /share/btop\033[0m\n "
2021-05-06 20:32:03 +02:00
@rm -rf $( DESTDIR) $( PREFIX) /share/btop
2022-05-08 13:37:48 +02:00
@printf " \033[1;91mRemoving: \033[1;97m $( DESTDIR) $( PREFIX) /share/applications/btop.desktop\033[0m\n "
@rm -rf $( DESTDIR) $( PREFIX) /share/applications/btop.desktop
@printf " \033[1;91mRemoving: \033[1;97m $( DESTDIR) $( PREFIX) /share/icons/hicolor/48x48/apps/btop.png\033[0m\n "
@rm -rf $( DESTDIR) $( PREFIX) /share/icons/hicolor/48x48/apps/btop.png
@printf " \033[1;91mRemoving: \033[1;97m $( DESTDIR) $( PREFIX) /share/icons/hicolor/scalable/apps/btop.svg\033[0m\n "
@rm -rf $( DESTDIR) $( PREFIX) /share/icons/hicolor/scalable/apps/btop.svg
2021-05-06 20:32:03 +02:00
2021-08-22 16:04:01 +02:00
#? Pull in dependency info for *existing* .o files
2021-06-19 14:57:27 +02:00
-include $(OBJECTS : .$( OBJEXT ) =.$( DEPEXT ) )
2023-06-01 16:42:02 +02:00
#? Compile rocm_smi
2023-06-02 15:44:44 +02:00
i f e q ( $( RSMI_STATIC ) $( PLATFORM_LC ) , t r u e l i n u x )
2023-06-01 16:42:02 +02:00
.ONESHELL :
rocm_smi :
2023-06-01 19:37:53 +02:00
@printf "\n\033[1;92mBuilding ROCm SMI static library\033[37m...\033[0m\n"
2023-06-01 16:42:02 +02:00
@TSTAMP= $$ ( date +%s 2>/dev/null || echo "0" )
2023-06-01 19:37:53 +02:00
@mkdir -p lib/rocm_smi_lib/build
2023-06-01 16:42:02 +02:00
@cd lib/rocm_smi_lib/build
2023-06-01 19:49:00 +02:00
@$( QUIET) || printf "\033[1;97mRunning CMake...\033[0m\n"
2023-06-02 15:44:44 +02:00
@cmake .. $( SUPPRESS) || { printf "\033[1;91mCMake failed, continuing build without statically linking ROCm SMI\033[37m...\033[0m\n" ; exit 0; }
2023-06-01 19:37:53 +02:00
@$( QUIET) || printf "\n\033[1;97mBuilding and linking...\033[0m\n"
2023-06-02 15:44:44 +02:00
@$( MAKE) $( SUPPRESS) || { printf "\033[1;91mMake failed, continuing build without statically linking ROCm SMI\033[37m...\033[0m\n" ; exit 0; }
@ar -crs rocm_smi/librocm_smi64.a $$ ( find rocm_smi -name '*.o' ) $( SURPRESS) || { printf "\033[1;91mFailed to pack ROCm SMI into static library, continuing build without statically linking ROCm SMI\033[37m...\033[0m\n" ; exit 0; }
2023-06-01 19:37:53 +02:00
@printf " \033[1;92m100 $( P) \033[10D\033[5C-> \033[1;37mrocm_smi/librocm_smi64.a \033[100D\033[38C\033[1;93m(\033[1;97m $$ (du -ah rocm_smi/librocm_smi64.a | cut -f1)iB\033[1;93m)\033[0m\n "
2023-06-01 19:49:00 +02:00
@printf " \033[1;92mROCm SMI build complete in \033[92m(\033[97m $$ ( $( DATE_CMD) -d @ $$ (expr $$ (date +%s 2>/dev/null || echo " 0" ) - $( TIMESTAMP) 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo " unknown")\033[92m)\033[0m\n"
2023-07-14 02:39:44 +02:00
@$( eval override LDFLAGS += lib/rocm_smi_lib/build/rocm_smi/librocm_smi64.a -DRSMI_STATIC) # TODO: this seems to execute every time, no matter if the compilation failed or succeeded
2023-06-02 16:14:24 +02:00
@$( eval override CXXFLAGS += -DRSMI_STATIC)
2023-06-01 16:42:02 +02:00
e l s e
rocm_smi :
@true
e n d i f
2021-08-22 16:04:01 +02:00
#? Link
2021-09-01 21:40:13 +02:00
.ONESHELL :
2023-06-01 19:37:53 +02:00
btop : $( OBJECTS ) | rocm_smi directories
2021-11-13 21:19:18 +01:00
@sleep 0.2 2>/dev/null || true
2021-09-01 21:40:13 +02:00
@TSTAMP= $$ ( date +%s 2>/dev/null || echo "0" )
2021-09-21 18:57:16 +02:00
@$( QUIET) || printf "\n\033[1;92mLinking and optimizing binary\033[37m...\033[0m\n"
2022-10-10 13:02:07 +02:00
@$( VERBOSE) || printf " $( CXX) -o $( TARGETDIR) /btop $^ $( LDFLAGS) \n "
2021-09-01 21:40:13 +02:00
@$( CXX) -o $( TARGETDIR) /btop $^ $( LDFLAGS) || exit 1
2022-02-10 08:46:39 +01:00
@printf " \033[1;92m100 $( P) -> \033[1;37m $( TARGETDIR) /btop \033[100D\033[38C\033[1;93m(\033[1;97m $$ (du -ah $( TARGETDIR) /btop | cut -f1)iB\033[1;93m) \033[92m(\033[97m $$ ( $( DATE_CMD) -d @ $$ (expr $$ (date +%s 2>/dev/null || echo " 0" ) - $$ {TSTAMP} 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo '')\033[92m)\033[0m\n "
2021-11-13 21:19:18 +01:00
@printf " \n\033[1;92mBuild complete in \033[92m(\033[97m $$ ( $( DATE_CMD) -d @ $$ (expr $$ (date +%s 2>/dev/null || echo " 0" ) - $( TIMESTAMP) 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo " unknown")\033[92m)\033[0m\n"
2021-06-19 14:57:27 +02:00
2021-08-22 16:04:01 +02:00
#? Compile
2021-09-01 21:40:13 +02:00
.ONESHELL :
2023-06-01 19:37:53 +02:00
$(BUILDDIR)/%.$(OBJEXT) : $( SRCDIR ) /%.$( SRCEXT ) | rocm_smi directories
2021-11-13 21:19:18 +01:00
@sleep 0.3 2>/dev/null || true
2021-09-01 21:40:13 +02:00
@TSTAMP= $$ ( date +%s 2>/dev/null || echo "0" )
2021-09-21 18:57:16 +02:00
@$( QUIET) || printf " \033[1;97mCompiling $<\033[0m\n "
2022-10-10 13:02:07 +02:00
@$( VERBOSE) || printf " $( CXX) $( CXXFLAGS) $( INC) -MMD -c -o $@ $<\n "
2021-12-19 23:53:01 +01:00
@$( CXX) $( CXXFLAGS) $( INC) -MMD -c -o $@ $< || exit 1
2022-02-10 08:46:39 +01:00
@printf " \033[1;92m $$ ( $( PROGRESS) ) $( P) \033[10D\033[5C-> \033[1;37m $@ \033[100D\033[38C\033[1;93m(\033[1;97m $$ (du -ah $@ | cut -f1)iB\033[1;93m) \033[92m(\033[97m $$ ( $( DATE_CMD) -d @ $$ (expr $$ ( $( DATE_CMD) +%s 2>/dev/null || echo " 0" ) - $$ {TSTAMP} 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo '')\033[92m)\033[0m\n "
2021-06-19 14:57:27 +02:00
2021-08-22 16:04:01 +02:00
#? Non-File Targets
2021-09-01 21:40:13 +02:00
.PHONY : all msg help pre