Skip to content

Instantly share code, notes, and snippets.

@xrl
Created April 25, 2011 20:11
Show Gist options
  • Save xrl/941114 to your computer and use it in GitHub Desktop.
Save xrl/941114 to your computer and use it in GitHub Desktop.
Makefile when dealing with file -> many files generators
IDLGEN=rtiddsgen
IDLGEN_FLAGS=-d generated/ -language C -replace -I idl/
IDL=$(wildcard idl/*.idl)
CFLAGS=-std=c99 -Wall -Werror -DRTI_LINUX -DRTI_UNIX -I/usr/local/include/ndds
LDFLAGS=-L/usr/local/lib -lnddscored -lnddscd -lrt -ldl
SRCS=$(wildcard *.c)
IDL_SRCS=$(patsubst idl/%.idl,generated/%.c,${IDL})
IDL_EXTRA_SRCS=$(wildcard generated/*Support.c) $(wildcard generated/*Plugin.c)
IDL_OBJS=$(patsubst %.c,%.o,${IDL_SRCS}) $(patsubst %.c,%.o,${IDL_EXTRA_SRCS})
OBJS=logger.o
all: logger
$(IDL_SRCS):$(IDL)
$(IDLGEN) $(IDLGEN_FLAGS) $(patsubst generated/%.c,idl/%.idl,$@)
$(IDL_OBJS):$(IDL_SRCS)
$(CC) $(CFLAGS) -c -o $@ $(patsubst %.o,%.c,$@)
.c:.o
$(CC) $(CFLAGS) -c $<
logger: $(IDL_OBJS) $(OBJS)
$(CC) $(OBJS) $(IDL_OBJS) -o logger $(LDFLAGS)
clean:
rm -f *.o logger
clean-all: clean
rm -f generated/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment