2 CFLAGS=-std=c11 -pedantic-errors -Wall -Werror -Wextra -Wformat-security -g
3 TARGET_SERVER=roguelike-server
4 TARGET_CLIENT=roguelike-client
11 # Build object file lists by building object paths from all source file paths.
12 SOURCES_SERVER=$(shell find $(SRCDIR)/$(SERVERDIR)/ -type f -name \*.c)
13 SOURCES_CLIENT=$(shell find $(SRCDIR)/$(CLIENTDIR)/ -type f -name \*.c)
14 SOURCES_COMMON=$(shell find $(SRCDIR)/$(COMMONDIR)/ -type f -name \*.c)
15 OBJECTS_SERVER=$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES_SERVER:.c=.o))
16 OBJECTS_CLIENT=$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES_CLIENT:.c=.o))
17 OBJECTS_COMMON=$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES_COMMON:.c=.o))
19 # "make" without further specifications builds both server and client.
20 default : $(TARGET_SERVER) $(TARGET_CLIENT)
22 # "make roguelike-server" builds only the server.
23 $(TARGET_SERVER) : $(OBJECTS_SERVER) $(OBJECTS_COMMON)
24 $(CC) $(CFLAGS) -o $(TARGET_SERVER) $(OBJECTS_SERVER) $(OBJECTS_COMMON)
26 # "make roguelike-client" builds only the ncurses client.
27 $(TARGET_CLIENT) : $(OBJECTS_CLIENT) $(OBJECTS_COMMON)
28 $(CC) $(CFLAGS) -o $(TARGET_CLIENT) $(OBJECTS_CLIENT) $(OBJECTS_COMMON)\
31 # Build respective object file to any source file. Create build dirs as needed.
32 $(BUILDDIR)/%.o : $(SRCDIR)/%.c
34 $(CC) $(CFLAGS) -c $< -o $@
36 # "make clean" to try to delete all files that could possibly have been built.
37 # Declare target "phony", i.e. this is not about building a file.
41 rm -f $(TARGET_SERVER)
42 rm -f $(TARGET_CLIENT)