Question

I have a makefile that I am using to generate artifacts using a third party IDL compiler (rtiddsgen). This takes in idl files and spits out C/Ada files relating to them. The C files are then compiled and put into a library (idl_dds_types.a)

I have the IDL files listed in the IDL_TYPES variable. Each IDL_TYPES file will generate (through rtiddsgen) files of the following form (For example with alerts.idl):

alerts.c
alerts.h
alerts_idl.ads
alerts_idl.adb

So, what I want to happen is when alerts.idl's timestamp is newer than the alerts.c (or the obj.Linux-i686/alerts.o) file, then the alerts.c file is regenerated. This doesn't seem to be happening. Any ideas what I need to do to make this happen? I've tested by "touch"-ing the idl file and then re-running make.

Here is the makefile:

DDS_OUT_DIR = $(MY_HOME)/DDS/DDS_Types/src

IDL_DIR=$(MY_HOME)/DDS/DDS_Types/IDL
IDL_TYPES=common.idl alerts.idl summary.idl
GENERATED_SOURCES =  $(IDL_TYPES:%.idl=%.c)
GENERATED_HEADERS =  $(IDL_TYPES:%.idl=%.h)

LIBNAME  = idl_dds_types

OBJS_DIR       = obj.$(CPUTYPE)

GENERATED_OBJS = $(GENERATED_SOURCES:%.c=$(OBJS_DIR)/%.o)

LIBDIR   = $(DDS_OUT_DIR)/../../lib.$(CPUTYPE)
BINDIR   = $(DDS_OUT_DIR)/../../../../bin.$(CPUTYPE)
CC       = $(C_COMPILER)
CXX      = $(CPP_COMPILER)
OS       = $(shell uname)
DDSCOMMON = $(DDS_OUT_DIR)/../../Common/src

CFLAGS   = -m32 -g -DRTI_UNIX -DRTI_32BIT
CXXFLAGS = -m32 -g
LDFLAGS  = -m32 -static-libgcc
SYSLIBS  = -ldl -lnsl -lpthread -lm -lc


DEFINES_ARCH_SPECIFIC = -DRTI_UNIX

DEFINES = $(DEFINES_ARCH_SPECIFIC) $(cxx_DEFINES_ARCH_SPECIFIC)

INCLUDES  = -I. -I$(NDDSHOME)/include -I$(NDDSHOME)/include/ndds
INCLUDES += -I$(DDSCOMMON)

LIBS = -L$(NDDSLIBDIR) -L$(LIBDIR) -lrt \
      -lnddscppz -lnddscz -lnddscorez $(SYSLIBS) $(OS_SPECIFIC_LIBS)

COMMONLIBSRC  = $(DDSCOMMON)/dds_common.cxx
COMMONLIBOBJS = $(DDSCOMMON)/obj.$(CPUTYPE)/%.o

$(shell mkdir -p $(OBJS_DIR) $(DDSCOMMON)/obj.$(CPUTYPE) $(DDS_CPP_DIR))

default:        $(GENERATED_OBJS) $(LIBDIR)/lib$(LIBNAME).a

$(OBJS_DIR)/%.o : %.idl $(DDSCOMMON)/dds_common.h
       $(C_COMPILER)  -o $(OBJS_DIR)/$(*F).o $(DEFINES) $(INCLUDES) $(CFLAGS) -c $(*F).c; \
       $(C_COMPILER)  -o $(OBJS_DIR)/$(*F)Support.o $(DEFINES) $(INCLUDES) $(CFLAGS) -c $(*F)Support.c; \
       $(C_COMPILER)  -o $(OBJS_DIR)/$(*F)Plugin.o $(DEFINES) $(INCLUDES) $(CFLAGS) -c $(*F)Plugin.c; \

$(LIBDIR)/lib$(LIBNAME).a: $(GENERATED_OBJS) $(CPP_OBJS)
       @echo "Adding these to lib: " $(OBJS_DIR)/*.o; \
       mkdir -p $(LIBDIR)
       rm -f $(LIBDIR)/lib$(LIBNAME).a
       $(AR) -cr $(LIBDIR)/lib$(LIBNAME).a $(OBJS_DIR)/*.o
       ranlib $(LIBDIR)/lib$(LIBNAME).a

%.idl:
       @echo "Generating C and Ada from $@ ..."; \
       $(NDDSHOME)/scripts/rtiddsgen ${IDL_DIR}/$@ -d $(DDS_OUT_DIR) -I ${IDL_DIR} -replace -language Ada; # -example i86Linux2.6gcc4.1.2;



clean:
       rm -rf $(LIBDIR)/lib$(LIBNAME).a; \
       rm -rf $(DDS_OUT_DIR)/*.h; \
   rm -rf $(DDS_OUT_DIR)/*.c; \
       rm -rf $(DDS_OUT_DIR)/*.gpr; \
       rm -rf $(DDS_OUT_DIR)/samples; \
       rm -rf $(DDS_OUT_DIR)/*.xml; \
       rm -rf $(DDS_OUT_DIR)/makefile_*; \
       rm -rf $(DDS_OUT_DIR)/bin; \
       rm -rf $(DDS_OUT_DIR)/summary_idl*; \
       rm -rf $(DDS_OUT_DIR)/common_idl*; \
       rm -rf $(DDS_OUT_DIR)/alerts_idl*; \
       rm -rf $(DDS_OUT_DIR)/$(OBJS_DIR);
Was it helpful?

Solution

A rule like your %.idl: rule tells make how to generate .idl files, not how to generate things from .idl files. You want to change this to %.c: %.idl -- how to generate .c files from .idl files.

That will do most of what you want -- the only problem is if you ever want to be able to generate .ads/.adb files WITHOUT generating .c files or rebuilding the library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top