add Makefile

This commit is contained in:
Benson Wong
2024-10-04 11:07:00 -07:00
parent bfdba43bd8
commit aaca9d889b
2 changed files with 28 additions and 1 deletions

27
Makefile Normal file
View File

@@ -0,0 +1,27 @@
# Define variables for the application
APP_NAME = llamagate
BUILD_DIR = build
# Default target: Builds binaries for both OSX and Linux
all: mac linux
# Clean build directory
clean:
rm -rf $(BUILD_DIR)
# Build OSX binary
mac:
@echo "Building Mac binary..."
GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(APP_NAME)-darwin-arm64
# Build Linux binary
linux:
@echo "Building Linux binary..."
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64
# Ensure build directory exists
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Phony targets
.PHONY: all clean osx linux

View File

@@ -25,7 +25,7 @@ func main() {
proxyManager := proxy.New(config) proxyManager := proxy.New(config)
http.HandleFunc("/", proxyManager.HandleFunc) http.HandleFunc("/", proxyManager.HandleFunc)
fmt.Println("Proxy server started on :8080") fmt.Println("Proxy server started on " + *listenStr)
if err := http.ListenAndServe(*listenStr, nil); err != nil { if err := http.ListenAndServe(*listenStr, nil); err != nil {
fmt.Printf("Error starting server: %v\n", err) fmt.Printf("Error starting server: %v\n", err)
os.Exit(1) os.Exit(1)