aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-09 17:31:27 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-09 17:31:27 +0200
commitfd234aeb2f90757d2115cdabfc488e78d87d0f46 (patch)
tree6e7b5a1a6961530fce956d3c0151c39728571f07
parent73471f4fb7ada04ae3a6a041f3cb2475782144a7 (diff)
downloaddungeon_game-fd234aeb2f90757d2115cdabfc488e78d87d0f46.tar.xz
Fix plugin target
-rw-r--r--Makefile5
-rw-r--r--README.md2
-rw-r--r--plugins/apple/Makefile6
-rw-r--r--plugins/apple/apple.c2
-rw-r--r--plugins/game/Makefile6
-rw-r--r--plugins/game/game.c2
-rw-r--r--plugins/monster/Makefile6
-rw-r--r--plugins/monster/monster.c2
8 files changed, 19 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 5241f4f..01017e6 100644
--- a/Makefile
+++ b/Makefile
@@ -3,5 +3,6 @@ all: dungeon plugins
dungeon: dungeon.c
cc -g -o dungeon dungeon.c -ldl -D_GNU_SOURCE
-plugins:
- make -f plugins/*/Makefile
+include plugins/*/Makefile
+
+plugins: ${PLUGINS}
diff --git a/README.md b/README.md
index c608770..fbfc863 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ You might want to include the game.h file from plugins/game/game.h. Have a look
Controls: WASD to move, Q to quit.
-To build the loader and the plugins in the plugins/ folder, simply type `make` or `make all`. There are separate targets for the loader (`dungeon`) and the plugins. The plugins target simply triggerst all Makefiles that are placed in plugin directories, so you might want to include a makefile in your plugin.
+To build the loader and the plugins in the plugins/ folder, simply type `make` or `make all`. There are separate targets for the loader (`dungeon`) and the plugins. All Makefiles that are placed in plugin directories, so you might want to include a makefile in your plugin. The plugins target simply depends on ${PLUGINS}, so just add things to this in your plugin Makefile to add them to the plugins target (usually your plugin.so)
To run the loader, type `./dungeon`. It will load all plugins including the game itself dynamically and run the game.
Plugins are loaded in alphabethical order, with the exception of the game plugin that is loaded first. If you want to make a plugin that depends on another plugin, make sure the other plugin is loaded first by setting the name of your plugin accordingly. A cleaner solution to this is coming soon.
diff --git a/plugins/apple/Makefile b/plugins/apple/Makefile
index 8e3ccca..33c3303 100644
--- a/plugins/apple/Makefile
+++ b/plugins/apple/Makefile
@@ -1,2 +1,4 @@
-apple.so: apple.c ../game/game.h
- cc -g -shared -fpic -o apple.so apple.c
+plugins/apple/apple.so: plugins/apple/apple.c plugins/game/game.h
+ cc -g -shared -fpic -o plugins/apple/apple.so plugins/apple/apple.c
+
+PLUGINS := ${PLUGINS} plugins/apple/apple.so
diff --git a/plugins/apple/apple.c b/plugins/apple/apple.c
index 7c2de77..dd8a559 100644
--- a/plugins/apple/apple.c
+++ b/plugins/apple/apple.c
@@ -1,6 +1,6 @@
#include <stddef.h>
#include <stdlib.h>
-#include "dungeon.h"
+#include "../game/game.h"
static struct entity apple;
diff --git a/plugins/game/Makefile b/plugins/game/Makefile
index 83714da..b8472f6 100644
--- a/plugins/game/Makefile
+++ b/plugins/game/Makefile
@@ -1,2 +1,4 @@
-game.so: game.c game.h
- cc -g -shared -fpic -o game.so game.c -lm -lpthread
+plugins/game/game.so: plugins/game/game.c plugins/game/game.h
+ cc -g -shared -fpic -o plugins/game/game.so plugins/game/game.c -lm -lpthread
+
+PLUGINS := ${PLUGINS} plugins/game/game.so
diff --git a/plugins/game/game.c b/plugins/game/game.c
index f0496b8..b283214 100644
--- a/plugins/game/game.c
+++ b/plugins/game/game.c
@@ -11,7 +11,7 @@
#include <sys/ioctl.h>
#include <math.h>
#include <pthread.h>
-#include "dungeon.h"
+#include "game.h"
bool running = true;
diff --git a/plugins/monster/Makefile b/plugins/monster/Makefile
index 1ba16c5..28edde8 100644
--- a/plugins/monster/Makefile
+++ b/plugins/monster/Makefile
@@ -1,2 +1,4 @@
-monster.so: monster.c ../game/game.h
- cc -g -shared -fpic -o monster.so monster.c
+plugins/monster/monster.so: plugins/monster/monster.c plugins/game/game.h
+ cc -g -shared -fpic -o plugins/monster/monster.so plugins/monster/monster.c
+
+PLUGINS := ${PLUGINS} plugins/monster/monster.so
diff --git a/plugins/monster/monster.c b/plugins/monster/monster.c
index 167de88..6cb14ff 100644
--- a/plugins/monster/monster.c
+++ b/plugins/monster/monster.c
@@ -1,6 +1,6 @@
#include <stdlib.h>
#include <stddef.h>
-#include "dungeon.h"
+#include "../game/game.h"
static struct entity monster;