
COLLECT = ar cru
RANLIB = ranlib
LINK = ln -s

DL = --ldflags # --ldstaticflags

X_CPPFILES = icc_helfer_x.cpp
OSX_CPPFILES = icc_helfer_osx.cpp
FLTK_CPPFILES = icc_helfer_fltk.cpp
I18N_CXXFILES = #fl_i18n.cxx fl_i18n_fl.cxx
I18N_HEADERS = #fl_i18n.H
MSGFMT = msgfmt -c --statistics
RPMARCH = `rpmbuild --showrc | awk '/^build arch/ {print $$4}'`

LIB_LIBS = -L$(libdir) -L./ $(FLTK_LIBS) $(FLU_LIBS) \
	-llcms -L/lib \
	$(DBG_LIBS) -lintl


LIBSONAMEFULL = lib$(TARGET)$(LIBMID).$(VERSION_A).$(VERSION_B).$(VERSION_C)$(LIBEXT)
LIBSONAME = lib$(TARGET)$(LIBMID).$(VERSION_A)$(LIBEXT)
LIBSO = lib$(TARGET)$(LIBMID)$(LIBEXT)
LIBFL_I18N = fl_i18n/libfl_i18n.a

TOOLKIT_FILES = $(FLTK_CPPFILES)


INCL_DEP = $(INCL) $(X_H) $(OSX_H) $(OYRANOS_H) \
			$(FLU_H) $(FLTK_H) $(FTGL_H) $(LCMS_H) $(ALL_SOURCEFILES)
ALL_INCL = $(INCL) \
			$(FLU_H) $(FLTK_H) $(X_H) $(OSX_H) $(OYRANOS_H) $(LCMS_H) $(FTGL_H)
CFLAGS_ = $(CFLAGS) $(DEBUG) $(ALL_INCL)
CXXFLAGS_ = $(CXXFLAGS) $(DEBUG) $(ALL_INCL)

top_builddir = ../../..
OPENEXR_LIBS = -pthread -lIlmImf -lz -lImath -lHalf -lIex -lIlmThread
CINEPAINT_HALF_LIBS = $(top_builddir)/libhalf/.libs/cinepaint_half.o



LDLIBS = $(LDFLAGS) -L$(libdir) -L./ $(LIBFL_I18N) $(FLTK_LIBS) \
	$(X11_LIBS) -llcms -L/lib $(OYRANOS_LIBS) $(LCMS_LIBS) \
	$(FTGL_LIBS) $(I18N_LIB) $(DBG_LIBS) $(LIBNAME) $(CWLIB) \
        $(CINEPAINT_HALF_LIBS) \
	$(OPENEXR_LIBS) 


CPP_HEADERS = \
	agviewer.h \
	icc_betrachter.h \
	cccie64.h \
	ciexyz64_1.h \
	flstring.h \
	icc_cgats_filter.h \
	icc_dateiwahl.h \
	icc_draw.h \
	icc_draw_fltk.h \
	icc_fenster.h \
	icc_formeln.h \
	icc_examin.h \
	icc_examin_io.h \
	icc_examin_version.h \
	icc_gamut.h \
	icc_gl.h \
	icc_helfer.h \
	icc_helfer_fltk.h \
	icc_helfer_ui.h \
	icc_helfer_x.h \
	icc_info.h \
	icc_icc.h \
	icc_kette.h \
	icc_measurement.h \
	icc_modell_beobachter.h \
	icc_oyranos.h \
	icc_oyranos_extern.h \
	icc_profile.h \
	icc_profile_header.h \
	icc_profile_tags.h \
	icc_speicher.h \
	icc_thread_daten.h \
	icc_ueber.h \
	icc_utils.h \
	icc_vrml.h \
	icc_vrml_parser.h \
	icc_waehler.h \
	my_file_chooser.h \
	threads.h
#	Fl_Slot.H

