iCopyediting. - bitreich-style - Style guide for programmers. Err bitreich.org 70
hgit clone git://bitreich.org/bitreich-style URL:git://bitreich.org/bitreich-style bitreich.org 70
1Log /scm/bitreich-style/log.gph bitreich.org 70
1Files /scm/bitreich-style/files.gph bitreich.org 70
1Refs /scm/bitreich-style/refs.gph bitreich.org 70
1Tags /scm/bitreich-style/tag bitreich.org 70
1README /scm/bitreich-style/file/README.md.gph bitreich.org 70
1LICENSE /scm/bitreich-style/file/LICENSE.gph bitreich.org 70
i--- Err bitreich.org 70
1commit 9b48be81f3efe169f41975d6202ec4ed0651895c /scm/bitreich-style/commit/9b48be81f3efe169f41975d6202ec4ed0651895c.gph bitreich.org 70
1parent 4630281bedde87837f7c5ae63ffd10483a9d206e /scm/bitreich-style/commit/4630281bedde87837f7c5ae63ffd10483a9d206e.gph bitreich.org 70
hAuthor: Benjamin Neumann <btdn@lab-btdn.com> URL:mailto:btdn@lab-btdn.com bitreich.org 70
iDate: Wed, 10 Jun 2020 09:11:05 -0500 Err bitreich.org 70
i Err bitreich.org 70
iCopyediting. Err bitreich.org 70
i Err bitreich.org 70
iDiffstat: Err bitreich.org 70
i M c/makefile-guideline.txt | 43 ++++++++++++++++--------------- Err bitreich.org 70
i Err bitreich.org 70
i1 file changed, 22 insertions(+), 21 deletions(-) Err bitreich.org 70
i--- Err bitreich.org 70
1diff --git a/c/makefile-guideline.txt b/c/makefile-guideline.txt /scm/bitreich-style/file/c/makefile-guideline.txt.gph bitreich.org 70
i@@ -1,14 +1,14 @@ Err bitreich.org 70
i-Title: Guidelins for writing simple portable Makefiles Err bitreich.org 70
i+Title: Guidelines for writing simple portable Makefiles Err bitreich.org 70
i Err bitreich.org 70
i Err bitreich.org 70
i-This page describes some guidelines and good practises for writing simple Err bitreich.org 70
i-portable POSIX Makefiles. It assumes a basic level of understanding in writing Err bitreich.org 70
i-Makefiles already. It will focus on projects that use the C programming Err bitreich.org 70
i+This page describes some guidelines and good practices for writing simple, Err bitreich.org 70
i+portable POSIX Makefiles. It assumes a basic level of understanding in Err bitreich.org 70
i+writing Makefiles and focuses on projects that use the C programming Err bitreich.org 70
i language. Err bitreich.org 70
i Err bitreich.org 70
i-make is used because it has been around for a long time, it is available on Err bitreich.org 70
i-many systems, it is a POSIX standard and it has proven to work well for most Err bitreich.org 70
i-projects. Err bitreich.org 70
i+make is used because it has been around for a long time, is available Err bitreich.org 70
i+on many systems, is a POSIX standard and has been proven to work well Err bitreich.org 70
i+for most projects. Err bitreich.org 70
i Err bitreich.org 70
i Err bitreich.org 70
i Targets Err bitreich.org 70
i@@ -29,12 +29,13 @@ The following targets should be defined in the Makefile: Err bitreich.org 70
i Portability Err bitreich.org 70
i ----------- Err bitreich.org 70
i Err bitreich.org 70
i-Do not use GNUisms in Makefiles. Testing with different make implementations Err bitreich.org 70
i-like BSD make which mostly respect POSIX is very useful. Use POSIX Makefile Err bitreich.org 70
i-rules: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html Err bitreich.org 70
i+Do not use GNUisms in Makefiles. Testing with different make Err bitreich.org 70
i+implementations, such as BSD make, which mostly respects POSIX, is very Err bitreich.org 70
i+useful. Use POSIX Makefile rules: Err bitreich.org 70
i+https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html Err bitreich.org 70
i Err bitreich.org 70
i-Try to place yourself into the shoes of a package maintainer / porter. This Err bitreich.org 70
i-is helpful to make sure the package is easy to maintain: Err bitreich.org 70
i+Try to place yourself in the shoes of a package maintainer / porter. This Err bitreich.org 70
i+helps make sure that the package is easy to maintain: Err bitreich.org 70
i Err bitreich.org 70
i * https://www.openbsd.org/faq/ports/ Err bitreich.org 70
i * https://www.netbsd.org/docs/pkgsrc/ Err bitreich.org 70
i@@ -68,8 +69,8 @@ Specifying compiler and linker flags: Err bitreich.org 70
i the set variables and not having to patch the Makefile in some way. Err bitreich.org 70
i Err bitreich.org 70
i * $CFLAGS: do not hard-code optimization flags like (-O2) or diagnostic flags Err bitreich.org 70
i- such as -Wall, -Wextra, -pedantic. Of course do not specify unportable compiler Err bitreich.org 70
i- flags. Err bitreich.org 70
i+ such as -Wall, -Wextra, -pedantic. Even more importantly, do not Err bitreich.org 70
i+ specify unportable compiler flags. Err bitreich.org 70
i Err bitreich.org 70
i * $LDFLAGS: do not hard-code linker flags like -s (symbol stripping) or -g, Err bitreich.org 70
i -static or such flags. Err bitreich.org 70
i@@ -106,8 +107,9 @@ Testing on many different systems is useful! For example: Linux, OpenBSD, NetBSD Err bitreich.org 70
i Examples Err bitreich.org 70
i -------- Err bitreich.org 70
i Err bitreich.org 70
i-Below is an example of a Makefile from project json2tsv. It is line-numbered and Err bitreich.org 70
i-annotated with remarks on why things are done the way they are. Err bitreich.org 70
i+Below is an example of a Makefile from the json2tsv project. It is Err bitreich.org 70
i+line-numbered and annotated with remarks on why things are done the way Err bitreich.org 70
i+they are. Err bitreich.org 70
i Err bitreich.org 70
i 1 .POSIX: Err bitreich.org 70
i Err bitreich.org 70
i@@ -217,8 +219,8 @@ separately for cross-compiling. Err bitreich.org 70
i 48 cp -f ${MAN1} ${DOC} ${HDR} \ Err bitreich.org 70
i 49 ${SRC} ${LIBJSONSRC} Makefile "${NAME}-${VERSION}" Err bitreich.org 70
i Err bitreich.org 70
i-Use the -f (force) options for rm to make sure to not return an error in case Err bitreich.org 70
i-of failure. For cp it ensures to overwrite the file even if it is busy. For Err bitreich.org 70
i+Use the -f (force) options for rm ensures make does not return an error Err bitreich.org 70
i+on failure. For cp it ensures to overwrite the file even if it is busy. For Err bitreich.org 70
i mkdir the -p flag is used to create all intermediary directories and to not Err bitreich.org 70
i return an error if the directory already exists. Err bitreich.org 70
i Err bitreich.org 70
i@@ -242,8 +244,7 @@ Remove the binary, object files and the local archive library (.a) file. Err bitreich.org 70
i 59 mkdir -p "${DESTDIR}${PREFIX}/bin" Err bitreich.org 70
i 60 cp -f ${BIN} "${DESTDIR}${PREFIX}/bin" Err bitreich.org 70
i Err bitreich.org 70
i-For cp it ensures to overwrite the file even if it is installed already and Err bitreich.org 70
i-busy as a process. Err bitreich.org 70
i+cp's -f flag ensures overwriting the file even if it is busy. Err bitreich.org 70
i Err bitreich.org 70
i 61 for f in ${BIN}; do chmod 755 "${DESTDIR}${PREFIX}/bin/$$f"; done Err bitreich.org 70
i 62 # installing example files. Err bitreich.org 70
i@@ -255,7 +256,7 @@ busy as a process. Err bitreich.org 70
i 68 for m in ${MAN1}; do chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; done Err bitreich.org 70
i 69 Err bitreich.org 70
i Err bitreich.org 70
i-Explicitly sets permissions for executable files and for documentation. Err bitreich.org 70
i+Explicitly set permissions for executable files and for documentation. Err bitreich.org 70
i Err bitreich.org 70
i 70 uninstall: Err bitreich.org 70
i 71 # removing executable files. Err bitreich.org 70
.
Response:
text/plain