# flruler Makefile
SHELL=/bin/sh

# --- OPERATING SYSTEM ---
OS=$(shell uname | tr a-z A-Z)

# INCLUDE VERSION NUMBER FROM FIRST NUMBER IN 'CHANGES' FILE
VERSION=$(shell awk '/^[0-9]*\.[^ \t]/ {print $$1; exit(0);}' CHANGES.txt)

# INCLUDE OS SPECIFIC SETTINGS
include Makefile.$(OS)

all: flruler

docs: FORCE
	( cd docs && \
	  pod2man --center "Erco's FLTK Tools" \
	          --name=flruler --section=1 --release=$(VERSION) \
		  < flruler.pod > flruler.1 && \
	  pod2html --title "flruler $(VERSION) Erco's FLTK Tools" \
	          < flruler.pod > flruler.html \
	)

.SUFFIXES: .C .H
.C.o:
	$(CXX) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c $<

%.o: %.C %.H
	$(CXX) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c $<

flruler: flruler.o
	$(CXX) flruler.o $(LIBS) -o $@
	strip flruler
	$(REZ) flruler
	$(PACKAGEAPP)

clean:
	-rm -f $(ALL) flruler core
	-rm -f *.o
	-rm -f core.*
	-rm -f *.idb
	-rm -f *.pdb
	-rm -f *.obj
	-rm -f *.exe
	-rm -f *.rc
	-rm -f *.res
	-rm -f *.RES
	-rm -rf docs/pod2htm*~~
	-rm -rf docs/pod2htm*.tmp
	-rm -rf ._[A-z]*
	-rm -f flruler.app/Contents/MacOS/flruler   >& /dev/null
	-rm -f flruler.app/Contents/MacOS/._flruler >& /dev/null

distclean: clean
	-rm -rf bin.*
	-rm -rf reldir
	-rm -rf flruler.app

###############################################################
### ERCO'S USE ONLY                                         ###
### These targets are ONLY used by the author for managing  ###
### the distro website.                                     ###
###############################################################

# BUILD SRC TAR FILE
tar: docs FORCE
	./distro-helper -tar $(VERSION)

# SEND SRC TAR
sendtar: tar docs FORCE
	./distro-helper -sendtar $(VERSION)

# SEND + BUILD DISTRO WEBPAGE
sendwww: docs FORCE
	./distro-helper -sendwww $(VERSION)

# CREATE BINARY DISTROS
bins: FORCE
	./distro-helper -makebins $(VERSION)

# SEND BINARY DISTROS
sendbins: bins FORCE
	./distro-helper -sendbins $(VERSION)

# SEND ALL
#    Rebuilds everything and updates website
#
sendall: distclean sendtar sendwww sendbins

.SILENT:

FORCE:
	
