From 44aa2be93d86e5bac3768962f4fea14a4b3778d3 Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Fri, 19 Sep 2025 16:53:49 -0400 Subject: Makefile updates --- Makefile | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bcfa271..f0b9b83 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,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 -.PHONY: build +# Directory creation targets +bin: + @mkdir -p bin + build: - -mkdir bin - -mkdir build - -bin/cdf: build src/cdf.c include/cdf.h - clang -std=c2x -Iinclude src/cdf.c -o bin/cdf + @mkdir -p build + +# Build targets +bin/cdf: bin src/cdf.c include/cdf.h + $(CC) $(CFLAGS) src/cdf.c -o bin/cdf -bin/cumsum: src/cumsum.c include/cumsum.h - clang -std=c2x -Iinclude src/cumsum.c -o bin/cumsum +bin/cumsum: bin src/cumsum.c include/cumsum.h + $(CC) $(CFLAGS) src/cumsum.c -o bin/cumsum +# Clean target .PHONY: clean clean: - -rm -r bin - -rm -r build + @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" -- cgit v1.2.3