#program name
PRGNAME	= new_sh_statusd	
#MNGNAME = rcmng_client
RCCHKNAME = rccheck
VSHMNAME = view_shm
INSTALLDIR = /user/service/bin

# Which Compiler
CC	=	gcc
CXX	=	g++

# Which OS
#OS	=	FreeBSD
OS	=	Linux

#library directory
LIBDIR	=	-L/usr/local/lib -L/usr/lib -L../lib -L/usr/lib64/mysql\
				-L/user/db/pgsql/lib
				
INCLUDEDIR	=	-I/usr/local/include -I/usr/include\
					-I../include -I/usr/include/mysql\
					-I/user/db/pgsql/include
RCCHK_INCLUDEDIR = -I/usr/local/include -I/usr/include\
				   		-I../include
#libraries
#LIBS	= /usr/local/lib/libxml2.so
LIBS	=	-lpthread -lmysqlclient -lpq -lshsdk -lrt

#RCCHK_LIBS = -lexpat -lintl -lcrypt
RCCHK_LIBS = -lexpat -lmcrypt 

#compile option
CFLAGS	=	-Wall -O -g3 -Wall -Wimplicit -Wreturn-type -Wunused -Wuninitialized
#           -Wparentheses -Wshadow -Wpointer-arith -Woverloaded-virtual

#link  option
LFLAGS	= 
#LFLAGS	=

#Definition flag
#DFLAGS	=	-D__DEBUG__
DFLAGS	=	-D__SETLOG__ -D_REENTRANT
#DFLAGS	=	-D__SETLOG__ -D_REENTRANT -D__DEBUG__
#DFLAGS =	-D__RELEASE__
#DFLAGS	=	-D_REENTRANT

# Source List
SRC	=	errfunc.c util.c wrapunix.c wrapsock.c wrappthread.c vrcd_proc.c report_proc.c check_rtime_serv.c tcp_listen.c udp_server.c sock_ntop.c signal.c main.c view_shm.c ReadConfig.c

RCCHK_SRC = rccheck.cpp util_rccheck.c

# Object List
OBJ	=	errfunc.o util.o wrapunix.o wrapsock.o wrappthread.o vrcd_proc.o report_proc.o check_rtime_serv.o tcp_listen.o udp_server.o sock_ntop.o signal.o main.o ReadConfig.o
RCMNG_OBJ = errfunc.o wrapunix.o wrapsock.o util.o
VSHM_OBJ = view_shm.o errfunc.o wrapunix.o
RCCHECK_OBJ = rccheck.o util_rccheck.o

all	:	Makefile ${OBJ} rccheck view_shm
	${CC} ${CFLAGS} ${OBJ} -o ${PRGNAME} ${LIBDIR} ${LIBS} ${LFLAGS}

view_shm : ${VSHM_OBJ}
	${CC} ${CFLAGS} ${VSHM_OBJ} -o ${VSHMNAME} -lrt

rccheck : ${RCCHECK_OBJ}
	${CXX} ${CFLAGS} ${RCCHECK_OBJ} -o ${RCCHKNAME} ${LIBDIR} ${RCCHK_LIBS} ${LIBS}

.c.o	:	${SRC}
	${CC} $(CFLAGS) -c -o $@ $< ${INCLUDEDIR} ${DFLAGS}

.cpp.o	:	${RCCHK_SRC}
	${CXX} $(CFLAGS) -c -o $@ $< ${RCCHK_INCLUDEDIR} ${DFLAGS}

install	:
	cp -f $(PRGNAME) $(INSTALLDIR)
	cp -f $(RCCHKNAME) $(INSTALLDIR)
	cp -f $(VSHMNAME) $(INSTALLDIR)

clean	:
	rm -f $(OBJ) $(RCCHECK_OBJ) ${HOSTSTATOBJ} ${VSHM_OBJ} $(PRGNAME) ${RCCHKNAME} ${VSHMNAME} *.log *.pid *.core
