From c1f82110d1ca6f7187d89f89ac0cd5a69cb9f36b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 22 Jan 2009 17:10:47 -0800 Subject: [PATCH] Make choices to build and to distribute modules independent of each other. --- datapath/Modules.mk | 20 ++++++++++++++------ datapath/hwtable_dummy/Modules.mk | 2 +- datapath/linux-2.4/Kbuild.in | 8 ++++---- datapath/linux-2.4/Makefile.main.in | 6 +++--- datapath/linux-2.4/Modules.mk | 2 +- datapath/linux-2.6/Kbuild.in | 4 ++-- datapath/linux-2.6/Makefile.main.in | 6 +++--- datapath/linux-2.6/Modules.mk | 4 +--- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/datapath/Modules.mk b/datapath/Modules.mk index 9193d509..ab1769c3 100644 --- a/datapath/Modules.mk +++ b/datapath/Modules.mk @@ -1,5 +1,13 @@ -all_modules = $(dist_modules) -dist_modules = openflow +# Some modules should be built and distributed, e.g. openflow. +# +# Some modules should be distributed but not built, e.g. we do not build +# veth if the kernel in question already has it. +# +# Some modules should be built but not distributed, e.g. third-party +# hwtable modules. +both_modules = openflow +build_modules = $(both_modules) # Modules to build +dist_modules = $(both_modules) # Modules to distribute openflow_sources = \ chain.c \ @@ -32,7 +40,7 @@ openflow_headers = \ dist_sources = $(foreach module,$(dist_modules),$($(module)_sources)) dist_headers = $(foreach module,$(dist_modules),$($(module)_headers)) -all_sources = $(foreach module,$(all_modules),$($(module)_sources)) -all_headers = $(foreach module,$(all_modules),$($(module)_headers)) -all_links = $(notdir $(all_sources)) -all_objects = $(notdir $(patsubst %.c,%.o,$(all_sources))) +build_sources = $(foreach module,$(build_modules),$($(module)_sources)) +build_headers = $(foreach module,$(build_modules),$($(module)_headers)) +build_links = $(notdir $(build_sources)) +build_objects = $(notdir $(patsubst %.c,%.o,$(build_sources))) diff --git a/datapath/hwtable_dummy/Modules.mk b/datapath/hwtable_dummy/Modules.mk index 2a3014d9..7f6b86ba 100644 --- a/datapath/hwtable_dummy/Modules.mk +++ b/datapath/hwtable_dummy/Modules.mk @@ -1,5 +1,5 @@ # Specify the module to build. -all_modules += hwtable_dummy +build_modules += hwtable_dummy # Specify the source files that comprise the module. hwtable_dummy_sources = \ diff --git a/datapath/linux-2.4/Kbuild.in b/datapath/linux-2.4/Kbuild.in index 86bfa6b2..047da499 100644 --- a/datapath/linux-2.4/Kbuild.in +++ b/datapath/linux-2.4/Kbuild.in @@ -30,7 +30,7 @@ endif override CFLAGS := $(OF_CFLAGS) # Multipart objects -list-multi := $(patsubst %,%_mod.o,$(all_modules)) +list-multi := $(patsubst %,%_mod.o,$(build_modules)) # Module objects that we can build obj-m += $(list-multi) @@ -39,10 +39,10 @@ obj-m += $(list-multi) define parts_template $(1)_mod-objs = $$(patsubst %.c,%.o,$(notdir $($(1)_sources))) endef -$(foreach module,$(all_modules),$(eval $(call parts_template,$(module)))) +$(foreach module,$(build_modules),$(eval $(call parts_template,$(module)))) # Objects that export symbols -export-objs = $(all_objects) +export-objs = $(build_objects) # Include the kernel's global Rules.make include $(TOPDIR)/Rules.make @@ -52,7 +52,7 @@ define link_template $(1)_mod.o: $($(1)_mod-objs) $(LD) -r -o $$@ $($(1)_mod-objs) endef -$(foreach module,$(all_modules),$(eval $(call link_template,$(module)))) +$(foreach module,$(build_modules),$(eval $(call link_template,$(module)))) # Build system rewrite May 2008: Bobby Holley # diff --git a/datapath/linux-2.4/Makefile.main.in b/datapath/linux-2.4/Makefile.main.in index 08848c5c..1647f60e 100644 --- a/datapath/linux-2.4/Makefile.main.in +++ b/datapath/linux-2.4/Makefile.main.in @@ -12,8 +12,8 @@ include $(srcdir)/../Modules.mk include $(srcdir)/Modules.mk include @HW_TABLES@ -default: $(all_links) -$(foreach m,$(all_modules), \ +default: $(build_links) +$(foreach m,$(build_modules), \ $(foreach s,$($(m)_sources), \ $(eval $(notdir $(s)): ; ln -s $(srcdir)/../$(s) .))) @@ -24,7 +24,7 @@ all: default check: all clean: rm -f *.o *_mod.o .*.o.flags - for d in $(all_links); do if test -h $$d; then rm $$d; fi; done + for d in $(build_links); do if test -h $$d; then rm $$d; fi; done ifneq (,$(KSRC)) diff --git a/datapath/linux-2.4/Modules.mk b/datapath/linux-2.4/Modules.mk index 39199095..5aa1a39c 100644 --- a/datapath/linux-2.4/Modules.mk +++ b/datapath/linux-2.4/Modules.mk @@ -1,4 +1,4 @@ -dist_modules += compat24 +both_modules += compat24 compat24_sources = \ linux-2.4/compat-2.4/attr.c \ diff --git a/datapath/linux-2.6/Kbuild.in b/datapath/linux-2.6/Kbuild.in index 1d405cce..4e03a078 100644 --- a/datapath/linux-2.6/Kbuild.in +++ b/datapath/linux-2.6/Kbuild.in @@ -27,10 +27,10 @@ EXTRA_CFLAGS += -include $(builddir)/kcompat.h # right place, even though it's conceptually incorrect. NOSTDINC_FLAGS += -I$(srcdir)/compat-2.6 -I$(srcdir)/compat-2.6/include -obj-m := $(patsubst %,%_mod.o,$(all_modules)) +obj-m := $(patsubst %,%_mod.o,$(build_modules)) define module_template $(1)_mod-y = $$(notdir $$(patsubst %.c,%.o,$($(1)_sources))) endef -$(foreach module,$(all_modules),$(eval $(call module_template,$(module)))) +$(foreach module,$(build_modules),$(eval $(call module_template,$(module)))) diff --git a/datapath/linux-2.6/Makefile.main.in b/datapath/linux-2.6/Makefile.main.in index aef3e3d0..e5a6593e 100644 --- a/datapath/linux-2.6/Makefile.main.in +++ b/datapath/linux-2.6/Makefile.main.in @@ -9,9 +9,9 @@ include $(srcdir)/../Modules.mk include $(srcdir)/Modules.mk include @HW_TABLES@ -default: $(all_links) +default: $(build_links) -$(foreach s,$(sort $(foreach m,$(all_modules),$($(m)_sources))), \ +$(foreach s,$(sort $(foreach m,$(build_modules),$($(m)_sources))), \ $(eval $(notdir $(s)): ; ln -s $(srcdir)/../$(s) $@)) distclean: clean @@ -22,7 +22,7 @@ all: default check: all clean: rm -f *.o *.ko *_mod.* Module.symvers *.cmd kcompat.h.new - for d in $(all_links); do if test -h $$d; then rm $$d; fi; done + for d in $(build_links); do if test -h $$d; then rm $$d; fi; done ifneq ($(KSRC),) diff --git a/datapath/linux-2.6/Modules.mk b/datapath/linux-2.6/Modules.mk index d66d1016..bc0317e6 100644 --- a/datapath/linux-2.6/Modules.mk +++ b/datapath/linux-2.6/Modules.mk @@ -1,9 +1,6 @@ -dist_modules += brcompat - openflow_sources += \ linux-2.6/compat-2.6/genetlink-openflow.c \ linux-2.6/compat-2.6/random32.c - openflow_headers += \ linux-2.6/compat-2.6/compat26.h \ linux-2.6/compat-2.6/include/asm-generic/bug.h \ @@ -29,6 +26,7 @@ openflow_headers += \ linux-2.6/compat-2.6/include/net/genetlink.h \ linux-2.6/compat-2.6/include/net/netlink.h +both_modules += brcompat brcompat_sources = \ linux-2.6/compat-2.6/genetlink-brcompat.c \ brcompat.c \ -- 2.30.2