
CC=gcc
CXX=g++
CFLAGS=-DDONT_USE_CAL_MAIN
CXXFLAGS=
#CXXFLAGS=-DSPEW -g

#	My environment has QT_DIR exported as /usr/local/qt
#	You can set the proper path here if you like
#
INCLUDES=-I$(QTDIR)/include
LDFLAGS=-L$(QTDIR)/lib -lqt -lgdbm -lc
VERSION=1.1

# For systems that don't have install, use this
#INSTALL=cp
#INSTALL_BIN_FLAGS=

INSTALL=install
INSTALL_BIN_FLAGS=-s

INSTALL_ROOT=/usr/local
INSTALL_BIN=$(INSTALL_ROOT)/bin
INSTALL_MAN=$(INSTALL_ROOT)/man

METAFILES=m_calendar m_remind m_setint m_event_edit
METASRC=$(addsuffix .cpp,$(METAFILES))
METAOBJS=$(addsuffix .o,$(METAFILES))

OBJS = alarm.o cal.o calendar.o event.o event_edit.o main.o month_cache.o \
       monthday_button.o persist.o remind.o settime.o setint.o util.o \
       weekday_labels.o $(METAOBJS)

DEPEND_FILES=$(addprefix .,$(patsubst %.o,%.d,$(OBJS)))
MOC=moc
 
.SUFFIXES: .cpp

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(INCLUDES) $<

qtremind: $(OBJS)
	$(CXX) -o $@ $(LDFLAGS) $^

install:
	$(INSTALL) $(INSTALL_BIN_FLAGS) qtremind $(INSTALL_BIN)
	$(INSTALL) qtremind.1 $(INSTALL_MAN)/man1

m_calendar.cpp: calendar.h
	$(MOC) -o m_calendar.cpp calendar.h

m_remind.cpp: remind.h
	$(MOC) -o m_remind.cpp remind.h

m_setint.cpp: setint.h
	$(MOC) -o m_setint.cpp setint.h

m_event_edit.cpp: event_edit.h
	$(MOC) -o m_event_edit.cpp event_edit.h

tar: qtremind 
	$(MAKE) clean
	rm qtremind
	cd ..; tar -cvf qtremind-$(VERSION).tar qtremind-$(VERSION)

clean:
	rm -f .*.d *.o core $(METASRC)

.%.d: %.c
	$(CC) -MM -E $(CFLAGS) $< | sed 's/\($*\.o\)[ :]*/\1 $@: /g' > $@

.%.d: %.cpp
	$(CXX) -MM -E $(CXXFLAGS) $< | sed 's/\($*\.o\)[ :]*/\1 $@: /g' > $@

#
# if you are working on the program and want GNU make to generate dependancy
# files export the variable WANT_DEPENDS with some value
#  i.e. export WANT_DEPENDS=true
#

ifdef WANT_DEPENDS
include $(DEPEND_FILES)
endif

