include Makefile.inc

prefix=/usr/local/X11
sdl_prefix=/usr

CFLAGS=-Wall -O -I$(sdl_prefix)/include/SDL \
	-DFONTPATH=\"$(prefix)/share/xdiashow\" \
	-I/usr/include/freetype2 -DHAVE_FREETYPE \
	-I/usr/X11R6/include \
	-I/usr/X11R6/include/freetype2 \
	-DVERSION=\"$(VERSION)\" \
	-I/usr/X11R6/include/freetype2/freetype #-DDEBUG

LDFLAGS=-L/usr/local/X11/lib -lSDL -lSDL_image -lSDL_gfx -lfreetype

OBJS=xdiashow.o SDL_ttf.o

default: xdiashow
all: xdiashow xdiashow.exe xdiashow.pdf

xdiashow: $(OBJS) Makefile.inc
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

xdiashow.exe: xdiashow.c Makefile.inc
	cross-make -f Makefile.mingw32

%.o: %.c
	$(CC) $(CFLAGS) -c $<

xdiashow.1: xdiashow.man Makefile.inc
	sed "s/VERSION/$(VERSION)/" < $< > $@

xdiashow.ps: xdiashow.1
	groff -man -Tps $< > $@

xdiashow.pdf: xdiashow.ps
	ps2pdf $< $@

clean:
	rm -f *.o *.obj *.ps

install: xdiashow xdiashow.1
	install xdiashow $(prefix)/bin
	install xdiashow.1 $(prefix)/man/man1
	-@mkdir $(prefix)/share/
	-@mkdir $(prefix)/share/xdiashow
	install cmsr.ttf $(prefix)/share/xdiashow

zip: xdiashow.exe xdiashow.pdf
	make -f Makefile.mingw32 zip

tar: clean
	cd .. && tar -czvf xdiashow-$(VERSION).tar.gz xdiashow-$(VERSION)/

