Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision cd76bbd516f36017eb62c38e2de3aa95ee8c5650)
+++ 	(revision )
@@ -1,93 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-
-FPU_NO_CFLAGS = -mno-sse -mno-sse2
-
-# TODO: Red Zone is only a problem if we allow interrupts to land on an active
-#       stack. Using separate stack for interrupts and ensuring that we never
-#       enable interrupts on an interrupt stack would allow us to get rid of
-#       the argument.
-
-COMMON_CFLAGS += -mcmodel=$(MEMORY_MODEL) -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
-
-BITS = 64
-ENDIANESS = LE
-
-## Accepted CPUs
-#
-
-ifeq ($(PROCESSOR),opteron)
-	COMMON_CFLAGS += -march=opteron
-endif
-
-ARCH_SOURCES = \
-	arch/$(KARCH)/src/fpu_context.c \
-	arch/$(KARCH)/src/boot/multiboot.S \
-	arch/$(KARCH)/src/boot/multiboot2.S \
-	arch/$(KARCH)/src/boot/memmap.c \
-	arch/$(KARCH)/src/debug/stacktrace.c \
-	arch/$(KARCH)/src/debug/stacktrace_asm.S \
-	arch/$(KARCH)/src/pm.c \
-	arch/$(KARCH)/src/vreg.c \
-	arch/$(KARCH)/src/kseg.c \
-	arch/$(KARCH)/src/context.S \
-	arch/$(KARCH)/src/ddi/ddi.c \
-	arch/$(KARCH)/src/drivers/i8254.c \
-	arch/$(KARCH)/src/delay.S \
-	arch/$(KARCH)/src/amd64.c \
-	arch/$(KARCH)/src/bios/bios.c \
-	arch/$(KARCH)/src/interrupt.c \
-	arch/$(KARCH)/src/mm/km.c \
-	arch/$(KARCH)/src/mm/as.c \
-	arch/$(KARCH)/src/mm/frame.c \
-	arch/$(KARCH)/src/mm/page.c \
-	arch/$(KARCH)/src/mm/tlb.c \
-	arch/$(KARCH)/src/asm.S \
-	arch/$(KARCH)/src/cpu/cpu.c \
-	arch/$(KARCH)/src/proc/scheduler.c \
-	arch/$(KARCH)/src/proc/task.c \
-	arch/$(KARCH)/src/proc/thread.c \
-	arch/$(KARCH)/src/userspace.c \
-	arch/$(KARCH)/src/smc.c \
-	arch/$(KARCH)/src/syscall.c
-
-ifeq ($(CONFIG_SMP),y)
-	ARCH_SOURCES += \
-		arch/$(KARCH)/src/smp/ap.S \
-		arch/$(KARCH)/src/smp/apic.c \
-		arch/$(KARCH)/src/smp/ipi.c \
-		arch/$(KARCH)/src/smp/mps.c \
-		arch/$(KARCH)/src/smp/smp.c
-endif
-
-ARCH_AUTOCHECK_HEADERS = \
-	arch/$(KARCH)/include/arch/istate_struct.h \
-	arch/$(KARCH)/include/arch/context_struct.h \
-	arch/$(KARCH)/include/arch/kseg_struct.h \
-	arch/$(KARCH)/include/arch/boot/memmap_struct.h
Index: kernel/arch/amd64/meson.build
===================================================================
--- kernel/arch/amd64/meson.build	(revision e428becb1f92b5b4d8d6b10b19091c39ea1b79f9)
+++ kernel/arch/amd64/meson.build	(revision e428becb1f92b5b4d8d6b10b19091c39ea1b79f9)
@@ -0,0 +1,95 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2019 Jiří Zárevúcky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# TODO: Red Zone is only a problem if we allow interrupts to land on an active
+#       stack. Using separate stack for interrupts and ensuring that we never
+#       enable interrupts on an interrupt stack would allow us to get rid of
+#       the argument.
+
+kernel_c_args += [ '-mno-sse', '-mno-sse2', '-mcmodel=' + MEMORY_MODEL, '-mno-red-zone', '-fno-unwind-tables', '-fno-omit-frame-pointer' ]
+
+# TODO: fix this
+kernel_link_args += [ '-Wl,--no-gc-sections' ]
+
+if PROCESSOR == 'opteron'
+	kernel_c_args += '-march=opteron'
+endif
+
+arch_src += files(
+	'src/amd64.c',
+	'src/asm.S',
+	'src/bios/bios.c',
+	'src/boot/memmap.c',
+	'src/boot/multiboot2.S',
+	'src/boot/multiboot.S',
+	'src/context.S',
+	'src/cpu/cpu.c',
+	'src/ddi/ddi.c',
+	'src/debug/stacktrace_asm.S',
+	'src/debug/stacktrace.c',
+	'src/delay.S',
+	'src/drivers/i8254.c',
+	'src/fpu_context.c',
+	'src/interrupt.c',
+	'src/kseg.c',
+	'src/mm/as.c',
+	'src/mm/frame.c',
+	'src/mm/km.c',
+	'src/mm/page.c',
+	'src/mm/tlb.c',
+	'src/pm.c',
+	'src/proc/scheduler.c',
+	'src/proc/task.c',
+	'src/proc/thread.c',
+	'src/smc.c',
+	'src/syscall.c',
+	'src/userspace.c',
+	'src/vreg.c',
+)
+
+if CONFIG_SMP
+	arch_src += files(
+		'src/smp/apic.c',
+		'src/smp/ap.S',
+		'src/smp/ipi.c',
+		'src/smp/mps.c',
+		'src/smp/smp.c',
+	)
+endif
+
+_check_headers = [
+	'include/arch/boot/memmap_struct.h',
+	'include/arch/context_struct.h',
+	'include/arch/istate_struct.h',
+	'include/arch/kseg_struct.h',
+]
+
+foreach h : _check_headers
+	arch_src += [ autocheck.process(h) ]
+endforeach
