GNU time

(Not sure if this is the correct forum for this topic)

I'm trying to use GNU time but can't work how. There is no pkg gtime or gnutime, but the FreeBSD man page does mention it. It says
GNU VERSION
Below a description of the GNU 1.7 version of time. Disregarding the
name of the utility, GNU makes it output lots of useful information,
not only about time used, but also on other resources like memory, I/O
and IPC calls (where available). The output is formatted using a for-
mat string that can be specified using the -f option or the TIME envi-
ronment variable.
So, how do I invoke GNU time?
 
You're reading Red Hat Linux 8.0 i386 "time" manual page.
4vTn2YL.png

So this utility shouldn't be available in FreeBSD.
Here is FreeBSD time(1) man page.
 
So why does FreeBSD have a man page for a Linux program?:confused:

And how can I run the equivalent of GNU time on FreeBSD?
 
Note that there's a time shell builtin and a /usr/bin/time executable. They're both different, have different options and different outputs.
 
Most likely the shell builtin (it has precedence over one on the path). Execute /usr/bin/time if you need to use time(1).
 
FreeBSD includes the time(1) program. Are there specific features of GNU time you are trying to use that aren't available in FreeBSD time?

There probably are, but I don't know specifically what. A configure script runs OK on Linux but fails on FreeBSD when checking time. I installed all the GNU utils on FreeBSD one by one as I ran the script checking where it failed. Eventually it stopped at the time check, but I could not find a FreeBSD port of GNU time.

Here's what I got initially:-
Code:
root@Vbox:~/openwrt # ls -al[6D./scripts/update -a[4hf[4l[4he[4l[4he[4l[4hd[4l[4hs[4l[4h [4l

Updating feed 'packages' from '[URL]https://git.openwrt.org/feed/packages.git[/URL]' ...
Already up to date.
Create index file './feeds/packages.index' 
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'proper-umask'... ok.
Checking 'gcc'... ok.
Checking 'working-gcc'... ok.
Checking 'g++'... ok.
Checking 'working-g++'... ok.
Checking 'ncurses'... ok.
Checking 'perl-thread-queue'... ok.
Checking 'tar'... failed.
Checking 'find'... failed.
Checking 'bash'... ok.
Checking 'patch'... failed.
Checking 'diff'... ok.
Checking 'cp'... failed.
Checking 'seq'... failed.
Checking 'awk'... failed.
Checking 'grep'... ok.
Checking 'getopt'... failed.
Checking 'stat'... failed.
Checking 'unzip'... ok.
Checking 'bzip2'... ok.
Checking 'wget'... ok.
Checking 'time'... failed.
Checking 'perl'... ok.
Checking 'python'... ok.
Checking 'git'... ok.
Checking 'file'... ok.
Prerequisite check failed. Use FORCE=1 to override.
gmake: *** [/root/openwrt/include/toplevel.mk:168: staging_dir/host/.prereq-build] Error 1
awk: calling undefined function asort

and finally after installing the GNU programs:
Code:
Create index file './feeds/packages.index' 
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'proper-umask'... ok.
Checking 'gcc'... ok.
Checking 'working-gcc'... ok.
Checking 'g++'... ok.
Checking 'working-g++'... ok.
Checking 'ncurses'... ok.
Checking 'perl-thread-queue'... ok.
Checking 'tar'... ok.
Checking 'find'... ok.
Checking 'bash'... ok.
Checking 'patch'... ok.
Checking 'diff'... ok.
Checking 'cp'... ok.
Checking 'seq'... ok.
Checking 'awk'... ok.
Checking 'grep'... ok.
Checking 'getopt'... ok.
Checking 'stat'... ok.
Checking 'unzip'... ok.
Checking 'bzip2'... ok.
Checking 'wget'... ok.
[B]Checking 'time'... failed.[/B]
Checking 'perl'... ok.
Checking 'python'... ok.
Checking 'git'... ok.
Checking 'file'... ok.
Prerequisite check failed. Use FORCE=1 to override.
gmake: *** [/root/source/include/toplevel.mk:168: staging_dir/host/.prereq-build] Error 1
/bin/sh: mkhash: not found

