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