makefile-guidelines: some incremental improvements - bitreich-style - Style gui… | |
git clone git://bitreich.org/bitreich-style | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit 60d0637f5edd99ec9ee1175d37a3f7b03db3d318 | |
parent 040830cabbba670cfbac39d214fe274d7c10b88d | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 10 Jun 2020 14:46:27 +0200 | |
makefile-guidelines: some incremental improvements | |
* Fix the direct link to the POSIX make link (it was a HTML frame). | |
* Add a note to make porters-life easier. #porterlivesmatter | |
* Fix ar rc to ar -rc (quinq). | |
* Also copy the LICENSE documentation: cp ${DOC}. | |
* Add some references. | |
* Some line-wrapping fixes. | |
Diffstat: | |
M c/makefile-guideline.txt | 42 ++++++++++++++++++++---------… | |
1 file changed, 27 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/c/makefile-guideline.txt b/c/makefile-guideline.txt | |
@@ -33,6 +33,14 @@ Do not use GNUisms in Makefiles. Testing with different make… | |
like BSD make which mostly respect POSIX is very useful. Use POSIX Makefile | |
rules: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html | |
+Trying to place yourself into the shoes of a package maintainer / porter. This | |
+is helpful to make sure the package is easy to maintain: | |
+ | |
+* https://www.openbsd.org/faq/ports/ | |
+* https://www.netbsd.org/docs/pkgsrc/ | |
+* https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/book.html | |
+* https://wiki.voidlinux.org/A_General_Introduction_To_Package_Creation | |
+ | |
Variables | |
--------- | |
@@ -54,13 +62,19 @@ It is recommended to respect the following commonly-used va… | |
Specifying compiler and linker flags: | |
* $CC, $CFLAGS, $LDFLAGS, $CPPFLAGS: make sure to respect the default set flags | |
- as specified in POSIX: https://pubs.opengroup.org/onlinepubs/9699919799/ | |
- under the section "Default rules". This make it easier for the ports build s… | |
- to use the set variables and not having to patch the Makefile in some way. | |
-* $CFLAGS: do not hard-code optimization flags like (-O2) or diagnostic flags … | |
- -Wall, -Wextra, -pedantic. Of course do not specify unportable compiler flag… | |
-* $LDFLAGS: do not hard-code linker flags like -s (symbol stripping) or -g, -s… | |
- or such flags. | |
+ as specified in POSIX: | |
+ | |
+ https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html under t… | |
+ section "Default rules". This make it easier for the ports build system to u… | |
+ the set variables and not having to patch the Makefile in some way. | |
+ | |
+* $CFLAGS: do not hard-code optimization flags like (-O2) or diagnostic flags | |
+ such as -Wall, -Wextra, -pedantic. Of course do not specify unportable compi… | |
+ flags. | |
+ | |
+* $LDFLAGS: do not hard-code linker flags like -s (symbol stripping) or -g, | |
+ -static or such flags. | |
+ | |
* Libraries: using separate variables for compile and link per library (for | |
example libpng, libjpeg) can be useful for building in ports. | |
For example a variable LIBPNG_CFLAGS, LIBPNG_LDFLAGS for the header files or | |
@@ -190,7 +204,7 @@ Compiling, use the system specified CFLAGS and CPPFLAGS. | |
40 | |
41 ${LIBJSON}: ${LIBJSONOBJ} | |
- 42 ${AR} rc $@ $? | |
+ 42 ${AR} -rc $@ $? | |
43 ${RANLIB} $@ | |
44 | |
@@ -235,7 +249,7 @@ busy as a process. | |
61 for f in ${BIN}; do chmod 755 "${DESTDIR}${PREFIX}/bin/$… | |
62 # installing example files. | |
63 mkdir -p "${DESTDIR}${DOCPREFIX}" | |
- 64 cp -f README "${DESTDIR}${DOCPREFIX}" | |
+ 64 cp -f ${DOC} "${DESTDIR}${DOCPREFIX}" | |
65 # installing manual pages for general commands: section … | |
66 mkdir -p "${DESTDIR}${MANPREFIX}/man1" | |
67 cp -f ${MAN1} "${DESTDIR}${MANPREFIX}/man1" | |
@@ -261,12 +275,10 @@ rmdir returns an error code then that is ok and make stil… | |
79 .PHONY: all clean dist install uninstall | |
+References | |
+---------- | |
- | |
-TODO | |
- | |
-References: | |
- https://www.gnu.org/prep/standards/standards.html#DESTDIR | |
- https://nullprogram.com/blog/2017/08/20/ | |
- | |
-- https://www.openbsd.org/faq/ports/ | |
+- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html | |
+- https://pubs.opengroup.org/onlinepubs/9699919799/ |