Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ result-*
/src/kernel/arch/riscv64/kernel.elf
/src/kernel/kernel.elf
/src/kernel/kernel.sym

cscope.*
*.swp
Comment thread
arbormoss marked this conversation as resolved.
*~
42 changes: 40 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,44 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

define HELP_TEXT
Configuring:
mkdir build
cd build
../configure

Make targets other than "help" require configuration.

Make Targets:
- (default): Build UkoOS.
- qemu: Run inside of the QEMU virtual machine.
- qemu-debug: Run inside of QEMU for debugging. Run make gdb in another
terminal to attach.
- gdb: Attach gdb to a running debug session.
- clean: Clean build artefacts.
- watch: Build and rebuild on new changes in doc/ and src/.
- doc-serve: Serve the UkoOS docs on port 3000, and rebuild on changes.
- doc: Build HTML documentation.
- help: Show this help text.
- format: clang-format source files.

More documentation is available at https://docs.ukoos.org
endef
export HELP_TEXT

ifeq ($(strip $(MAKECMDGOALS)),$(strip $(filter help,$(MAKECMDGOALS))))
ifneq (,$(MAKECMDGOALS))
help_only = 1
endif
endif

# Include config.mak, and make sure that it is present.
ifndef help_only
-include config.mak
ifndef config_mak_present
$(error The build was not configured; run ./configure)
endif
endif # help_only

# Turn off some built-in behavior we don't want.
.DEFAULT_GOAL = all
Expand Down Expand Up @@ -40,18 +73,23 @@ $(1)-ldflags ?=
endef

# Information about the build to perform.
ifndef help_only
include $(srcdir)/doc/include.mak
include $(srcdir)/src/kernel/include.mak

# Load the target.
ifeq ($(realpath $(srcdir)/src/targets/$(arch)/$(target).mak),)
$(error The target $(target) did not exist; rerun ./configure)
endif

include $(srcdir)/src/targets/$(arch)/$(target).mak
endif # help_only

# Common rules.
all::
$(call defcleanable,compile_commands.json)
help:
@echo "$$HELP_TEXT"
distclean: clean
@if [[ -e config.mak ]]; then echo "CLEAN config.mak"; rm config.mak; fi
@if [[ -e Makefile ]]; then echo "CLEAN Makefile"; rm Makefile; fi
Expand All @@ -66,9 +104,9 @@ watch:
format:
@find $(srcdir) -type f \( -name '*.c' -o -name '*.h' \) \
-exec clang-format -i {} \; \
-printf "FORMAT %P\n"
-exec echo 'FORMAT {}' \;

.PHONY: all clean install watch format
.PHONY: all clean install watch format help
.SUFFIXES:

define common_rules_for_dir
Expand Down
Loading