36 lines
880 B
Makefile
36 lines
880 B
Makefile
CC = gcc
|
|
CFLAGS = -O2 -g -Wall
|
|
|
|
# Check if sys/sdt.h is available
|
|
SDT_CHECK := $(shell echo '\#include <sys/sdt.h>' | $(CC) -E - >/dev/null 2>&1 && echo yes)
|
|
|
|
ifeq ($(SDT_CHECK),yes)
|
|
CFLAGS += -DHAVE_SDT
|
|
SDT_STATUS = "USDT probes ENABLED"
|
|
else
|
|
SDT_STATUS = "USDT probes DISABLED (install systemtap-sdt-dev)"
|
|
endif
|
|
|
|
all: server
|
|
@echo $(SDT_STATUS)
|
|
|
|
server: server.c
|
|
$(CC) $(CFLAGS) -o $@ $<
|
|
|
|
# List the probes embedded in the binary
|
|
list-probes: server
|
|
@echo "Probes in binary (requires USDT support):"
|
|
readelf -n server 2>/dev/null | grep -A2 "stapsdt" || echo "No probes found"
|
|
|
|
# Alternative: use perf to list probes
|
|
perf-list: server
|
|
perf probe -x ./server --list 2>/dev/null || echo "No probes found or perf not supported"
|
|
|
|
clean:
|
|
rm -f server
|
|
|
|
install-deps:
|
|
sudo apt install systemtap-sdt-dev bpftrace
|
|
|
|
.PHONY: all clean list-probes perf-list install-deps
|