Repository: bitcoin/bitcoin (language: cpp)

Issue:
depends: `touch` command for creating determinstic archive timestamps fails on OpenBSD
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

In the course of the "Caching..." step of a depends build, the `touch` command for creating determinstic package archive timestamps fails on OpenBSD. The reason is that the used option `-h` option (introduced in PR #21995, commit 6ebe57622cb70df529879b15f291166177f2827c) doesn't exist in OpenBSD's version of touch (see https://man.openbsd.org/touch.1). E.g. for zeromq:
```
[ ... ]
Postprocessing zeromq...
Caching zeromq...
touch: unknown option -- h
usage: touch [-acm] [-d ccyy-mm-ddTHH:MM:SS[.frac][Z]] [-r file]
             [-t [[cc]yy]mmddHHMM[.SS]] file ...
```

### Expected behaviour

Ideally, creating deterministic package archive timestamps should also work on OpenBSD. As an alternative, if that's not easily possible, the touch command shouldn't be executed at all on OpenBSD, do avoid the "unknown option" error message.

### Steps to reproduce

Make a fresh depends build on OpenBSD, e.g. (for zeromq):
```
$ gmake -C depends clean
$ gmake -C depends NO_BDB=1 NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_SQLITE=1 NO_NATPMP=1 NO_UPNP=1 NO_USDT=1
```

### Relevant log output

_No response_

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

master branch (commit 6c24eb55e021991196003dc7f0a643e806b14295)

### Operating system and version

OpenBSD 7.4 (amd64)

### Machine specifications

_No response_


Discussion / hints:
ping @hebasto
(Haven't investigated deeper what `-h` exactly does, but as far as I understand, the build still succeeds and there is no big harm in the failing `touch` command other than that the timestamps are not determinstic. Considering that OpenBSD is rather a niche OS, I think it's only worth fixing if there's an easy way to do so.)
> Haven't investigated deeper what `-h` exactly does

```
$ touch --help | grep -A 2 -e "-h," 
  -h, --no-dereference   affect each symbolic link instead of any referenced
                         file (useful only on systems that can change the
                         timestamps of a symlink)
```

Fix patch:
diff --git a/depends/builders/default.mk b/depends/builders/default.mk
index cc6dec66c2ba0..806d6e7c50d7c 100644
--- a/depends/builders/default.mk
+++ b/depends/builders/default.mk
@@ -5,13 +5,14 @@ default_build_TAR = tar
 default_build_RANLIB = ranlib
 default_build_STRIP = strip
 default_build_NM = nm
+default_build_TOUCH = touch -h -m -t 200001011200
 
 define add_build_tool_func
 build_$(build_os)_$1 ?= $$(default_build_$1)
 build_$(build_arch)_$(build_os)_$1 ?= $$(build_$(build_os)_$1)
 build_$1=$$(build_$(build_arch)_$(build_os)_$1)
 endef
-$(foreach var,CC CXX AR TAR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_build_tool_func,$(var))))
+$(foreach var,CC CXX AR TAR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL DSYMUTIL TOUCH,$(eval $(call add_build_tool_func,$(var))))
 define add_build_flags_func
 build_$(build_arch)_$(build_os)_$1 += $(build_$(build_os)_$1)
 build_$1=$$(build_$(build_arch)_$(build_os)_$1)
diff --git a/depends/builders/openbsd.mk b/depends/builders/openbsd.mk
index 44825d106acf6..9c94c4baae7a3 100644
--- a/depends/builders/openbsd.mk
+++ b/depends/builders/openbsd.mk
@@ -5,3 +5,5 @@ build_openbsd_SHA256SUM = sha256
 build_openbsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o
 
 build_openbsd_TAR = gtar
+# openBSD touch doesn't understand -h
+build_openbsd_TOUCH = touch -m -t 200001011200
diff --git a/depends/funcs.mk b/depends/funcs.mk
index 24c911b0f7a63..7b5c3d0c59158 100644
--- a/depends/funcs.mk
+++ b/depends/funcs.mk
@@ -234,7 +234,7 @@ $($(1)_postprocessed): | $($(1)_staged)
 $($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed)
 	echo Caching $(1)...
 	cd $$($(1)_staging_dir)/$(host_prefix); \
-	  find . ! -name '.stamp_postprocessed' -print0 | TZ=UTC xargs -0r touch -h -m -t 200001011200; \
+	  find . ! -name '.stamp_postprocessed' -print0 | TZ=UTC xargs -0r $(build_TOUCH); \
 	  find . ! -name '.stamp_postprocessed' | LC_ALL=C sort | $(build_TAR) --numeric-owner --no-recursion -czf $$($(1)_staging_dir)/$$(@F) -T -
 	mkdir -p $$(@D)
 	rm -rf $$(@D) && mkdir -p $$(@D)


Test patch: