From 24179b12cad93bc30e613cddbe8e0d6ae56a3f9e Mon Sep 17 00:00:00 2001 From: Dendy Date: Sun, 7 Feb 2021 10:59:00 +0100 Subject: [PATCH] Make installable --- Makefile | 14 +++++++++++++- README.md | 13 ++++++++++--- examples/nodetree/Makefile | 13 +++---------- examples/nodetree/main.c | 4 ++-- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 4bfb921..c7a1d31 100644 --- a/Makefile +++ b/Makefile @@ -7,17 +7,29 @@ CC="tcc" DIR=build SRC=src +OUT=libnodesystem.so OBJ_FLAGS=-c -Wall -Werror -I include/ all: $(DIR)/node.o $(DIR)/node2d.o - $(CC) -shared -o libnodesystem.so $^ + $(CC) -shared -o $(OUT) $^ build/node.o: $(SRC)/node.c $(DIR) $(CC) $(OBJ_FLAGS) $(SRC)/node.c -o $@ build/node2d.o: $(SRC)/node2d.c $(DIR) $(CC) $(OBJ_FLAGS) $(SRC)/node2d.c -o $@ +install: + cp $(OUT) /usr/lib/ + chmod 0755 /usr/lib/$(OUT) + ldconfig + [ -d /usr/include/NODESYS ] || mkdir /usr/include/NODESYS + cp -r include/* /usr/include/NODESYS + +remove: + rm -f /usr/lib/$(OUT) + rm -rf /usr/include/NODESYS + $(DIR): mkdir $(DIR) diff --git a/README.md b/README.md index bf8db41..f3a8615 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ # NodeSystem -Just a library for handling node logic inside C, inspired by Godot, mainly focused for the creation of games. +Just a library for handling node logic inside C, inspired +by Godot, mainly focused for the creation of games. -For now there's a basic Node struct and a Node2D that "inherits" from it. +For now there's a basic Node struct and a Node2D that +"inherits" from it. -To compile and run the examples just do "make run" on their folders +To compile run "make" and to compile and install run +"make install" as superuser. You can uninstall by running +"make remove" +To compile and run the examples you have to have the library +installed. To compile and run them just do "make run" on +their folders. diff --git a/examples/nodetree/Makefile b/examples/nodetree/Makefile index 2a5071b..ac59af6 100644 --- a/examples/nodetree/Makefile +++ b/examples/nodetree/Makefile @@ -7,18 +7,11 @@ CC="tcc" SRC=main.c -main: $(SRC) ../../libnodesystem.so - tcc -o $@ -I ../../include $(SRC) -lnodesystem -L../../ +main: $(SRC) + tcc -o $@ $(SRC) -lnodesystem run: main - LD_LIBRARY_PATH=../..:$LD_LIBRARY_PATH ./main - -full: $(SRC) - make -C ../../ - tcc -o main -I ../../include $(SRC) -lnodesystem -L../../ - -../../libnodesystem.so: - make -C ../../ + ./main clean: rm -rf main diff --git a/examples/nodetree/main.c b/examples/nodetree/main.c index ad1f97d..b4088d6 100644 --- a/examples/nodetree/main.c +++ b/examples/nodetree/main.c @@ -1,7 +1,7 @@ #include -#include "node.h" -#include "node2d.h" +#include "NODESYS/node.h" +#include "NODESYS/node2d.h" int main(int argc, char* *argv){ NOD_Node *distros = NOD_CreateNode("Distros");