NAME=grocget
PROGRAMNAME=$(NAME)
VERSION=0.3

#determine place to store binary
BINDIR = $(shell gnome-config --bindir)

#determine place to store other project files
DATADIR = $(shell gnome-config --datadir)

#dclare place to store project files
MYDATADIR = $(DATADIR)/$(PROGRAMNAME)

#declare place to store project documentation
MYDOCDIR = $(DESTDIR)/$(DATADIR)/doc/$(NAME)-$(VERSION)


all:

install:
	install -D --mode=755 $(PROGRAMNAME) $(DESTDIR)/$(BINDIR)/$(PROGRAMNAME)	#put the main program into the bin directory
	install --directory $(DESTDIR)/$(MYDATADIR)					#create directory to hold project files
	install --mode=644 $(PROGRAMNAME).glade $(DESTDIR)/$(MYDATADIR)			#copy glade file over
	install --mode=644 list.txt $(DESTDIR)/$(MYDATADIR)				#copy skeleton grocery list file over
	install --directory $(DESTDIR)/$(MYDATADIR)/pixmaps				#create pixmap directory to hold project pictures
	install --mode=644 pixmaps/*.png $(DESTDIR)/$(MYDATADIR)/pixmaps		#copy project specific pictures over
	install --directory $(DESTDIR)/$(DATADIR)/pixmaps				#create pixmaps directory to hold gnome pictures (one probably exists)
	install --mode=644 pixmaps/$(PROGRAMNAME)_icon.png $(DESTDIR)/$(DATADIR)/pixmaps	#copy gnome icon over
	install --directory $(DESTDIR)/$(DATADIR)/gnome/apps/Utilities			#create a directory for gnome menu description (one probably exists)
	install --mode=644 $(PROGRAMNAME).desktop $(DESTDIR)/$(DATADIR)/gnome/apps/Utilities	#copy the gnome menu description
	install --directory $(MYDOCDIR) 						#create a directory that holds project documentation
	install --mode=644 doc/* $(MYDOCDIR)						#copy project documentation

uninstall:
	rm -f $(DESTDIR)/$(BINDIR)/grocget
	rm -f $(DESTDIR)/$(DATADIR)/gnome/apps/Utilities/grocget.desktop
	rm -f $(DESTDIR)/$(DATADIR)/pixmaps/grocget_icon.png
	rm -rf $(DATADIR)/grocget							#don't use all variables here for safety (in case variable is empty
	rm -rf $(DESTDIR)/$(DATADIR)/doc/$(NAME)-$(VERSION)				#don't use all variables here for safety (in case variable is empty

dist:
	if test -d "$(NAME)-$(VERSION)"; then rm -rf $(NAME)-$(VERSION); fi
	if test -f "$(NAME)-$(VERSION).tar.gz"; then rm -f $(NAME)-$(VERSION).tar.gz; fi
	mkdir $(NAME)-$(VERSION)
	cp Makefile $(NAME)-$(VERSION)
	cp -R doc $(NAME)-$(VERSION)
	cp $(PROGRAMNAME) $(NAME)-$(VERSION)
	cp $(PROGRAMNAME).glade $(NAME)-$(VERSION)
	cp list.txt $(NAME)-$(VERSION)
	cp $(PROGRAMNAME).desktop $(NAME)-$(VERSION)
	cp -R pixmaps $(NAME)-$(VERSION)
	tar cvzf $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)
	rm -rf $(NAME)-$(VERSION)
