gmp: Update and rewrite makefiles
* Update the makefiles to build the imported 6.3.0.
* Split the building of file generation tools into a separate makefile
in the `tools/` subdirectory, and move the library building to the
`lib/` subdirectory.
* Use <bsd.hostprog.mk> to build the generation tools.
* Keep `gmp.h` at the main directory so there is no `config.h` that
may possibly confuse the GMP users, such as the case with MPC that's
got fixed in commit 140e2138b6e2614a71884aa87702138fe3691e53.
* Re-organize the sources in a separate `Makefile.src`. Just copy the
`mpn_objs_in_libgmp` list from the generated Makefile, and thus
greatly simplify the makefile rules.
* Adjust cc80/cc120 to use the updated `libgmp.a` location.
bsd.hostprog.mk: Reimplement to support multiple programs
Introduce PROGS and PROGS_CXX together with per-program variables to
support the multiple-program mode, allowing to build multiple programs
with one makefile. This mode can help simplify the makefiles as well as
the hierarchies.
The original single-program mode is kept backward compatible.
mpc: Fix inclusion paths to correctly include its own 'config.h'
It wrongly included the GMP's 'config.h', as the '../gmp/' directory has
both 'gmp.h' and 'config.h'.
libncurses: Remove obsolete targets from libtic's Makefile
The <bsd.hostlib.mk> already handles the 'afterdepend' and 'install'
targets, so no need to manually define them.
world: Remove obsolete 'build-tools' uses for host programs
These host programs (except share/syscons/mapsmk) are built with
<bsd.hostprog.mk>, which has replaced the 'build-tools' target in 2004.
So just remove the obsolete 'build-tools' target as well as the
'install' target.
Also remove the 'build-tools' target from <bsd.sys.mk>.
kernel: Fix two bugs in gptinit()
* Fix the wrong type for 'table_lba'; should be 'uint64_t' instead of
'uint32_t', and fix the read to use le64toh().
* Allow the partition table has entries more than 128 (MAX_GPT_ENTRIES).
The UEFI specification basically has no upper limit, but we limit to
parsing the first 128 (MAX_GPT_ENTRIES) entries.
This actually happens with a Proxmox v9.2 ISO, which uses GPT and
allocates 44 blocks for the partition table, so there are 176 entries.
For example, here is the gpt(8) of a USB stick written with this ISO:
```
Disk da8: 57.3GB (120225792 512-byte sectors)
Start Sectors Size Index Contents
0 1 512B - PMBR
1 1 512B - Primary GPT header
[13 lines not shown]
gcc120,gcc80: Fix depend generation for multiple libraries
In the makefiles of these libraries, the `depend` and `all` targets were
used to create the generated files, so the builtin `depend` rules that
call mkdep(1) were simply overridden and ignored.
Fix this by using the `beforedepend` target instead. This convention
has been already used in a few other libraries, such as
gcc*/libstdc++/components/*.
mk: Fix ${group}_FLAGS_FILES to support sources with subdirs
Previously ${group}_FLAGS_FILES required bare filenames as the
per-group flags were propagated into build commands via
${_${.IMPSRC:T}_FLAGS}, where the `:T` suffix required the subdirs
be ignored for the sources. However, this caused the following problems:
* `make depend` on ${group}_FLAGS_FILES will fail when the subdirs of
the sources are excluded, because `make` will be unable to find them.
* Ignoring the subdir portion of the sources can make the flags be
wrongly set for unwanted files in different directories that share a
same filename.
To fix the above problems, propagate the per-group flags via variables
that use the target names, which are predictable and includes the
subdirs that avoid the ambiguity. In addition, strip the filename
suffix so the flags apply to all kinds of objects such as *.o, *.po and
*.So.
Adjust cc120/libbackend/Makefile accordingly.
mkdep(1): Fix target conflicts by prepending relative subdirs
* mkdep(1) calls cc/c++ to generate the dependency lists for the source
files. However, the targets in the output are bare names (e.g.,
`example.o`), so multiple sources share a file name in different
subdirectories have the same targets, which can cause build failures
or broken output.
To fix this problem, introduce the '-S srcdir' option to specify the
root directory of the source files on the command line, and use it to
determine the relative subdirectories that are prepended to each
target. As a result, the targets and their sources are 1:1 correlated
and the duplicate targets are avoided.
* Further add a check to catch duplicate targets and fail the generation
if there are any.
* Introduce MKDEPSRCDIR in <bsd.dep.mk> to set the new option for
mkdep(1).
[17 lines not shown]
tools/gitrev.sh: Remove duplicate "cd" command
The 'cd $srcdir' was added in commit
f5a0be5909f64049304cc253123a5f9e4c5f38a3, which can cause the later
'cd $(dirname $0)' to fail, e.g.,
```
% sh ./sys/conf/../../tools/gitrev.sh
cd: ./sys/conf/../../tools: No such file or directory
$ bash ./sys/conf/../../tools/gitrev.sh
./sys/conf/../../tools/gitrev.sh: line 14: cd: ./sys/conf/../../tools: No such file or directory
```
The above invocation happens with:
```
$ env KERN_IDENT=XXX sh ./sys/conf/newvers.sh
```
So fix the issue by removing the duplicate "cd" command in gitrev.sh.