/ Makefile
Makefile
  1  
  2  # Project variables
  3  PROJECT_NAME := prheri
  4  VERSION := 0.1.0
  5  CARGO := cargo
  6  CROSS := cross
  7  
  8  # Default target is the native build
  9  .PHONY: all
 10  all: build
 11  
 12  # Standard development build
 13  .PHONY: build
 14  build:
 15  	$(CARGO) build
 16  
 17  # Release build (optimized)
 18  .PHONY: release
 19  release:
 20  	$(CARGO) build --release
 21  
 22  # Run tests
 23  .PHONY: test
 24  test:
 25  	$(CARGO) test
 26  
 27  # Clean build artifacts
 28  .PHONY: clean
 29  clean:
 30  	$(CARGO) clean && rm -rf web/build
 31  
 32  # Install the application
 33  .PHONY: install
 34  install: release
 35  	cp target/release/$(PROJECT_NAME) /usr/local/bin/
 36  
 37  # Cross-compilation targets
 38  #
 39  # Linux targets
 40  .PHONY: linux-x86_64
 41  linux-x86_64:
 42  	$(CROSS) build --release --target x86_64-unknown-linux-gnu
 43  
 44  .PHONY: linux-aarch64
 45  linux-aarch64:
 46  	$(CROSS) build --release --target aarch64-unknown-linux-gnu
 47  
 48  .PHONY: linux-armv7
 49  linux-armv7:
 50  	$(CROSS) build --release --target armv7-unknown-linux-gnueabihf
 51  
 52  .PHONY: linux-i686
 53  linux-i686:
 54  	$(CROSS) build --release --target i686-unknown-linux-gnu
 55  
 56  .PHONY: linux-aarch64-musl
 57  linux-aarch64-musl:
 58  	$(CROSS) build --release --target aarch64-unknown-linux-musl 
 59  
 60  .PHONY: linux-armv7-musl
 61  linux-armv7-musl:
 62  	$(CROSS) build --release --target armv7-unknown-linux-musleabihf
 63  
 64  .PHONY: linux-x86_64-musl
 65  linux-x86_64-musl:
 66  	$(CROSS) build --release --target x86_64-unknown-linux-musl
 67  
 68  .PHONY: linux-i686-musl
 69  linux-i686-musl:
 70  	$(CROSS) build --release --target i686-unknown-linux-musl
 71  
 72  
 73  # Build all supported targets
 74  .PHONY: all-targets
 75  all-targets: linux-x86_64 linux-aarch64 linux-armv7 linux-i686 linux-aarch64-musl linux-armv7-musl linux-x86_64-musl linux-i686-musl
 76  
 77  # Install cross-compilation toolchains
 78  .PHONY: install-cross
 79  install-cross:
 80  	cargo install cross --git https://github.com/cross-rs/cross
 81  
 82  .PHONY: docker
 83  docker:
 84  	docker build -t $(PROJECT_NAME) .
 85  
 86  .PHONY: docker-all
 87  docker-all:
 88  	docker buildx build -t $(PROJECT_NAME) --platform linux/amd64,linux/arm64,linux/386,linux/arm/v7 .
 89  
 90  .PHONY: web
 91  web:
 92  	cd web && bun run build && mkdir -p build/static && cp build/index.html build/auth.html build/favicon.png build/Inter-Regular.woff build/Inter-Regular.woff2 build/RobotoMono-Regular.woff build/RobotoMono-Regular.woff2 build/static
 93  
 94  .PHONY: web-setup
 95  web-setup:
 96  	cd web && bun install
 97  
 98  # Help
 99  .PHONY: help
100  help:
101  	@echo "$(PROJECT_NAME) v$(VERSION) Makefile help:"
102  	@echo ""
103  	@echo "Standard targets:"
104  	@echo "  all          Default target, builds in debug mode"
105  	@echo "  build        Build in debug mode"
106  	@echo "  release      Build with optimizations"
107  	@echo "  run          Build and run the project"
108  	@echo "  test         Run tests"
109  	@echo "  clean        Remove build artifacts"
110  	@echo "  install      Install release binary to /usr/local/bin"
111  	@echo ""
112  	@echo "Cross-compilation targets:"
113  	@echo "  linux-x86_64       64-bit Linux (x86_64)"
114  	@echo "  linux-aarch64      64-bit ARM Linux"
115  	@echo "  linux-armv7        32-bit ARM Linux"
116  	@echo "  linux-i686         32-bit Linux (x86)"
117  	@echo "  linux-aarch64-musl 64-bit ARM Linux (musl)"
118  	@echo "  linux-armv7-musl   32-bit ARM Linux (musl)"
119  	@echo "  linux-x86_64-musl  64-bit Linux (x86_64, musl)"
120  	@echo "  linux-i686-musl    32-bit Linux (x86, musl)"
121  	@echo ""
122  	@echo "Special targets:"
123  	@echo "  all-targets        Build all supported targets"
124  	@echo "  install-cross      Install all cross-compilation toolchains"
125  	@echo "  docker             Build a Docker image"
126  	@echo "  docker-all         Build a multi-arch Docker image"
127  	@echo "  web                Build the web frontend"
128  	@echo "  web-setup          Install web dependencies"
129  	@echo ""
130  	@echo "Miscellaneous:"
131  	@echo "  help               Show this help message"
132  	@echo ""