]> git.armaanb.net Git - sic.git/commitdiff
Makefile improvements
authorHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 5 May 2021 23:39:46 +0000 (01:39 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 5 May 2021 23:45:51 +0000 (01:45 +0200)
- Respect system/port flags by default.
- Be verbose and do not hide output. This makes it easier to debug a build.
- Remove the "options" target.
- Remove config.mk: just edit the Makefile or override flags if needed.
- dist: no need to clean before packaging files.
- dist: pipe directly to gzip without an intermediate tarball file.
- Define and add a POSIX marker to the Makefile.

Makefile
README
config.mk [deleted file]

index bbea026d2427c60cb2324f8bb5901473d08e3d83..58efc9f66551bc5d14be9ce5cb91c2c3deefd8ec 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,58 +1,59 @@
-# sic - simple irc client
+.POSIX:
 
-include config.mk
+NAME = sic
+VERSION = 1.3
 
-SRC = sic.c
+# paths
+PREFIX = /usr/local
+MANPREFIX = ${PREFIX}/share/man
+
+# use system flags.
+SIC_CFLAGS = ${CFLAGS}
+SIC_LDFLAGS = ${LDFLAGS}
+SIC_CPPFLAGS = ${LDFLAGS} -DVERSION=\"${VERSION}\" -D_GNU_SOURCE
+
+BIN = sic
+SRC = ${BIN:=.c}
 OBJ = ${SRC:.c=.o}
+MAN1 = ${BIN:=.1}
 
-all: options sic
+all: ${BIN}
 
-options:
-       @echo sic build options:
-       @echo "CFLAGS   = ${CFLAGS}"
-       @echo "LDFLAGS  = ${LDFLAGS}"
-       @echo "CC       = ${CC}"
+${BIN}: ${@:=.o}
 
-.c.o:
-       @echo CC $<
-       @${CC} -c ${CFLAGS} $<
+${OBJ}: config.h strlcpy.c util.c
 
-${OBJ}: config.h config.mk strlcpy.c util.c
+.o:
+       ${CC} -o $@ $< ${SIC_LDFLAGS}
 
-config.h:
-       @echo creating $@ from config.def.h
-       @cp config.def.h $@
+.c.o:
+       ${CC} -c ${SIC_CFLAGS} ${SIC_CPPFLAGS} -o $@ -c $<
 
-sic: ${OBJ}
-       @echo CC -o $@
-       @${CC} -o $@ ${OBJ} ${LDFLAGS}
+config.h:
+       cp config.def.h $@
 
 clean:
-       @echo cleaning
-       @rm -f sic ${OBJ} sic-${VERSION}.tar.gz
+       rm -f ${BIN} ${OBJ} "${NAME}-${VERSION}.tar.gz"
 
-dist: clean
-       @echo creating dist tarball
-       @mkdir -p sic-${VERSION}
-       @cp -R LICENSE Makefile README arg.h config.def.h config.mk sic.1 sic.c util.c strlcpy.c sic-${VERSION}
-       @tar -cf sic-${VERSION}.tar sic-${VERSION}
-       @gzip sic-${VERSION}.tar
-       @rm -rf sic-${VERSION}
+dist:
+       mkdir -p "${NAME}-${VERSION}"
+       cp -fR LICENSE Makefile README arg.h config.def.h \
+               ${MAN1} ${SRC} util.c strlcpy.c "${NAME}-${VERSION}"
+       tar -cf - "${NAME}-${VERSION}" | \
+               gzip -c > "${NAME}-${VERSION}.tar.gz"
+       rm -rf "${NAME}-${VERSION}"
 
 install: all
-       @echo installing executable file to ${DESTDIR}${PREFIX}/bin
-       @mkdir -p ${DESTDIR}${PREFIX}/bin
-       @cp -f sic ${DESTDIR}${PREFIX}/bin
-       @chmod 755 ${DESTDIR}${PREFIX}/bin/sic
-       @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
-       @mkdir -p ${DESTDIR}${MANPREFIX}/man1
-       @sed "s/VERSION/${VERSION}/g" < sic.1 > ${DESTDIR}${MANPREFIX}/man1/sic.1
-       @chmod 644 ${DESTDIR}${MANPREFIX}/man1/sic.1
+       mkdir -p ${DESTDIR}${PREFIX}/bin
+       cp -f ${BIN} "${DESTDIR}${PREFIX}/bin"
+       chmod 755 "${DESTDIR}${PREFIX}/bin/${BIN}"
+       mkdir -p "${DESTDIR}${MANPREFIX}/man1"
+       sed "s/VERSION/${VERSION}/g" < ${MAN1} > "${DESTDIR}${MANPREFIX}/man1/${MAN1}"
+       chmod 644 "${DESTDIR}${MANPREFIX}/man1/${MAN1}"
 
 uninstall:
-       @echo removing executable file from ${DESTDIR}${PREFIX}/bin
-       @rm -f ${DESTDIR}${PREFIX}/bin/sic
-       @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
-       @rm -f ${DESTDIR}${MANPREFIX}/man1/sic.1
+       rm -f \
+               "${DESTDIR}${PREFIX}/bin/${BIN}"\
+               "${DESTDIR}${MANPREFIX}/man1/${MAN1}"
 
-.PHONY: all options clean dist install uninstall
+.PHONY: all clean dist install uninstall
diff --git a/README b/README
index ee5ecacc5c90e24badab8742b910f896a84cc89a..efeb5ac0a54c636d1f8f5f7a256f4f59f3acab7d 100644 (file)
--- a/README
+++ b/README
@@ -8,13 +8,14 @@ different channel buffers, that's actually a feature.
 
 Installation
 ------------
-Edit config.mk to match your local setup. sic is installed into
-/usr/local by default.
+Edit the Makefile or override the flags to match your local setup. sic is
+installed into /usr/local by default.
 
 Afterwards enter the following command to build and install sic 
 (if necessary as root):
 
-    $ make clean install
+       $ make
+       # make install
 
 
 Running sic
diff --git a/config.mk b/config.mk
deleted file mode 100644 (file)
index 87395f4..0000000
--- a/config.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# sic version
-VERSION = 1.3
-
-# Customize below to fit your system
-
-# paths
-PREFIX = /usr/local
-MANPREFIX = ${PREFIX}/share/man
-
-# includes and libs
-INCS = -I. -I/usr/include
-LIBS = -L/usr/lib -lc
-
-# flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" -D_GNU_SOURCE
-CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
-LDFLAGS = -s ${LIBS}
-
-# compiler and linker
-CC = cc