summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile48
1 files changed, 25 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 64074dc..616c474 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,23 @@
CC = gcc
-CFLAGS = -ggdb -std=c99 -pedantic -Wall $(DEFINES) \
- $(shell pkg-config --cflags gdk-pixbuf-2.0 glib-2.0 gthread-2.0) \
- -DN_THREADS=$(shell grep -c ^processor /proc/cpuinfo || echo 2)
-LDFLAGS = -Wl,--as-needed $(LIBS) -lm \
- $(shell pkg-config --libs gdk-pixbuf-2.0 glib-2.0 gthread-2.0)
+CFLAGS = -ggdb -std=c99 -pedantic -Wall $(DEFINES)
+LDFLAGS = -Wl,--as-needed $(LIBS)
+
+util_CFLAGS=$(shell pkg-config --cflags gdk-pixbuf-2.0 glib-2.0)
+wimmel_CFLAGS=$(shell pkg-config --cflags gdk-pixbuf-2.0 glib-2.0) \
+ -DN_THREADS=$(shell grep -c ^processor /proc/cpuinfo || echo 2)
+wimmel_LIBS=-lm $(shell pkg-config --libs gdk-pixbuf-2.0 glib-2.0)
+
+wimmel_gl_CFLAGS=$(shell pkg-config --cflags egl glesv2 glib-2.0 gdk-pixbuf-2.0)
+wimmel_gl_LIBS=$(shell pkg-config --libs egl glesv2 glib-2.0 gdk-pixbuf-2.0)
+
+roi_CFLAGS=$(shell pkg-config --cflags gtk+-3.0 gdk-pixbuf-2.0 glib-2.0)
+roi_LIBS=$(shell pkg-config --libs gtk+-3.0 gdk-pixbuf-2.0 glib-2.0)
+
+capture_CFLAGS=$(shell pkg-config --cflags gtk+-3.0 opencv glib-2.0)
+capture_LIBS=$(shell pkg-config --libs gtk+-3.0 opencv glib-2.0)
PROGS = wimmel wimmel_gl roi capture
-OBJS = wimmel.o wimmel_gl.o util.o roi.o capture.o
+OBJS = $(PROGS:=.o) util.o
all: $(PROGS)
@@ -17,25 +28,16 @@ capture: capture.o
.PHONY: clean all
-%:
- $(CC) -o $@ $+ $(LDFLAGS)
+define cc
+ $(CC) $(CFLAGS) $($(@:.o=)_CFLAGS) -c -o $@ $<
+endef
+%:
+ $(CC) -o $@ $+ $(LDFLAGS) $($@_LIBS)
+%.o: %.c
+ $(call cc)
%.o: %.c %.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-
-wimmel_gl:
- $(CC) -o $@ $+ $(LDFLAGS) `pkg-config --cflags --libs egl glesv2`
-
-roi.o: roi.c
- $(CC) -c -o $@ $+ $(CFLAGS) `pkg-config --cflags gtk+-3.0`
-roi:
- $(CC) -o $@ $+ $(LDFLAGS) `pkg-config --libs gtk+-3.0`
-
-capture.o: capture.c
- $(CC) -c -o $@ $+ $(CFLAGS) `pkg-config --cflags gtk+-3.0 opencv`
-capture:
- $(CC) -o $@ $+ $(LDFLAGS) `pkg-config --libs gtk+-3.0 opencv`
+ $(call cc)
clean:
rm -f $(PROGS) $(OBJS)