cstring

Lightweight string library for C
git clone git://git.christosmarg.xyz/cstring.git
Log | Files | Refs | README | LICENSE

commit c333ea917961b609f6b85a36606922b7280498b4
parent 3627920b7d721f4a228c8e519af04607bacb7564
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sun, 20 Sep 2020 21:50:49 +0300

standardized Makefile

Diffstat:
MMakefile | 33++++++++++++++++++++++-----------
Mcstring.c | 2+-
2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,7 +1,11 @@ -TARGET = cstring +BIN = cstring +MAN1 = ${BIN}.1 +PREFIX = /usr/local +MAN_DIR = ${PREFIX}/man/man1 +BIN_DIR = ${PREFIX}bin -SRC = $(wildcard *.c) -OBJ = $(SRC:%.c=%.o) +SRC = ${wildcard *.c} +OBJ = ${SRC:%.c=%.o} CC = gcc CPPFLAGS += -Iinclude -pedantic @@ -9,21 +13,28 @@ CFLAGS += -Wall -std=c99 -O3 LDFLAGS += -Llib #LDLIBS += -MOVE = mv -MKDIR_P = mkdir -p +CP=cp -f +MKDIR = mkdir -p .PHONY: all clean -all: $(TARGET) +all: ${BIN} -$(TARGET): $(OBJ) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ +${BIN}: ${OBJ} + ${CC} ${LDFLAGS} $^ ${LDLIBS} -o $@ %.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@ run: - ./$(TARGET) + ./${BIN} + +#install: all + #${MKDIR} ${DESTDIR}${BIN_DIR} + #${CP} ${BIN} ${BIN_DIR} + #${MKDIR} ${DESTDIR}${MAN_DIR} + #${CP} ${MAN1} ${DESTDIR}${MAN_DIR} + #chmod 644 ${DESTDIR}${MAN_DIR}/${MAN1} clean: - $(RM) $(OBJ) $(TARGET) + ${RM} ${OBJ} ${BIN} diff --git a/cstring.c b/cstring.c @@ -111,7 +111,7 @@ cstring_front(const cstring *cs) char cstring_back(const cstring *cs) { - return (!cstring_empty(cs) ? cs->str[cs->len-1] : cs->str[0]); + return (!cstring_empty(cs) ? cs->str[cs->len - 1] : cs->str[0]); } int