COMMON_CPPFILES = \
	agviewer.cpp \
	icc_cgats_filter.cpp \
	icc_draw.cpp \
	icc_examin.cpp \
	icc_examin_farbraum.cpp \
	icc_examin_io.cpp \
	icc_examin_tagwahl.cpp \
	icc_fenster.cpp \
	icc_formeln.cpp \
	icc_gamut.cpp \
	icc_gl.cpp \
	icc_helfer.cpp \
	icc_info.cpp \
	icc_kette.cpp \
	icc_measurement.cpp \
	icc_modell_beobachter.cpp \
	icc_oyranos.cpp \
	icc_profile.cpp \
	icc_profile_header.cpp \
	icc_profile_tags.cpp \
	icc_schnell.cpp \
	icc_speicher.cpp \
	icc_thread_daten.cpp \
	icc_ueber.cpp \
	icc_utils.cpp \
	icc_vrml.cpp \
	icc_vrml_parser.cpp \
	threads.cpp


DEBUG_CC = debug.cc
DEBUG_H  = sys.h debug.h

MAIN_SOURCES = icc_main.cpp
CINEPAINT_SOURCES = icc_cinepaint.cpp

COMMON_CFILES =  \
	icc_oyranos_extern.c \
	flstring.c \
	vsnprintf.c \
	icc_argyll.c
CFILES = \
	$(COMMON_CFILES)
CPPFILES = \
	$(COMMON_CPPFILES) \
	$(TOOLKIT_FILES) \
	$(X_CPP) \
	$(OSX_CPP)
CXXFILES = \
	icc_betrachter.cxx \
	my_file_chooser.cxx \
	my_file_chooser2.cxx
TEST_CPP = \
	tests/dE2000_test.cpp \
	tests/fltk_test.cxx \
	tests/tiff_test.cxx \
	tests/gettext_test.cxx \
	tests/lib_test.cxx
TEST_H = \
	tests/ciede2000testdata.h
TEST_FILES = $(TEST_CPP) $(TEST_H)

EXTRA_CPPFILES = icc_cinepaint_intern.cpp

ALL_SOURCEFILES = \
	$(COMMON_CFILES) \
	$(COMMON_CPPFILES) \
	$(OSX_CPPFILES) \
	$(X_CPPFILES) \
	$(FLTK_CPPFILES) \
	$(I18N_CXXFILES) \
	$(CXXFILES) \
	$(MAIN_SOURCES) \
	$(CINEPAINT_SOURCES) \
	$(EXTRA_CPPFILES)

ALL_HEADERFILES = \
	$(CPP_HEADERS) \
	$(I18N_HEADERS)

DOKU = \
	TODO \
	README \
	ChangeLog \
	COPYING \
	BUGS \
	AUTHORS \
	INSTALL \
	icc_examin.desktop \
	icc_examin.png \
	icc_examin.xpm \
	icc_examin.spec.in \
	icc.xml
FLUID = \
	icc_betrachter.fl \
	my_file_chooser.fl
FONT = FreeSans.ttf

SOURCES = $(ALL_SOURCEFILES) $(ALL_HEADERFILES)

OBJECTS = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(CXXFILES:.cxx=.o) $(CCFILES:.cc=.o)
MAIN_OBJECTS = $(MAIN_SOURCES:.cpp=.o)
CINEPAINT_OBJECTS = $(CINEPAINT_SOURCES:.cpp=.o)
I18N_OBJECTS =  $(I18N_CXXFILES:.cxx=.o)
LINGUAS_SRC = $(LING:.po=.gmo)
ALL_OBJECTS = $(OBJECTS) $(MAIN_OBJECTS) $(CINEPAINT_OBJECTS) $(I18N_OBJECTS) \
	$(LINGUAS_SRC)

POT_FILE = po/$(TARGET).pot

APPL_FILES = \
	ICC\ Examin.app/ \
	ICC\ Examin.sh \
	Info.plist

CWDBUG_FILES = $(DEBUG_CC) $(DEBUG_H)

ALL_FILES =	$(SOURCES) \
	makefile.in \
	configure \
	configure.sh \
	$(DOKU) \
	$(FONT) \
	$(APPL_FILES) \
	$(CWDBUG_FILES) \
	$(FLUID)


# get time stamp
MTIME   := $(shell date +%y%m%d.%H%M%S)


