From 445b6dcf26955f80ea7b0c1f708236a9fce4dd2a Mon Sep 17 00:00:00 2001 From: acidvegas Date: Sat, 7 Dec 2024 12:11:43 -0500 Subject: [PATCH] Added make file --- Makefile | 27 +++++++++++++++++++++++++++ README.md | 16 +++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4af5ae3 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +# Compiler settings +CC = gcc +CFLAGS = -Wall -Wextra -O2 +PREFIX = /usr/local + +# Files +PROG = shardz +SOURCES = shardz.c +OBJECTS = $(SOURCES:.c=.o) + +# Targets +all: $(PROG) + +$(PROG): $(OBJECTS) + $(CC) $(OBJECTS) $(CFLAGS) -o $(PROG) + +install: $(PROG) + install -d $(DESTDIR)$(PREFIX)/bin + install -m 755 $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG) + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(PROG) + +clean: + rm -f $(PROG) $(OBJECTS) + +.PHONY: all install uninstall clean \ No newline at end of file diff --git a/README.md b/README.md index 7c100b4..811581b 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,25 @@ Shardz is a lightweight C utility that shards *(splits)* the output of any proce - Load balancing input streams - Splitting any line-based input for distributed processing -## Building +## Building & Installation + +### Quick Build ```bash gcc -o shardz shardz.c ``` +### Using Make +```bash +# Build only +make + +# Build and install system-wide (requires root/sudo) +sudo make install + +# To uninstall +sudo make uninstall +``` + ## Usage ```bash some_command | shardz INDEX/TOTAL