Makefile: improve Makefile, sync from hurl Makefile - gopherproxy-c - Gopher HTTP proxy in C (CGI)
(HTM) git clone git://git.codemadness.org/gopherproxy-c
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit ec71ea5200ff67c6c121dca56c8e50772488163c
(DIR) parent 7f0e6929a919fc00a9af4b4858a4d43a89a25e05
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 3 Aug 2024 15:03:26 +0200
Makefile: improve Makefile, sync from hurl Makefile
Diffstat:
M Makefile | 52 +++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 10 deletions(-)
---
(DIR) diff --git a/Makefile b/Makefile
@@ -1,19 +1,51 @@
.POSIX:
-BIN = gopherproxy
-OBJ = $(BIN:=.o)
+NAME = gopherproxy
+VERSION = 0.1
+
+PREFIX = /usr/local
+BINDIR = ${PREFIX}/bin
+MANDIR = ${PREFIX}/man/man1
+
+GOPHER_CFLAGS = ${CFLAGS}
+GOPHER_LDFLAGS = ${LDFLAGS}
+GOPHER_CPPFLAGS = -D_DEFAULT_SOURCE -D_GNU_SOURCE -D_BSD_SOURCE
# build static: useful in www chroot.
-LDFLAGS += -static
-# Linux
-#CPPFLAGS += -D_DEFAULT_SOURCE
+GOPHER_LDFLAGS = ${LDFLAGS} -static
+
+SRC = gopherproxy.c
+OBJ = ${SRC:.c=.o}
+
+all: ${NAME}
-all: $(BIN)
+.c.o:
+ ${CC} ${GOPHER_CFLAGS} ${GOPHER_CPPFLAGS} -c $<
-$(BIN): $(OBJ)
- $(CC) $(OBJ) $(LDFLAGS) -o $@
+${OBJ}:
-$(OBJ): Makefile
+${NAME}: ${OBJ}
+ ${CC} -o $@ ${OBJ} ${GOPHER_LDFLAGS}
clean:
- rm -f $(BIN) $(OBJ)
+ rm -f ${NAME} ${OBJ} ${NAME}-${VERSION}.tar.gz
+
+install: all
+ mkdir -p "${DESTDIR}${BINDIR}"
+ cp -f ${NAME} "${DESTDIR}${BINDIR}"
+ chmod 755 "${DESTDIR}${BINDIR}/${NAME}"
+ mkdir -p "${DESTDIR}${MANDIR}"
+
+uninstall:
+ rm -f "${DESTDIR}${BINDIR}/${NAME}"
+
+dist: clean
+ rm -rf "${NAME}-${VERSION}"
+ mkdir -p ${NAME}-${VERSION}
+ cp -R README LICENSE Makefile \
+ ${NAME}.c ${NAME}-${VERSION}
+ tar cf - ${NAME}-${VERSION} | \
+ gzip -c > "${NAME}-${VERSION}.tar.gz"
+ rm -rf "${NAME}-${VERSION}"
+
+.PHONY: all clean dist install uninstall