
#
# This makefile is used to build trick utils standalone.
# That is, without Trick.
#
# It does NOT create lib or object dirs for each platform.
# 
# Once ran, all libraries go into "lib" .

TRICK_HOST_CPU := $(shell uname -s)

CC = cc
OBJ_DIR = object_${TRICK_HOST_CPU}
ADT_LIB = $(OBJ_DIR)/libtrick_adt.a

FLAGS = -g -I../include -D_REENTRANT -DSTAND_ALONE -D${TRICK_HOST_CPU} -Iinclude

trick: start

start: $(ADT_LIB)
	@ echo "[32m$(ADT_LIB) is up to date[00m"

real_clean: clean

clean:
	/bin/rm -rf $(OBJ_DIR)

#=======================================================================
# TRICK_ADT

SRC_DIR = src

TRICK_ADT_OBJECTS = \
	$(OBJ_DIR)/MapStrToPtr.o \
	$(OBJ_DIR)/bst.o \
	$(OBJ_DIR)/dllist.o \
	$(OBJ_DIR)/lqueue.o \
	$(OBJ_DIR)/lstack.o \
	$(OBJ_DIR)/record_array.o \
	$(OBJ_DIR)/bubble_sort.o

$(ADT_LIB) : $(TRICK_ADT_OBJECTS)
	ar cr $(ADT_LIB) $?
	@ if [ "`uname -s`" = "Darwin" ] ; then \
         echo ranlib $(ADT_LIB) ; \
         ranlib $(ADT_LIB) ; \
      fi

$(OBJ_DIR) :
	mkdir -p $(OBJ_DIR)

$(TRICK_ADT_OBJECTS) : $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c | $(OBJ_DIR)
	$(CC) $(FLAGS) -c $< -o $@

