
#
# This makefile is used to build trick utils standalone.
# That is, without Trick.
#

TRICK_HOST_CPU := $(shell uname -s)

CC = cc
CPP = c++

SHM_INC_DIR = include

OBJ_DIR   = object_${TRICK_HOST_CPU}
SHM_LIB  = $(OBJ_DIR)/libtrick_shm.a

FLAGS = -g -I../include -D_REENTRANT -DSTAND_ALONE

trick: start

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

real_clean: clean

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

#=======================================================================
# SHM

SRC_DIR = src

SHM_OBJECTS = $(OBJ_DIR)/tsm_disconnect.o \
    $(OBJ_DIR)/tsm_init.o \
    $(OBJ_DIR)/tsm_init_with_lock.o \
    $(OBJ_DIR)/tsm_reconnect.o

$(SHM_LIB): $(SHM_OBJECTS)
	ar cr $(SHM_LIB) $?
	@ if [ "${TRICK_RANLIB}" != "" ] ; then \
         echo ${TRICK_RANLIB} $(SHM_LIB) ; \
         ${TRICK_RANLIB} $(SHM_LIB) ; \
      fi

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

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

