aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 12 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index edfbdc9..b05d4e4 100644
--- a/Makefile
+++ b/Makefile
@@ -6,16 +6,26 @@ CFLAGS = -W -Wall -std=gnu11 `sdl2-config --cflags`
LDFLAGS = `sdl2-config --libs` -lfreeimage
TARGET = imv
-OBJECTS = main.o image.o texture.o navigator.o viewport.o
+BUILDDIR = build
+
+SOURCES = $(wildcard src/*.c)
+OBJECTS = $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SOURCES))
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-debug: CFLAGS += -DDEBUG -g
+debug: CFLAGS += -DDEBUG -g -pg
debug: $(TARGET)
+$(BUILDDIR)/%.o: src/%.c $(BUILDDIR)
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+$(BUILDDIR):
+ mkdir -p $(BUILDDIR)
+
clean:
$(RM) $(TARGET) $(OBJECTS)
+ rmdir $(BUILDDIR)
install: $(TARGET)
install -m 0755 $(TARGET) $(prefix)/bin