开发者

Makefile for compiling .idls

I'm writing my first Makefile to compile some CORBA .idl definitions for use as part of a larger system. I use omniORB's omniidl program which takes file.idl and creates file.hh and a fileSK.cc. Each .idl has no d开发者_如何学运维ependencies and is created with the command omniidl -bcxx file.idl.

From reading the GNU Make tutorial it seems like Pattern Rules will do exactly what I need. The target for .idl conversion is inspired by the bison example in Section 10.5.2 of the GNU manual. My main question is how do I actually trigger these rules? I've tried putting in an all target and introducing the dependency on the .idls but to no avail.

    OMNIIDL := omniidl 
    DEPENDFLAGS := -g 
    CXX := g++
    CXXFLAGS := $(DEPENDFLAGS) -Wall -Werror -ansi

    %.o : %.cc
        $(CXX) $(CXXFLAGS) -c $< -o $@

    %.hh %SK.cc : %.idl
        $(OMNIIDL) -bcxx $<

    all : $(wildcard *.idl)

In a related note, where should auto-generated code normally be placed? I intend to copy the compiled .o files into my project's /lib or /include directory but should the .hh and .cc files be left in the src folder or placed elsewhere to ease the cleaning process?


The dependencies of your all target should be a list of object files, instead of the list of idl files. Something like this:

all: $(patsubst %.idl, %SK.o, $(wildcard *.idl))

(For clarity, you could also introduce a variable to hold the list of idl files, and then use a substitution reference to get the list of object files:

IDLS := $(wildcard *.idl)

all: $(IDLS:%.idl=%SK.o)

)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