#
# Rebooter Makefile
#
#############################################################################

#
# Valid extra defines:
#
# -DPARSE_CONFIG	Parse configuration file (/etc/chos.conf)
#			automagically.
#
#############################################################################

EXTRA_DEFINES=-DPARSE_CONFIG

# Just defines whether to compile kde version
ifeq (.config,$(wildcard .config))
 include .config
endif

#
# You shouldn't need to play with stuff below
#
#############################################################################

ifdef KDE_VERSION
 PIXMAP_PATH=-DPIXMAP_PATH="\"/share/apps/krebooter/pixmaps\""
 EXTRA_INCLUDES=-I$(KDEDIR)/include
 EXTRA_LIBS=	-L$(KDEDIR)/lib -lX11 -lXext -lkdecore -lkdeui
else
 PIXMAP_PATH=-DPIXMAP_PATH="\"/usr/local/share/rebooter/pixmaps\""
# EXTRA_LIBS=-lintl
endif

MOC=		/usr/bin/moc
CC=		g++
GETTEXT=	xgettext

INCLUDE=	-I/usr/include/qt $(EXTRA_INCLUDES)
CC_FLAGS=	-O3 $(INCLUDE) $(EXTRA_DEFINES) $(PIXMAP_PATH)
LINK_FLAGS=	-s
LIBS=		-L/usr/X11R6/lib -lqt $(EXTRA_LIBS)

ifdef KDE_VERSION
 CC_FLAGS:=	$(CC_FLAGS) -DKDE_VERSION
 TARGET=	../krebooter
else
 TARGET=	../rebooter
endif


#
# No user serviceable parts below. 
#
#############################################################################

META_OBJS=	meta_rebooter.o meta_about.o

OBJS=		rebooter.o gui.o about.o mapfile.o configfile.o boot.o \
		$(META_OBJS)

all:	$(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(LINK_FLAGS) $(OBJS) -o $(TARGET) $(LIBS)

.C.o:
	$(CC) $(CC_FLAGS) -c $< -o $*.o

meta_about.C: about.h
	$(MOC) $< -o meta_about.C

meta_rebooter.C: rebooter.h
	$(MOC) $< -o meta_rebooter.C

get_messages:
	$(GETTEXT) -C -kgettext -kTR -d po/TEMPLATE *.C

messages:
	$(MAKE) -C po

msgmerge:
	$(MAKE) -C po msgmerge
clean:
	rm -f *.o meta* .depend .config
	$(MAKE) -C po clean

depend:
	$(CC) $(CC_FLAGS) -M -E *.C > .depend

ifeq (.depend,$(wildcard .depend))
 include .depend
endif
