########################################################################## # I tried to create this makefile so that it can be used as a # template for projects that have idl, a client and/or a server. # # It is assumed that you'll create a directory to build in and invoke this # makefile from the build directory. # # Note that the dependencies are not complete, so if in doubt, # "make realclean" and "make". ########################################################################## ########################################################################## # You must define these for your project - this is the only section # of the makefile that you'll probably need to change. ########################################################################## PROJECT_TOP= $(CIPRES_LIB_ROOT)/examples/LargeSequence SRC_DIR = $(PROJECT_TOP)/C++ IDL_DIR = $(PROJECT_TOP)/idl IDL_FILES = ls GEN_DIR = ./generated IDL_LIBNAME = libLargeSequence EXTRA_INC= -I$(CIPRES_LIB_ROOT)/commlib/C++ EXTRA_LIB= -lCipres EXTRA_LIB_DIR= -L$(CIPRES_LIB_ROOT)/commlib # T1_OBJ and other T1_* variables are derived from these below T1 = client T1_SRC = client.cpp # T2_OBJ and other T2_* variables are derived from these below T2 = server T2_SRC = server.cpp \ ls_i.cpp ########################################################################## # You probably won't need to change these, though you may want to # remove libs or includes you know you don't need. ########################################################################## # Passed to the idl compiler IDLINCDIRS += -I$(TAO_ROOT)/tao \ -I$(TAO_ROOT)/orbsvcs \ -I$(TAO_ROOT)/orbsvcs/orbsvcs \ -I$(IDL_DIR) # Passed to the cpp compiler BASIC_INCDIRS = -I$(ACE_ROOT) \ -I$(TAO_ROOT) \ -I$(TAO_ROOT)/orbsvcs \ -I$(TAO_ROOT)/orbsvcs/orbsvcs \ -I$(GEN_DIR) BASIC_LIBS = -lcc_dynamic -lstdc++ -lSystem \ -lACE\ -lTAO\ -lTAO_PortableServer\ -lTAO_ObjRefTemplate\ -lTAO_ValueType\ -lTAO_IORInterceptor \ -lTAO_IORTable \ -lTAO_CosNaming \ -lTAO_Svc_Utils \ -lTAO_messaging \ BASIC_LIB_DIRS = -L$(ACE_ROOT)/ace\ -L$(TAO_ROOT)/tao\ -L$(TAO_ROOT)/orbsvcs/orbsvcs INCDIRS = $(BASIC_INCDIRS) $(EXTRA_INC) LIBS = $(BASIC_LIBS) $(EXTRA_LIB) LIB_DIRS = $(BASIC_LIB_DIRS) $(EXTRA_LIB_DIR) ########################################################################## # These definitions are always the same. ########################################################################## IDL_LIB = $(IDL_LIBNAME).a CC=g++ AR=ar ifeq ($(debug), 1) CFLAGS += -g endif ifeq ($(generate), 1) IDL_FLAGS += -GI endif IDLC = $(TAO_ROOT)/TAO_IDL/tao_idl IDL_FLAGS += $(IDLINCDIRS) IDL_EXT_LIST = C S ## A list of all the idl generated extensions, eg. "C.h C.cpp C.i S.h ..." IDL_EXT = $(foreach ext, $(IDL_EXT_LIST), $(foreach ending, .h .cpp .i, $(ext)$(ending))) ## The names of all the generated files (without path) - add each ext to each .idl filename GEN_FILES = $(foreach file, $(IDL_FILES), $(foreach ext, $(IDL_EXT), $(file)$(ext))) ## Generated .cpp files without paths GEN_CPPS = $(filter %.cpp, $(GEN_FILES)) ## Generated .o files without paths GEN_OBJS = $(GEN_CPPS:.cpp=.o) ## The full pathname of all the .idl files in this project IDL_FILES_FULLPATH =$(addsuffix .idl,$(addprefix $(IDL_DIR)/,$(IDL_FILES))) ## The full pathname of all the generated files in this project GEN_FILES_FULLPATH =$(foreach file, $(GEN_FILES), $(GEN_DIR)/$(file)) T1_OBJS = $(T1_SRC:.cpp=.o) T2_OBJS = $(T2_SRC:.cpp=.o) ########################################################################## # Rules for building application targets - you shouldn't need to change # this. ########################################################################## all: $(IDL_LIB) $(T1) $(T2) $(T1): $(T1_OBJS) $(CC) -o $@ $(CFLAGS) $^ $(IDL_LIB) $(LIB_DIRS) $(LIBS) $(T2): $(T2_OBJS) $(CC) -o $@ $(CFLAGS) $^ $(IDL_LIB) $(LIB_DIRS) $(LIBS) # Note that dependencies on header files are missing. $(T1_OBJS):%.o : $(SRC_DIR)/%.cpp $(CC) -c $(CFLAGS) $(INCDIRS) $< -o $@ $(T2_OBJS):%.o : $(SRC_DIR)/%.cpp $(CC) -c $(CFLAGS) $(INCDIRS) $< -o $@ ########################################################################## # Rules for generating code from idl, compiling it and putting it in a lib. ########################################################################## # The lib depends on the object files in the current directory. # The rule above says each object depends on the corresponding .cpp and .h. $(IDL_LIB) : $(GEN_OBJS) ar rcs $(IDL_LIB) $^ # Need to use a "static pattern rule rather than an implicit rule # because the prerequisite (the generated cpp file doesn't exist) and # implicit rules don't apply when pre-req doesn't exist. # $< is name of prereq, $@ is name of target $(GEN_OBJS):%.o : $(GEN_DIR)/%.cpp $(GEN_DIR)/%.h $(CC) -c $(CFLAGS) $(INCDIRS) $< -o $@ # All the generated files depend on all the .idl files - this isn't exactly right but it'll work. $(GEN_FILES_FULLPATH): $(IDL_FILES_FULLPATH) -mkdir $(GEN_DIR) $(IDLC) $(IDL_FLAGS) -o $(GEN_DIR) $(IDL_FILES_FULLPATH) runidlc: -mkdir $(GEN_DIR) $(IDLC) -o $(GEN_DIR) $(IDL_FLAGS) $(IDL_FILES_FULLPATH) ########################################################################## # Rules for cleaning. ########################################################################## clean: rm -f $(GEN_OBJS) $(T1_OBJS) $(T2_OBJS) realclean: clean rm -rf $(GEN_DIR) rm -rf $(LIB) rm -rf $(T1) rm -rf $(T2)