summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/Makefile26
-rwxr-xr-xsource4/build/make/lex_compile.sh (renamed from source4/script/lex_compile.sh)0
-rw-r--r--source4/build/make/python.mk58
-rw-r--r--source4/build/make/rules.mk (renamed from source4/rules.mk)131
-rwxr-xr-xsource4/build/make/yacc_compile.sh (renamed from source4/script/yacc_compile.sh)0
-rw-r--r--source4/dynconfig.mk3
-rw-r--r--source4/scripting/python/config.mk17
7 files changed, 198 insertions, 37 deletions
diff --git a/source4/Makefile b/source4/Makefile
index ab3ef47fed..8c74b4899d 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -19,6 +19,25 @@ BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS)
HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
+$(srcdir)/version.h: $(srcdir)/VERSION
+ @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
+
+.DEFAULT_GOAL := all
+
+ifneq ($(automatic_deps),yes)
+ALL_PREDEP = proto
+.NOTPARALLEL:
+endif
+
+regen_version::
+ @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
+
+clean_pch::
+ @echo "Removing precompiled headers"
+ @-rm -f include/includes.h.gch
+
+pch:: clean_pch include/includes.h.gch
+
.DEFAULT_GOAL := all
ifneq ($(automatic_dependencies),yes)
@@ -26,9 +45,12 @@ ALL_PREDEP = proto
.NOTPARALLEL:
endif
-include rules.mk
+include build/make/rules.mk
+include build/make/python.mk
include data.mk
+BINARIES += $(BIN_PROGS) $(SBIN_PROGS)
+
DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
include/includes.d
@@ -55,7 +77,7 @@ endif
DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
$(srcdir)/version.h
-binaries::
+binaries:: $(BINARIES)
libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
modules:: $(PLUGINS)
headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
diff --git a/source4/script/lex_compile.sh b/source4/build/make/lex_compile.sh
index 9bba7257b1..9bba7257b1 100755
--- a/source4/script/lex_compile.sh
+++ b/source4/build/make/lex_compile.sh
diff --git a/source4/build/make/python.mk b/source4/build/make/python.mk
new file mode 100644
index 0000000000..57bf0169fe
--- /dev/null
+++ b/source4/build/make/python.mk
@@ -0,0 +1,58 @@
+pythonbuilddir = $(builddir)/bin/python
+
+# Install Python
+# Arguments: Module path
+define python_module_template
+
+installpython:: $$(pythonbuilddir)/$(1) ;
+ cp $$< $$(DESTDIR)$$(PYTHONDIR)/$(1)
+
+uninstallpython::
+ rm -f $$(DESTDIR)$$(PYTHONDIR)/$(1) ;
+
+pythonmods:: $$(pythonbuilddir)/$(1) ;
+
+endef
+
+define python_py_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+ mkdir -p $$(@D)
+ cp $$< $$@
+
+$(call python_module_template,$(1))
+
+endef
+
+# Python C module
+# Arguments: Module path, object files
+define python_c_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+ @echo Linking $$@
+ @mkdir -p $$(@D)
+ @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+
+$(call python_module_template,$(1))
+endef
+
+# Swig extensions
+swig:: pythonmods
+
+.SUFFIXES: _wrap.c .i
+
+.i_wrap.c:
+ [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
+
+realdistclean::
+ @echo "Removing SWIG output files"
+ # FIXME: Remove _wrap.c files
+
+pythonmods::
+
+clean::
+ @echo "Removing python modules"
+ @rm -rf $(pythonbuilddir)
+
+pydoctor:: pythonmods
+ LD_LIBRARY_PATH=bin/shared PYTHONPATH=$(pythonbuilddir) pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package $(pythonbuilddir)/samba
diff --git a/source4/rules.mk b/source4/build/make/rules.mk
index 5f91f8132e..faefb4e323 100644
--- a/source4/rules.mk
+++ b/source4/build/make/rules.mk
@@ -1,3 +1,6 @@
+# Rules file for Samba 4
+# This relies on GNU make.
+#
# Dependencies command
DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
$(CFLAGS) $(CPPFLAGS) $< -o $@
@@ -26,22 +29,14 @@ PCHCOMPILE = @$(CC) -Ilib/replace \
# Partial linking
PARTLINK = @$(PROG_LD) -r
+make_utility_dir = $(srcdir)/build/make/
+
include/config.h:
@echo "include/config.h not present"
@echo "You need to rerun ./autogen.sh and ./configure"
@/bin/false
-$(srcdir)/version.h: $(srcdir)/VERSION
- @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
-
-regen_version::
- @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
-
-clean_pch::
- @echo "Removing precompiled headers"
- @-rm -f include/includes.h.gch
-
-pch:: clean_pch include/includes.h.gch
+pch::
clean:: clean_pch
@echo Removing objects
@@ -51,7 +46,7 @@ clean:: clean_pch
@echo Removing binaries
@-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
@echo Removing libraries
- @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
+ @-rm -f $(STATIC_LIBS) $(SHARED_LIBS)
@-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
@echo Removing modules
@-rm -f bin/modules/*/*.$(SHLIBEXT)
@@ -94,6 +89,103 @@ unused_macros:
@$(STLD) $(STLD_FLAGS) $@ $^
###############################################################################
+# 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): $(2) ;
+ @echo Linking $$@
+ @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Link a host-machine binary
+# Arguments: target file, depends, flags
+define host_binary_link_template
+$(1): $(2) ;
+ @echo Linking $$@
+ @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Create a prototype header
+# Arguments: header file, c files
+define proto_header_template
+$(1): $(2) ;
+ @echo "Creating $$@"
+ @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --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)
+
+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)))
+
+ifneq ($(notdir $(1)),$(notdir $(4)))
+$(4): $(1)
+ @echo "Creating symbolic link for $$@"
+ @ln -fs $$(<F) $$@
+endif
+
+ifneq ($(notdir $(1)),$(notdir $(5)))
+$(5): $(1)
+ @echo "Creating symbolic link for $$@"
+ @ln -fs $$(<F) $$@
+endif
+endef
+
+# Shared alias
+# Arguments: Target, subsystem name, alias name
+define shared_module_alias_template
+bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1)
+ @ln -fs $$(<F) $$@
+
+PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
+
+uninstallplugins::
+ @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+installplugins::
+ @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+
+endef
+
+define shared_module_install_template
+installplugins:: bin/modules/$(1)/$(2)
+ @echo Installing$(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+ @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/
+ @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+uninstallplugins::
+ @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+ @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+
+endef
+
+###############################################################################
# File types
###############################################################################
@@ -119,11 +211,9 @@ include/includes.d: include/includes.h
@echo "Compiling $<"
@-mkdir -p `dirname $@`
@$(COMPILE) && exit 0 ; \
- echo "The following command failed:" 1>&2;\
- $(COMPILE) >/dev/null 2>&1
+ $(COMPILE)
-# echo "$(COMPILE)" 1>&2;\
.c.ho:
@echo "Compiling $< with host compiler"
@@ -139,11 +229,18 @@ include/includes.d: include/includes.h
.y.c:
@echo "Building $< with $(YACC)"
- @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
+ @-$(make_utility_dir)/yacc_compile.sh "$(YACC)" "$<" "$@"
.l.c:
@echo "Building $< with $(LEX)"
- @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+ @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+
+%.a:
+ @echo Linking $@
+ @rm -f $@
+ @mkdir -p $(@D)
+ @$(STLD) $(STLD_FLAGS) $@ $^
+
DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
diff --git a/source4/script/yacc_compile.sh b/source4/build/make/yacc_compile.sh
index a56a51da0a..a56a51da0a 100755
--- a/source4/script/yacc_compile.sh
+++ b/source4/build/make/yacc_compile.sh
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index aa0565cd7a..ba9c5467ba 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -21,5 +21,4 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
dynconfig.o: dynconfig.c Makefile
@echo Compiling $<
- @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) \
- $(PATH_FLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) $(PATH_FLAGS) -c $< -o $@
diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk
index 09c77813ca..22e9a2ff7b 100644
--- a/source4/scripting/python/config.mk
+++ b/source4/scripting/python/config.mk
@@ -15,24 +15,9 @@ OBJ_FILES = uuidmodule.o
PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS
SWIG_FILE = misc.i
-# Swig extensions
-swig:: pythonmods
-
-.SUFFIXES: _wrap.c .i
-
-.i_wrap.c:
- [ "$(SWIG)" = "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
-
-realdistclean::
- @echo "Removing SWIG output files"
- # FIXME: Remove _wrap.c files
-
-pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS)
-
PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py
-pydoctor:: pythonmods
- LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES))
+pythonmods:: $(PYTHON_PYS) $(PYTHON_MODS)
bin/python/%.py:
mkdir -p $(@D)