I can't work out where these checks are made, but apparently it was possibly to run this on FreeBSD at one point.
 
So when execute time how do you know which you are running?
Also, when you don't want to use shell built-in commands, add "\" to the begining of
command, so, when you need to start /usr/bin/time instead of shell built-in "time",
you should use % \time, this method also useful, when you don't want
to use shell aliases, set in your shell configuration file. For example
i8R5Ojv.png

It's working with tcsh, bash, zsh and some other shells.
 
The feature of GNU time in question is, I believe, the non-standard -f flag that is used by the build system that OpenWRT presently uses. The version of sysutils/busybox installed by pkg(8) apparently does not include the time applet (used by the OpenWRT build system as a fall-back option). The Makefile for the FreeBSD port of busybox, at least by my reading of it, does not supply options to enable/disable specific applets.

Once an appropriate "time" is selected by the build system, it appears to be called from include/subdir.mk
Code:
     41 log_make = \
     42          $(if $(call debug,$(1),v),,@)+ \
     43          $(if $(BUILD_LOG), \
     44                 set -o pipefail; \
     45                 mkdir -p $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4));) \
     46         env time -f "time: $(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2)\#%U\#%S\#%e" -- \
     47         $$(SUBMAKE) $(subdir_make_opts) $(if $(3),$(3)-)$(2) \
     48                 $(if $(BUILD_LOG),SILENT= 2>&1 | tee $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2).txt)
 
The feature of GNU time in question is, I believe, the non-standard -f flag that is used by the build system that OpenWRT presently uses. The version of sysutils/busybox installed by pkg(8) apparently does not include the time applet (used by the OpenWRT build system as a fall-back option). The Makefile for the FreeBSD port of busybox, at least by my reading of it, does not supply options to enable/disable specific applets.

Are you suggesting that if I built sysutils/busybox from ports, making some changes to the Makefile I would be able to use the OpenWrt build system on FreeBSD?
 
FreeBSD includes the time(1) program. Are there specific features of GNU time you are trying to use that aren't available in FreeBSD time?


Apparently GNU time supports an '-f' parameter which is required by the OpenWrt build system, otherwise I need to make changes to the build system to accomodate FreeBSD.

It seems strange the most of the GNU utils have been ported to FreeBSD, but gtime is an exception...
 
The feature of GNU time in question is, I believe, the non-standard -f flag that is used by the build system that OpenWRT presently uses. The version of sysutils/busybox installed by pkg(8) apparently does not include the time applet (used by the OpenWRT build system as a fall-back option). The Makefile for the FreeBSD port of busybox, at least by my reading of it, does not supply options to enable/disable specific applets.

Once an appropriate "time" is selected by the build system, it appears to be called from include/subdir.mk
Code:
     41 log_make = \
     42          $(if $(call debug,$(1),v),,@)+ \
     43          $(if $(BUILD_LOG), \
     44                 set -o pipefail; \
     45                 mkdir -p $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4));) \
     46         env time -f "time: $(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2)\#%U\#%S\#%e" -- \
     47         $$(SUBMAKE) $(subdir_make_opts) $(if $(3),$(3)-)$(2) \
     48                 $(if $(BUILD_LOG),SILENT= 2>&1 | tee $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2).txt)

Can I just omit the '-f' parameter from line 46?

Any idea where the actual checking of required components is done?
 
After getting some help from the OpenWrt Forum I managed to run make menuconfig as part of the OpenWrt build system and it looked the same as it does on Linux, but at the end when running make I was hit by the lack of a GNU time again.

It's strange that GNU time hasn't been ported since many other GNU utilities are available under FreeBSD.

Does anyone know what is involved in getting a simple utility like time built on FreeBSD? Looking at gsed in ports there is only a makefile - no patches. gawk has a single one line patch. But if it hasn't already been ported it may be trickier than it seems...
 
I managed to build it! This is all it took:-
Code:
wget https://ftp.gnu.org/gnu/time/time-1.9.tar.gz
tar zxf time-1.9.tar.gz
cd time-1.9
./configure
make
For my purposes I can simply copy time as gtime to /usr/local/bin/ but is there a way of doing it properly using make install? ie like FreeBSD pkg would handle it...
 
Back
Top