diff --git a/Makefile b/Makefile index ff8d587..dff71f2 100644 --- a/Makefile +++ b/Makefile @@ -182,7 +182,7 @@ endef .PHONY: all re clean fclean \ install uninstall \ debug debug_build valgrind \ - unit_tests tests_run coverage functional_tests \ + unit_tests tests_run coverage functional_tests plugin \ help all: $(NAME) @@ -278,10 +278,24 @@ fclean: clean $(call pretty_header, Full clean: objects binary tests coverage) @$(RM) $(NAME) $(TO_RM) @$(RM) $(LOGS_DIR)/functional_tests + @find ./plugins -type f -name 'lib*.so' -delete @$(RM) /tmp/test.* /tmp/.shell.* /tmp/.refer.* /tmp/.tester.* /tmp/.runner.* /tmp/.tmp.* test/ dir; @$(RM) "dir \"" "dir;" test output @$(MAKE) fclean -C tests/ +plugin: all + $(call pretty_header, Building Plugins) + @set -e; \ + for plugin_src in $$(find ./plugins -type d -name src | sort); do \ + plugin_dir=$$(dirname "$$plugin_src"); \ + plugin_name=$$(basename "$$plugin_dir"); \ + printf "%b\n" "$(H_CYAN)Building plugin$(END) $(BOLD)$$plugin_name$(END) ..."; \ + clang -fPIC -shared $(CFLAGS) \ + -I"$$plugin_dir/include" -Iinclude -I"$$plugin_dir/src" \ + -o "plugins/lib$$plugin_name.so" \ + $$(find "$$plugin_src" -type f -name '*.c' | sort); \ + done + re: fclean all # ─── Help ──────────────────────────────────────────────────────────────── diff --git a/plugins/example/crocus/src/crocus.c b/plugins/example/crocus/src/crocus.c index 62d2d3b..5bd6f55 100644 --- a/plugins/example/crocus/src/crocus.c +++ b/plugins/example/crocus/src/crocus.c @@ -5,8 +5,7 @@ ** tic-tac-toe.c */ -#include "../../../include/core/plugins.h" -#include "../../../include/c_zsh.h" +#include "c_zsh.h" #include "../include/crocus.h" #include diff --git a/plugins/example/hello/hello.c b/plugins/example/hello/src/hello.c similarity index 91% rename from plugins/example/hello/hello.c rename to plugins/example/hello/src/hello.c index 95c3e29..f786052 100644 --- a/plugins/example/hello/hello.c +++ b/plugins/example/hello/src/hello.c @@ -5,8 +5,7 @@ ** hello.c */ -#include "../include/core/plugins.h" -#include "../include/c_zsh.h" +#include "c_zsh.h" #include static int hello_builtin(main_t *main_stock, command_ctx_t *ctx)