Bug 3041 - Makefile.in incorrect for building outside of source directory
Summary: Makefile.in incorrect for building outside of source directory
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.20
Hardware: All Solaris
: P3 normal
Target Milestone: none
Assignee: Tim Potter
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-25 05:24 UTC by Eric Boehm
Modified: 2007-05-14 23:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Boehm 2005-08-25 05:24:24 UTC
Makefile.in does not generate the correct rules for dynconfig and lib/version
when building outside of the source directory

Current contents are:
dynconfig.o: dynconfig.c Makefile
        @echo Compiling $*.c
        @$(CC) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c dynconfig.c -o $@ 

dynconfig.@PICSUFFIX@: dynconfig.c Makefile
        @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
          dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
        @echo Compiling $*.c with @PICFLAGS@
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c dynconfig.c 
-o $@
@BROKEN_CC@     -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.@PICSUFFIX@$$%.o%'` $@

lib/version.o: lib/version.c include/version.h
        @echo Compiling $*.c
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c lib/versio
n.c -o $@ 

lib/version.@PICSUFFIX@: lib/version.c include/version.h
        @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
          dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
        @echo Compiling $*.c with @PICFLAGS@
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c lib/version.
c -o $@

The compile command should use the macro $< instead of the hard-coded source
file. This changed sometime after 3.0.14a, it was correct in 3.0.14a.

Potential corrected version:

dynconfig.o: dynconfig.c Makefile
        @echo Compiling $*.c
        @$(CC) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $< -o $@ 

dynconfig.@PICSUFFIX@: dynconfig.c Makefile
        @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
          dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
        @echo Compiling $*.c with @PICFLAGS@
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $< -o $@
@BROKEN_CC@     -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.@PICSUFFIX@$$%.o%'` $@

lib/version.o: lib/version.c include/version.h
        @echo Compiling $*.c
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $< -o $@ 

lib/version.@PICSUFFIX@: lib/version.c include/version.h
        @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
          dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
        @echo Compiling $*.c with @PICFLAGS@
        @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $< -o $@
Comment 1 Gerald (Jerry) Carter (dead mail address) 2005-08-25 07:33:03 UTC
Tim,  This was your change in r6407.  See bug 2623.
What should we do now?
Comment 2 Gerald (Jerry) Carter (dead mail address) 2005-09-27 13:43:49 UTC
Tim?
Comment 3 David Hull 2005-10-03 17:45:45 UTC
I also encountered this problem, and independently made the same change to work
around it.

A better fix (more likely to be compatible with more versions of make) might be
to add $(srcdir), for example, "$(srcdir)/dynconfig.c", instead.
Comment 4 James Peach 2007-05-14 23:56:08 UTC
Building with $srcdir != $builddir works. Not sure when this was fixed.