BUILDDIR := build DIRS := $(shell ls -d */) ifndef VERBOSE .SILENT: endif all: build test clean .PHONY: build build: echo "Building Go examples..." mkdir -p $(BUILDDIR) for dir in $(DIRS); do \ if [ ! -f "$$dir/main.go" ]; then \ continue; \ fi; \ pkg=$${dir%/}; \ go build -o $(BUILDDIR)/$$pkg ./$$dir/main.go; \ done .PHONY: test test: for bin in $(BUILDDIR)/*; do \ echo "\n"; \ $$bin; \ echo "\n"; \ done echo "All Go examples executed." .PHONY: clean clean: echo "Cleaning build directory..." rm -rf $(BUILDDIR)/*