This library was imported from the BSD 4.4 source code but it is a
portion of code with ownership from AT&T and it can be used under
the Caldera open source license.
This version is almost finished, but it does not implements the return
keyword (it is ignored) and it does not include the default bc library
(the option to load it is silently ignored). It also lack tests.
Building from the tarball fails:
curl --no-progress-meter https://dl.suckless.org/sbase/sbase-0.1.tar.gz \
| tar -xz --strip-components=1 \
&& make >/dev/null
ar: creating libutf.a
ar: creating libutil.a
/bin/sh: line 1: scripts/getconf.sh: No such file or directory
make: *** [Makefile:221: getconf.h] Error 127
The scripts contained in the script directory are required
for several make targets (including all, install, uninstall,
sbase-box and maybe some others).
Signed-off-by: Eduardo Santos <eduardo.experimental@gmail.com>
This implementation is ported from the scc compiler with
the author permission to re license it with sbase license.
Using this make implementation to bootstrap sbase removes
the problems found by some buggy make implementations
(specially in the case of OpenBSD). It has a drawback
that the options passed for parallel build with -j are
ignored(improvement are expected).
Due to the multi file nature of make, embedding it in
sbas-box creates some problems, and for now, we keep
it out of sbase-box.
The Makefile was relaying in two extensions:
1- Inference rule chaining: Based in getconf.c -> getconf.o -> getconf
2- Inference rule .o: POSIX defines the .c rule, but not the .o rule
(what makes sense because to be useful you need inference rule chaining).
We are using a wildcard to copy things into the directory used to
build the distribution tar file, and this directory can contain
the .1 extension used in the *.1 wildcard used to copy the man
pages. Also, changed the cp command line from -r to -R because
-r is not specified in POSIX.
The target tried to execute a non valid shell script
and there was a possibility to fatorize the creation
of the proto file instead of repeating it in all
the actions that required.
The MAN macro was not used, and it and OBJ had the same problem
because they were defined using an empty string in the replace
pattern of the macro expansion, but as it is said by POSIX:
The subst1 to be replaced shall be recognized when it is a suffix
at the end of a word in string1
so, an empty string should not be used.
Also, a new inference rule is added to generate the binary
directly from the .c without generating the intermediate
object, removing the need of chaining different inference
rules which is not guaranteed to work in all the make
implementations.
Make will search in the catalogue of rules for a way to
update the target, and in case of finding the dependency
it will apply the rule without a need of specifying that
dependency.
The Makefile rule was too complex and these cases is better to just
move it to a script where will be eassier to use sed properly
and not looping over all the files 4 times.
I have noticed this issue while I was trying to package sbase-box. Since
sbase-box was in the PHONY target, running sbase-box-install caused it to
be rebuilt when it was unnecessary. This also caused options passed to make
to be lost (such as LDFLAGS).
Although mknod is not a POSIX tool, it is widely available on nearly
all UNIX-like systems. It also can be implemented portably apart
from use of the makedev macros, which is already a requirement of
a couple other tools in sbase.
While we're at it, fix a few bugs:
- Include sys/sysmacros.h if makedev was not defined by sys/types.h
- The default mode should respect the user's umask, rather than
assuming it is 022.
- Clear the umask when -m is specified explicitly so that nodes can
be created with permissions wider than the user's umask.
- Utilize parsemode from libutil to support symbolic mode strings.
writeall makes successive write calls to write an entire buffer to the
output file descriptor. It returns the number of bytes written, or -1 on
the first error.
For sort(1) we need memmem(), which I imported from OpenBSD.
Inside sort(1), the changes involved working with the explicit lengths
given by getlines() earlier and rewriting some of the functions.
Now we can handle NUL-characters in the input just fine.
strmem() was not very well thought out. The thing is the following:
If the string contains a zero character, we want to match it, and not
stop right there in place.
The "real" solution is to use memmem() where needed and replace all
functions that assume zero-terminated-strings from standard input, which
could lead to early string-breakoffs.
This requires a strict tracking of string lengths.
We want our delimiters to also contain 0 characters and have them
handled gracefully.
To accomplish this, I wrote a function strmem(), which looks for a
certain, arbitrarily long memory subset in a given string.
memmem() is a GNU extension and forces you to call strlen every time.
-s strip binary
-d create directory
-D create missing directories
-t DIR target directory
-m MODE permission bits
-o USER set owner
-g GROUP set group
Installed files are copied, and default mode is 755.
Signed-off-by: Mattias Andrée <maandree@kth.se>