#
# Introduction to Computing II (Keisanki Joron 2)
# Dept. of Engineering Systems, University of Tsukuba
# 2009/10/16, kameda[at]iit.tsukuba.ac.jp

#
# To use make command for compiling a single source file, 
# e.g. foo.c, type
#
# $ make foo
#

#---------------------------------------------------------
# common variables
#---------------------------------------------------------

# Compiler
CC	 = gcc

# Options used on compiling
#CFLAGS   = -O2 -Wall 
CFLAGS   = -g -Wall 

# Options used on linking
LDFLAGS	 = 

# Libraries to be linked (OpenGL), even -lm could be omitted
LDLIBS	 = -lglut -lm 

#---------------------------------------------------------
# local variables
#---------------------------------------------------------

EXENAME = Animator-run

# Quiz-B2 (must)
OBJECT_B2 = \
	st-animator-data.o \
	st-animator-script.o
PRECOMPILED_B2 = \
	fl-animator-global.o \
	fl-animator-geomextra.o \
	fl-animator-geom.o \
	fl-animator-drawprimitive.o \
	fl-animator-drawextra.o \
	fl-animator-drawcore.o \
	fl-animator-callback.o \
	fl-animator-initgl.o \
	fl-animator-main.o

# Quiz-B23 (option)
OBJECT_B23 = \
	st-animator-data.o \
	st-animator-script.o \
	st-animator-callback.o \
	st-animator-main.o
PRECOMPILED_B23 = \
	fl-animator-global.o \
	fl-animator-geomextra.o \
	fl-animator-geom.o \
	fl-animator-drawprimitive.o \
	fl-animator-drawextra.o \
	fl-animator-drawcore.o \
	fl-animator-initgl.o 

# Quiz-C1/C11/D1, if you didn't do Quiz-B23
OBJECT_C1 = \
	st-animator-data.o \
	st-animator-script.o \
	st-animator-geom.o \
	st-animator-drawcore.o 
PRECOMPILED_C1 = \
	fl-animator-global.o \
	fl-animator-geomextra.o \
	fl-animator-drawprimitive.o \
	fl-animator-drawextra.o \
	fl-animator-callback.o \
	fl-animator-initgl.o \
	fl-animator-main.o

# Quiz-C1/C11/D1, # if you did Quiz-B23
OBJECT_C1e = \
	st-animator-data.o \
	st-animator-script.o \
	st-animator-geom.o \
	st-animator-drawcore.o \
	st-animator-callback.o \
	st-animator-main.o
PRECOMPILED_C1e = \
	fl-animator-global.o \
	fl-animator-geomextra.o \
	fl-animator-drawprimitive.o \
	fl-animator-drawextra.o \
	fl-animator-initgl.o 

OBJECT_ALL = $(OBJECT_B2) $(OBJECT_B23) $(OBJECT_C1) $(OBJECT_C1e) 

#---------------------------------------------------------
# make rules
#---------------------------------------------------------

default:
	echo "Please specify one target ...."

# clean up objects written by students
st-clean:
	rm -f $(OBJECT_ALL) *~ core

# clean up exec files too
st-cleanup: st-clean
	rm -f $(EXENAME)*

# do compile for all the reports
through: B2 B23 C1 C1e C11 C11e D1 D1e

# generic rule for making object files
.c.o:
	$(CC) $(CFLAGS) $(INCLUDES) -c $<

# student source files should be recompiled once st-animator.h is updated
$(OBJECT_ALL): st-animator-ic2.h

#----
B2: $(EXENAME)B2
$(EXENAME)B2: $(OBJECT_B2)
	gcc -o $@ $(OBJECT_B2) $(PRECOMPILED_B2) $(LDFLAGS) $(LDLIBS)

#------------------------------------
B23: $(EXENAME)B23
$(EXENAME)B23: $(OBJECT_B23)
	gcc -o $@ $(OBJECT_B23) $(PRECOMPILED_B23) $(LDFLAGS) $(LDLIBS)

#------------------------------------
C1: $(EXENAME)C1
$(EXENAME)C1: $(OBJECT_C1)
	gcc -o $@ $(OBJECT_C1) $(PRECOMPILED_C1) $(LDFLAGS) $(LDLIBS)

#------------------------------------
C1e: $(EXENAME)C1e
$(EXENAME)C1e: $(OBJECT_C1e)
	gcc -o $@ $(OBJECT_C1e) $(PRECOMPILED_C1e) $(LDFLAGS) $(LDLIBS)

#------------------------------------
C11: $(EXENAME)C11
$(EXENAME)C11: $(OBJECT_C1)
	gcc -o $@ $(OBJECT_C1) $(PRECOMPILED_C1) $(LDFLAGS) $(LDLIBS)

#------------------------------------
C11e: $(EXENAME)C11e
$(EXENAME)C11e: $(OBJECT_C1e)
	gcc -o $@ $(OBJECT_C1e) $(PRECOMPILED_C1e) $(LDFLAGS) $(LDLIBS)

#------------------------------------
D1: $(EXENAME)D1
$(EXENAME)D1: $(OBJECT_C1)
	gcc -o $@ $(OBJECT_C1) $(PRECOMPILED_C1) $(LDFLAGS) $(LDLIBS)

#------------------------------------
D1e: $(EXENAME)D1e
$(EXENAME)D1e: $(OBJECT_C1e)
	gcc -o $@ $(OBJECT_C1e) $(PRECOMPILED_C1e) $(LDFLAGS) $(LDLIBS)


# end of Makefile


