phoebos: 1 Makefile: make POSIX-compliant 1 files changed, 43 insertions(+), 15 deletions(-)
The Makefile was marked as POSIX-compliant (first target is .POSIX), but made use of a number of extensions, such as the GNU extensions $(shell ...) and ifeq, and the widely-used, but not POSIX, += ?= != := etc. These other types of macro definitions _will_ be part of the next version of POSIX, but they are not currently. For this Makefile, ?= and := were not required, and != is replaced by adding the output of the `find` command manually. The RM macro was not defined, and it is not one of the predefined MACROS required by POSIX. Merging this commit will require the Makefile to be updated under the following conditions: - new source files are added: add them to the GOSRC macro - version is updated: manually change the value of the VERSION macro
I'm not sure how I feel about manually updating the list of files. It's unfortunate that make doesn't include an easy way to do this. Also, the previous VERSION macro code would use git (if available) to make versions based on the git tag, so that if someone modified their local copy we could tell from their VERSION. Is there a way to replicate this functionality with POSIX make?No, unfortunately. Most people looking for functionality like this use a ./configure sh script, something like this: $ cat ./configure #!/bin/sh -e exec > config.mk ver="$(git describe --tags --dirty 2>/dev/null || echo 0.1.0)" printf "VERSION = %s\n" "$ver" Then, you'd include config.mk at the top of your Makefile: -include config.mkFinally, is there a good resource to learn which features are supported in POSIX? I couldn't really find one.
v2: oops, one := slipped through --- Makefile | 58 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6645c33..62dc6f9 100644 --- a/Makefile +++ b/Makefile @@ -2,26 +2,54 @@ .SUFFIXES: .SUFFIXES: .1 .1.scd -_git_version=$(shell git describe --tags --dirty 2>/dev/null) -ifeq ($(strip $(_git_version)),) VERSION=0.1.0 -else -VERSION=$(_git_version) -endif -PREFIX?=/usr/local -BINDIR?=$(PREFIX)/bin -SHAREDIR?=$(PREFIX)/share/astronaut -MANDIR?=$(PREFIX)/share/man +PREFIX=/usr/local +BINDIR=$(PREFIX)/bin +SHAREDIR=$(PREFIX)/share/astronaut +MANDIR=$(PREFIX)/share/man VPATH=doc -GO?=go -GOFLAGS?= -GOSRC!=find . -name '*.go' -GOSRC+=go.mod go.sum -GOSRC+=about/* +RM=rm +GO=go +GOFLAGS= +GOSRC= \ + ui/wrap.go \ + ui/view.go \ + ui/ui.go \ + ui/splice.go \ + ui/spinner.go \ + ui/input.go \ + text.go \ + templates.go \ + tab.go \ + styles/styles.go \ + response.go \ + parse.go \ + main.go \ + io.go \ + errors.go \ + config.go \ + command.go \ + browser.go \ + bookmarks.go \ + binds.go \ + go.mod \ + go.sum \ + about/about.tmpl \ + about/bookmarks.gmi \ + about/certificate.tmpl \ + about/certificates.tmpl \ + about/error.tmpl \ + about/knownhosts.tmpl \ + about/mismatch.tmpl \ + about/newtab.gmi \ + about/redirect.tmpl \ + about/too-many-redirects.tmpl \ + about/trust.tmpl \ + about/welcome.gmi \ -DOCS := \ +DOCS = \ astronaut.1 all: astronaut doc -- 2.34.1
Hi! Thanks for the patch. On Sat Dec 18, 2021 at 10:57 PM EST, phoebos wrote: > The Makefile was marked as POSIX-compliant (first target is .POSIX), but made > use of a number of extensions, such as the GNU extensions $(shell ...) and ifeq, > and the widely-used, but not POSIX, += ?= != := etc. > > These other types of macro definitions _will_ be part of the next version of > POSIX, but they are not currently. For this Makefile, ?= and := were not > required, and != is replaced by adding the output of the `find` command manually. If the other macro definitions will eventually be part of POSIX, should we really be concerned? Are there implementations that don't support these macros?