
# the most documentation you find in Makefile.am
# this file is just to demonstrate, how complex it is to
# write good Makefiles, if you don't use automake ;)

# export the variables, we're using
prefix		= @prefix@
exec_prefix	= @exec_prefix@
top_srcdir 	= @top_srcdir@
kde_appsdir 	= @kde_appsdir@
kde_cgidir 	= @kde_cgidir@
kde_confdir 	= @kde_confdir@
kde_datadir 	= @kde_datadir@
kde_htmldir 	= @kde_htmldir@
kde_icondir 	= @kde_icondir@
kde_locale 	= @kde_locale@
kde_mimedir 	= @kde_mimedir@
kde_minidir 	= @kde_minidir@
kde_toolbardir 	= @kde_toolbardir@
kde_wallpaperdir= @kde_wallpaperdir@
bindir		= @bindir@

all_includes	= @all_includes@
all_libraries	= @all_libraries@

MOC		= @MOC@
XGETTEXT	= @XGETTEXT@
CXX		= @CXX@
LDFLAGS		= @LDFLAGS@
CXXFLAGS	= @CXXFLAGS@
LIBSOCKET	= @LIBSOCKET@
INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA 	= @INSTALL_DATA@
INSTALL_SCRIPT 	= @INSTALL_SCRIPT@   

# define some variables
mkinstalldirs	= $(SHELL) $(top_srcdir)/mkinstalldirs 
APPSDIR 	= $(kde_appsdir)/Utilities
INCLUDES	= $(all_includes)
TARGET		= khexdit
LIBS		= -lkfm -lkdeui -lkdecore -lqt -lX11 -lXext $(LIBSOCKET)
LDFLAGS		+= $(all_libraries)

# rules to make .o files
.SUFFIXES: .cpp
.cpp.o:
	$(CXX) $(CXXFLAGS) $(DEFS) $(INCLUDES) -c $< 

OBJECTS = hexfile.o hexwidget.o
SRCMOCS = hexwidget.moc hexfile.moc

all: $(TARGET)

$(TARGET): $(SRCMOCS) $(OBJECTS) 
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)

# recreate the Makefile
Makefile: Makefile.in
	cd .. && CONFIG_FILES=khexdit/$@ CONFIG_HEADERS= $(SHELL) ./config.status

install: install-data install-exec

# make messages.po. Move this one to ../po/ and "make merge" in po
messages:
	$(XGETTEXT) -C -ktranslate *.cpp

install-exec: $(TARGET)
	$(mkinstalldirs) $(bindir)
	$(INSTALL_PROGRAM) $(TARGET) $(bindir)

install-data: 
	(cd doc && $(MAKE) install-data)
	$(mkinstalldirs) $(APPSDIR)
	$(INSTALL_DATA) khexdit.kdelnk $(APPSDIR)
	$(mkinstalldirs) $(kde_icondir)
	$(INSTALL_DATA) khexdit.xpm $(kde_icondir)
	$(mkinstalldirs) $(kde_minidir)
	$(INSTALL_DATA) mini-khexdit.xpm $(kde_minidir)/khexdit.xpm

uninstall:
	(cd doc && $(MAKE) uninstall)
	-rm -f $(bindir)/$(TARGET)
	-rm -f $(APPSDIR)/khexdit.kdelnk
	-rm -f $(kde_icondir)/khexdit.xpm
	-rm -f $(kde_minidir)/khexdit.xpm

clean:
	-rm -f $(TARGET) $(OBJECTS) *~ core

distclean: clean
	-rm -f Makefile $(SRCMOCS)

# add a dependcy for all moc files to help some FreeBSD users ;)
hexwidget.moc: hexwidget.h
	$(MOC) hexwidget.h -o hexwidget.moc

hexfile.moc: hexfile.h
	$(MOC) hexfile.h -o hexfile.moc
