# -*- Makefile -*-
#
# @file  Makefile.GlobalNavigation
# @brief RTComponent makefile for "GlobalNavigation component"
# @date  $Date$
#
# This file is generated by rtc-template with the following argments.
#
#  /usr/bin/rtc-template -bcxx --module-name=GlobalNavigation  \
#  --module-desc=GlobalNavigation --module-version=0.0  \
#  --module-vendor=fuRo at Chiba Institute of Technology  \
#  --module-category=Generic --module-comp-type=DataFlowComponent  \
#  --module-act-type=SPORADIC --module-max-inst=1  \
#  --consumer=MapService:MapService:MapService  \
#  --consumer-idl=RgisOperator_simple.idl  \
#  --consumer=RouteService:routeService:RouteService  \
#  --consumer-idl=RgisOperator_simple.idl --outport=xmlOut:TimedString  \
#  --inport=xmlIn:TimedString  
#
#
# $Id$
#
#### Further warning flags are added by sagami ####
#  N. B. 
#  -Wall is redundunt because `rtm-config --cflags` generate it.
#
#  Combining -Wunused with -Wextra may be too pedantic, for it
#  complains about unused function auguments.
#
WARNS = -Wall -Wparentheses -Wdisabled-optimization	\
        -Wswitch-enum -Wswitch-default -Wunused		\
        -Wformat=2 -Wstrict-aliasing=2 -Wcast-align
#WARNS += -Wextra

# WARNS+=  -Winline


DESTDIR = ../bin
RTM_COMMON = ../../common
DOC_DIR=../doc/

TARGET = GlobalNavigationComp

CXXFLAGS =  $(WARNS) `rtm-config --cflags` -I. -I$(RTM_COMMON)/include
LDFLAGS  = `rtm-config --libs` 
LDFLAGS += -lboost_serialization-mt -lboost_wserialization-mt 
LDFLAGS += -L$(RTM_COMMON)/lib
LDFLAGS += -lxerces-c -lXmlSerDes -lBaseRTC 
SHFLAGS  = -shared 

IDLC     = `rtm-config --idlc`
IDLFLAGS = `rtm-config --idlflags` -I`rtm-config --prefix`/include/rtm/idl
WRAPPER  = rtm-skelwrapper
WRAPPER_FLAGS = --include-dir="" --skel-suffix=Skel --stub-suffix=Stub

SKEL_OBJ =  
STUB_OBJ = RgisOperator_simpleStub.o  
IMPL_OBJ =  
OBJS     = GlobalNavigationRTC.o gnav.o service_if.o \
           debug_utils.o config_data.o merge_grid.o \
           $(SKEL_OBJ) $(STUB_OBJ) $(IMPL_OBJ)

MKDEPEND= $(CXX) $(CXXFLAGS) -MM -MG  `rtm-config --cflags` 
DEPENDENCY = .depend

SRCS=$(patsubst %.o,%.cpp,$(OBJS))
HDRS =   $(shell ls ./*.h) $(shell ls $(RTM_COMMON)/include/*.h)

OTHERDPES = $(shell ls $(RTM_COMMON)/src/serdes/*.cpp)	\
	    $(shell ls $(RTM_COMMON)/src/baseRTC/*.cpp)


.SUFFIXES : .so
.PHONY : doc install depend 


first: depend all

all: $(TARGET)
	echo make all
	$(MAKE)  $(TARGET)

depend: 
	echo make depend
	$(MAKE) $(DEPENDENCY)

$(DEPENDENCY): $(SRCS) $(HDRS) $(OTHERDEPS)
	$(MKDEPEND) $(CXXLAGS) $(SRCS)  >$(DEPENDENCY)


.cpp.o:
	rm -f $@
	$(CXX) $(CXXFLAGS) -c -o $@ $<

.o.so:
	rm -f $@
	$(CXX) $(SHFLAGS) -o $@ $(OBJS) $(LDFLAGS)

$(TARGET): GlobalNavigationComp.o $(OBJS)
	$(CXX) -o $@ $(OBJS) GlobalNavigationComp.o $(LDFLAGS) 


ifneq ($(wildcard .depend),)
include $(DEPENDENCY)
endif


clean: clean_objs #clean_skelstub # by sagami
	rm -f *~
	rm -f $(DEPENDENCY)

clean_objs:
	rm -f $(OBJS) GlobalNavigationComp.o GlobalNavigation.so $(TARGET)

clean_skelstub:
#	rm -f *Skel.h *Skel.cpp
#	rm -f *Stub.h *Stub.cpp



#RgisOperator_simpleStub.cpp : RgisOperator_simple.idl 
#	$(IDLC) $(IDLFLAGS) RgisOperator_simple.idl 
#	$(WRAPPER) $(WRAPPER_FLAGS) --idl-file=RgisOperator_simple.idl 
#RgisOperator_simpleStub.h : RgisOperator_simple.idl 
#	$(IDLC) $(IDLFLAGS) RgisOperator_simple.idl 
#	$(WRAPPER) $(WRAPPER_FLAGS) --idl-file=RgisOperator_simple.idl 

#GlobalNavigation.so: $(OBJS)
GlobalNavigationRTC.o: GlobalNavigationRTC.h   
GlobalNavigationComp.o: GlobalNavigationComp.cpp GlobalNavigationRTC.cpp GlobalNavigationRTC.h  


# end of Makefile

doc: 
	env DOC_DIR=$(DOC_DIR) RTM_COMMON=$(RTM_COMMON) doxygen Doxyfile

install: all
	install -m 0755 $(TARGET) $(DESTDIR)/
	install -m 0644 rtc.conf $(DESTDIR)/
	install -m 0644 GlobalNavigation.xml $(DESTDIR)/