[Reformatted--please break lines at a reasonable length,
especially when quoting source code. Thanks.]
On 2008-07-08 05:20Z, x z wrote:
> So, how to write a Makefile that can accomodate the inclusion
> of certain flags when compiling certain files?
> Of course, one can always set up separate rules for these
> special files, and a general rule (without those flags) for the
> rest. But that looks clumsy:
> SRCS = file1.c file2.c file3.c .....
> OBJ = ${SRCS:.c=.o}
> $(OBJ): %.o: %.c
> $(CC) -c $< -o $@
> special1.o: special1.c
> $(CC) -D_POSIX_PTHREAD_SEMANTICS -c $< -o $@
> special2.o: special2.c
> $(CC) -D_POSIX_C_SOURCE -c $< -o $@
special1.o: extra_cpp_flags := -D_POSIX_PTHREAD_SEMANTICS
special2.o: extra_cpp_flags := -D_POSIX_C_SOURCE
Then pass $(extra_cpp_flags) to the generic command, e.g.:
$(CC) $(extra_cpp_flags) -c $< -o $@
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make