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 dependencies 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
alltarget should be a list of object files, instead of the list of idl files. Something like this:(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:
)