162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci# We need this for the "cc-option" macro. 362306a36Sopenharmony_ciinclude ../../build/Build.include 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciVERSION = 1.0 662306a36Sopenharmony_ci 762306a36Sopenharmony_ciBINDIR=usr/bin 862306a36Sopenharmony_ciWARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 962306a36Sopenharmony_cioverride CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS} 1062306a36Sopenharmony_ci# Add "-fstack-protector" only if toolchain supports it. 1162306a36Sopenharmony_cioverride CFLAGS+= $(call cc-option,-fstack-protector-strong) 1262306a36Sopenharmony_ciCC?= $(CROSS_COMPILE)gcc 1362306a36Sopenharmony_ciPKG_CONFIG?= $(CROSS_COMPILE)pkg-config 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cioverride CFLAGS+=-D VERSION=\"$(VERSION)\" 1662306a36Sopenharmony_ciTARGET=tmon 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciINSTALL_PROGRAM=install -m 755 -p 1962306a36Sopenharmony_ciDEL_FILE=rm -f 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci# Static builds might require -ltinfo, for instance 2262306a36Sopenharmony_ciifneq ($(findstring -static, $(LDFLAGS)),) 2362306a36Sopenharmony_ciSTATIC := --static 2462306a36Sopenharmony_ciendif 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciTMON_LIBS=-lm -lpthread 2762306a36Sopenharmony_ciTMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \ 2862306a36Sopenharmony_ci $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \ 2962306a36Sopenharmony_ci echo -lpanel -lncurses) 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_cioverride CFLAGS += $(shell $(PKG_CONFIG) --cflags $(STATIC) panelw ncursesw 2> /dev/null || \ 3262306a36Sopenharmony_ci $(PKG_CONFIG) --cflags $(STATIC) panel ncurses 2> /dev/null) 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciOBJS = tmon.o tui.o sysfs.o pid.o 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_citmon: $(OBJS) Makefile tmon.h 3762306a36Sopenharmony_ci $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_civalgrind: tmon 4062306a36Sopenharmony_ci sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciinstall: 4362306a36Sopenharmony_ci - $(INSTALL_PROGRAM) -D "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ciuninstall: 4662306a36Sopenharmony_ci $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciclean: 4962306a36Sopenharmony_ci rm -f $(TARGET) $(OBJS) 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cidist: 5262306a36Sopenharmony_ci git tag v$(VERSION) 5362306a36Sopenharmony_ci git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \ 5462306a36Sopenharmony_ci gzip > $(TARGET)-$(VERSION).tar.gz 55