summaryrefslogtreecommitdiffstats
path: root/tools/rmtop/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tools/rmtop/Makefile')
-rw-r--r--tools/rmtop/Makefile46
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/rmtop/Makefile b/tools/rmtop/Makefile
new file mode 100644
index 0000000..3a5cd67
--- /dev/null
+++ b/tools/rmtop/Makefile
@@ -0,0 +1,46 @@
+# rmtop - read-only ncurses GPU dashboard (Open-IOV).
+#
+# Reuses rmtool's RM query layer (../rmtool/src) so there is exactly one
+# ioctl implementation. Requires ncursesw; falls back to -lncursesw when
+# pkg-config is unavailable.
+CC ?= gcc
+CFLAGS ?= -O2 -Wall -Wextra
+RMTOOL = ../rmtool
+CPPFLAGS += -Iinclude -I$(RMTOOL)/include
+NCURSES_CFLAGS := $(shell pkg-config --cflags ncursesw 2>/dev/null)
+NCURSES_LIBS := $(shell pkg-config --libs ncursesw 2>/dev/null || echo -lncursesw)
+CFLAGS += $(NCURSES_CFLAGS)
+
+OBJS = src/main.o src/panel.o
+SHARED = build/rm_api.o build/query.o build/output.o
+PREFIX ?= /usr/local
+
+all: rmtop
+
+rmtop: $(OBJS) $(SHARED)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(NCURSES_LIBS)
+
+build:
+ @mkdir -p build
+
+build/rm_api.o: $(RMTOOL)/src/rm_api.c $(RMTOOL)/include/rm_api.h | build
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+build/query.o: $(RMTOOL)/src/query.c $(RMTOOL)/include/rm_api.h $(RMTOOL)/include/rmtool.h | build
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+build/output.o: $(RMTOOL)/src/output.c $(RMTOOL)/include/rmtool.h | build
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+src/%.o: src/%.c include/rmtop.h $(RMTOOL)/include/rm_api.h $(RMTOOL)/include/rmtool.h | build
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+install: rmtop
+ install -d $(DESTDIR)$(PREFIX)/bin
+ install -m 0755 rmtop $(DESTDIR)$(PREFIX)/bin/rmtop
+
+clean:
+ rm -f $(OBJS) $(SHARED) rmtop
+ rmdir build 2>/dev/null || true
+
+.PHONY: all install clean