[omniORB] project directory structure and Makefiles
Carl Thompson
cet@carlthompson.net
Fri, 19 Oct 2001 22:12:42 -0700
This is a multi-part message in MIME format.
--------------020507060708090305010208
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I have attached a basic example makefile which shows how I normally
handle building CORBA projects. It builds two targets and handles
dependencies reasonably (always will rebuild files when they need to be
rebuilt). It also shows how you can organize things in multiple
directories without having to write multiple makefiles; ".IDL" files are
in the "Interface" subdirectory, generated source files go in the
"Corba" subdirectory and object files go in the "Obj" subdirectory. It
scales up reasonably; I use a makefile based on this for a project that
compiles on 6 platforms and 2 different ORBS with several targets and
60+ source files.
Feel free to use this if it helps.
Carl Thompson
Ian wrote:
> Hello all,
>
> I am new to CORBA and to this list. I want to write a simpke
> application to learn about CORBA, but I want to do it in such a way
> that I can scale up the "method" to larger projects. The problem I am
> trying to solve is what is the best way to organize a project
> directory to build a project with omniORB. It will have a client and a
> server application. Also, I'm at a loss as in how to write the
> Makefiles in such a way that the stubs are properly scanned for
> dependencies with the implementation code. Could someone with a little
> experience on omniORB projects enlighten me? I'd be very greatful. I
> looked through comp.object.corba and searched through the archives,
> but could not really find anything that could help me out.
>
> Another thing that I would like to mention is, while I compiled
> omniORB at home on my SGI Indy with IRIX 6.2 (yes I know it's old, but
> I love that box ;). I came accross an error which I managed to solve,
> but ehm... not so elegantly. I can't find the line back... maybe it
> was in a stub? Anyway, the line involved a call to
> pthread_mutexattr_settype if I remember correctly, setting the mutex
> type to PTHREAD_MUTEX_RECURSIVE. I am no expert on pthreads either,
> and did a google for it. Turns out that to set this type is usually
> not necessary. So I commented out the line. Everything seems to work,
> any comments on this? (The problem was that IRIX 6.2 doesn't have the
> function).
>
> Thanks,
>
> Ian.
>
>
--------------020507060708090305010208
Content-Type: text/plain;
name="Makefile-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Makefile-1"
# Carl Thompson
# Platform, compiler & ORB dependent stuff. Normally you would put this
# section in a separate file and include it based on the platform. For
# example, this came from my file Linux-2.4_gcc_omniorb.mk
CC=gcc
CXX=gcc
LD=gcc
OPT=-g
WARN=-Wall
CFLAGS=$(OPT) $(WARN)
CXXFLAGS=$(OPT) $(WARN)
OBJSUFFIX=o
IDL=/opt/omniORB/bin/omniidl
IDLFLAGS=-bcxx -Wbh=".h" -Wbs=".cc" -Wbuse_quotes
ORBFLAGS=-D_REENTRANT -D__x86__ -D__linux__ -D__OSVERSION__=2 -D__OMNIORB4__ \
-I/opt/omniORB/include -I/opt/omniORB/include/omniORB4
ORBLIBS=-L/opt/omniORB/lib -lomniORB4 -lomniAsyncInvoker -lomnithread \
-lomnisslTP4 -lpthread -lssl -lcrypto
# Targets
TARGET1=test1
TARGET2=test2
TARGETS=$(TARGET1) $(TARGET2)
# the CORBA inteface files used by the targets (without extension).
TARGET1_CORBA=foo bar baz
TARGET2_CORBA=spork foon weasel
# files for the targets
TARGET1_SRC_C=target1.cc foo_impl.cc bar_impl.cc baz_impl.cc
TARGET1_SRC_H=target1.h
TARGET2_SRC_C=target2.cc spork_impl.cc foon_impl.cc weasel_impl.cc
TARGET2_SRC_H=target2.h
##############################################################################
# You should not have to modify anything below this
# (except to add more targets).
##############################################################################
# Where the files are / go
OBJDIR=Obj
CORBADIR=Corba
IDLDIR=Interface
# files for the CORBA interfaces
TARGET1_CORBA_IDL=$(patsubst %,$(IDLDIR)/%.idl,$(TARGET1_CORBA))
TARGET1_CORBA_SRC_C=$(patsubst %,$(CORBADIR)/%.cc,$(TARGET1_CORBA))
TARGET1_CORBA_SRC_H=$(patsubst %,$(CORBADIR)/%.h,$(TARGET1_CORBA))
TARGET1_CORBA_SRC=$(TARGET1_CORBA_SRC_C) $(TARGET1_CORBA_SRC_H)
TARGET1_CORBA_OBJ=$(patsubst %,$(OBJDIR)/%.$(OBJSUFFIX),$(TARGET1_CORBA))
TARGET2_CORBA_IDL=$(patsubst %,$(IDLDIR)/%.idl,$(TARGET2_CORBA))
TARGET2_CORBA_SRC_C=$(patsubst %,$(CORBADIR)/%.cc,$(TARGET2_CORBA))
TARGET2_CORBA_SRC_H=$(patsubst %,$(CORBADIR)/%.h,$(TARGET2_CORBA))
TARGET2_CORBA_SRC=$(TARGET2_CORBA_SRC_C) $(TARGET2_CORBA_SRC_H)
TARGET2_CORBA_OBJ=$(patsubst %,$(OBJDIR)/%.$(OBJSUFFIX),$(TARGET2_CORBA))
TARGET1_SRC=$(TARGET1_SRC_C) $(TARGET1_SRC_H)
TARGET1_OBJ=$(patsubst %.cc,$(OBJDIR)/%.$(OBJSUFFIX),$(TARGET1_SRC_C))
TARGET2_SRC=$(TARGET2_SRC_C) $(TARGET2_SRC_H)
TARGET2_OBJ=$(patsubst %.cc,$(OBJDIR)/%.$(OBJSUFFIX),$(TARGET2_SRC_C))
# extensions that this makefile knows about
.SUFFIXES: .c .cc .h .idl .$(OBJSUFFIX)
# the default target
all: $(TARGETS)
# rules to build generated files
$(OBJDIR)/%.$(OBJSUFFIX): %.cc
$(CXX) -c $(CXXFLAGS) $(ORBFLAGS) $< -o $@
$(OBJDIR)/%.$(OBJSUFFIX): $(CORBADIR)/%.cc
$(CXX) -c $(CXXFLAGS) $(ORBFLAGS) $< -o $@
$(CORBADIR)/%.cc $(CORBADIR)/%.h: $(IDLDIR)/%.idl
cd $(IDLDIR) && $(IDL) $(IDLFLAGS) $(<F)
mv $(IDLDIR)/$*.cc $(IDLDIR)/$*.h $(CORBADIR)/
%.cc %.h: %.idl
$(IDL) $(IDLFLAGS) $<
# The following dependencies assume that the IDL files all include each
# other. If they don't then you can probably just comment these lines
# out. Note that make automatically handles the specific source file to
# generated file dependency (foo.o depends on foo.cc) so we don't need
# to put that here.
# all TARGET1 CORBA object files dependant on all TARGET1 CORBA header files
$(TARGET1_CORBA_OBJ): $(TARGET1_CORBA_SRC_H)
# all TARGET1 CORBA source files dependant on all TARGET1 CORBA IDL files
$(TARGET1_CORBA_SRC): $(TARGET1_CORBA_IDL)
# all TARGET2 CORBA object files dependant on all TARGET2 CORBA header files
$(TARGET1_CORBA_OBJ): $(TARGET1_CORBA_SRC_H)
# all TARGET2 CORBA source files dependant on all TARGET2 CORBA IDL files
$(TARGET1_CORBA_SRC): $(TARGET1_CORBA_IDL)
# The targets and their dependencies are below
# all TARGET1 object files dependant on all TARGET1 and CORBA header files
$(TARGET1_OBJ): $(TARGET1_SRC_H) $(TARGET1_CORBA_SRC_H)
# how to build TARGET1
$(TARGET1): $(TARGET1_OBJ) $(TARGET1_CORBA_OBJ)
$(LD) -o $(TARGET1) $(TARGET1_OBJ) $(TARGET1_CORBA_OBJ) $(ORBLIBS)
# all TARGET2 object files dependant on all TARGET2 and CORBA header files
$(TARGET2_OBJ): $(TARGET2_SRC_H) $(TARGET2_CORBA_SRC_H)
# how to build TARGET2
$(TARGET2): $(TARGET2_OBJ) $(CORBA_OBJ)
$(LD) -o $(TARGET2) $(TARGET2_OBJ) $(TARGET2_CORBA_OBJ) $(ORBLIBS)
.PHONY: clean
clean:
rm -f $(OBJDIR)/*.o $(TARGETS) $(TARGET1_CORBA_SRC) $(TARGET2_CORBA_SRC)
--------------020507060708090305010208--