Skip to content

Commit

Permalink
Merge pull request #42 from jmpsec/makefile-static
Browse files Browse the repository at this point in the history
Compile osctrl statically
  • Loading branch information
javuto authored Feb 25, 2020
2 parents bf10f84 + 4f5bb97 commit 8d1b0eb
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ DEST ?= /opt/osctrl

OUTPUT = bin

.PHONY: build clean tls admin cli api
STATIC_ARGS = -ldflags "-linkmode external -extldflags -static"

.PHONY: build static clean tls admin cli api

# Build code according to caller OS and architecture
build:
Expand All @@ -31,22 +33,45 @@ build:
make api
make cli

# Build everything statically
static:
make tls-static
make admin-static
make api-static
make cli-static

# Build TLS endpoint
tls:
go build -o $(OUTPUT)/$(TLS_NAME) $(TLS_CODE)

# Build TLS endpoint statically
tls-static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(TLS_NAME) -a $(TLS_CODE)

# Build Admin UI
admin:
go build -o $(OUTPUT)/$(ADMIN_NAME) $(ADMIN_CODE)

# Build Admin UI statically
admin-static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(ADMIN_NAME) -a $(ADMIN_CODE)

# Build API
api:
go build -o $(OUTPUT)/$(API_NAME) $(API_CODE)

# Build API statically
api-static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(API_NAME) -a $(API_CODE)

# Build the CLI
cli:
go build -o $(OUTPUT)/$(CLI_NAME) $(CLI_CODE)

# Build the CLI statically
cli-static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(CLI_NAME) -a $(CLI_CODE)

# Delete all compiled binaries
clean:
rm -rf $(OUTPUT)/$(TLS_NAME)
Expand Down

0 comments on commit 8d1b0eb

Please sign in to comment.