commit 7ce00b93730a7021d0cc60d3e9eb63c8120b7897
Author: rani <clagv.randomgames@gmail.com>
Date: Thu Jan 12 20:10:57 2023 +0000
diff --git a/Makefile b/Makefile
index 641ef5e..3ba5fa3 100644
--- a/Makefile
+++ b/Makefile
@@ -142 +130 @@
-SOURCES ?= src/*.c
-HEADERS ?= include/*.h
-INCLUDEDIR ?= include
-DEST ?= cscroll
+.POSIX:
-ICONS ?= 1
+include config.mk
-CC ?= cc
-CFLAGS += -DICONS=$(ICONS) -Wall -Wextra -pedantic $(shell pkg-config --cflags ncurses)
-
-UNAME := $(shell uname)
-$(shell pkg-config --exists ncursesw)
-ifeq ($(.SHELLSTATUS),0)
- NCURSES := ncursesw
-else
- NCURSES := ncurses
-endif
+BIN = cscroll
+SRC = src/commands.c src/dir.c src/hash.c src/io.c src/main.c \
+ src/opts.c src/type.c src/var.c
+OBJ = ${SRC:.c=.o}
-LIBS += $(shell pkg-config --libs $(NCURSES)) -lm
-ifneq ($(UNAME), Darwin)
- LIBS += -ltinfo
-endif
+CC ?= cc
-PREFIX ?= /usr/local
+all: ${BIN}
-all: cscroll
+${BIN}: ${OBJ}
+ ${CC} ${LDFLAGS} ${OBJ} -o $@
-cscroll: $(SOURCES) $(HEADERS)
- $(CC) -I$(INCLUDEDIR) -o $(DEST) $(SOURCES) $(CFLAGS) $(LIBS)
+%.o:
+ ${CC} -c ${CFLAGS} $<
-debug: $(SOURCES) $(HEADERS)
- $(CC) -I$(INCLUDEDIR) -DDEBUG -o $(DEST) $(SOURCES) $(CFLAGS) $(LIBS) -g
+clean:
+ rm -f ${BIN} ${OBJ}
install: all
- install -D $(DEST) $(DESTDIR)$(PREFIX)/bin/$(DEST)
+ mkdir -p ${DESTDIR}${PREFIX}/bin
+ install -Dm755 ${BIN} ${DESTDIR}${PREFIX}/bin/${BIN}
uninstall:
- rm -f $(DESTDIR)$(PREFIX)/bin/$(DEST)
-
-clean:
- rm -f $(DEST)
+ rm -f ${DESTDIR}${PREFIX}/bin/${BIN}
+.PHONY: all clean install uninstall
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..eee5652
--- /dev/null
+++ b/config.mk
@@ -00 +18 @@
+PREFIX = /usr/local
+
+ICONS = 1
+CFLAGS = -Iinclude -Wall -Wextra -pedantic -DICONS=${ICONS}
+
+NCURSES = ncurses`pkg-config --exists ncursesw && echo w`
+TINFO = `[ "$$(uname)" = Darwin ] && echo -ltinfo`
+LDFLAGS = -l${NCURSES} ${TINFO}