[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: When some files need special compilation flags, ...
From: |
Greg Chicares |
Subject: |
Re: When some files need special compilation flags, ... |
Date: |
Tue, 08 Jul 2008 13:31:44 +0000 |
User-agent: |
Thunderbird 2.0.0.14 (Windows/20080421) |
[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 $@