# Makefile for RMC
# Portions of the Makefile were contributed by Tyler Mitchell.  Thanks, Tyler!

OBJS = callbacks.o interface.o helpers.o constants.o main.o
HDRS = callbacks.h interface.h helpers.h constants.h client.h
LIBS = `gtk-config --libs`

# Change this if you want the binary to be built elsewhere
BINDIR = ../bin
# Change this if you moved the documentation
DOCDIR = ../doc

# Change this to define a different directory for the binary
# installation.
INSTALL = /usr/local/bin
# Change this to define a different directory for the documentation
# installation.
#
# NOTE:  You MUST change the DOC_LIBS define in client.h to match
# this directory.
DOCINSTALL = /usr/local/doc

CC = gcc
# If you dont want debug code, change the next line to:
# CFLAGS = -O2 -Wall `gtk-config --cflags`
CFLAGS = -g -Wall `gtk-config --cflags`

rmc : $(OBJS)
	$(CC) $(CFLAGS) -o $(BINDIR)/rmc $(OBJS) $(LIBS)
	@echo Make complete.  To 'install', type make install
	@echo If a newer version is already installed, type make reinstall

main.o : main.c $(HDRS)
	$(CC) $(CFLAGS) -c main.c
	
constants.o : constants.c
	$(CC) $(CFLAGS) -c constants.c
	
helpers.o : helpers.c client.h callbacks.h constants.h
	$(CC) $(CFLAGS) -c helpers.c
	
interface.o : interface.c client.h callbacks.h interface.h
	$(CC) $(CFLAGS) -c interface.c
	
callbacks.o : callbacks.c $(HDRS)
	$(CC) $(CFLAGS) -c callbacks.c
	
.PHONY : clean
clean :
	rm $(BINDIR)/rmc *.o
	
install : $(BINDIR)/rmc
	cp $(BINDIR)/rmc $(INSTALL)/rmc
	mkdir -p $(DOCINSTALL)/rmc
	cp $(DOCDIR)/* $(DOCINSTALL)/rmc
	@echo Installed in $(INSTALL)
	
uninstall : $(INSTALL)/rmc
	rm $(INSTALL)/rmc
	rm $(DOCINSTALL)/rmc/*
	rmdir $(DOCINSTALL)/rmc
	@echo Removed from $(INSTALL)

reinstall : $(INSTALL)/rmc $(BINDIR)/rmc
	cp $(BINDIR)/rmc $(INSTALL)/rmc
	@echo Binary reinstalled to $(INSTALL)
	cp $(DOCDIR)/* $(DOCINSTALL)/rmc
	@echo Documentation reintsalled to $(DOCINSTALL)
