Added strerror(3) as a Rust library #76

Closed
emma wants to merge 16 commits from strerror into main
Showing only changes of commit c75bb93001 - Show all commits

View File

@ -13,18 +13,18 @@
.PRAGMA: posix_202x # future POSIX standard support à la pdpmake(1) .PRAGMA: posix_202x # future POSIX standard support à la pdpmake(1)
.PRAGMA: command_comment # breaks without this? .PRAGMA: command_comment # breaks without this?
DESTDIR=./dist DESTDIR ?= dist
emma marked this conversation as resolved Outdated

I really like these Makefile changes.

I really like these Makefile changes.

For readability, spaces between the assignment operators and their names and values would be nice. e.g. DESTDIR = ./dist (though I would forego the ./ as Makefiles are conventionally run relative to $PWD anyway).

For readability, spaces between the assignment operators and their names and values would be nice. e.g. `DESTDIR = ./dist` (though I would forego the `./` as Makefiles are conventionally run relative to `$PWD` anyway).
PREFIX=/usr/local PREFIX ?= /usr/local
SYSEXITS!=printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \ SYSEXITS != printf '\043include <sysexits.h>\n' | cpp -M - | sed 's/ /\n/g' \
| sed -n 's/sysexits\.h//p' || printf 'include/\n' | sed -n 's/sysexits\.h//p' || printf 'include\n'
CC?=cc CC ?= cc
RUSTC?=rustc RUSTC ?= rustc
RUSTLIBS=--extern getopt=build/o/libgetopt.rlib \ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \
--extern sysexits=build/o/libsysexits.rlib \ --extern sysexits=build/o/libsysexits.rlib \
--extern strerror=build/o/libstrerror.rlib --extern strerror=build/o/libstrerror.rlib
CFLAGS+=-I$(SYSEXITS) CFLAGS += -I$(SYSEXITS)
.PHONY: all .PHONY: all
all: dj false fop hru intcmp rpn scrut str strcmp true all: dj false fop hru intcmp rpn scrut str strcmp true
@ -36,12 +36,12 @@ build:
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf build/ dist/ rm -rf build dist
dist: all dist: all
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/man/man1 mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
emma marked this conversation as resolved Outdated

Consecutive directory delimiters are ignored when evaluating UNIX paths; /// is an unnecessarily wordy equivalent to / when used as a pathname. $(DESTDIR)/$(PREFIX)/bin and so on is preferable, though, to ensure that hasty modifications won't write to a distbuildbin or something. Mistakes happen!

The names PREFIX and DESTDIR sound equivalent to me. On face value I would expect the prefix to come first.

Consecutive directory delimiters are ignored when evaluating UNIX paths; `///` is an unnecessarily wordy equivalent to `/` when used as a pathname. `$(DESTDIR)/$(PREFIX)/bin` and so on is preferable, though, to ensure that hasty modifications won't write to a `distbuildbin` or something. Mistakes happen! The names `PREFIX` and `DESTDIR` sound equivalent to me. On face value I would expect the prefix to come first.
Outdated
Review

Historically, $DESTDIR is a directory inside the tree (in this case, dist/) to which programs are installed in a phony root filesystem. Then, when make install is called, the $PREFIX is already baked into $DESTDIR and you can copy it straight into the root filesystem.

[Historically](https://people.freebsd.org/~rafan/ph/porting-prefix.html), `$DESTDIR` is a directory inside the tree (in this case, `dist/`) to which programs are installed in a phony root filesystem. Then, when `make install` is called, the `$PREFIX` is already baked into `$DESTDIR` and you can copy it straight into the root filesystem.
cp build/bin/* $(DESTDIR)$(PREFIX)/bin/ cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
cp docs/*.1 $(DESTDIR)$(PREFIX)/share/man/man1/ cp docs/*.1 $(DESTDIR)/$(PREFIX)/share/man/man1
.PHONY: install .PHONY: install
install: dist install: dist