1# 2# This file contains rules which are shared between multiple Makefiles. 3# 4 5# 6# False targets. 7# 8.PHONY: dummy 9 10# 11# Special variables which should not be exported 12# 13unexport EXTRA_ASFLAGS 14unexport EXTRA_CFLAGS 15unexport EXTRA_LDFLAGS 16unexport EXTRA_ARFLAGS 17unexport SUBDIRS 18unexport SUB_DIRS 19unexport ALL_SUB_DIRS 20unexport MOD_SUB_DIRS 21unexport O_TARGET 22unexport O_OBJS 23unexport L_OBJS 24unexport M_OBJS 25unexport ALL_MOBJS 26# objects that export symbol tables 27unexport OX_OBJS 28unexport LX_OBJS 29unexport MX_OBJS 30unexport SYMTAB_OBJS 31 32unexport MOD_LIST_NAME 33 34# 35# Get things started. 36# 37first_rule: sub_dirs 38 $(MAKE) all_targets 39 40# 41# Common rules 42# 43 44%.s: %.c 45 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@ 46 47%.o: %.c 48 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< 49 50%.o: %.s 51 $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $< 52 53# 54# 55# 56all_targets: $(O_TARGET) $(L_TARGET) 57 58# 59# Rule to compile a set of .o files into one .o file 60# 61ifdef O_TARGET 62ALL_O = $(OX_OBJS) $(O_OBJS) 63$(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h 64 rm -f $@ 65ifneq "$(strip $(ALL_O))" "" 66 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O) 67else 68 $(AR) rcs $@ 69endif 70endif 71 72# 73# Rule to compile a set of .o files into one .a file 74# 75ifdef L_TARGET 76$(L_TARGET): $(LX_OBJS) $(L_OBJS) $(TOPDIR)/include/linux/config.h 77 rm -f $@ 78 $(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS) 79endif 80 81# 82# This make dependencies quickly 83# 84fastdep: dummy 85 if [ -n "$(wildcard *.[chS])" ]; then \ 86 $(TOPDIR)/scripts/mkdep *.[chS] > .depend; fi 87ifdef ALL_SUB_DIRS 88 set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done 89endif 90 91# 92# A rule to make subdirectories 93# 94sub_dirs: dummy 95ifdef SUB_DIRS 96 set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done 97endif 98 99# 100# A rule to make modules 101# 102ALL_MOBJS = $(MX_OBJS) $(M_OBJS) 103ifneq "$(strip $(ALL_MOBJS))" "" 104PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh) 105endif 106modules: $(ALL_MOBJS) dummy 107ifdef MOD_SUB_DIRS 108 set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done 109endif 110ifneq "$(strip $(MOD_LIST_NAME))" "" 111 rm -f $$TOPDIR/modules/$(MOD_LIST_NAME) 112ifdef MOD_SUB_DIRS 113 for i in $(MOD_SUB_DIRS); do \ 114 echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done 115endif 116ifneq "$(strip $(ALL_MOBJS))" "" 117 echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME) 118endif 119endif 120ifneq "$(strip $(ALL_MOBJS))" "" 121 echo $(PDWN) 122 cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \ 123 ln -sf ../$(PDWN)/$$i .; done 124endif 125 126# 127# A rule to do nothing 128# 129dummy: 130 131# 132# This is useful for testing 133# 134script: 135 $(SCRIPT) 136 137# 138# This sets version suffixes on exported symbols 139# Uses SYMTAB_OBJS 140# Separate the object into "normal" objects and "exporting" objects 141# Exporting objects are: all objects that define symbol tables 142# 143ifdef CONFIG_MODVERSIONS 144SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS) 145ifneq "$(strip $(SYMTAB_OBJS))" "" 146 147MODINCL = $(TOPDIR)/include/linux/modules 148 149# The -w option (enable warnings) for /bin/genksyms will return here in 2.1 150$(MODINCL)/%.ver: %.c 151 @if [ ! -x /sbin/genksyms ]; then echo "Please read: Documentation/modules.txt"; fi 152 $(CC) $(CFLAGS) -E -D__GENKSYMS__ $< | /sbin/genksyms $(MODINCL) 153 154$(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h 155 156$(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)) 157 @echo updating $(TOPDIR)/include/linux/modversions.h 158 @(echo "#ifdef MODVERSIONS";\ 159 echo "#undef CONFIG_MODVERSIONS";\ 160 echo "#define CONFIG_MODVERSIONS";\ 161 echo "#ifndef _set_ver";\ 162 echo "#define _set_ver(sym,vers) sym ## _R ## vers";\ 163 echo "#endif";\ 164 cd $(TOPDIR)/include/linux/modules; for f in *.ver;\ 165 do echo "#include <linux/modules/$${f}>"; done; \ 166 echo "#undef CONFIG_MODVERSIONS";\ 167 echo "#endif") \ 168 > $(TOPDIR)/include/linux/modversions.h 169 170$(MX_OBJS): $(TOPDIR)/include/linux/modversions.h 171 $(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c) 172 173$(LX_OBJS) $(OX_OBJS): $(TOPDIR)/include/linux/modversions.h 174 $(CC) $(CFLAGS) -DMODVERSIONS -DEXPORT_SYMTAB -c $(@:.o=.c) 175 176dep fastdep: $(TOPDIR)/include/linux/modversions.h 177 178endif 179$(M_OBJS): $(TOPDIR)/include/linux/modversions.h 180ifdef MAKING_MODULES 181$(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h 182endif 183# This is needed to ensure proper dependency for multipart modules such as 184# fs/ext.o. (Otherwise, not all subobjects will be recompiled when 185# version information changes.) 186 187endif 188 189# 190# include dependency files they exist 191# 192ifeq (.depend,$(wildcard .depend)) 193include .depend 194endif 195 196ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend)) 197include $(TOPDIR)/.hdepend 198endif 199

