# FILE:    Makefile
# AUTHOR:  Erik Nygren (nygren@mit.edu)
# PURPOSE: Makefile for 6.866 Final Project.
#          Requires GNU make and gcc

COMMONSRCS = 	image.c imagedisplayer.c bresenham.c opflow.c \
		projxform.c linalg.c util.c apputils.c

TESTPROGS = testimage testproj \
	testbuttons testlinalg testfindproj

UNUSEDTESTPROGS = testimagemotif testopflow

APPS = xformtool

CC      = gcc
CFLAGS  = -ansi -Wall -pedantic -g
LDFLAGS = -lX11 -lm

######## MACHINE SPECIFIC ########

# For Solaris (and possibly SunOS)
ifeq ($(shell uname), SunOS)  
	CFLAGS := $(CFLAGS) -I/usr/openwin/include
	LDFLAGS := -L/usr/openwin/lib $(LDFLAGS) 
endif

# For Linux
ifeq ($(shell uname), Linux)  
endif

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

COMMONOBJS = $(COMMONSRCS:%.c=%.o)

ALLOBJS = $(TESTPROGS:%=%.o) $(COMMONOBJS) $(APPS:%=%.o)
ALLSRCS = $(TESTPROGS:%=%.c) $(COMMONSRCS) $(APPS:%=%.c)

all: $(APPS)

tests: $(TESTPROGS)

$(TESTPROGS): %: %.o $(COMMONOBJS)
	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(APPS): %: %.o $(COMMONOBJS)
	$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

dist:
	tar -cvzf projxformtool.src.tar.gz *.c *.h Makefile

depend:
	makedepend $(ALLSRCS)

clean:
	-/bin/rm -f *.o $(TESTPROGS) $(APPS) *~

TESTPROGS: $(COMMONOBJS)

# DO NOT DELETE
