summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: f0b9b8327c08af0e60d7910faa743f2837d29b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Math Utils Makefile
# Variables
CC = clang
CFLAGS = -std=c2x -Iinclude -Wall -Wextra
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1

# Default target
.PHONY: all
all: build bin/cdf bin/cumsum

# Directory creation targets
bin:
	@mkdir -p bin

build:
	@mkdir -p build

# Build targets
bin/cdf: bin src/cdf.c include/cdf.h
	$(CC) $(CFLAGS) src/cdf.c -o bin/cdf

bin/cumsum: bin src/cumsum.c include/cumsum.h
	$(CC) $(CFLAGS) src/cumsum.c -o bin/cumsum

# Clean target
.PHONY: clean
clean:
	@rm -rf bin build

# Install target
.PHONY: install
install: all
	@echo "Installing binaries to $(BINDIR)..."
	@mkdir -p $(BINDIR)
	@cp bin/cdf $(BINDIR)/
	@cp bin/cumsum $(BINDIR)/
	@echo "Installing man pages to $(MANDIR)..."
	@mkdir -p $(MANDIR)
	@cp doc/cdf.1 $(MANDIR)/
	@echo "Installation complete."

# Uninstall target
.PHONY: uninstall
uninstall:
	@echo "Removing binaries from $(BINDIR)..."
	@rm -f $(BINDIR)/cdf
	@rm -f $(BINDIR)/cumsum
	@echo "Removing man pages from $(MANDIR)..."
	@rm -f $(MANDIR)/cdf.1
	@echo "Uninstallation complete."

# Help target
.PHONY: help
help:
	@echo "Available targets:"
	@echo "  all       - Build all binaries (default)"
	@echo "  build     - Create build directories"
	@echo "  clean     - Remove build artifacts"
	@echo "  install   - Install binaries and man pages to system"
	@echo "  uninstall - Remove installed files from system"
	@echo "  help      - Show this help message"
	@echo ""
	@echo "Variables:"
	@echo "  PREFIX    - Installation prefix (default: /usr/local)"
	@echo "  CC        - Compiler (default: clang)"
	@echo "  CFLAGS    - Compiler flags"