# Makefile for sample file
CC = g++
CFLAGS = -g -Wall 

SDK_INCLUDE = ./SDK/include
SDK_LIB = ./SDK/lib

PATH_INC = -I$(SDK_INCLUDE)

UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
    PATH_LIBS = -lc -lz -lexpat -lgssapi_krb5 -L$(SDK_LIB)
else
    PATH_LIBS = -lc -lexpat  -L$(SDK_LIB)
endif

APP= sample sample_csdk_static sample_csdk_dynamic sample_ssdk_static sample_ssdk_dynamic auth_token

all: $(APP)
	sync

sample: sample.o
	$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshcsdk.a $(SDK_LIB)/libshssdk.a

sample.o: sample.cpp
	$(CC) $(CFLAGS) -c $^ $(PATH_INC)

sample_csdk_static: sample_csdk.o
	$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshcsdk.a
	
sample_csdk_dynamic: sample_csdk.o
	$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS)  -Wl,-rpath,'$(SDK_LIB)' -lshcsdk

sample_csdk.o: sample_csdk.cpp
	$(CC) $(CFLAGS) -c $^ $(PATH_INC)

sample_ssdk_static: sample_ssdk.o
	$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshssdk.a

sample_ssdk_dynamic: sample_ssdk.o
	$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS)  -Wl,-rpath,'$(SDK_LIB)' -lshssdk

sample_ssdk.o: sample_ssdk.cpp
	$(CC) $(CFLAGS) -c $^ $(PATH_INC)

auth_token.o: auth_token.cpp
	$(CC) $(CFLAGS) -c $^ $(PATH_INC)

auth_token: auth_token.o
	 $(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshssdk.a
	
clean:
	rm -f *.o $(APP)


