github.com/aitjcize/Overlord@v0.0.0-20240314041920-104a804cf5e8/Makefile (about)

     1  # Copyright 2015 The Chromium OS Authors. All rights reserved.
     2  # Use of this source code is governed by a BSD-style license that can be
     3  # found in the LICENSE file.
     4  
     5  GO=go
     6  BIN=$(CURDIR)/bin
     7  BUILD=$(CURDIR)/build
     8  DEPS?=true
     9  STATIC?=false
    10  LDFLAGS=
    11  
    12  ifeq ($(STATIC), true)
    13  	LDFLAGS=-a -tags netgo -installsuffix netgo \
    14  		-ldflags '-extldflags "-static"'
    15  endif
    16  
    17  all: ghost overlordd
    18  
    19  deps:
    20  	mkdir -p $(BIN)
    21  	if $(DEPS); then \
    22  		cd $(CURDIR)/overlord; \
    23  		$(GO) get -d .; \
    24  	fi
    25  
    26  overlordd: deps
    27  	GOBIN=$(BIN) $(GO) install $(LDFLAGS) $(CURDIR)/cmd/$@
    28  	rm -f $(BIN)/app
    29  	ln -s $(CURDIR)/overlord/app $(BIN)
    30  
    31  ghost: deps
    32  	GOBIN=$(BIN) $(GO) install $(LDFLAGS) $(CURDIR)/cmd/$@
    33  
    34  py-bin:
    35  	mkdir -p $(BUILD)
    36  	# Create virtualenv environment
    37  	rm -rf $(BUILD)/.venv
    38  	python -m venv $(BUILD)/.venv
    39  	# Build ovl binary with pyinstaller
    40  	cd $(BUILD); \
    41  	. $(BUILD)/.venv/bin/activate; \
    42  	pip install -r $(CURDIR)/requirements.txt; \
    43  	pip install pyinstaller; \
    44  	pyinstaller --onefile $(CURDIR)/scripts/ovl.py; \
    45  	pyinstaller --onefile $(CURDIR)/scripts/ghost.py
    46  	# Move built binary to bin
    47  	mv $(BUILD)/dist/ovl $(BIN)/ovl.py.bin
    48  	mv $(BUILD)/dist/ghost $(BIN)/ghost.py.bin
    49  
    50  clean:
    51  	rm -rf $(BIN)/ghost $(BIN)/overlordd $(BUILD) \
    52  		$(BIN)/ghost.py.bin $(BIN)/ovl.py.bin