From c592ec0e13ea90528ceffc1a8d7c83637d0f0dbf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 15 Sep 2008 14:30:15 +0200 Subject: [PATCH] Import merged build patch. --- source3/Makefile.in | 38 +++----- source3/autogen.sh | 2 +- source3/configure.in | 9 +- source3/samba4-templates.mk | 145 ++++++++++++++++++++++++++++++ source3/samba4.m4 | 138 +++++++++++++++++++++++++++++ source3/samba4.mk | 170 ++++++++++++++++++++++++++++++++++++ 6 files changed, 474 insertions(+), 28 deletions(-) create mode 100644 source3/samba4-templates.mk create mode 100644 source3/samba4.m4 create mode 100644 source3/samba4.mk diff --git a/source3/Makefile.in b/source3/Makefile.in index b67cfe8bb87..51103ffc492 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -150,12 +150,7 @@ CODEPAGEDIR = @codepagedir@ # the directory where pid files go PIDDIR = @piddir@ -FLAGS1 = $(CFLAGS) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) -FLAGS2 = -FLAGS3 = -FLAGS4 = -I$(CTDBDIR)/include -FLAGS5 = $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) -FLAGS = $(ISA) $(FLAGS5) -I$(srcdir)/lib -D_SAMBA_BUILD_=3 +FLAGS = -I. -I$(srcdir) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) -I$(CTDBDIR)/include $(ISA) -I$(srcdir)/lib -D_SAMBA_BUILD_=3 PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \ -DPRIVATE_DIR=\"$(PRIVATE_DIR)\" \ @@ -1169,14 +1164,13 @@ modules:: SHOWFLAGS $(MODULES) ##################################################################### ## Perl IDL Compiler -IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ - srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ - epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl drsuapi.idl drsblobs.idl \ - nbt.idl - -idl:: - @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ +samba3-idl:: + @IDL_FILES="lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ + srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ + epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ + dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl drsuapi.idl drsblobs.idl \ + nbt.idl" \ + CPP="$(CPP)" PERL="$(PERL)" \ srcdir="$(srcdir)" $(srcdir)/script/build_idl.sh $(PIDL_ARGS) @@ -1190,7 +1184,7 @@ everything:: all libtalloc libsmbclient libnetapi debug2html smbfilter talloctor .SUFFIXES: .c .o .lo SHOWFLAGS:: - @echo "Using FLAGS = $(FLAGS)" + @echo "Using CFLAGS = $(CFLAGS)" @echo " PICFLAG = $(PICFLAG)" @echo " LIBS = $(LIBS)" @echo " LDFLAGS = $(LDFLAGS)" @@ -1208,11 +1202,11 @@ MAKEDIR = || exec false; \ exec false; fi || exec false # Run a static checker. -CHECK_CC = $(CC_CHECKER) -I. -I$(srcdir) $(FLAGS) $(PICFLAG) -c $< -o $@ +CHECK_CC = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) -c $< -o $@ # Compile a source file. -COMPILE_CC = $(CC) -I. -I$(srcdir) $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC = $(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@ # Compile a source file with the installation paths defined. -COMPILE_CC_PATH = $(CC) -I. -I$(srcdir) $(PATH_FLAGS) $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC_PATH = $(CC) $(PATH_FLAGS) $(CFLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) @@ -1226,7 +1220,7 @@ COMPILE = $(COMPILE_CC) @echo Compiling $*.c @$(COMPILE) && exit 0;\ echo "The following command failed:" 1>&2;\ - echo "$(COMPILE_CC)" 1>&2;\ + echo "$(subst ",\",$(COMPILE_CC))" 1>&2;\ $(COMPILE_CC) >/dev/null 2>&1 @BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@ @@ -2627,12 +2621,6 @@ include/build_env.h: script/build_env.sh > $(builddir)/include/build_env.h proto:: - @echo - @echo "NOTE: 'proto' is no longer a valid make target as proto.h" - @echo "and other prototype headers are not generated anymore." - @echo - -.PHONY: proto etags: etags `find $(srcdir) -name "*.[ch]"` diff --git a/source3/autogen.sh b/source3/autogen.sh index 018944e6847..9c817b9b1d3 100755 --- a/source3/autogen.sh +++ b/source3/autogen.sh @@ -53,7 +53,7 @@ echo "$0: running script/mkversion.sh" rm -rf autom4te*.cache rm -f configure include/config.h* -IPATHS="-Im4 -Ilib/replace" +IPATHS="-Im4 -Ilib/replace -I../samba4/source" echo "$0: running $AUTOHEADER $IPATHS" $AUTOHEADER $IPATHS || exit 1 diff --git a/source3/configure.in b/source3/configure.in index f813e87fb75..c26e65f1281 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -131,8 +131,6 @@ else CFLAGS="-O" fi -CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3" - m4_include(lib/socket_wrapper/config.m4) m4_include(lib/nss_wrapper/config.m4) @@ -6200,6 +6198,13 @@ MSG fi +esyscmd([test -d ../samba4]) +ifelse(sysval,0,[ +AC_SUBST(MERGED_BUILD) +MERGED_BUILD=1 +m4_include(samba4.m4) +],[]) + dnl Remove -L/usr/lib/? from LDFLAGS and LIBS LIB_REMOVE_USR_LIB(LDFLAGS) LIB_REMOVE_USR_LIB(LIBS) diff --git a/source3/samba4-templates.mk b/source3/samba4-templates.mk new file mode 100644 index 00000000000..3180be30d3d --- /dev/null +++ b/source3/samba4-templates.mk @@ -0,0 +1,145 @@ +# Templates file for Samba 4 +# This relies on GNU make. +# +# © 2008 Jelmer Vernooij +# +############################################################################### +# Templates +############################################################################### + +# Partially link +# Arguments: target object file, source object files +define partial_link_template +$(1): $(2) ; + @echo Partially linking $$@ + @mkdir -p $$(@D) + @$$(PARTLINK) -o $$@ $$^ +endef + +# Link a binary +# Arguments: target file, depends, flags +define binary_link_template +$(1)4: $(2) $(LIBREPLACE_OBJ) ; + @echo Linking $$@ + @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBS) $$(LIBREPLACE_OBJ) +clean:: + @rm -f $(1) + +binaries:: $(1) + + +endef + +# Link a host-machine binary +# Arguments: target file, depends, flags +define host_binary_link_template +$(1)4: $(2) $(LIBREPLACE_OBJ) ; + @echo Linking $$@ + @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBREPLACE_OBJ) + +clean:: + rm -f $(1) + +binaries:: $(1) + + +endef + +# Create a prototype header +# Arguments: header file, c files +define proto_header_template +echo:: ; + echo $(1) ; + +proto:: $(1) ; + +clean:: ; + rm -f $(1) ; + +$(1): $(2) ; + @echo "Creating $$@" + @$$(PERL) $$(srcdir)/../samba4/source/script/mkproto.pl --srcdir=$$(srcdir)/../samba4/source --builddir=$$(builddir)/../samba4/source --public=/dev/null --private=$$@ $$^ +endef + +# Shared module +# Arguments: Target, dependencies, objects +define shared_module_template + +$(1): $(2) ; + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) + +PLUGINS += $(1) + +endef + +# Shared library +# Arguments: Target, dependencies, link flags, soname +define shared_library_template +$(1): $(2) + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \ + $(3) \ + $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) $$(LIBS) + +ifneq ($(notdir $(1)),$(notdir $(4))) +$(4): $(1) + @echo "Creating symbolic link for $$@" + @ln -fs $$(= 1.2.0, + [], + [ + SMB_INCLUDE_MK(lib/talloc/config.mk) + ] +) + +SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0, + [], + [ + m4_include(lib/tdb/libtdb.m4) + SMB_INCLUDE_MK(lib/tdb/config.mk) + ] +) + +SMB_INCLUDE_MK(lib/tdb/python.mk) + +SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1, + [ + SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) + SMB_INCLUDE_MK(lib/ldb/tools/config.mk) + define_ldb_modulesdir=no + ], + [ + # Here we need to do some tricks + # with AC_CONFIG_COMMANDS_PRE + # as that's the deferrs the commands + # to location after $prefix and $exec_prefix + # have usefull values and directly before + # creating config.status. + # + # The 'eval eval echo' trick is used to + # actually get the raw absolute directory + # path as this is needed in config.h + define_ldb_modulesdir=yes + AC_CONFIG_COMMANDS_PRE([ + if test x"$define_ldb_modulesdir" = x"yes";then + LDB_MODULESDIR=`eval eval echo ${modulesdir}/ldb` + AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory]) + fi + ]) + ldbdir="\$(abspath \$(srcdir)/../samba4/source/lib/ldb)" + AC_SUBST(ldbdir) + m4_include(lib/ldb/sqlite3.m4) + m4_include(lib/ldb/libldb.m4) + SMB_INCLUDE_MK(lib/ldb/config.mk) + AC_CONFIG_FILES(../samba4/source/lib/ldb/ldb.pc) + ] +) +SMB_INCLUDE_MK(lib/ldb/python.mk) + +# Not sure why we need this.. +SMB_ENABLE(swig_ldb,YES) + +m4_include(lib/tls/config.m4) +eventsdir="../samba4/source/lib/events" +m4_include(lib/events/libevents.m4) + +dnl m4_include(auth/kerberos/config.m4) +m4_include(scripting/python/config.m4) +m4_include(auth/gensec/config.m4) +m4_include(smbd/process_model.m4) +m4_include(ntvfs/posix/config.m4) +m4_include(ntvfs/unixuid/config.m4) +m4_include(auth/config.m4) +m4_include(kdc/config.m4) +m4_include(ntvfs/sysdep/config.m4) +m4_include(lib/appweb/config.m4) +m4_include(nsswitch/config.m4) + +dnl Samba 4 files +AC_SUBST(LD) +AC_LIBREPLACE_SHLD_FLAGS +SMB_WRITE_MAKEVARS(samba4-config.mk, [prefix exec_prefix CPPFLAGS LDSHFLAGS POPT_OBJ CFLAGS TALLOC_OBJ]) + +oldbuilddir="$builddir" +builddir="$builddir/../samba4/source" +SMB_WRITE_PERLVARS(../samba4/source/build/smb_build/config.pm) +builddir="$oldbuilddir" + +echo "configure: creating ../samba4/source/config.mk" +cat >../samba4/source/config.mk<> ${builddir}/Makefile +]) + diff --git a/source3/samba4.mk b/source3/samba4.mk new file mode 100644 index 00000000000..7d2489c3d0d --- /dev/null +++ b/source3/samba4.mk @@ -0,0 +1,170 @@ +# samba 4 bits + +PROG_LD = $(LD) +BNLD = $(CC) +HOSTLD = $(CC) +PARTLINK = $(PROG_LD) -r +MDLD = $(SHLD) +MDLD_FLAGS = $(LDSHFLAGS) + +samba4srcdir = $(call abspath,$(srcdir)/../samba4/source) + +# Flags used for the samba 4 files +# $(srcdir)/include is required for config.h +SAMBA4_CFLAGS = -I$(samba4srcdir) -I$(samba4srcdir)/include \ + -I$(samba4srcdir)/lib/replace -I$(samba4srcdir)/lib \ + -I$(heimdalsrcdir)/lib/hcrypto -I$(tallocdir) \ + -I$(srcdir)/include -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H + +.SUFFIXES: .ho + +# No cross compilation for now, thanks +.c.ho: + @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ + dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi + @if test -n "$(CC_CHECKER)"; then \ + echo "Checking $*.c with '$(CC_CHECKER)'";\ + $(CHECK_CC); \ + fi + @echo Compiling $*.c + @$(COMPILE) && exit 0;\ + echo "The following command failed:" 1>&2;\ + echo "$(subst ",\",$(COMPILE_CC))" 1>&2;\ + $(COMPILE_CC) >/dev/null 2>&1 + +# The order really does matter here! GNU Make 3.80 will break if the more specific +# overrides are not specified first. +ifeq ($(MAKE_VERSION),3.81) +%.o: CFLAGS+=$(FLAGS) +$(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS) +$(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS) +$(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +else +$(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS) +$(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS) +%.o: CFLAGS+=$(FLAGS) +endif + +# Create a static library +%.a: + @echo Linking $@ + @rm -f $@ + @mkdir -p $(@D) + @$(AR) -rc $@ $^ + +INTERN_LDFLAGS = -L${builddir}/bin/static -L${builddir}/bin/shared + +pidldir = $(samba4srcdir)/pidl +include $(pidldir)/config.mk +include samba4-config.mk +include samba4-templates.mk + +zlibsrcdir := $(samba4srcdir)/lib/zlib +dynconfigsrcdir := $(samba4srcdir)/dynconfig +heimdalsrcdir := $(samba4srcdir)/heimdal +dsdbsrcdir := $(samba4srcdir)/dsdb +smbdsrcdir := $(samba4srcdir)/smbd +clustersrcdir := $(samba4srcdir)/cluster +libnetsrcdir := $(samba4srcdir)/libnet +authsrcdir := $(samba4srcdir)/auth +nsswitchsrcdir := $(samba4srcdir)/nsswitch +libsrcdir := $(samba4srcdir)/lib +libsocketsrcdir := $(samba4srcdir)/lib/socket +libcharsetsrcdir := $(samba4srcdir)/lib/charset +ldb_sambasrcdir := $(samba4srcdir)/lib/ldb-samba +libtlssrcdir := $(samba4srcdir)/lib/tls +libregistrysrcdir := $(samba4srcdir)/lib/registry +libmessagingsrcdir := $(samba4srcdir)/lib/messaging +libeventssrcdir := $(samba4srcdir)/lib/events +libcmdlinesrcdir := $(samba4srcdir)/lib/cmdline +poptsrcdir := $(samba4srcdir)/lib/popt +socketwrappersrcdir := $(samba4srcdir)/lib/socket_wrapper +nsswrappersrcdir := $(samba4srcdir)/lib/nss_wrapper +appwebsrcdir := $(samba4srcdir)/lib/appweb +libstreamsrcdir := $(samba4srcdir)/lib/stream +libutilsrcdir := $(samba4srcdir)/lib/util +libtdrsrcdir := $(samba4srcdir)/lib/tdr +libdbwrapsrcdir := $(samba4srcdir)/lib/dbwrap +libcryptosrcdir := $(samba4srcdir)/lib/crypto +libtorturesrcdir := $(samba4srcdir)/lib/torture +libcompressionsrcdir := $(samba4srcdir)/lib/compression +libgencachesrcdir := $(samba4srcdir)/lib +paramsrcdir := $(samba4srcdir)/param +smb_serversrcdir := $(samba4srcdir)/smb_server +rpc_serversrcdir := $(samba4srcdir)/rpc_server +ldap_serversrcdir := $(samba4srcdir)/ldap_server +web_serversrcdir := $(samba4srcdir)/web_server +winbindsrcdir := $(samba4srcdir)/winbind +nbt_serversrcdir := $(samba4srcdir)/nbt_server +wrepl_serversrcdir := $(samba4srcdir)/wrepl_server +cldap_serversrcdir := $(samba4srcdir)/cldap_server +librpcsrcdir := $(samba4srcdir)/librpc +torturesrcdir := $(samba4srcdir)/torture +utilssrcdir := $(samba4srcdir)/utils +ntvfssrcdir := $(samba4srcdir)/ntvfs +ntptrsrcdir := $(samba4srcdir)/ntptr +clientsrcdir := $(samba4srcdir)/client +libclisrcdir := $(samba4srcdir)/libcli +ejsscriptsrcdir := $(samba4srcdir)/scripting/ejs +pyscriptsrcdir := $(samba4srcdir)/scripting/python +kdcsrcdir := $(samba4srcdir)/kdc +smbreadlinesrcdir := $(samba4srcdir)/lib/smbreadline +ntp_signdsrcdir := $(samba4srcdir)/ntp_signd +tdbsrcdir := $(samba4srcdir)/lib/tdb +ldbsrcdir := $(samba4srcdir)/lib/ldb +override ASN1C = bin/asn1_compile4 +override ET_COMPILER = bin/compile_et4 +include samba4-data.mk +include $(samba4srcdir)/static_deps.mk +include $(samba4srcdir)/build/make/python.mk + +INSTALLPERMS = 0755 + +$(DESTDIR)$(bindir)/%: bin/%4 installdirs + @mkdir -p $(@D) + @echo Installing $(@F) as $@ + @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi + @cp $< $@ + @chmod $(INSTALLPERMS) $@ + +$(DESTDIR)$(sbindir)/%: bin/%4 installdirs + @mkdir -p $(@D) + @echo Installing $(@F) as $@ + @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi + @cp $< $@ + @chmod $(INSTALLPERMS) $@ + +clean:: + @echo Removing samba 4 objects + @-find $(samba4srcdir) -name '*.o' -exec rm -f '{}' \; + @echo Removing samba 4 hostcc objects + @-find $(samba4srcdir) -name '*.ho' -exec rm -f '{}' \; + @echo Removing samba 4 libraries + @-rm -f $(STATIC_LIBS) $(SHARED_LIBS) + @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o + @echo Removing samba 4 modules + @-rm -f bin/modules/*/*.$(SHLIBEXT) + @-rm -f bin/*_init_module.c + @echo Removing samba 4 dummy targets + @-rm -f bin/.*_* + @echo Removing samba 4 generated files + @-rm -f bin/*_init_module.c + @-rm -rf $(samba4srcdir)/librpc/gen_* + +proto:: $(PROTO_HEADERS) +modules:: $(PLUGINS) + +all:: basics bin/smbd4 bin/regpatch4 bin/regdiff4 bin/regshell4 bin/regtree4 bin/smbclient4 +torture:: basics bin/smbtorture4 +everything:: basics $(patsubst %,%4,$(BINARIES)) + + +etags:: + etags --append=yes `find $(samba4srcdir) -name "*.[ch]"` + +ctags:: + ctags --append=yes `find $(samba4srcdir) -name "*.[ch]"` + -- 2.34.1