all:	dynamic
	
BASE = 
	
release:	icc_alles.o
	echo Verknuepfen $@...
	$(CXX) $(CXXFLAGS_) -o $(BINTARGET) \
	icc_alles.o \
	$(LDLIBS)
	$(REZ)
	$(RM) icc_alles.o

dynamic:	$(BINTARGET) $(CINEPAINT)

$(BINTARGET):	$(BASE) $(OBJECTS) $(MAIN_OBJECTS) $(LINGUAS_SRC) $(I18N_OBJECTS) $(LIBNAME) $(LIBFL_I18N)
	echo Verknuepfen $@ ...
	$(CXX) $(CXXFLAGS_) -o $@ \
	$(MAIN_OBJECTS) $(OBJECTS) \
	$(LDLIBS) $(LINK_LIB_PATH) $(LINK_SRC_PATH)
	$(REZ)

$(CINEPAINT_OBJECTS):	$(CINEPAINT_SOURCES)
	echo Compiling Gtk CinePaint plug-in ...
	$(CXX) $(CXXFLAGS_) `$(CP_FLAGS)` -c $(CINEPAINT_SOURCES)

$(CINEPAINT):	$(BASE) $(CINEPAINT_OBJECTS) $(OBJECTS) $(LINGUAS_SRC) $(I18N_OBJECTS) $(LIBNAME) $(LIBFL_I18N)
	echo Verknuepfen $@ ...
	$(CXX) $(CXXFLAGS_) `$(CP_FLAGS)` -o $@ \
	$(CINEPAINT_OBJECTS) $(OBJECTS) \
	`$(CP_LIBS)` $(LDLIBS) $(LINK_LIB_PATH) $(LINK_SRC_PATH)
	$(REZ)


$(LIBSONAMEFULL):	$(I18N_OBJECTS)
	echo Verknuepfen $@ ...
	$(CXX) $(CFLAGS_) $(LDFLAGS) $(LINK_NAME) -o $(LIBSONAMEFULL) \
	$(I18N_OBJECTS)  icc_utils.o icc_helfer.o icc_speicher.o
	$(REZ)
	$(RM)  $(LIBSONAME)
	$(LINK) $(LIBSONAMEFULL) $(LIBSONAME)
	$(RM)  $(LIBSO)
	$(LINK) $(LIBSONAMEFULL) $(LIBSO)

$(LIBNAME):	$(I18N_OBJECTS)
	echo Verknuepfen $@ ...
	$(COLLECT) $(LIBNAME) $(I18N_OBJECTS)
	$(RANLIB) $(LIBNAME)

$(LIBFL_I18N):
	cd fl_i18n/ && $(MAKE) -f $(MAKEFILE_ARCH)

static:	$(BINTARGET)
	echo Verknuepfen $@ ...
	$(CXX) $(CXXFLAGS_) -o $(BINTARGET) $(MAIN_OBJECTS) $(OBJECTS) \
	-L./ \
	`test -f /opt/local/lib/libfltk_images.a && (echo /opt/local/lib/libfltk_images.a; \
	    (test -f /opt/local/lib/libpng.a && echo /opt/local/lib/libpng.a || echo "-lpng"); (test -f /opt/local/lib/libjpeg.a && echo /opt/local/lib/libjpeg.a || echo "-ljpeg"); echo -lz) || \
	$(fltkconfig) --use-gl --use-images --ldstaticflags` \
	`$(fltkconfig) --use-gl --ldstaticflags` \
	-L/opt/local/lib \
	`oyranos-config --ld_x_staticflags` -L/$(libdir) \
	-lftgl \
	`test -f /usr/X11R6/lib/libfreetype.a \
	  && echo /usr/X11R6/lib/libfreetype.a || (test -f /usr/lib/libfreetype.a \
	    && echo /usr/lib/libfreetype.a || echo -lfreetype)` \
	$(I18N_LIBSTAT) $(X11_LIBS) \
	$(DBG_LIBS) \
	`test -f /opt/kai-uwe/lib/liblcms.a && echo /opt/kai-uwe/lib/liblcms.a || \
	  (test -f /usr/lib/liblcms.a && echo /usr/lib/liblcms.a || \
	  (test -f /opt/local/lib/liblcms.a && echo /opt/local/lib/liblcms.a || \
        (test -f /usr/local/lib/liblcms.a && echo /usr/local/lib/liblcms.a || \
	      (pkg-config --libs lcms))))` $(LIBFL_I18N) #/usr/lib/libelektra.a # Hack for static lcms
	$(REZ)

