svn commit: samba r20677 - in branches/SAMBA_4_0/source: .

jpeach at samba.org jpeach at samba.org
Thu Jan 11 04:32:43 GMT 2007


Author: jpeach
Date: 2007-01-11 04:32:43 +0000 (Thu, 11 Jan 2007)
New Revision: 20677

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20677

Log:
Condense compilations rules.

Modified:
   branches/SAMBA_4_0/source/main.mk


Changeset:
Modified: branches/SAMBA_4_0/source/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk	2007-01-11 04:12:35 UTC (rev 20676)
+++ branches/SAMBA_4_0/source/main.mk	2007-01-11 04:32:43 UTC (rev 20677)
@@ -81,6 +81,9 @@
 	@echo '  SHLD       = $(SHLD)'
 	@echo '  SHLD_FLAGS = $(SHLD_FLAGS)'
 	@echo '  SHLIBEXT   = $(SHLIBEXT)'
+	@echo '  srcdir     = $(srcdir)'
+	@echo '  builddir   = $(builddir)'
+	@echo '  pwd        = '`/bin/pwd`
 
 # The permissions to give the executables
 INSTALLPERMS = 0755
@@ -141,7 +144,7 @@
 	@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(STLIBEXT)" $(STATIC_LIBS)
 
 installheader: headers installdirs
-	@$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
+	@srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
 
 installdat: installdirs
 	@$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
@@ -283,47 +286,50 @@
 
 test: $(DEFAULT_TEST_TARGET)
 
+SELFTEST = builddir=$(builddir) srcdir=$(srcdir) \
+	    $(srcdir)/script/tests/selftest.sh ${selftest_prefix}
+
 test-swrap: all libraries
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+	$(SELFTEST) all SOCKET_WRAPPER
 
 test-noswrap: all libraries
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
+	$(SELFTEST) all
 
 quicktest: all
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+	$(SELFTEST) quick SOCKET_WRAPPER
 
 testenv: all libraries
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} xterm SOCKET_WRAPPER
+	$(SELFTEST) xterm SOCKET_WRAPPER
 
 valgrindtest: valgrindtest-quick
 
 valgrindtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+	$(SELFTEST) quick SOCKET_WRAPPER
 
 valgrindtest-all: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+	$(SELFTEST) all SOCKET_WRAPPER
 
 valgrindtest-env: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} xterm SOCKET_WRAPPER
+	$(SELFTEST) xterm SOCKET_WRAPPER
 
 gdbtest: gdbtest-quick
 
 gdbtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+	$(SELFTEST) quick SOCKET_WRAPPER
 
 gdbtest-all: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+	$(SELFTEST) all SOCKET_WRAPPER
 
 wintest: all
-	$(srcdir)/script/tests/selftest.sh ${selftest_prefix} win
+	$(SELFTEST) win
 
 unused_macros:
 	$(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
@@ -334,17 +340,27 @@
 
 .SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
 
+# Dependencies command
+DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
+    `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
+# Dependencies for host objects
+HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \
+    `$(PERL) $(srcdir)/script/cflags.pl $@` $(HOSTCC_CFLAGS) $< -o $@
+# Dependencies for precompiled headers
+PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \
+    $(CFLAGS) $< -o $@
+
 .c.d:
 	@echo "Generating dependencies for $<"
-	@$(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
+	@$(DEPENDS)
 
 .c.hd:
 	@echo "Generating host-compiler dependencies for $<"
-	@$(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ `$(PERL) $(srcdir)/script/cflags.pl $@` $(HOSTCC_CFLAGS) $< -o $@
+	@$(HDEPENDS)
 
 include/includes.d: include/includes.h
 	@echo "Generating dependencies for $<"
-	@$(CC) -M -MG -MT include/includes.h.gch -MT $@ $(CFLAGS) $< -o $@
+	@$(PCHDEPENDS)
 
 #
 # $< is broken in older BSD versions:
@@ -352,27 +368,47 @@
 # if it also exists. So better use $* which is foo/bar
 # and append .c manually to get foo/bar.c
 #
+
+# Run a static analysis checker
+CHECK = $(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+    $(CFLAGS) $(PICFLAG) -c $*.c -o $@
+
+# Run the configured compiler
+COMPILE = $(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+    $(CFLAGS) $(PICFLAG) -c $*.c -o $@
+
+# Run the compiler for the build host
+HCOMPILE = $(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+    $(HOSTCC_CFLAGS) -c $*.c -o $@
+
+# Precompile headers
+PCHCOMPILE = @$(CC) -Ilib/replace \
+    `$(PERL) $(srcdir)/script/cflags.pl $@` \
+    $(CFLAGS) $(PICFLAG) -c $*.c -o $@
+
 .c.o:
 	@if test -n "$(CC_CHECKER)"; then \
-		echo "Checking  $*.c with '$(CC_CHECKER)'"; \
-		$(CC_CHECKER) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@; \
+		echo "Checking  $< with '$(CC_CHECKER)'"; \
+		$(CHECK) ; \
 	fi
-	@echo "Compiling $*.c"
-	@$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ && exit 0;\
-		echo "The following command failed:" 1>&2;\
-		echo "$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@" 1>&2;\
-		$(CC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $*.c -o $@ >/dev/null 2>&1
+	@echo "Compiling $<"
+	@-mkdir -p `dirname $@`
+	@$(COMPILE) && exit 0 ; \
+		@echo "The following command failed:" 1>&2;\
+		@echo "$(COMPILE)" 1>&2;\
+		@$(COMPILE) >/dev/null 2>&1
 
 .c.ho:
-	@echo "Compiling $*.c with host compiler"
-	@$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(HOSTCC_CFLAGS) -c $*.c -o $@ && exit 0;\
-		echo "The following command failed:" 1>&2;\
-		echo "$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(HOSTCC_CFLAGS) -c $*.c -o $@" 1>&2;\
-		$(HOSTCC) `$(PERL) $(srcdir)/script/cflags.pl $@` $(HOSTCC_CFLAGS) -c $*.c -o $@ >/dev/null 2>&1
+	@echo "Compiling $< with host compiler"
+	@-mkdir -p `dirname $@`
+	@$(HCOMPILE) && exit 0;\
+		@echo "The following command failed:" 1>&2;\
+		@echo "$(HCOMPILE)" 1>&2;\
+		@$(HCOMPILE) >/dev/null 2>&1
 
 .h.h.gch:
 	@echo "Precompiling $<"
-	@$(CC) -Ilib/replace `$(PERL) $(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
+	@$(PCHCOMPILE)
 
 .y.c:
 	@echo "Building $< with $(YACC)"



More information about the samba-cvs mailing list