SUBDIRS = src 

desktopdir= $(datadir)/applications
desktop_DATA = jd.desktop

icondir = $(datadir)/pixmaps
icon_DATA = jd.png

EXTRA_DIST = AUTHORS TODO README configure 

BUILDINFO_HEADER = buildinfo.h

all: $(BUILDINFO_HEADER)

.PHONY: $(BUILDINFO_HEADER)

$(BUILDINFO_HEADER):
	@-rm -f $@.new

	@echo '/* This file is generated from Makefile by make. */' >> $@.new
	@echo '#ifndef _BUILDINFO_H' >> $@.new
	@echo '#define _BUILDINFO_H' >> $@.new

	@echo '' >> $@.new
	@echo '// Build information.' >> $@.new

	@if test -n "$(CC)"; \
	then \
	    CC_INFO=$(CC); \
	    CC_VERSION=`LANG=C $(CC) -dumpversion 2>/dev/null`; \
	    test -n "$${CC_VERSION}" && CC_INFO="$(CC)($${CC_VERSION})"; \
	    echo "#define CC_INFO \"$${CC_INFO}\"" >> $@.new;\
	fi
	@if test -n "$(CXX)"; \
	then \
	    CXX_INFO=$(CXX); \
	    CXX_VERSION=`LANG=C $(CXX) -dumpversion 2>/dev/null`; \
	    test -n "$${CXX_VERSION}" && CXX_INFO="$(CXX)($${CXX_VERSION})"; \
	    echo "#define CXX_INFO \"$${CXX_INFO}\"" >> $@.new;\
	fi

	@echo '' >> $@.new
	@echo '// Version information of SVN.' >> $@.new

	@if test -n "$(SVN)" -a -n "$(AWK)"; \
	then \
	    SVN_REPOSITORY=`LANG=C $(SVN) info 2>/dev/null | $(AWK) '/^URL/ {print $$2}' 2>/dev/null`; \
	    if test -n "$${SVN_REPOSITORY}"; \
	    then \
	        echo "SVN: Repository = \"$${SVN_REPOSITORY}\""; \
	        echo "#define SVN_REPOSITORY \"$${SVN_REPOSITORY}\"" >> $@.new; \
	    fi \
	fi

	@if test -n "$(SVNVERSION)"; \
	then \
	    SVN_REVISION=`LANG=C $(SVNVERSION) -n 2>/dev/null`; \
	    if test -n "$${SVN_REVISION}" -a "$${SVN_REVISION}" != "exported"; \
	    then \
	        echo "SVN: Revision = \"$${SVN_REVISION}\""; \
	        echo "#define SVN_REVISION \"$${SVN_REVISION}\"" >> $@.new; \
	    fi \
	fi

	@echo '' >> $@.new
	@echo '#endif' >> $@.new

	@if test -n "$(DIFF)"; \
	then \
	    $(DIFF) -Nq $@ $@.new >/dev/null 2>&1; \
	    if test $$? -eq 1; \
	    then \
	        echo '$@: Modified.'; \
	        mv -f $@.new $@; \
	    else \
	        echo '$@: Not modified.'; \
	        rm -f $@.new; \
	    fi \
	else \
	    echo '$@: Refreshed.'; \
	    mv -f $@.new $@; \
	fi

	@test -e $@ || touch $@;
