Update to gcc11

Change to openssl
Clean up some `C` for HitchHiker specific utils
This commit is contained in:
Nathan Fisher 2022-01-28 11:44:56 -05:00
parent 6f7db66683
commit 2feff2a5d3
26 changed files with 30474 additions and 186 deletions

View file

@ -44,10 +44,11 @@ subdirs += expat
subdirs += kmod
subdirs += gettext
# for musl
subdirs += argp-standalone
#subdirs += argp-standalone
subdirs += elfutils
subdirs += libffi
subdirs += libressl
#subdirs += libressl
subdirs += openssl
subdirs += wget
#subdirs += python
#subdirs += ninja
@ -65,8 +66,6 @@ subdirs += texinfo
subdirs += procps-ng
subdirs += util-linux
# for musl
#subdirs += argp-standalone
# for musl
#subdirs += musl-fts
subdirs += e2fsprogs
subdirs += haveged

View file

@ -29,7 +29,8 @@
#define _GNU_SOURCE // getline, getopt
#include <ctype.h> // isprint
#include <err.h> // err
#include <err.h> // err, perror
#include <errno.h> // errno
#include <inttypes.h> // uint*_t
#include <libgen.h> // basename
#include <stdio.h> // fclose, fopen, getline, nread, perror, printf
@ -87,6 +88,23 @@ void _head(char *file) {
}
}
long parselong(char *buf) {
errno = 0;
char *endptr;
int num = strtol(optarg, &endptr, 10);
if (errno != 0) {
perror("Error parsing integer from input: ");
exit(EXIT_FAILURE);
} else if (num == 0 && endptr == optarg) {
fprintf(stderr, "Error: invalid input: %s\n", optarg);
exit(EXIT_FAILURE);
} else if (*endptr != '\0') {
fprintf(stderr, "Error: invalid input: %s\n", optarg);
exit(EXIT_FAILURE);
}
return num;
}
int main(int argc, char *argv[]) {
int c, index;
__progname = basename(argv[0]);
@ -109,7 +127,7 @@ int main(int argc, char *argv[]) {
switch (c) {
case 'c':
cflag = 1;
chars = (int)strtol(optarg, NULL, 10);
chars = (int)parselong(optarg);
break;
case 'q':
qflag = 1;
@ -124,7 +142,7 @@ int main(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
case 'n':
nflag = 1;
lines = (int)strtol(optarg, NULL, 10);
lines = (int)parselong(optarg);
break;
case '0':
case '1':

View file

@ -28,13 +28,13 @@
#define _DEFAULT_SOURCE
#include <sys/param.h>
#include <sys/param.h> // HOST_NAME_MAX
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h> // basename
#include <stdio.h> // printf, fprintf
#include <stdlib.h> // exit
#include <string.h> // strlen
#include <unistd.h> // gethostname, sethostname, getopt
static const char *__progname;

View file

@ -2,6 +2,7 @@
# Copyright 2020 Nathan Fisher <nfisher.sr@gmail.com>
#
distname = gcc
patches = gcc-nostdinc.patch
include world.mk
ifeq ($(arch),x86_64)

View file

@ -0,0 +1,11 @@
--- gcc-11.2.0.orig/configure 2021-07-28 02:55:06.628278148 -0400
+++ gcc-11.2.0.new/configure 2021-10-19 11:51:51.300514740 -0400
@@ -16478,7 +16478,7 @@
fi
-RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
+RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET -nostdinc++"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target ar" >&5
$as_echo_n "checking where to find the target ar... " >&6; }

View file

@ -1,8 +1,7 @@
# Makefile - hhl - /usr/src/world/m4
# Copyright 2020 Nathan Fisher <nfisher.sr@gmail.com>
#
#
distname = m4
patches = m4-glibc-fixes.patch
include world.mk
config_opts += --host=$(tgt)
CFLAGS += --sysroot=$(DESTDIR)

View file

@ -1,107 +0,0 @@
diff -Naur m4-1.4.18.orig/lib/fflush.c m4-1.4.18/lib/fflush.c
--- m4-1.4.18.orig/lib/fflush.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/fflush.c 2020-05-19 16:21:43.578036277 -0400
@@ -33,7 +33,7 @@
#undef fflush
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
static void
@@ -72,7 +72,7 @@
#endif
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
@@ -148,7 +148,7 @@
if (stream == NULL || ! freading (stream))
return fflush (stream);
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
clear_ungetc_buffer_preserving_position (stream);
diff -Naur m4-1.4.18.orig/lib/fpending.c m4-1.4.18/lib/fpending.c
--- m4-1.4.18.orig/lib/fpending.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/fpending.c 2020-05-19 16:21:43.578036277 -0400
@@ -32,7 +32,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
return fp->_IO_write_ptr - fp->_IO_write_base;
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
diff -Naur m4-1.4.18.orig/lib/fpurge.c m4-1.4.18/lib/fpurge.c
--- m4-1.4.18.orig/lib/fpurge.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/fpurge.c 2020-05-19 16:21:43.578036277 -0400
@@ -62,7 +62,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_end = fp->_IO_read_ptr;
fp->_IO_write_ptr = fp->_IO_write_base;
/* Avoid memory leak when there is an active ungetc buffer. */
diff -Naur m4-1.4.18.orig/lib/freadahead.c m4-1.4.18/lib/freadahead.c
--- m4-1.4.18.orig/lib/freadahead.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/freadahead.c 2020-05-19 16:21:43.578036277 -0400
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -Naur m4-1.4.18.orig/lib/freading.c m4-1.4.18/lib/freading.c
--- m4-1.4.18.orig/lib/freading.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/freading.c 2020-05-19 16:21:43.578036277 -0400
@@ -31,7 +31,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
return ((fp->_flags & _IO_NO_WRITES) != 0
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
&& fp->_IO_read_base != NULL));
diff -Naur m4-1.4.18.orig/lib/fseeko.c m4-1.4.18/lib/fseeko.c
--- m4-1.4.18.orig/lib/fseeko.c 2016-12-31 08:54:41.000000000 -0500
+++ m4-1.4.18/lib/fseeko.c 2020-05-19 16:21:43.578036277 -0400
@@ -47,7 +47,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
@@ -123,7 +123,7 @@
return -1;
}
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
diff -Naur m4-1.4.18.orig/lib/stdio-impl.h m4-1.4.18/lib/stdio-impl.h
--- m4-1.4.18.orig/lib/stdio-impl.h 2016-12-31 08:54:42.000000000 -0500
+++ m4-1.4.18/lib/stdio-impl.h 2020-05-19 16:21:43.601369662 -0400
@@ -138,3 +138,4 @@
# define _IOERR 0x10
#endif
+#define _IO_IN_BACKUP 0x100

37
world/openssl/Makefile Normal file
View file

@ -0,0 +1,37 @@
# Makefile - hhl - /usr/src/world/openssl
# Copyright 2020 Nathan Fisher <nfisher.sr@gmail.com>
#
distname = openssl
distext = gz
include world.mk
config_cmd = cd $(objdir) && $(srcdir)/Configure $(config_opts)
export CFLAGS = --sysroot=$(DESTDIR)
ifeq (aarch64, $(arch))
config_opts += linux-aarch64
endif
ifeq (riscv64, $(arch))
config_opts += linux64-riscv64
endif
ifeq (x86_64, $(arch))
config_opts += linux-x86_64
endif
ifeq ($(filter i486 i586 i686, $(arch)), $(arch))
config_opts += linux-x86
endif
ifeq (i486, $(arch))
export CFLAGS = -latomic
endif
ifeq (armv7l, $(arch))
config_opts += linux-generic32
export CFLAGS = -latomic
endif
config_opts += --cross-compile-prefix=$(tgt)-
config_opts += --openssldir=/etc/ssl
config_opts += --libdir=/usr/lib
config_opts += shared
consif_opts += zlib-dynamic
include targets.mk

View file

@ -28,12 +28,11 @@
#define _GNU_SOURCE
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <dirent.h> // opendir, rewinddir, readdir
#include <stdio.h> // fopen, fclose, fwrite
#include <stdlib.h> // exit, srand
#include <string.h> // strncat, strcmp, strdup
#include <time.h> // time
#include "config.h"

View file

@ -28,12 +28,12 @@
#define _XOPEN_SOURCE
#include <err.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h> // err
#include <libgen.h> // basename
#include <stdio.h> // fprintf, puts
#include <stdlib.h> // exit
#include <string.h> // strlen, strcmp
#include <unistd.h> // getopt
static const char *__progname;

View file

@ -28,12 +28,11 @@
#define _XOPEN_SOURCE
#include <err.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h> // err
#include <libgen.h> // basename, dirname
#include <stdio.h> // fprintf, puts
#include <stdlib.h> // exit
#include <unistd.h> // getopt
static const char *__progname;

View file

@ -27,11 +27,11 @@
*/
#define _XOPEN_SOURCE
#include <ctype.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h> // isprint
#include <libgen.h> // basename
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <unistd.h> // getopt, link
static const char *__progname;

View file

@ -28,13 +28,13 @@
#define _DEFAULT_SOURCE
#include <sys/sysinfo.h>
#include <sys/sysinfo.h> // get_nprocs, get_nprocs_conf
#include <ctype.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h> // isprint
#include <libgen.h> // basename
#include <stdio.h> // fprintf, printf
#include <stdlib.h> // exit
#include <unistd.h> // getopt
static const char *__progname;

View file

@ -28,13 +28,12 @@
#define _DEFAULT_SOURCE
#include <err.h>
#include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h> // warn
#include <libgen.h> // basename
#include <limits.h> // realpath
#include <stdio.h> // fprintf
#include <stdlib.h> // exit, realpath
#include <unistd.h> // getopt, access
static const char *__progname;

View file

@ -27,13 +27,14 @@
*/
#define _XOPEN_SOURCE
#include <ctype.h>
#include <inttypes.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h> // isprint
#include <errno.h> // errno
#include <stdint.h> // uint8_t
#include <libgen.h> // basename
#include <stdio.h> // fopen, fclose, fseek, ftell, fflush, fwrite
#include <stdlib.h> // exit, system
#include <string.h> // strcomp
#include <unistd.h> // getopt
static const char *__progname;
const int slice = 4096; // read/write 4k at a time
@ -95,7 +96,7 @@ int _shredit(char *file, char *dev, unsigned long int _size) {
uint8_t percent; // percentage finished
unsigned long int _tsize = (_size);
char *data; // data type
/* hide the cursor */
if (vflag)
system("tput civis");
@ -204,6 +205,23 @@ int _unlinkit(char *file) {
}
}
long parselong(char *buf) {
errno = 0;
char *endptr;
int num = strtol(optarg, &endptr, 10);
if (errno != 0) {
perror("Error parsing integer from input: ");
exit(EXIT_FAILURE);
} else if (num == 0 && endptr == optarg) {
fprintf(stderr, "Error: invalid input: %s\n", optarg);
exit(EXIT_FAILURE);
} else if (*endptr != '\0') {
fprintf(stderr, "Error: invalid input: %s\n", optarg);
exit(EXIT_FAILURE);
}
return num;
}
int main(int argc, char *argv[]) {
unsigned int index;
unsigned int c;
@ -216,7 +234,7 @@ int main(int argc, char *argv[]) {
return 0;
break;
case 'n':
pass = strtol(optarg, NULL, 10);
pass = parselong(optarg);
break;
case 'S':
Sflag = 1;

View file

@ -28,11 +28,11 @@
#define _XOPEN_SOURCE
#include <ctype.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h> // isprint
#include <libgen.h> // basename
#include <stdio.h> // fprintf, printf
#include <stdlib.h> // exit
#include <unistd.h> // getopt, unlink
static const char *__progname;
int vflag;

View file

@ -26,7 +26,7 @@
*
*/
#include <stdio.h>
#include <stdio.h> // puts
int main(int argc, char * argv[]) {
char * y;