# Makefile for arrange
#

COMP = cc
#COMP = gcc
INCLUDES = -I/usr/include
O1 = $(HOSTTYPE)


FILES = \
        $(O1)/arrange.o \
        $(O1)/arrange_debug.o \
	$(O1)/dheap.o \
	$(O1)/lists.o \
	$(O1)/main.o \
        $(O1)/polygon.o \
    	$(O1)/spheregeom.o \
    	$(O1)/traverse.o

GEOM_FILES = \
        $(O1)/arrange_geom_float.o

IGEOM_FILES = \
        $(O1)/arrange_geom_int.o

GRAPHICS_FILES = \
        $(O1)/debug_graphics.o

MEM_DEBUG_FILES = \
	$(O1)/memory_debug.o


# choose from the next two lines depending on whether or not the
# special memory management debug code should be used
#OFILES = $(FILES) $(GEOM_FILES) $(MEM_DEBUG_FILES) $(GRAPHICS_FILES)
OFILES = $(FILES) $(GEOM_FILES) $(GRAPHICS_FILES)


# choose from the next two lines depending on whether or not the
# special memory management debug code should be used
#IFILES = $(FILES) $(IGEOM_FILES) $(MEM_DEBUG_FILES) $(GRAPHICS_FILES)
IFILES = $(FILES) $(IGEOM_FILES) $(GRAPHICS_FILES)


# choose from the next two lines depending on whether or not the
# special memory management debug code should be used
#DEFINE = -DMEMORY_DETOUR
DEFINE = 

LIBS = -lX11 -lm

CFLAGS = -c -g $(DEFINE) -o $@


driver: $(OFILES)
	$(COMP) -g -o driver.$(O1) $(OFILES) $(LIBS)

int: $(IFILES)
	$(COMP) -g -o driver.int.$(O1) $(IFILES) $(LIBS)

# ---- alphabetized list of modules ----
$(O1)/arrange.o: arrange.c arrange.h arrange_geom.h arrange_type.h arrange_macros.h dheap.h lists.h polygon.h standards.h
	$(COMP) -DARRANGE_DEBUG $(CFLAGS) arrange.c

$(O1)/arrange_debug.o: arrange_debug.c arrange_debug.h arrange.h standards.h arrange_type.h arrange_macros.h arrange_geom.h debug_graphics.h
	$(COMP) -DARRANGE_DEBUG -DARRANGE_GRAPHICS $(CFLAGS) arrange_debug.c

$(O1)/arrange_geom_float.o: arrange_geom_float.c arrange_geom.h standards.h spheregeom.h
	$(COMP) -DARRANGE_DEBUG -DARRANGE_GRAPHICS $(CFLAGS) arrange_geom_float.c

$(O1)/arrange_geom_int.o: arrange_geom_int.c arrange_geom.h standards.h spheregeom.h
	$(COMP) -DARRANGE_DEBUG -DARRANGE_GRAPHICS $(CFLAGS) arrange_geom_int.c

$(O1)/debug_graphics.o: debug_graphics.c debug_graphics.h standards.h lists.h arrange.h
	$(COMP) $(CFLAGS) debug_graphics.c

$(O1)/dheap.o: dheap.c dheap.h
	$(COMP) $(CFLAGS) dheap.c

$(O1)/lists.o: lists.c lists.h
	$(COMP) $(CFLAGS) lists.c

$(O1)/main.o: main.c standards.h arrange.h
	$(COMP) $(CFLAGS) main.c

$(O1)/memory_debug.o: memory_debug.c memory_debug.h
	$(COMP) $(CFLAGS) -DDEBUG memory_debug.c

$(O1)/polygon.o: polygon.c polygon.h spheregeom.h lists.h standards.h
	$(COMP) $(CFLAGS) -DDEBUG polygon.c

$(O1)/spheregeom.o: spheregeom.c spheregeom.h standards.h
	$(COMP) $(CFLAGS) spheregeom.c

$(O1)/traverse.o: traverse.c traverse.h arrange.h arrange_geom.h arrange_type.h arrange_macros.h standards.h lists.h polygon.h
	$(COMP) $(CFLAGS) -DSTRIPPED_VERSION traverse.c


