FILTER=
PARAMS=
# Set debug
ifeq ($(debug),1)
PARAMS+=debug=1
endif

# Set filter pid
ifdef pid
	ifneq ($(pid),0)
		PARAMS+=pid=$(pid)
		FILTER=FILTER_PID=${pid}
	endif
endif

# Set send data
ifeq ($(send),1)
FILTER+= SEND=1
endif

# Set eBPF build kernel
ifdef kernel
	PARAMS+= kernel=${kernel}
endif

all: c-build go-build

build:
	CGO_ENABLED=1 go build -gcflags="all=-N -l" -buildvcs=false -o dist/package_dir/bin/euspace
c:
	docker exec -it 62d0676aa0b7 sh -c 'cd /opt/github/euspace/ebpftracer && make all ${PARAMS}'
c-build: c

go-build:
	docker exec -it 62d0676aa0b7 bash -c 'cd /opt/github/euspace && source ~/.g/env && make build'
go: go-build run

run:
	ssh root@10.211.55.27 'cd /opt/github/euspace && CONFIG_ENDPOINT=10.0.16.250:18080 && TRACES_ENDPOINT=http://10.0.16.250:18080/docp/api/v2/data/receive ${FILTER} ./euspace --listen="0.0.0.0:8123"'