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 25# intermediate objects that form part of a module 26unexport MI_OBJS 27unexport ALL_MOBJS 28# objects that export symbol tables 29unexport OX_OBJS 30unexport LX_OBJS 31unexport MX_OBJS 32unexport MIX_OBJS 33unexport SYMTAB_OBJS 34 35unexport MOD_LIST_NAME 36 37# 38# Get things started. 39# 40first_rule: sub_dirs 41 $(MAKE) all_targets 42 43# 44# Common rules 45# 46 47%.s: %.c 48 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@ 49 50%.i: %.c 51 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E $< > $@ 52 53%.o: %.c 54 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< 55 56%.o: %.s 57 $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $< 58 59# 60# 61# 62all_targets: $(O_TARGET) $(L_TARGET) 63 64# 65# Rule to compile a set of .o files into one .o file 66# 67ifdef O_TARGET 68ALL_O = $(OX_OBJS) $(O_OBJS) 69$(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h 70 rm -f $@ 71ifneq "$(strip $(ALL_O))" "" 72 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O) 73else 74 $(AR) rcs $@ 75endif 76endif # O_TARGET 77 78# 79# Rule to compile a set of .o files into one .a file 80# 81ifdef L_TARGET 82$(L_TARGET): $(LX_OBJS) $(L_OBJS) $(TOPDIR)/include/linux/config.h 83 rm -f $@ 84 $(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS) 85endif 86 87# 88# This make dependencies quickly 89# 90fastdep: dummy 91 $(TOPDIR)/scripts/mkdep *.[chS] > .depend 92ifdef ALL_SUB_DIRS 93 set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done 94endif 95 96# 97# A rule to make subdirectories 98# 99sub_dirs: dummy 100ifdef SUB_DIRS 101 set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done 102endif 103 104# 105# A rule to make modules 106# 107ALL_MOBJS = $(MX_OBJS) $(M_OBJS) 108ifneq "$(strip $(ALL_MOBJS))" "" 109PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh) 110endif 111modules: $(ALL_MOBJS) $(MIX_OBJS) $(MI_OBJS) dummy 112ifdef MOD_SUB_DIRS 113 set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done 114endif 115ifdef MOD_IN_SUB_DIRS 116 set -e; for i in $(MOD_IN_SUB_DIRS); do $(MAKE) -C $$i modules; done 117endif 118ifneq "$(strip $(MOD_LIST_NAME))" "" 119 rm -f $$TOPDIR/modules/$(MOD_LIST_NAME) 120ifdef MOD_SUB_DIRS 121 for i in $(MOD_SUB_DIRS); do \ 122 echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done 123endif 124ifneq "$(strip $(ALL_MOBJS))" "" 125 echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME) 126endif 127ifneq "$(strip $(MOD_TO_LIST))" "" 128 echo $(MOD_TO_LIST) >> $$TOPDIR/modules/$(MOD_LIST_NAME) 129endif 130endif 131ifneq "$(strip $(ALL_MOBJS))" "" 132 echo $(PDWN) 133 cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \ 134 ln -sf ../$(PDWN)/$$i .; done 135endif 136 137# 138# A rule to do nothing 139# 140dummy: 141 142# 143# This is useful for testing 144# 145script: 146 $(SCRIPT) 147 148# 149# This sets version suffixes on exported symbols 150# Uses SYMTAB_OBJS 151# Separate the object into "normal" objects and "exporting" objects 152# Exporting objects are: all objects that define symbol tables 153# 154ifdef CONFIG_MODULES 155 156SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS) $(MIX_OBJS) 157 158ifdef CONFIG_MODVERSIONS 159ifneq "$(strip $(SYMTAB_OBJS))" "" 160 161MODINCL = $(TOPDIR)/include/linux/modules 162 163# The -w option (enable warnings) for genksyms will return here in 2.1 164$(MODINCL)/%.ver: %.c 165 $(CC) $(CFLAGS) -E -D__GENKSYMS__ $<\ 166 | $(GENKSYMS) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp 167 mv $@.tmp $@ 168 169$(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h 170 171$(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)) 172 @echo updating $(TOPDIR)/include/linux/modversions.h 173 @(echo "#ifndef _LINUX_MODVERSIONS_H";\ 174 echo "#define _LINUX_MODVERSIONS_H"; \ 175 echo "#include <linux/modsetver.h>"; \ 176 cd $(TOPDIR)/include/linux/modules; \ 177 for f in *.ver; do \ 178 if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \ 179 done; \ 180 echo "#endif"; \ 181 ) > $@ 182 183dep fastdep: $(TOPDIR)/include/linux/modversions.h 184 185endif # SYMTAB_OBJS 186 187$(M_OBJS): $(TOPDIR)/include/linux/modversions.h 188ifdef MAKING_MODULES 189$(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h 190endif 191 192else 193 194$(TOPDIR)/include/linux/modversions.h: 195 @echo "#include <linux/modsetver.h>" > $@ 196 197endif # CONFIG_MODVERSIONS 198 199ifneq "$(strip $(SYMTAB_OBJS))" "" 200$(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c) 201 $(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c) 202endif 203 204endif # CONFIG_MODULES 205 206 207# 208# include dependency files they exist 209# 210ifeq (.depend,$(wildcard .depend)) 211include .depend 212endif 213 214ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend)) 215include $(TOPDIR)/.hdepend 216endif 217

