From: Huck Boles Date: Tue, 17 Jan 2023 17:19:41 +0000 (-0600) Subject: README and Makefile cleanup X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=b360986fba0ac0c9db99b01111d0780c6203617d;p=base.git README and Makefile cleanup --- diff --git a/Makefile b/Makefile index 6105579..38cc393 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,57 @@ -SHELL = /bin/bash PROG = base -PREFIX = /usr -DESTDIR = /bin +VERSION ?= 0.0.1 + +SHELL = /bin/bash + +DESTDIR ?= +PREFIX ?= $(DESTDIR)/usr +BINDIR ?= $(PREFIX)/bin +LIBDIR ?= $(PREFIX)/lib +MANDIR ?= $(PREFIX)/share/man/man1 + +FILES ?= $(wildcard *.c) +HEADERS ?= $(wildcard *.h) +OBJECTS ?= $(wildcard *.o) + +CC ?= gcc +CFLAGS += -O2 -std=c17 -pipe +WARNINGS ?= -Werror -Wall -Wextra -Wpedantic -Wno-unused +CPPFLAGS += -I . +LDFLAGS += -L . +LDLIBS += -lm +ALL_FLAGS = $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(LDFLAGS) $(LDLIBS) + +.PHONY: all +all: $(FILES) $(HEADERS) + $(CC) $(FILES) $(ALL_FLAGS) -o $(PROG) + +.PHONY: install +install: $(PROG) $(PROG).1 + install -CDTm 755 $(PROG) $(BINDIR)/$(PROG) + [[ -e $(PROG).1]] && gzip -fc $(PROG).1 > $(MANDIR)/$(PROG).1.gz + +.PHONY: tar +tar: $(FILES) $(HEADERS) $(PROG).1 Makefile README LICENSE + tar -g gzip -cf $(PROG)-$(VERSION).tar.gz $(FILES) $(HEADERS) $(PROG).1 Makefile README LICENSE + +.PHONY: compile +compile: $(FILES) + $(CC) $(FILES) $(ALL_FLAGS) -c -CFILE = main.c function.c -HEADER = base.h +.PHONY: link +link: $(OBJECTS) + $(CC) $(OBJECTS) $(ALL_FLAGS) -o $(PROG) -header: ${HEADER} - gcc ${CFILE} ${HEADER} -lm -Wall -o ${PROG} +.PHONY: assemble +assemble: $(FILES) + $(CC) $(FILES) $(ALL_FLAGS) -S -install: ${CFILE} ${HEADER} - gcc ${CFILE} ${HEADER} -lm -Wall -o ${PREFIX}${DESTDIR}/${PROG} +.PHONY: debug +debug: $(FILES) + $(CC) $(FILES) $(ALL_FLAGS) -ggdb3 -Og -o $(PROG) -debug: ${CFILE} - gcc ${CFILE} -lm -Wall -g -o ${PROG} +.PHONY: clean +clean: + [[ -f $(BINDIR)/$(PROG) ]] && rm $(BINDIR)/$(PROG) + [[ -f $(PROG) ]] && rm $(PROG) -clean: - rm ${PREFIX}${DESTDIR}/${PROG} diff --git a/README.md b/README.md deleted file mode 100644 index 81f2956..0000000 --- a/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# base -CLI utility to convert numbers between arbitrary bases. - -base converts from base 10 to binary if called with no options. Input and output base can be specified with -i and -o respectively, ranging from 2-62. If no number is given, base will prompt for a number, or convert stdin if given. -If not specified, base will print binary numbers as unsigned longs with 64 bits, hexadecimal numbers with a leading 0x, octal and any other number with no leading zeroes. - -## Usage: -Print binary representation: - $ base 555 - 00000000 00000000 00000000 00000000 00000000 00000000 00000010 00101011 - -Print a number in hexadecimal: - $ base -o 16 1234 - 0x4d2 - -Print an octal representation of a base 12 number - $ base -o 8 -i 12 5a - 106 - - Convert stdin to base 8 - $ echo "123456" | base -o 8 - 361100 - -## Installation : -Download .tar.gz and decompress - $ curl "https://download.huck.website/base-[VERSION].tar.gz" - $ tar -xzvf base-[VERSION].tar.gz - -Build base from source - $ cd base-[VERSION] - $ sudo make install -