Skip to content

Commit

Permalink
add generic make file for cmd/*
Browse files Browse the repository at this point in the history
  • Loading branch information
dmke committed Feb 22, 2018
1 parent 54e8c63 commit bb7847f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
cmd/multiping/multiping
cmd/multiping/multiping.log
cmd/ping-test/ping-test
cmd/ping-test/ping-test.log
14 changes: 14 additions & 0 deletions cmd/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: all
all: $(TARGET)

$(TARGET):
go build -o $@
$(MAKE) setcap

.PHONY: setcap
setcap: $(TARGET)
sudo setcap cap_net_raw+ep $<

.PHONY: clean
clean:
rm -f $(TARGET) $(TARGET).log
11 changes: 1 addition & 10 deletions cmd/multiping/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
TARGET = multiping

.PHONY: all
all: $(TARGET)

$(TARGET):
go build -o $@
sudo setcap cap_net_raw+ep $<

.PHONY: clean
clean:
rm -f $(TARGET) $(TARGET).log
include ../common.mk

.PHONY: test
test: all
Expand Down
12 changes: 12 additions & 0 deletions cmd/ping-test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TARGET = ping-test

include ../common.mk

.PHONY: test
test: all
@truncate -s0 $(TARGET).log
@./$(TARGET) golang.org 2>>$(TARGET).log
@./$(TARGET) cloudflare.com 2>>$(TARGET).log

@echo error log:
@cat $(TARGET).log

0 comments on commit bb7847f

Please sign in to comment.