summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2007-04-02 21:21:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:49:45 -0500
commitf3455f0f446830e5c1fcf8748bd25ee02cd8fcba (patch)
tree62f9caa358b642bb1f0aca7b670781d7c84b3d60
parent4e8fd9f2f4b06dfed9f0c58b476463c34f2c2aa7 (diff)
downloadsamba-f3455f0f446830e5c1fcf8748bd25ee02cd8fcba.tar.gz
samba-f3455f0f446830e5c1fcf8748bd25ee02cd8fcba.tar.bz2
samba-f3455f0f446830e5c1fcf8748bd25ee02cd8fcba.zip
r22047: Move suffix rules into smb_build. Enable $< if we are building with
GNU Make. This lets GNU Make users bild with $srcdir != $builddir. (This used to be commit bb473bf856c0108646c67792d5750c84743ea46e)
-rw-r--r--source4/build/smb_build/makefile.pm52
1 files changed, 52 insertions, 0 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 2df85461c6..2c789b8d62 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -46,6 +46,7 @@ sub new($$$)
$self->output("default: all\n\n");
$self->_prepare_path_vars();
+ $self->_prepare_suffix_rules();
$self->_prepare_compiler_linker();
if (!$self->{automatic_deps}) {
@@ -104,6 +105,57 @@ __EOD__
);
}
+sub _prepare_suffix_rules($)
+{
+ my ($self) = @_;
+ my $first_prereq = '$*.c';
+
+ if ($self->{config}->{GNU_MAKE} eq 'yes') {
+ $first_prereq = '$<';
+ }
+
+ $self->output(<< "__EOD__"
+# Dependencies command
+DEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.o) -MT \$@ \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) $first_prereq-o \$@
+# Dependencies for host objects
+HDEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.ho) -MT \$@ \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(HOSTCC_CFLAGS) $first_prereq -o \$@
+# Dependencies for precompiled headers
+PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
+ \$(CFLAGS) $first_prereq -o \$@
+
+# \$< is broken in older BSD versions:
+# when \$@ is foo/bar.o, \$< could be torture/foo/bar.c
+# if it also exists. So better use \$* which is foo/bar
+# and append .c manually to get foo/bar.c
+#
+# If we have GNU Make, it is safe to use \$<, which also lets
+# building with \$srcdir != \$builddir work.
+
+# Run a static analysis checker
+CHECK = \$(CC_CHECKER) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+
+# Run the configured compiler
+COMPILE = \$(CC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+
+# Run the compiler for the build host
+HCOMPILE = \$(HOSTCC) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(HOSTCC_CFLAGS) -c $first_prereq -o \$@
+
+# Precompile headers
+PCHCOMPILE = @\$(CC) -Ilib/replace \\
+ `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
+ \$(CFLAGS) \$(PICFLAG) -c $first_prereq -o \$@
+
+__EOD__
+);
+}
+
sub _prepare_compiler_linker($)
{
my ($self) = @_;