问题
I don't like the built-in time utility in Alpine Linux and would like to improve it for my needs -- I want to edit the time.c and compile it to a binary. I have done the apk add build-base to install the gcc and have copypasted the time.c from Github, but when I do the gcc /tmp/time.c -o /tmp/time I get the:
/tmp/time.c:34:10: fatal error: libbb.h: No such file or directory
#include "libbb.h"
^~~~~~~~~
So I copypasted it too but it relies on dozens more header files. I saw somewhere that I might need the apk add alpine-sdk and maybe it would also garantee version compatibility so I did it but gcc still does not see header files. Should I provide some -I flag?
What do I really have to do to finally compile my custom time.c?
P.S.: there is probably a SO tag for time but I can't find it.
UPD: I've copied the whole include folder but it says:
In file included from /tmp/time.c:34:
include/libbb.h:406:42: error: 'ENABLE_FEATURE_VERBOSE' undeclared here (not in a function)
FILEUTILS_VERBOSE = (1 << 12) * ENABLE_FEATURE_VERBOSE, /* -v */
^~~~~~~~~~~~~~~~~~~~~~
but I can't find where it's defined even in the whole https://github.com/mirror/busybox
UPD: oh no, it's more complex.
/ # ls -l `which time`
lrwxrwxrwx 1 root root 12 Jan 30 2019 /usr/bin/time -> /bin/busybox
Seems like there is no such thing as time binary.
回答1:
Assuming that GNU time functionality is what your after, and BusyBox time being insufficient for your needs, just install the GNU time package which was recently made available on Alpine:
apk add time --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
When installed, it will replace the /usr/bin/time BusyBox symlink with the GNU time executable.
来源:https://stackoverflow.com/questions/57589231/how-do-i-compile-the-time-c-on-alpine