dep
isodir
isos.iso
+Makefile-conf
# You should have received a copy of the CC0 Public Domain Dedication along with
# this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-# So, about the license. I don't think I have a copyright on this file's code, but,
-# since I gave it the CC0 license in case I do, that doesn't matter either way.
+ifneq ($(MAKECMDGOALS),clean)
+ include Makefile-conf
+endif
.PHONY: build qemu clean
build: # Build as default target
-CXX := x86_64-elf-g++
CXXFLAGS ?= -O2
CXXFLAGS := $(CXXFLAGS) -std=c++20 -fno-strict-aliasing -Wall -Wextra -Werror -Wfatal-errors \
-mgeneral-regs-only -fno-exceptions -fno-rtti -ffreestanding
build: isos.iso
qemu: build
qemu-system-x86_64 -cdrom isos.iso -serial stdio -cpu qemu64,pdpe1gb -no-reboot $(QEMUFLAGS)
+check:
clean:
-rm -rf $(TO_CLEAN)
+install:
+ install -D isos.iso -t "$(PREFIX)"
isos.iso: $(TO_ISO)
grub-mkrescue -o "$@" isodir
--- /dev/null
+#!/bin/sh
+
+# Written in 2023 by Amélia COUTARD <eliottulio.coutard@gmail.com>
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this file to the
+# public domain worldwide. This file is distributed without any warranty.
+# You should have received a copy of the CC0 Public Domain Dedication along
+# with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+
+printf '' > Makefile-conf
+
+TEMP=$(getopt -o 'h' --long 'prefix:,c++-includes-stdlib:,build:,enable-fast-install,help' -n 'download-playlist' -- "$@") || (echo 'Terminating.' >&2; exit 1)
+eval set -- "$TEMP"
+unset TEMP
+
+while true; do
+ case "$1" in
+ '--c++-includes-stdlib')
+ INCLUDES="$2"
+ shift 2
+ continue
+ ;;
+ '--prefix')
+ PREFIX="$2"
+ shift 2
+ continue
+ ;;
+ '--build') # Ignored, but accepted.
+ shift 2
+ continue
+ ;;
+ '--enable-fast-install') # Ignored, but accepted.
+ shift 1
+ continue
+ ;;
+ '-h'|'--help')
+ echo '--prefix Install prefix'
+ echo '--c++-includes-stdlib C++ standard library include files location'
+ shift
+ exit 0
+ ;;
+ '--')
+ shift
+ break
+ ;;
+ esac
+done
+
+if test "$PREFIX" = ""; then
+ echo 'Missing argument: --prefix.' >&2
+ echo 'See --help for more detail.' >&2
+ exit 1
+fi
+
+if test "$INCLUDES" = ""; then
+ echo 'Missing argument: --c++-includes-stdlib.' >&2
+ echo 'See --help for more detail.' >&2
+ exit 1
+fi
+
+echo "PREFIX = $PREFIX" >> Makefile-conf
+echo "INCLUDES = $INCLUDES" >> Makefile-conf
# You should have received a copy of the CC0 Public Domain Dedication along with
# this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-# So, about the license. I don't think I have a copyright on this file's code, but,
-# since I gave it the CC0 license in case I do, that doesn't matter either way.
-
menuentry "isos" {
multiboot2 /boot/kernel.elf64
module2 /boot/test-module.elf64 test-module
* This file is distributed without any warranty.
* You should have received a copy of the CC0 Public Domain Dedication along with
* this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-
- * So, about the license. I don't think I have a copyright on this file's code, but,
- * since I gave it the CC0 license in case I do, that doesn't matter either way.
*/
ENTRY(_start)
# You should have received a copy of the CC0 Public Domain Dedication along with
# this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-# So, about the license. I don't think I have a copyright on this file's code, but,
-# since I gave it the CC0 license in case I do, that doesn't matter either way.
-
SRC_DIR := kernel/src/
OUT_DIR := kernel/out/
DEP_DIR := kernel/dep/
TO_ISO += isodir/boot/$(EXEC_NAME)
TO_CLEAN += $(OUT_DIR) $(DEP_DIR)
+LOCAL_CXX := g++-system
LOCAL_CXXFLAGS := $(CXXFLAGS) -mcmodel=kernel -mno-red-zone \
- -isystem /usr/include -isystem /usr/include/c++/13.1.1 \
- -isystem /usr/include/c++/13.1.1/x86_64-pc-linux-gnu
- # The previous two lines are a dirty hack. But not that much, because it doesn't allow me to include non-freestanding headers anyways
+ -isystem $(INCLUDES) -isystem $(INCLUDES)/c++ -isystem $(INCLUDES)/c++/x86_64-unknown-linux-gnu
+ # The previous line is a dirty hack. But not that much, because it doesn't allow me to include non-freestanding headers anyways
LOCAL_LDFLAGS := $(LDFLAGS) -T kernel/linker.ld -z max-page-size=0x1000 \
-mno-red-zone -mcmodel=kernel
ASMOBJS := $(ASMSRCS:$(SRC_DIR)%=$(OUT_DIR)%.o)
CRTI_OBJ := $(OUT_DIR)/lib/crti.S.o
-CRTBEGIN_OBJ := $(shell $(CXX) $(LOCAL_LDFLAGS) -print-file-name=crtbegin.o)
-CRTEND_OBJ := $(shell $(CXX) $(LOCAL_LDFLAGS) -print-file-name=crtend.o)
+CRTBEGIN_OBJ := $(shell $(LOCAL_CXX) $(LOCAL_LDFLAGS) -print-file-name=crtbegin.o)
+CRTEND_OBJ := $(shell $(LOCAL_CXX) $(LOCAL_LDFLAGS) -print-file-name=crtend.o)
CRTN_OBJ := $(OUT_DIR)/lib/crtn.S.o
OBJS := $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(CPPOBJS) $(ASMOBJS) $(CRTEND_OBJ) $(CRTN_OBJ)
$(OUT_DIR)$(EXEC_NAME): OBJS := $(OBJS)
$(OUT_DIR)$(EXEC_NAME): LDLIBS := -nostdlib -lgcc
$(OUT_DIR)$(EXEC_NAME): LDFLAGS := $(LOCAL_LDFLAGS)
+$(OUT_DIR)$(EXEC_NAME): CXX := $(LOCAL_CXX)
$(OUT_DIR)$(EXEC_NAME): $(OBJS) kernel/linker.ld
mkdir -p "$(@D)"
$(CXX) $(LDFLAGS) -o "$@" $(OBJS) $(LDLIBS)
$(OUT_DIR)%.o: DEP_DIR := $(DEP_DIR)
$(OUT_DIR)%.o: CXXFLAGS := $(LOCAL_CXXFLAGS)
+$(OUT_DIR)%.o: CXX := $(LOCAL_CXX)
$(OUT_DIR)%.o: $(SRC_DIR)%
mkdir -p $(@D)
mkdir -p $(dir $(DEP_DIR)$*)
# You should have received a copy of the CC0 Public Domain Dedication along with
# this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-# So, about the license. I don't think I have a copyright on this file's code, but,
-# since I gave it the CC0 license in case I do, that doesn't matter either way.
-
SRC_DIR := test_module/src/
OUT_DIR := test_module/out/
DEP_DIR := test_module/dep/
TO_ISO += isodir/boot/$(EXEC_NAME)
TO_CLEAN += $(OUT_DIR) $(DEP_DIR)
+LOCAL_CXX := g++-user
LOCAL_CXXFLAGS := $(CXXFLAGS)
LOCAL_LDFLAGS := $(LDFLAGS)
$(OUT_DIR)$(EXEC_NAME): OBJS := $(OBJS)
$(OUT_DIR)$(EXEC_NAME): LDLIBS := -nostdlib -lgcc
$(OUT_DIR)$(EXEC_NAME): LDFLAGS := $(LOCAL_LDFLAGS)
+$(OUT_DIR)$(EXEC_NAME): CXX := $(LOCAL_CXX)
$(OUT_DIR)$(EXEC_NAME): $(OBJS)
mkdir -p "$(@D)"
$(CXX) $(LDFLAGS) -o "$@" $+ $(LDLIBS)
$(OUT_DIR)%.o: DEP_DIR := $(DEP_DIR)
$(OUT_DIR)%.o: CXXFLAGS := $(LOCAL_CXXFLAGS)
+$(OUT_DIR)%.o: CXX := $(LOCAL_CXX)
$(OUT_DIR)%.o: $(SRC_DIR)%
mkdir -p $(@D)
mkdir -p $(dir $(DEP_DIR)$*)
# You should have received a copy of the CC0 Public Domain Dedication along with
# this file. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
-# So, about the license. I don't think I have a copyright on this file's code, but,
-# since I gave it the CC0 license in case I do, that doesn't matter either way.
-
SRC_DIR := test_module_2/src/
OUT_DIR := test_module_2/out/
DEP_DIR := test_module_2/dep/
TO_ISO += isodir/boot/$(EXEC_NAME)
TO_CLEAN += $(OUT_DIR) $(DEP_DIR)
+LOCAL_CXX := g++-user
LOCAL_CXXFLAGS := $(CXXFLAGS)
LOCAL_LDFLAGS := $(LDFLAGS)
$(OUT_DIR)$(EXEC_NAME): OBJS := $(OBJS)
$(OUT_DIR)$(EXEC_NAME): LDLIBS := -nostdlib -lgcc
$(OUT_DIR)$(EXEC_NAME): LDFLAGS := $(LOCAL_LDFLAGS)
+$(OUT_DIR)$(EXEC_NAME): CXX := $(LOCAL_CXX)
$(OUT_DIR)$(EXEC_NAME): $(OBJS)
mkdir -p "$(@D)"
$(CXX) $(LDFLAGS) -o "$@" $+ $(LDLIBS)
$(OUT_DIR)%.o: DEP_DIR := $(DEP_DIR)
$(OUT_DIR)%.o: CXXFLAGS := $(LOCAL_CXXFLAGS)
+$(OUT_DIR)%.o: CXX := $(LOCAL_CXX)
$(OUT_DIR)%.o: $(SRC_DIR)%
mkdir -p $(@D)
mkdir -p $(dir $(DEP_DIR)$*)