#ifndef $DESTDIR
DESTDIR=/usr
#fi

BINDIR=$(DESTDIR)/X11R6/bin
DATADIR=$(DESTDIR)/share/rmap/earthdata

all: earthview

earthview: earthview.c
	gcc -Wall -DDATADIR=\"$(DATADIR)\" earthview.c -o earthview -L/usr/X11R6/lib -lX11 -lm -lz -lbz2

install:
	install -c -s earthview $(BINDIR)
	mkdir -p $(DATADIR)
	mkdir -p $(DATADIR)/topography
	cp -f data/topography.cps $(DATADIR)/topography
	mkdir -p $(DATADIR)/population
	cp -f data/population.cps $(DATADIR)/population
	cp -f README $(DESTDIR)/share/rmap/doc/README.earthview

help: earthview
	./earthview -help

alt: altitude.jpg

pop: population.jpg

altitude.jpg: earthview
	./earthview -output ppm | convert ppm:- jpg:altitude.jpg

population.jpg: earthview
	./earthview -population -output ppm | convert ppm:- jpg:population.jpg

sun:
	if [ -r altitude.jpg ]; then sunclock -map -mapimage altitude.jpg ; fi
	if [ -r population.jpg ]; then sunclock -map -mapimage population.jpg ; fi

clean:
	rm -f core *~ *.jpg earthview

cleandir: clean

realclean: clean

cleandist: clean
