aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile49
-rw-r--r--src/room.h5
2 files changed, 48 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 6a17bdc..ca121ed 100644
--- a/Makefile
+++ b/Makefile
@@ -11,21 +11,60 @@ LDFLAGS = -lgcrypt -lev
HEADERS = src/*.h export/include/*.h
-all: $(OUT)/$(PLATFORM).bin Makefile SOURCES $(HEADERS)
+DEPS = $(NETCOSM_SRC:.c=.d)
+
+.PHONY: all
+all: $(OUT)/$(PLATFORM).bin Makefile SOURCES $(HEADERS) $(DEPS)
+
+%.o: %.c Makefile %.d
+ @echo "CC $<"
+ @$(CC) $(CFLAGS) $(OPTFLAGS) -c $< -o $@
$(OUT)/$(PLATFORM).bin: $(NETCOSM_OBJ) $(HEADERS) Makefile
@mkdir -p $(OUT)
- @echo "LD $<"
+ @echo "LD $@"
@$(CC) $(NETCOSM_OBJ) $(CFLAGS) $(LDFLAGS) -o $(OUT)/$(PLATFORM).bin
+# automatically generate dependency rules
+
+%.d : %.c
+ @echo "MKDEP $<"
+ @$(CC) $(CCFLAGS) -MF"$@" -MG -MM -MP -MT"$@" -MT"$(<:.c=.o)" "$<"
+
+# -MF write the generated dependency rule to a file
+# -MG assume missing headers will be generated and don't stop with an error
+# -MM generate dependency rule for prerequisite, skipping system headers
+# -MP add phony target for each header to prevent errors when header is missing
+# -MT add a target to the generated dependency
+
+-include $(DEPS)
+
+.PHONY: depend
+depend: $(DEPS)
+ @echo "Dependencies (re)generated."
+
+.PHONY: install
install: $(OUT)/$(PLATFORM).bin
@install $(OUT)/$(PLATFORM).bin /bin/netcosm
+.PHONY: clean
clean:
@echo "Cleaning build directory..."
@rm -f $(OUT)/$(PLATFORM).bin
@rm -f $(NETCOSM_OBJ)
-%.o: %.c Makefile $(HEADERS)
- @echo "CC $<"
- @$(CC) $(CFLAGS) $(OPTFLAGS) -c $< -o $@
+.PHONY: depclean
+depclean:
+ @echo "Cleaning dependencies..."
+ @rm -f $(DEPS)
+
+.PHONY: veryclean
+veryclean: clean depclean
+
+.PHONY: help
+help:
+ @echo "Cleaning targets:"
+ @echo " clean - Remove object files"
+ @echo " depclean - Remove dependency files"
+ @echo " veryclean - Remove object and dependency files"
+ @echo "Build targets:"
diff --git a/src/room.h b/src/room.h
index ad7898f..6568643 100644
--- a/src/room.h
+++ b/src/room.h
@@ -47,8 +47,9 @@ struct user_t {
};
struct object_t {
- const char *class;
obj_id id;
+ const char *class;
+ const char *name; /* no articles: "a", "an", "the" */
};
struct verb_t {
@@ -85,4 +86,6 @@ struct room_t *room_get(room_id id);
bool room_user_add(room_id id, struct child_data *child);
bool room_user_del(room_id id, struct child_data *child);
+struct object_t *obj_new(void);
+
void world_free(void);