strip: $(BINTARGET)
	echo strip $(BINTARGET)
	strip $(BINTARGET)

static_static:	$(OBJECTS)
	_$(CXX) $(CXXFLAGS_) -o $(BINTARGET) \
	$(OBJECTS) \
	$(LDLIBS) -static -ljpeg -lpng -lX11 -lpthread -lz -ldl \
	-lfreetype -lfontconfig -lXrender -lGLU -lXext -lexpat \
	-L/opt/local/lib liblcms.a
	$(REZ)

test:	icc_formeln.o icc_utils.o
	$(CXX) $(CXXFLAGS_) $(INCL) -o dE2000_test.o -c tests/dE2000_test.cpp
	$(CXX) $(CXXFLAGS_) -o dE2000_test dE2000_test.o icc_formeln.o icc_utils.o \
	-L$(libdir) -llcms
	$(REZ)

$(LINGUAS_SRC):	$(POT_FILE)
	echo Linguas ... $(@:.gmo=)
	for ling in $(@:.gmo=); do \
	  lingua=`echo $${ling} | sed s%po\/%%g`; \
	  echo "update $${ling}.gmo ..."; \
	  test -f $${ling}.po \
        && ($(MSGFMT) -o $${ling}.gmo $${ling}.po; \
            if [ ! -d $${ling} ]; then \
              mkdir -p $${ling}; \
            fi; \
            if [ ! -d ./$${ling}/LC_MESSAGES ]; then \
              mkdir -p $${ling}/LC_MESSAGES; \
            fi; \
            test -L $${ling}/LC_MESSAGES/$(TARGET).mo \
              && $(RM) $${ling}/LC_MESSAGES/$(TARGET).mo; \
	    cd $${ling}/LC_MESSAGES; \
            ln -s ../../$${lingua}.gmo $(TARGET).mo; \
	    cd ../.. \
	   ) \
        || (echo $${ling}.po is not yet ready ... skipping) \
	done;

$(POT_FILE):	$(ALL_SOURCEFILES)
	test `which xgettext` && xgettext --force-po $(XGETTEXT_OPTIONS) \
	-d $(TARGET) \
	-o $(POT_FILE) \
	$(SOURCES) || echo -e "\c"
	for ling in $(LINGUAS); do \
            test `which $(MSGMERGE)` && \
                 $(MSGMERGE) $(MSGMERG_OPTS) po/$${ling}.po \
                 $(POT_FILE) || \
	        echo -e "\c"; \
	done;
	echo $(POT_FILE) fertig


clean:	unbundle unpkg
	echo mache sauber $@ ...
	-$(RM) $(ALL_OBJECTS) $(BINTARGET) \
	$(LIBNAME) $(LIBSO) $(LIBSONAME) $(LIBSONAMEFULL)
	-for ling in $(LINGUAS); do \
	  test -f po/$${ling}.gmo \
        && $(RM) po/$${ling}.gmo; \
	done;
	cd fl_i18n/ && $(MAKE) -f $(MAKEFILE_ARCH) clean
	echo ... $@ fertig

config:
	./configure

depend:	$(ALL_HEADERFILES)
	echo "schaue nach Abhaengikeiten ..."
	echo "MAKEDEPEND_ISUP = 1" > mkdepend
	echo "#nicht editieren/dont edit - automatisch generiert" >> mkdepend
	-$(MAKEDEPEND) -I./ $(INCL_DEP) >> mkdepend


# The extension to use for executables...
EXEEXT		= 

# Build commands and filename extensions...
.SUFFIXES:	.0 .1 .3 .c .cxx .h .fl .man .o .z $(EXEEXT)

