7 # Use all .c files below SRCDIR for sources. Build object file paths by
8 # replacing SRCDIR with BUILDDIR and .c endings with .o endings.
9 SOURCES=$(shell find $(SRCDIR)/ -type f -name \*.c)
10 OBJECTS=$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.c=.o))
12 # Linking TARGET demands generation of all OBJECTS files. To build them,
13 # rely on this rule: Each file of path BUILDDIR/[name].o is compiled
14 # from a file of path SRCDIR/[name].c. Build BUILDDIR as needed.
16 $(CC) $(CFLAGS) -o roguelike $(OBJECTS) -lncurses
17 $(BUILDDIR)/%.o: $(SRCDIR)/%.c
18 mkdir -p $(BUILDDIR); $(CC) $(CFLAGS) -c $< -o $@
20 # Use "clean" to delete build and target files. Tell make that "clean"
21 # is a "phony" target, i.e. this is not about building a file.