#------------------------------------------------------------------------------
# Open Dynamics Engine and modular Robots
# Dr. Juan Gonzalez-Gomez. January 2009                          
#------------------------------------------------------------------------------
# GPL LICENSE                                                               
#------------------------------------------------------------------------------

CC = g++
CPPFLAGS =  -Iinclude  
            
DRAWSTUFF_FLAGS =  -Wall -fno-rtti -fno-exceptions -Wall -fomit-frame-pointer \
                   -ffast-math -Iinclude -DdNODEBUG -O2             
            
LIB = -lm -lode 
LIB3D = $(LIB) -lX11 -lGL -lGLU


#-- Drawstuff library
LIBDS = libdrawstuff.a
DEP = drawstuff/drawstuff.o drawstuff/x11.o

#-- Example: snake robot
NAME1 = snake
DEP1 = snake_ex/$(NAME1).o snake_ex/robot.o 

#-- Example1: 
NAME2 = grasping1
DEP2 = grasping1_ex/$(NAME2).o grasping1_ex/robot.o grasping1_ex/body_cyl.o

#-- Cylinder
NAME3 = cylinder
DEP3 = cylinder_ex/$(NAME3).o cylinder_ex/body_cyl.o 

#-- Example2: 
NAME4 = grasping2
DEP4 = grasping2_ex/$(NAME4).o grasping2_ex/robot.o grasping2_ex/body_cyl.o \
       grasping2_ex/oscillators.o

all: $(LIBDS) $(NAME1) $(NAME2) $(NAME3) $(NAME4)


#------------------------------
#-- Drawstuff.a
#------------------------------
$(LIBDS): $(DEP)
	    ar rc $(LIBDS) $(DEP)
			
drawstuff/drawstuff.o: drawstuff/drawstuff.cpp   
	  $(CC) $(DRAWSTUFF_FLAGS) -o $@ -c  $< 

drawstuff/x11.o: drawstuff/x11.cpp   
	  $(CC) $(DRAWSTUFF_FLAGS) -o $@ -c  $< 
    
clean::
	  rm -f $(LIBDS) $(DEP) *.bak *~
     

#-----------------------
#-- Example: Snake Robot
#-----------------------    
$(NAME1): $(DEP1) $(LIBDS)
	    $(CC) -o $@ $^ $(LIB3D)
      
$(DEP1): snake_ex/parameters.h snake_ex/robot.h

clean::
	  rm -f $(NAME1) $(DEP1) *.bak *~    
		
#-----------------------
#-- Grasping1
#-----------------------    
$(NAME2): $(DEP2) $(LIBDS)
	    $(CC) -o $@ $^ $(LIB3D)
      
$(DEP2): grasping1_ex/parameters.h grasping1_ex/robot.h

clean::
	  rm -f $(NAME2) $(DEP2) *.bak *~    

#-----------------------
#-- Grasping1
#-----------------------    
$(NAME3): $(DEP3) $(LIBDS)
	    $(CC) -o $@ $^ $(LIB3D)
      
$(DEP3): cylinder_ex/parameters.h cylinder_ex/body_cyl.h

clean::
	  rm -f $(NAME3) $(DEP3) *.bak *~    

#-----------------------
#-- Grasping2
#-----------------------    
$(NAME4): $(DEP4) $(LIBDS)
	    $(CC) -o $@ $^ $(LIB3D)
      
$(DEP4): grasping2_ex/parameters.h grasping2_ex/body_cyl.h

clean::
	  rm -f $(NAME4) $(DEP4) *.bak *~