.c.o:
	echo Compiling $< ...
	$(CC) $(CFLAGS_) -c $<

.cxx.o:
	echo Compiling $< ...
	$(CXX) $(CXXFLAGS_) -c $<

.cpp.o:
	echo Compiling $< ...
	$(CXX) $(CXXFLAGS_) -c $<

.fl.cxx:
	echo Expanding $< ...
	fluid -c $<

.fl.h:
	echo Expanding $< ...
	fluid -c $<

.po:
	echo Generating $@ ...
	msgfmt $<

tgz:
	$(MAKE) DESTDIR="`pwd`/Entwickeln" copy_files
	tar cf - Entwickeln/ \
	| gzip > $(TARGET)_$(MTIME).tgz
	test -d Entwickeln && \
	test `pwd` != `(cd Entwickeln; pwd)` && \
	$(RM) -R Entwickeln
	test -d ../Archiv && mv -v $(TARGET)_*.tgz ../Archiv

targz:
	$(MAKE) DESTDIR="`pwd`/$(TARGET)-$(VERSION)" copy_files
	tar cf - $(TARGET)-$(VERSION)/ \
	| gzip > $(TARGET)_$(MTIME).tgz
	test -d $(TARGET)-$(VERSION) && \
	test `pwd` != `(cd $(TARGET)-$(VERSION); pwd)` && \
	$(RM) -R $(TARGET)-$(VERSION) 
	test -d ../Archiv && mv -v $(TARGET)_*.tgz ../Archiv || echo no copy

# ein automake Ziel
distdir:
	cd . && $(MAKE) DESTDIR=$(distdir) copy_files
	# tar acepts only 99 chars for filenames
	$(RM) -R $(distdir)/ICC\ Examin.app/
	mkdir -p $(distdir)/ICC\ Examin.app/

copy_files:
	mkdir -p $(DESTDIR)
	cd fl_i18n && \
	  $(MAKE) DESTDIR=$(DESTDIR)/fl_i18n -f $(MAKEFILE_ARCH) copy_files
	$(COPY) -R \
	$(ALL_FILES) \
	$(DESTDIR)
	mkdir -p $(DESTDIR)/tests
	$(COPY) $(TEST_FILES) $(DESTDIR)/tests
	mkdir -p $(DESTDIR)/po
	$(COPY) $(POT_FILE) $(DESTDIR)/po
	for ling in $(LINGUAS); do \
	  test -f po/$${ling}.po \
	  && $(COPY) po/$${ling}.po $(DESTDIR)/po/; \
	done;


dist:	$(BASE) targz
	test -f && $(COPY) ../Archiv/$(TARGET)_$(MTIME).tgz $(TARGET)-$(VERSION).tar.gz || $(COPY) $(TARGET)_$(MTIME).tgz $(TARGET)-$(VERSION).tar.gz

$(TARGET).spec:
	./configure

rpm:	$(TARGET).spec dist
	./configure --prefix=/usr # for RedHat alike distributions
	mkdir -p rpmdir/BUILD \
	rpmdir/SPECS \
	rpmdir/SOURCES \
	rpmdir/SRPMS \
	rpmdir/RPMS/$(RPMARCH)
	cp -f $(TARGET)-$(VERSION).tar.gz rpmdir/SOURCES
	rpmbuild --clean -ba $(srcdir)/$(TARGET).spec --define "_topdir $$PWD/rpmdir"
	@echo "============================================================"
	@echo "Beendet - die Packete befinden sich in rpmdir/RPMS and rpmdir/SRPMS!"

install:	$(INSTALL_TARGET)

