# --------------------------------------------------------------------- 
# ---		 EPIC (Efficient Pyramid Image Coder)               ---
# ---	 Designed by Eero P. Simoncelli and Edward H. Adelson       ---
# ---		    Written by Eero P. Simoncelli                   ---
# ---  Developed at the Vision Science Group, The Media Laboratory  ---
# ---	Copyright 1989, Massachusetts Institute of Technology       ---
# ---			 All rights reserved.                       ---
# ---------------------------------------------------------------------
#
# Permission to use, copy, or modify this software and its documentation
# for educational and research purposes only and without fee is hereby
# granted, provided that this copyright notice appear on all copies and
# supporting documentation.  For any other uses of this software, in
# original or modified form, including but not limited to distribution
# in whole or in part, specific prior permission must be obtained from
# M.I.T. and the authors.  These programs shall not be used, rewritten,
# or adapted as the basis of a commercial software or hardware product
# without first obtaining appropriate licenses from M.I.T.  M.I.T. makes
# no representations about the suitability of this software for any
# purpose.  It is provided "as is" without express or implied warranty.
#
# ---------------------------------------------------------------------

SHARED_OBJECTS = utilities.o parse_args.o fileio.o quantize.o run_length.o huffman.o 
EPIC_OBJECTS = epic.o  build_pyr.o
UNEPIC_OBJECTS = unepic.o collapse_pyr.o 
CONVOLVE_OBJECTS =  convolve.o edges.o 

NC_SHARED_OBJECTS = $(addprefix nc_,$(SHARED_OBJECTS))
NC_EPIC_OBJECTS =  $(addprefix nc_,$(EPIC_OBJECTS))
NC_UNEPIC_OBJECTS = $(addprefix nc_,$(UNEPIC_OBJECTS))
NC_CONVOLVE_OBJECTS = $(addprefix nc_,$(CONVOLVE_OBJECTS))

AP_SHARED_OBJECTS = $(addprefix a_,$(SHARED_OBJECTS))
AP_EPIC_OBJECTS =  $(addprefix a_,$(EPIC_OBJECTS))
AP_UNEPIC_OBJECTS = $(addprefix a_,$(UNEPIC_OBJECTS))
AP_CONVOLVE_OBJECTS = $(addprefix a_,$(CONVOLVE_OBJECTS))

GP_SHARED_OBJECTS = $(addprefix g_,$(SHARED_OBJECTS))
GP_EPIC_OBJECTS =  $(addprefix g_,$(EPIC_OBJECTS))
GP_UNEPIC_OBJECTS = $(addprefix g_,$(UNEPIC_OBJECTS))
GP_CONVOLVE_OBJECTS = $(addprefix g_,$(CONVOLVE_OBJECTS))

CC = cyclone
# CC = gcc
# CC = cc

CFLAGS = -O3 $(EXTRACFLAGS) ## For GCC
# CFLAGS = -fsingle  ## Optimize on Sun-4/SPARC
# CFLAGS = -O4 -f68881   ## Sun-3 with standard Floating point co-processor
# CFLAGS = -ffpa         ## Sun-3 with fpa (Weitek) board
# CFLAGS = +x            ## HP Bobcats
# CFLAGS = -O -f          ## DECstations

all: epic unepic 

build: epic unepic
build-nocheck: epic-nochk unepic-nochk
build-aprof: epic-aprof unepic-aprof

epic: $(EPIC_OBJECTS) $(SHARED_OBJECTS) $(CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) -o epic $(EPIC_OBJECTS) $(SHARED_OBJECTS) $(CONVOLVE_OBJECTS) -lm -lc

unepic: $(UNEPIC_OBJECTS) $(SHARED_OBJECTS) $(CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) -o unepic $(UNEPIC_OBJECTS) $(SHARED_OBJECTS) $(CONVOLVE_OBJECTS) -lm -lc

epic-nochk: $(NC_EPIC_OBJECTS) $(NC_SHARED_OBJECTS) $(NC_CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) --nochecks -o epic-nochk $(NC_EPIC_OBJECTS) $(NC_SHARED_OBJECTS) $(NC_CONVOLVE_OBJECTS) -lm -lc

unepic-nochk: $(NC_UNEPIC_OBJECTS) $(NC_SHARED_OBJECTS) $(NC_CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) --nochecks -o unepic-nochk $(NC_UNEPIC_OBJECTS) $(NC_SHARED_OBJECTS) $(NC_CONVOLVE_OBJECTS) -lm -lc

epic-aprof: $(AP_EPIC_OBJECTS) $(AP_SHARED_OBJECTS) $(AP_CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) -pa -o epic-aprof $(AP_EPIC_OBJECTS) $(AP_SHARED_OBJECTS) $(AP_CONVOLVE_OBJECTS) -lm -lc

unepic-aprof: $(AP_UNEPIC_OBJECTS) $(AP_SHARED_OBJECTS) $(AP_CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) -pa -o unepic-nochk $(AP_UNEPIC_OBJECTS) $(AP_SHARED_OBJECTS) $(AP_CONVOLVE_OBJECTS) -lm -lc

epic-gprof: $(GP_EPIC_OBJECTS) $(GP_SHARED_OBJECTS) $(GP_CONVOLVE_OBJECTS)
	${CC} $(CFLAGS) -pg -o epic-gprof $(GP_EPIC_OBJECTS) $(GP_SHARED_OBJECTS) $(GP_CONVOLVE_OBJECTS) -lm -lc

$(CONVOLVE_OBJECTS): convolve.h
$(EPIC_OBJECTS) $(UNEPIC_OBJECTS) $(SHARED_OBJECTS): epic.h
$(NC_CONVOLVE_OBJECTS): convolve.h
$(NC_EPIC_OBJECTS) $(NC_UNEPIC_OBJECTS) $(NC_SHARED_OBJECTS): epic.h
$(AP_CONVOLVE_OBJECTS): convolve.h
$(AP_EPIC_OBJECTS) $(AP_UNEPIC_OBJECTS) $(AP_SHARED_OBJECTS): epic.h

%.o: %.cyc
	${CC} $(CFLAGS) -c $<

nc_%.o: %.cyc
	${CC} $(CFLAGS) --nochecks -c $< -o $@

a_%.o: %.cyc
	${CC} $(CFLAGS) -pa -c $< -o $@

g_%.o: %.cyc
	${CC} $(CFLAGS) -pg -c $< -o $@

clean:
	$(RM) *.o epic unepic epic-nochk unepic-nochk
