CFLAGS = -Wall -Wstrict-prototypes -O2 -I/usr/X11R6/include -I/usr/src/linux/include
SRC = motioneye.c avi.c display.c
OBJ = $(SRC:.c=.o)
LIBS =
PREFIX = /usr/local
DESTBIN = $(PREFIX)/bin
DESTMAN = $(PREFIX)/man/man1

# comment out WITH_X if you don't want X display
WITH_X = yes

ifeq ($(WITH_X),yes)
  CFLAGS += -DWITH_X
  LIBS += `imlib-config --libs`
endif

all: motioneye motioneye.1

motioneye: $(OBJ)
	$(CC) -o motioneye $(OBJ) $(LIBS)

motioneye.o: motioneye.c motioneye.h
avi.o: avi.c avi.h motioneye.h
display.o: display.c motioneye.h

motioneye.1: motioneye.sgml
	docbook2man $<
	mv MOTIONEYE.1 $@
	rm -f *refs *links

install: all
	install -m 755 -d $(DESTBIN)
	install -m 755 motioneye $(DESTBIN)
	install -m 755 -d $(DESTMAN)
	install -m 644 motioneye.1 $(DESTMAN)

clean:
	rm -f $(OBJ) motioneye motioneye.1 *~