install_cp:
	echo Installation ...
	mkdir -p $(DESTDIR)$(CP_DIR)
	$(INSTALL) -m 755 $(CINEPAINT) $(DESTDIR)$(CP_DIR)
	#strip $(DESTDIR)$(bindir)/$(CINEPAINT)
	mkdir -p $(DESTDIR)$(datadir)/fonts/
	$(INSTALL) -m 644 $(FONT) $(DESTDIR)$(datadir)/fonts/$(FONT)
	$(fltkconfig) --post $(DESTDIR)$(CP_DIR)/$(CINEPAINT)
	mkdir -p $(DESTDIR)$(datadir)/fonts/
	echo  Linguas ...
	for ling in $(LINGUAS); do \
	  echo "installiere po/$${ling}.gmo ..."; \
	  mkdir -p $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES; \
	  test -f po/$${ling}.gmo \
		&& (mkdir -p $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES; \
            $(INSTALL) -m 644 po/$${ling}.gmo $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES/$(CINEPAINT).mo ) \
		|| (echo $${ling}.gmo is not yet ready ... skipping); \
	done;
	echo ... Installation beendet

install_global:
	echo Installation ...
	mkdir -p $(DESTDIR)$(bindir)
	$(INSTALL) -m 755 $(BINTARGET) $(DESTDIR)$(bindir)
	strip $(DESTDIR)$(bindir)/$(BINTARGET)
	$(fltkconfig) --post $(DESTDIR)$(bindir)/$(BINTARGET)
	mkdir -p $(DESTDIR)$(datadir)/fonts/
	$(INSTALL) -m 644 $(FONT) $(DESTDIR)$(datadir)/fonts/$(FONT)
	mkdir -p $(DESTDIR)$(desktopdir)
	$(INSTALL) -m 644 icc_examin.desktop $(DESTDIR)$(desktopdir)/icc_examin.desktop
	mkdir -p $(DESTDIR)$(datadir)/mime/packages/
	$(INSTALL) -m 644 icc.xml $(DESTDIR)$(datadir)/mime/packages/icc.xml
	mkdir -p $(DESTDIR)$(pixmapdir)
	$(INSTALL) -m 644 icc_examin.png $(DESTDIR)$(pixmapdir)/icc_examin.png
	echo  Linguas ...
	for ling in $(LINGUAS); do \
	  echo "installiere po/$${ling}.gmo ..."; \
	  mkdir -p $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES; \
	  test -f po/$${ling}.gmo \
		&& (mkdir -p $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES; \
            $(INSTALL) -m 644 po/$${ling}.gmo $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES/$(TARGET).mo ) \
		|| (echo $${ling}.gmo is not yet ready ... skipping); \
	done;
	echo ... Installation beendet

uninstall:
	echo deinstalliere ...
	if [ "$(INSTALL_TARGET)" = "install_global" ]; then \
	  $(RM) $(DESTDIR)$(bindir)/$(BINTARGET); \
	else \
	  $(RM) $(DESTDIR)$(CP_DIR)/$(CINEPAINT); \
	fi
	$(RM) $(DESTDIR)$(desktopdir)/icc_examin.desktop
	$(RM) $(DESTDIR)$(datadir)/mime/packages/icc.xml
	$(RM) $(DESTDIR)$(pixmapdir)/icc_examin.png
	$(RM) $(DESTDIR)$(datadir)/fonts/$(FONT)
	for ling in $(LINGUAS); do \
	  $(RM) $(DESTDIR)$(datadir)/locale/$${ling}/LC_MESSAGES/$(TARGET).mo; \
	done;
	echo ... $@ fertig

bundle:	static
	echo bündeln ...
	test -d ICC\ Examin.app/Contents/Resources/lib/ || mkdir -p ICC\ Examin.app/ ICC\ Examin.app/Contents/ ICC\ Examin.app/Contents/MacOS/ ICC\ Examin.app/Contents/Resources/  ICC\ Examin.app/Contents/Resources/bin/ ICC\ Examin.app/Contents/Resources/lib/ ICC\ Examin.app/Contents/Resources/share/
	$(INSTALL) -m 644 Info.plist ICC\ Examin.app/Contents/Info.plist
	$(INSTALL) -m 755 ICC\ Examin.sh ICC\ Examin.app/Contents/MacOS/ICC\ Examin
	$(INSTALL) -m 755 $(BINTARGET) ICC\ Examin.app/Contents/MacOS/
	strip ICC\ Examin.app/Contents/MacOS/$(BINTARGET)
	echo  Bibliotheken ...
	for bib in jpeg png lcms dl intl iconv fltk freetype; do \
	  echo "bündele lib$${bib}$(LIBEXT) ..."; \
      test -f $(libdir)/lib$${bib}$(LIBEXT) \
		&& ($(COPY) -R $(libdir)/lib$${bib}*$(LIBEXT) 'ICC Examin.app/Contents/Resources/lib/' ) \
		|| ( test -f /usr/X11R6/lib/lib$${bib}$(LIBEXT) \
		    && ($(COPY) -R /usr/X11R6/lib/lib$${bib}*$(LIBEXT) 'ICC Examin.app/Contents/Resources/lib/' ) \
	        || (echo lib$${bib}$(LIBEXT) not found ... skipping)); \
	done;
	test -f ~/bin/iccgamut \
	  && $(INSTALL) -m 755 ~/bin/iccgamut ICC\ Examin.app/Contents/Resources/bin/ \
	  || test -f iccgamut && $(INSTALL) -m 755 iccgamut ICC\ Examin.app/Contents/Resources/bin/ \
	  || test -f $(bindir)/iccgamut && $(INSTALL) -m 755 $(bindir)/iccgamut ICC\ Examin.app/Contents/Resources/bin/ \
	    || echo iccgamut nicht gefunden
	$(INSTALL) -m 644 $(FONT) ICC\ Examin.app/Contents/Resources/share/
	echo  Linguas ...
	for ling in $(LINGUAS); do \
	  echo "bündele po/$${ling}.gmo ..."; \
      test -f po/$${ling}.gmo \
		&& (mkdir -p ICC\ Examin.app/Contents/Resources/locale/$${ling}/LC_MESSAGES; \
            $(INSTALL) -m 644 po/$${ling}.gmo ICC\ Examin.app/Contents/Resources/locale/$${ling}/LC_MESSAGES/$(TARGET).mo ) \
		|| (echo $${ling}.gmo is not yet ready ... skipping); \
	done;
	echo ... bündeln beendet

unbundle:
	echo mache sauber $@ in $(DESTDIR) ...
	$(RM) $(DESTDIR)ICC\ Examin.app/Contents/MacOS/*
	$(RM) $(DESTDIR)ICC\ Examin.app/Contents/Resources/share/$(FONT)
	$(RM) $(DESTDIR)ICC\ Examin.app/Contents/Resources/bin/*
	$(RM) $(DESTDIR)ICC\ Examin.app/Contents/Resources/lib/*
	$(RM) -R $(DESTDIR)ICC\ Examin.app/Contents/Resources/locale
	echo ... $@ fertig

.PHONY: install pkg bundle uninstall unbundle unpkg

pkg:	bundle
	echo Vorbereiten des osX Packetes ...
	$(RM) -r installation/*
	$(MAKE) DESTDIR=`pwd`/installation install
	mkdir -p installation/Applications/
	$(COPY) -R ICC\ Examin.app installation/Applications/
	$(MAKE) DESTDIR=`pwd`/installation/Applications/ unbundle
	test -f ~/bin/iccgamut \
	  && $(INSTALL) -m 755 ~/bin/iccgamut installation$(bindir) \
	  || test -f iccgamut && $(INSTALL) -m 755 iccgamut installation$(bindir) \
	  || test -f /opt/local/bin/iccgamut && $(INSTALL) -m 755 /opt/local/bin/iccgamut installation$(bindir) \
	    || echo iccgamut nicht gefunden
	$(LINK) $(bindir)/$(BINTARGET) installation/Applications/ICC\ Examin.app/Contents/MacOS/ICC\ Examin
	open /Developer/Applications/Utilities/PackageMaker.app ICC\ Examin.pmsp
	echo sudo: chown -R root:admin `pwd`/installation  -- bitte nicht vergessen
	echo ... Packet vorbereitet

unpkg:
	echo mache sauber $@ ...
	$(RM) -R installation/
	echo ... $@ fertig

fltkconfig:
	echo $(fltkconfig)

# mkdepend
include mkdepend

#ifndef MAKEDEPEND_ISUP
mkdepend: depend
#endif

