From dbd8b731344de441c5215e7ea9dbb12823982ab6 Mon Sep 17 00:00:00 2001 From: hanez Date: Sun, 14 Sep 2025 21:29:05 +0200 Subject: [PATCH] Added install routine to CMake and added a classic Makefile as a wrapper for easy building. --- CMakeLists.txt | 19 +++++++++++++++++++ Makefile | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ed8b6a..fd0b920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(fun C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) +include(GNUInstallDirs) + # Core VM/library sources add_library(fun_core src/bytecode.c @@ -58,3 +60,20 @@ add_custom_target(dist-clean ${CMAKE_BINARY_DIR}/.ninja_* COMMENT "Remove build outputs and CMake-generated files (reconfigure needed)" ) + +# Install rules +# - Binary +install(TARGETS fun + RUNTIME DESTINATION /usr/bin) + +# - Optionally install example scripts +option(FUN_INSTALL_EXAMPLES "Install example .fun scripts" ON) +if(FUN_INSTALL_EXAMPLES) + install(DIRECTORY examples/ + DESTINATION /usr/share/fun/examples + FILES_MATCHING PATTERN "*.fun") +endif() + +# - Docs +install(FILES README.md LICENSE + DESTINATION /usr/share/doc/fun) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a91a46d --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +all: + make clean + make fun + make fun_test + make test_opcodes + +fun: + cmake -S . -B build -DFUN_DEBUG=ON + cmake --build build --target fun + +fun_test: + cmake -S . -B build -DFUN_DEBUG=ON + cmake --build build --target fun_test + +clean: + cmake --build build --target clean-build + +# Or set a custom prefix: cmake --install build --prefix "$HOME/.local" +# Defaults: +# Binary: /usr/bin/fun +# Docs: /share/doc/fun/README.md, LICENSE +# Examples: /share/fun/examples/*.fun +install: + cmake --install build + +test_opcodes: + cmake -S . -B build -DFUN_DEBUG=ON + cmake --build build --target test_opcodes