On 09/02/2013 07:59 PM, [email protected] wrote:
> Hi!
Hi!
>> If we create/modify/touch file syscalls/utils/compat_16.h and execute
>> 'make' in any of syscalls directories which includes compat_16.mk, then
>> nothing will happen, because this approach:
>>
>>     %.c: $(COMPAT_16_H)
>>
>> is not working.
>>
>> Fixed this.
>>
>> Signed-off-by: Stanislav Kholmanskikh <[email protected]>
>> ---
>>   testcases/kernel/syscalls/utils/compat_16.mk |    6 ++++--
>>   1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/utils/compat_16.mk 
>> b/testcases/kernel/syscalls/utils/compat_16.mk
>> index 371bd43..36ece1b 100644
>> --- a/testcases/kernel/syscalls/utils/compat_16.mk
>> +++ b/testcases/kernel/syscalls/utils/compat_16.mk
>> @@ -55,6 +55,7 @@ CPPFLAGS           += -I$(abs_srcdir) 
>> -I$(abs_srcdir)/../utils
>>   SRCS                       ?= $(wildcard $(abs_srcdir)/*.c)
>>   
>>   MAKE_TARGETS               := $(notdir $(patsubst %.c,%,$(SRCS)))
>> +MAKE_TARGETS_OBJS_WO_COMPAT_16      := $(addsuffix .o,$(MAKE_TARGETS))
>>   
>>   ifneq ($(TST_COMPAT_16_SYSCALL),no)
>>   MAKE_TARGETS               += $(addsuffix _16,$(MAKE_TARGETS))
>> @@ -69,7 +70,8 @@ COMPAT_16_H                := 
>> $(abs_srcdir)/../utils/compat_16.h
>>   ifneq ($(wildcard $(COMPAT_16_H)),)
>>   HAS_COMPAT_16              := 1
>>   
>> -%.c: $(COMPAT_16_H)
>> +$(MAKE_TARGETS_OBJS_WO_COMPAT_16): $(COMPAT_16_H)
>> +.INTERMEDIATE: $(MAKE_TARGETS_OBJS_WO_COMPAT_16)
>>   
>>   else
>>   HAS_COMPAT_16              := 0
>> @@ -78,5 +80,5 @@ endif
>>   %_16: CPPFLAGS += -D$(DEF_16)=1
>>   # XXX (garrcoop): End section of code in question..
>>   
>> -%_16.o: %.c
>> +%_16.o: %.c $(COMPAT_16_H)
>>      $(COMPILE.c) $(OUTPUT_OPTION) $<
> Perhaps we can do this more cleanly by making the _16 binaries depend on
> the compat_16.h as with:
>
> --- a/testcases/kernel/syscalls/utils/compat_16.mk
> +++ b/testcases/kernel/syscalls/utils/compat_16.mk
> @@ -57,7 +57,8 @@ SRCS                        ?= $(wildcard $(abs_srcdir)/*.c)
>   MAKE_TARGETS                := $(notdir $(patsubst %.c,%,$(SRCS)))
>   
>   ifneq ($(TST_COMPAT_16_SYSCALL),no)
> -MAKE_TARGETS         += $(addsuffix _16,$(MAKE_TARGETS))
> +MAKE_TARGETS_16       = $(addsuffix _16,$(MAKE_TARGETS))
> +MAKE_TARGETS         += $(MAKE_TARGETS_16)
>   endif
>   
>   # XXX (garrcoop): This code should be put in question as it cannot be 
> applied
> @@ -69,8 +70,7 @@ COMPAT_16_H         := $(abs_srcdir)/../utils/compat_16.h
>   ifneq ($(wildcard $(COMPAT_16_H)),)
>   HAS_COMPAT_16               := 1
>   
> -%.c: $(COMPAT_16_H)
> -
> +$(MAKE_TARGETS_16): $(COMPAT_16_H)
>   else
>   HAS_COMPAT_16               := 0
>   endif
>
Not only _16 binaries should depend on compat_16.h, but binaries w/o _16 
too.

So in that case we need to use:

+$(MAKE_TARGETS): $(COMPAT_16_H)

instead of:

+$(MAKE_TARGETS_16): $(COMPAT_16_H)

And definition of MAKE_TARGETS_16 is not needed at all.

So the final variant is as follows:

--- a/testcases/kernel/syscalls/utils/compat_16.mk
+++ b/testcases/kernel/syscalls/utils/compat_16.mk
@@ -69,8 +69,7 @@ COMPAT_16_H           := 
$(abs_srcdir)/../utils/compat_16.h
  ifneq ($(wildcard $(COMPAT_16_H)),)
  HAS_COMPAT_16          := 1

-%.c: $(COMPAT_16_H)
-
+$(MAKE_TARGETS): $(COMPAT_16_H)
+
  else
  HAS_COMPAT_16          := 0
  endif

But I think that my approach is easier to understand: we explicitly 
define object files targets, make them depend on compat_16.h and also 
mark them as intermediate targets (so make will remove them after linking).

And if we make binaries to depend on compat_16.h gcc treats this header 
file not as a header:

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall 
-I/home/stas/ltp/testcases/kernel/include 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils 
-I../../../../include -I../../../../include   -L../../../../lib 
setgroups01.c 
/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils/compat_16.h 
-lltp -o setgroups01

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall 
-I/home/stas/ltp/testcases/kernel/include 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils 
-I../../../../include -I../../../../include 
-DTST_USE_COMPAT16_SYSCALL=1  -c -o setgroups01_16.o setgroups01.c
gcc   -L../../../../lib  setgroups01_16.o 
/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils/compat_16.h 
-lltp -o setgroups01_16

It doesn't look nice :)

On the other side if we make object files to depend on compat_16.h gcc 
treats this header file as a header:

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall 
-I/home/stas/ltp/testcases/kernel/include 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils 
-I../../../../include -I../../../../include  -c -o setgroups01.o 
setgroups01.c
gcc   -L../../../../lib  setgroups01.o   -lltp -o setgroups01

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall 
-I/home/stas/ltp/testcases/kernel/include 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups 
-I/home/stas/ltp/testcases/kernel/syscalls/setgroups/../utils 
-I../../../../include -I../../../../include 
-DTST_USE_COMPAT16_SYSCALL=1  -c -o setgroups01_16.o setgroups01.c
gcc   -L../../../../lib  setgroups01_16.o   -lltp -o setgroups01_16



------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to