limine-install: Make hgen a shell script

This commit is contained in:
mintsuki 2022-02-10 14:47:38 +01:00
parent f2b468c46c
commit 699d531eea
6 changed files with 20 additions and 56 deletions

1
.gitignore vendored
View File

@ -35,4 +35,3 @@
/common-uefi64
/decompressor-build
/stage1.stamp
/hgen

View File

@ -26,9 +26,6 @@ CC := @CC@
endif
export CC
HOST_CC ?= @HOST_CC@
export HOST_CC
INSTALL ?= @INSTALL@
export INSTALL
@ -80,15 +77,11 @@ override STAGE1_FILES := $(shell find '$(call SHESCAPE,$(SRCDIR))/stage1' -type
.PHONY: all
all: limine-uefi limine-bios
$(call MKESCAPE,$(BUILDDIR))/hgen: $(call MKESCAPE,$(SRCDIR))/limine-install/hgen.c
mkdir -p '$(call SHESCAPE,$(BUILDDIR))'
$(HOST_CC) $(CFLAGS) -std=c11 '$(call SHESCAPE,$(SRCDIR))/limine-install/hgen.c' -o '$(call SHESCAPE,$(BUILDDIR))/hgen'
.PHONY: limine-hdd.h
limine-hdd.h: $(call MKESCAPE,$(BINDIR))/limine-hdd.h
$(call MKESCAPE,$(BINDIR))/limine-hdd.h: $(call MKESCAPE,$(BUILDDIR))/hgen $(call MKESCAPE,$(BINDIR))/limine-hdd.bin
cd '$(call SHESCAPE,$(BINDIR))' && '$(call SHESCAPE,$(BUILDDIR))/hgen' >limine-hdd.h
$(call MKESCAPE,$(BINDIR))/limine-hdd.h: $(call MKESCAPE,$(BINDIR))/limine-hdd.bin
cd '$(call SHESCAPE,$(BINDIR))' && '$(call SHESCAPE,$(SRCDIR))/limine-install/hgen.sh' >limine-hdd.h
.PHONY: limine-install
limine-install:
@ -99,7 +92,7 @@ limine-install:
.PHONY: clean
clean: limine-bios-clean limine-uefi32-clean limine-uefi64-clean
rm -rf '$(call SHESCAPE,$(BINDIR))' '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp' '$(call SHESCAPE,$(BUILDDIR))/hgen'
rm -rf '$(call SHESCAPE,$(BINDIR))' '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp'
.PHONY: install-data
install-data:

View File

@ -62,9 +62,6 @@ if ! test "x$BUILD_ELTORITO_EFI" = "xno"; then
AC_SUBST(build_eltorito_efi, [yes])
fi
AC_ARG_VAR(HOST_CC, [C compiler for the build host [default: $CC]])
test "x$HOST_CC" = "x" && HOST_CC="$CC"
AC_ARG_VAR(TOOLCHAIN, [Alternative toolchain prefix [default: limine]])
test "x$TOOLCHAIN" = "x" && TOOLCHAIN='limine'

View File

@ -1,42 +0,0 @@
#include <stdio.h>
int main(void) {
int ok = 0;
FILE *limine_hdd = fopen("limine-hdd.bin", "r+b");
if (limine_hdd == NULL) {
goto err;
}
printf("const uint8_t _binary_limine_hdd_bin_data[] = {\n\t");
int c = fgetc(limine_hdd);
for (size_t i = 0; ; i++) {
printf("0x%02x", c);
c = fgetc(limine_hdd);
if (c == EOF) {
break;
}
printf(", ");
if (i % 12 == 11) {
printf("\n\t");
}
}
printf("\n};\n");
goto cleanup;
err:
perror("ERROR");
ok = 1;
cleanup:
if (limine_hdd != NULL) {
fclose(limine_hdd);
}
return ok;
}

14
limine-install/hgen.sh Executable file
View File

@ -0,0 +1,14 @@
#! /bin/sh
LC_ALL=C
export LC_ALL
cat <<EOF
const uint8_t _binary_limine_hdd_bin_data[] = {
EOF
od -v -An -t x1 <limine-hdd.bin | "$SED" 's/ /, 0x/g;s/^, / /g;s/$/,/g'
cat <<EOF
};
EOF

View File

@ -1,4 +1,7 @@
#! /bin/sh
LC_ALL=C
export LC_ALL
[ -f version ] || ( git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null || git log -n1 --pretty='%h' ) | sed 's/^v//g' | xargs printf '%s'
[ -f version ] && ( cat version 2>/dev/null ) | xargs printf '%s'