build: add Makefile with install/uninstall targets

Swadhin Biswas committed 7 months ago
4c556c2
1 parent d99b2e4
commit 4c556c2
1 file changed
+49 -0
Showing 1 changed file+49-0
▼Makefile
+49-0
1
+PREFIX ?= /usr/local
2
+BINDIR ?= $(PREFIX)/bin
3
+CARGO ?= cargo
4
+
5
+.PHONY: all build install uninstall clean test help
6
+
7
+all: build
8
+
9
+build:
10
+ @echo "Building FetchX..."
11
+ $(CARGO) build --release
12
+
13
+install: build
14
+ @echo "Installing FetchX to $(BINDIR)..."
15
+ @mkdir -p $(DESTDIR)$(BINDIR)
16
+ @cp -p target/release/fetchx $(DESTDIR)$(BINDIR)/fetchx
17
+ @chmod 755 $(DESTDIR)$(BINDIR)/fetchx
18
+ @echo "FetchX installed successfully!"
19
+
20
+uninstall:
21
+ @echo "Uninstalling FetchX..."
22
+ @rm -f $(DESTDIR)$(BINDIR)/fetchx
23
+ @echo "FetchX uninstalled!"
24
+
25
+clean:
26
+ @echo "Cleaning build artifacts..."
27
+ $(CARGO) clean
28
+ @echo "Clean complete!"
29
+
30
+test:
31
+ @echo "Running tests..."
32
+ $(CARGO) test
33
+
34
+help:
35
+ @echo "FetchX Build System"
36
+ @echo ""
37
+ @echo "Available targets:"
38
+ @echo " build - Build FetchX in release mode"
39
+ @echo " install - Build and install to $(BINDIR)"
40
+ @echo " uninstall- Remove FetchX from $(BINDIR)"
41
+ @echo " clean - Remove build artifacts"
42
+ @echo " test - Run tests"
43
+ @echo " help - Show this help message"
44
+ @echo ""
45
+ @echo "Variables:"
46
+ @echo " PREFIX - Installation prefix (default: /usr/local)"
47
+ @echo " BINDIR - Binary directory (default: $(PREFIX)/bin)"
48
+ @echo " CARGO - Cargo command (default: cargo)"
49
+ @echo " DESTDIR - Destination directory for packaging"
0
50