Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created November 21, 2009 21:55
Show Gist options
  • Save jakubkulhan/240299 to your computer and use it in GitHub Desktop.
Save jakubkulhan/240299 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
fmt.Println("hello, world!")
}
TARGET=$(notdir $(shell pwd))
MAGIC=$(shell (([ "$(GOARCH)" == "amd64" ] && echo 6) || ([ "$(GOARCH)" == "arm" ] && echo 5)) || echo 8)
all:
@for dir in `find * -type d`; do \
go=$$(find "$$dir" -maxdepth 1 -name "*.go"); \
if [ ! -z "$$go" ]; then \
echo "- $$dir: $$go"; \
$(MAGIC)g -I. -o _go_.8 $$go; \
rm -f $$dir.a; \
gopack grc $$dir.a _go_.8; \
fi \
done
@if [ -f 'main.go' ]; then \
$(MAGIC)g -I. -o _go_.8 main.go; \
$(MAGIC)l -o $(TARGET) _go_.8; \
fi
@rm -f _go_.8
clean:
@rm -f _go_.8 `find * -name "*.a"` $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment