# # This is a Makefile for 2.4 external module builds. Red Hat # Enterprise Linux does not support the usual: # # make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd` modules # # So we must hand-roll our compile lines. This is in a seperate # file to keep the regular Makefile readable. # # This uses the Makebo schema. So, the compile parts are filled in. # All Makefiles using this code should set MODULE_CFLAGS and # MODULE_DEFINES for any extra cflags/defines needed. # WARNINGS = -Wall -Wstrict-prototypes OPTIMIZE = -O2 KERNEL_DEFINES = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB KERNEL_CFLAGS = -pipe -nostdinc -fno-strict-aliasing -fno-common \ -fomit-frame-pointer KERNEL_LDADD = -nostdlib # # These arch-specific flags would normally be provided by the # kbuild system. Hope we got them right. # ifeq ($(PROCESSOR),ppc64) MACH_CFLAGS += -m64 -fsigned-char -fno-builtin -msoft-float \ -mminimal-toc MACH_LDADD += -m elf64ppc endif ifeq ($(PROCESSOR),x86_64) MACH_CFLAGS += -m64 -mcmodel=kernel endif ifeq ($(PROCESSOR),s390x) MACH_CFLAGS += -fno-strength-reduce -fpic MACH_LDADD += -m elf64_s390 endif INCLUDES = -I. -I$(KERNELINC) -I$(GCCINC) DEFINES = $(KERNEL_DEFINES) CFLAGS = $(OPTIMIZE) $(KERNEL_CFLAGS) $(MACH_CFLAGS) $(MODVERSIONS) \ $(WARNINGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) LDADD = $(KERNEL_LDADD) $(MACH_LDADD) # # Ripping off some kbuild 2.6 tricks # # Modules that have multiple parts. multi-used-m := $(sort $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs))), $(m)))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs))) # Modules that don't. single-used-m := $(sort $(filter-out $(multi-used-m), $(obj-m))) link_multi_deps = $($(@:.o=-objs)) # # It's impossible, AFAICT, to generate the dependancies for each # individual object:parts set. In fact, kbuild 2.6 doesn't try either. # They use a simpler trick...they force the rebuild like this, but # call if_changed on each target to avoid the useless rebuilds. # This is a 2.4 hack, so I don't care that much :-) # $(multi-used-m): $(multi-objs-m) $(CC) -Wl,-r -o $@ $(LDADD) $(link_multi_deps) build-modules: $(single-used-m) $(multi-used-m) # Kbuild uses INSTALL_MOD_PATH for rooted installs. Makebo uses # DESTDIR. Folks really should set INSTALL_MOD_PATH, but in case they # don't... INSTALL_MOD_PATH ?= $(DESTDIR) MODLIB = $(INSTALL_MOD_PATH)$(MODULEDIR) install-modules: $(obj-m) $(TOPDIR)/mkinstalldirs $(MODLIB)/$(INSTALL_MOD_DIR) for file in $(obj-m); do \ $(INSTALL_DATA) $$file $(MODLIB)/$(INSTALL_MOD_DIR)/$$file; \ done clean-modules: rm -f *.o *.p *.s