diff --git a/Makefile b/Makefile index 27bf1b7..7e9e210 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ +GOROOT := $(shell go env GOPATH) + build: go build install: build go install - chmod +x bin/* - cp bin/* /usr/local/bin + ln -f -s $(GOROOT)/bin/gowllvm $(GOROOT)/bin/gowclang + ln -f -s $(GOROOT)/bin/gowllvm $(GOROOT)/bin/gowclang++ + ln -f -s $(GOROOT)/bin/gowllvm $(GOROOT)/bin/gowextract diff --git a/bin/gowclang b/bin/gowclang deleted file mode 100755 index a9ba430..0000000 --- a/bin/gowclang +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec gowllvm compile clang "$@" diff --git a/bin/gowclang++ b/bin/gowclang++ deleted file mode 100755 index d06ef09..0000000 --- a/bin/gowclang++ +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec gowllvm compile clang++ "$@" diff --git a/bin/gowextract b/bin/gowextract deleted file mode 100755 index f7ecb6e..0000000 --- a/bin/gowextract +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec gowllvm extract "$@" diff --git a/compiler.go b/compiler.go index 47a6a9d..46169ec 100644 --- a/compiler.go +++ b/compiler.go @@ -11,17 +11,12 @@ import ( "io" ) -func compile(args []string) { - if len(args) < 1 { - log.Fatal("You must precise which compiler to use.") - } - var compilerName = args[0] +func compile(args []string, compilerName string) { var compilerExecName = getCompilerExecName(compilerName) var configureOnly bool if os.Getenv(CONFIGURE_ONLY) != "" { configureOnly = true } - args = args[1:] var pr = parse(args) // If configure only is set, try to execute normal compiling command then exit silently diff --git a/gowllvm.go b/gowllvm.go index 7c27d05..7d2661e 100644 --- a/gowllvm.go +++ b/gowllvm.go @@ -8,18 +8,15 @@ import( func main() { // Parse command line var args = os.Args - if len(args) < 2 { - log.Fatal("Not enough arguments.") - } - var modeFlag = args[1] - args = args[2:] + var callerName = args[0] + args = args[1:] - switch modeFlag { - case "compile": - // Call main compiling function with args - compile(args) - case "extract": - // Call main extracting function with args + switch callerName { + case "gowclang": + compile(args, "clang") + case "gowclang++": + compile(args, "clang++") + case "gowextract": extract(args) default: log.Fatal("You should call gowllvm with a valid mode.")