:: commit 060b654b7f0b27d8728fa8b7db3fc002f65b8ffd

mintsuki <mintsuki@protonmail.com> — 2022-02-20 22:05

parents: 97e0f74d22

build: Use config.h for generated constants

diff --git a/.gitignore b/.gitignore
index 419ae40e..6e84b730 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
 /config.log
 /autom4te.cache
 /GNUmakefile
+/common/config.h
 /common-bios
 /common-uefi32
 /common-uefi64
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9a093cda..0f8be1b7 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -71,12 +71,6 @@ export LIMINE_READELF
 override USING_CLANG := @USING_CLANG@
 export USING_CLANG
 
-override LIMINE_VERSION := @PACKAGE_VERSION@
-export LIMINE_VERSION
-
-override LIMINE_COPYRIGHT := $(shell $(GREP) Copyright '$(call SHESCAPE,$(SRCDIR))/LICENSE.md')
-export LIMINE_COPYRIGHT
-
 override STAGE1_FILES := $(shell find '$(call SHESCAPE,$(SRCDIR))/stage1' -type f -name '*.asm')
 
 .PHONY: all
diff --git a/common/GNUmakefile b/common/GNUmakefile
index 60fa37d8..14794d62 100644
--- a/common/GNUmakefile
+++ b/common/GNUmakefile
@@ -60,8 +60,6 @@ override INTERNAL_CFLAGS := \
 	-mno-sse \
 	-mno-sse2 \
 	-MMD \
-	-DLIMINE_VERSION='"$(LIMINE_VERSION)"' \
-	-DLIMINE_COPYRIGHT='"$(LIMINE_COPYRIGHT)"' \
 	-DCOM_OUTPUT=$(COM_OUTPUT) \
 	-DE9_OUTPUT=$(E9_OUTPUT) \
 	-I../freestanding_headers \
diff --git a/common/config.h.in b/common/config.h.in
new file mode 100644
index 00000000..c93e5113
--- /dev/null
+++ b/common/config.h.in
@@ -0,0 +1,7 @@
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define LIMINE_VERSION "@PACKAGE_VERSION@"
+#define LIMINE_COPYRIGHT "@LIMINE_COPYRIGHT@"
+
+#endif
diff --git a/common/console.c b/common/console.c
index 46fb14ad..8823f106 100644
--- a/common/console.c
+++ b/common/console.c
@@ -1,5 +1,6 @@
 #include <stddef.h>
 #include <stdint.h>
+#include <config.h>
 #include <console.h>
 #include <menu.h>
 #include <mm/pmm.h>
diff --git a/common/menu.c b/common/menu.c
index 9c76a66e..09f36d95 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -2,6 +2,7 @@
 #include <stddef.h>
 #include <stdbool.h>
 #include <stdnoreturn.h>
+#include <config.h>
 #include <menu.h>
 #include <lib/print.h>
 #include <lib/blib.h>
diff --git a/common/protos/multiboot1.c b/common/protos/multiboot1.c
index 7d3d2e3c..7902a481 100644
--- a/common/protos/multiboot1.c
+++ b/common/protos/multiboot1.c
@@ -1,6 +1,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <stdnoreturn.h>
+#include <config.h>
 #include <protos/multiboot1.h>
 #include <lib/libc.h>
 #include <lib/elf.h>
diff --git a/common/protos/multiboot2.c b/common/protos/multiboot2.c
index 40daee34..1ed1b688 100644
--- a/common/protos/multiboot2.c
+++ b/common/protos/multiboot2.c
@@ -1,6 +1,7 @@
 #include <protos/multiboot2.h>
 #include <stdint.h>
 #include <stddef.h>
+#include <config.h>
 #include <lib/libc.h>
 #include <lib/elf.h>
 #include <lib/blib.h>
diff --git a/common/protos/stivale2.c b/common/protos/stivale2.c
index ebd8334e..95c7555d 100644
--- a/common/protos/stivale2.c
+++ b/common/protos/stivale2.c
@@ -1,6 +1,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <stdbool.h>
+#include <config.h>
 #include <protos/stivale.h>
 #include <protos/stivale2.h>
 #include <lib/elf.h>
diff --git a/configure.ac b/configure.ac
index 5116ff1e..b67b6454 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,7 +232,10 @@ test "x$LIMINE_CFLAGS" = "x" && LIMINE_CFLAGS='-O3 -pipe -Wall -Wextra'
 AC_ARG_VAR(LIMINE_LDFLAGS, [Linker flags for Limine [default: ]])
 test "x$LIMINE_LDFLAGS" = "x" && LIMINE_LDFLAGS=' '
 
+LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/LICENSE.md")
+AC_SUBST(LIMINE_COPYRIGHT, [$LIMINE_COPYRIGHT])
+
 AC_PREFIX_DEFAULT(/usr/local)
 
-AC_CONFIG_FILES(GNUmakefile)
+AC_CONFIG_FILES(GNUmakefile common/config.h)
 AC_OUTPUT
tab: 248 wrap: offon