#  Makefile version 1.1
#  yudit package - Unicode Editor for the X Window System (and Linux) 
#
#  Author: gsinai@iname.com (Gaspar Sinai)
#  GNU Copyright (C) 1997,1998  Gaspar Sinai
# 
#  yudit version 1.1  Copyright(C) 23 August,   1998, Tokyo Japan  Gaspar Sinai
#  yudit version 1.0  Copyright(C) 17 May,      1998, Tokyo Japan  Gaspar Sinai
#  yudit version 0.99 Copyright(C)  4 April,    1998, Tokyo Japan  Gaspar Sinai
#  yudit version 0.97 Copyright(C)  4 February, 1998, Tokyo Japan  Gaspar Sinai
#  yudit version 0.95 Copyright(C) 10 January,  1998, Tokyo Japan  Gaspar Sinai
#  yudit version 0.94 Copyright(C) 17 December, 1997, Tokyo Japan  Gaspar Sinai
#  yudit version 0.9 Copyright (C)  8 December, 1997, Tokyo Japan  Gaspar Sinai
#  yutex version 0.8 Copyright (C)  5 November, 1997, Tokyo Japan  Gaspar Sinai
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Makefile
#


include ../../Makefile.conf

LOCALES=hu.utf8 ja.utf8 ru.utf8 zh_TW.utf8 your.utf8
TARGET=yudit

ALL_CFLAGS = -I../lib -I../../src -I../../config $(CFLAGS) \
	 -DLOCALE_DIR=\"$(LOCALE_DIR)\"

ALL_LIBS=-lugui -lconfig -lxunic -lnunic $(XLIBS) $(LIBS) \
	$(FREETYPE_LIB) $(TRANSLATE_LFLAGS)

ALL_LDFLAGS=-L../../src -L../lib -L../../config $(LDFLAGS)

INSTALL = ../../install-sh -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644

#-------------------------------------------------------------------------------


OBJECTS=MainWidget.o MenuAction.o Main.o 

SOURCES=$(patsubst %.o, %.cpp, $(OBJECTS))

.SUFFIXES: .o .cpp .h

%.o:%.cpp
	$(CXX)  -c -o $@  $(ALL_CFLAGS) $<

all: $(ERROR) $(TARGET)


$(TARGET): $(OBJECTS) ../lib/libugui.a ../../src/libnunic.a ../../src/libxunic.a ../../config/libconfig.a

	$(LD) -o $(TARGET) $(OBJECTS) $(ALL_LDFLAGS) $(ALL_LIBS)

clean:
	rm -f $(TARGET) *.o *.bak $(METASOURCES) core

depend:
	$(CXX) -M  $(ALL_CFLAGS) *.cpp > .depend

install: $(MESSAGES)
	@if test ! -d $(prefix) ;then mkdir $(prefix); fi
	@if test ! -d $(bindir) ;then mkdir $(bindir); fi
	@if test ! -d $(datadir) ; then mkdir $(datadir);fi
	@if test ! -d $(datadir)/yudit ; then mkdir $(datadir)/yudit;fi
	@if test ! -d $(datadir)/yudit/data ;then mkdir $(datadir)/yudit/data;fi
	@if test ! -d $(datadir)/yudit/config ;then mkdir $(datadir)/yudit/config;fi
	@if test ! -d $(LOCALE_DIR);then mkdir $(LOCALE_DIR);fi
	@for i in $(LOCALES); do \
		if test ! -d $(LOCALE_DIR)/$$i; then \
			mkdir $(LOCALE_DIR)/$$i; \
		fi ; \
		if test ! -d $(LOCALE_DIR)/$$i/LC_MESSAGES; then \
			mkdir $(LOCALE_DIR)/$$i/LC_MESSAGES; \
		fi ; \
		$(INSTALL_DATA) $$i/messages.mo \
			$(LOCALE_DIR)/$$i/LC_MESSAGES ; \
	done
	rm -f $(bindir)/yudit
	$(INSTALL_PROGRAM) $(TARGET) $(bindir)

messages:
	@echo "Translating  Messages"
	@if [ $(TUPDATE) != ":" ] ; then \
		xgettext --keyword=Translate --keyword=UTValue \
			--keyword=warn --keyword=info --keyword=ask \
	   	*.cpp ../../src/UCommon.cpp; \
	fi
	@for i in $(LOCALES); do \
		cd $$i ; touch messages.po;  \
		if [ $(TUPDATE) != ":" ] ; then \
			$(TUPDATE) ../messages.po messages.po > messages.pod; \
			if [ $$? != 0 ]; then \
				cd ..; \
				exit 1; \
			fi;  \
			mv messages.pod messages.po; \
		fi; \
		msgfmt -o messages.mo messages.po; \
		cd ..; \
	done
	

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

