Build multiple objects from one source file

2019-08-21 17:33发布

I have a set of C source files that need to be built in a shared lib and in an executable, with different CFLAGS:

%.o: %.c
    $(CC) -c -o $@ $^ $(BIN_CFLAGS)

lib-%.o: %.c
    $(CC) -c -o $@ $^ $(LIB_CFLAGS)

Make says:

No rule to make target 'lib-x.o', needed by 'liby.so'. Stop.

Is there no alternative to writing the rules for lib-x.o and the other object files one by one ?

0条回答
登录 后发表回答