#
# Makefile for Multi-Resolution-Morphing-Programs 'xmrm' and 'xmrm_mpeg'
#
# Please see README.TXT or the LEGAL NOTES-section in the manual
# before modifying or using 'xmrm' or 'xmrm_mpeg'
#
#   Idea: Manfred Kopp
#   Programming: Gerhard Waldhör, Andreas Artmann
#
# Usage: make [target]
#
#        all: make dynamic executables
#     static: make static executables
#      clean: remove o-files, bak-files...
#      empty: remove o-files, bak-files... AND executables
#
##############################################################################

CPP = g++
CC = gcc

# -c: don't link yet
# -g: produce debugging-information, don't use together with link_flag -s
#COMPILE_FLAGS = -c -g

# -O3: highest optimization level
# -m486: generates 486-specific code
# -c: don't link yet
#COMPILE_FLAGS = -O3 -m486 -c

# -O: normal optimization level  -c: don't link yet
COMPILE_FLAGS = -O -I. -I/usr/X11R6/include -I/home/guido/xmrm/xforms/xforms/FORMS -c 

# -s: DESTROYS symbol-table
LINK_FLAGS = -s


SYSLIB = -L/usr/X11R6/lib -L/home/guido/xmrm/xforms/xforms/FORMS -lX11 -lm
LIBS = -L/usr/lib -ltiff -ljpeg -lgz -lforms -lXpm $(SYSLIB)
LIBS = -L/usr/local/lib -L/usr/lib -ltiff -ljpeg -lforms -lXpm $(SYSLIB)

OBJECTS = xmrm.o xmrm_cb.o io.o morphvec.o init.o wavemorph.o wave_rts.o wave.o\
          areas.o xmrm_main.o

##############################################################################

all: xmrm xmrm_mpeg

xmrm: $(OBJECTS)
	$(CC) $(LINK_FLAGS) -o xmrm $(OBJECTS) $(LIBS)

xmrm_mpeg: xmrm_mpeg.o xmrm_mpeg_main.o
	$(CC) $(LINK_FLAGS) -o xmrm_mpeg xmrm_mpeg.o xmrm_mpeg_main.o $(LIBS)

static: $(OBJECTS) xmrm_mpeg.o xmrm_mpeg_main.o
	$(CC) $(LINK_FLAGS) -o xmrm $(OBJECTS) $(LIBS) -static
	$(CC) $(LINK_FLAGS) -o xmrm_mpeg xmrm_mpeg.o xmrm_mpeg_main.o $(LIBS) -static
	@echo
	@echo "REMOVE 'xmrm' AND 'xmrm_mpeg' BEFORE YOUR NEXT 'make all|dynamic' !!!"
	@echo

xmrm.o: xmrm.cc xmrm.h io.h morphvec.h const.h
	$(CPP) $(COMPILE_FLAGS) xmrm.cc

xmrm_cb.o: xmrm_cb.cc wavemorph.h morphvec.h io.h init.h xmrm.h const.h
	$(CPP) $(COMPILE_FLAGS) xmrm_cb.cc

io.o: io.cc io.h morphvec.h wavemorph.h wave_rts.h xmrm.h const.h init.h areas.h
	$(CPP) $(COMPILE_FLAGS) io.cc

morphvec.o: morphvec.cc morphvec.h init.h io.h const.h xmrm.h
	$(CPP) $(COMPILE_FLAGS) morphvec.cc

init.o: init.cc init.h const.h io.h
	$(CPP) $(COMPILE_FLAGS) init.cc

wavemorph.o: wavemorph.cc wavemorph.h wave.h morphvec.h init.h io.h xmrm.h xmrm_cb.h areas.h const.h
	$(CPP) $(COMPILE_FLAGS) wavemorph.cc

wave_rts.o: wave_rts.cc wave_rts.h wavemorph.h wave.h morphvec.h init.h io.h xmrm.h xmrm_cb.h areas.h const.h
	$(CPP) $(COMPILE_FLAGS) wave_rts.cc

wave.o: wave.cc wave.h const.h
	$(CPP) $(COMPILE_FLAGS) wave.cc

areas.o:	areas.cc areas.h morphvec.h init.h xmrm.h const.h
	$(CPP) $(COMPILE_FLAGS) areas.cc

xmrm_main.o: xmrm_main.cc xmrm.h io.h init.h morphvec.h wavemorph.h wave.h areas.h const.h
	$(CPP) $(COMPILE_FLAGS) xmrm_main.cc

xmrm_mpeg.o: xmrm_mpeg.cc xmrm_mpeg.h
	$(CPP) $(COMPILE_FLAGS) xmrm_mpeg.cc

xmrm_mpeg_main.o: xmrm_mpeg_main.cc xmrm_mpeg.h
	$(CPP) $(COMPILE_FLAGS) xmrm_mpeg_main.cc

clean:
	-rm -f *.bak *.ESV *.o core a.out *~ xmrmdesign.c xmrmdesign_cb.c xmrmdesign_main.c xmrmdesign.h
	-rm -f xmrm_mpegdesign.c xmrm_mpegdesign_main.c xmrm_mpegdesign.h

empty:
	-rm -f *.bak *.ESV *.o core a.out *~ xmrmdesign.c xmrmdesign_cb.c xmrmdesign_main.c xmrmdesign.h
	-rm -f xmrm xmrm_mpeg xmrm_mpegdesign.c xmrm_mpegdesign_main.c xmrm_mpegdesign.h
