Import 2.1.46
[davej-history.git] / Rules.make
blob87845cb40215ead4160759d664bf6aa42e70672b
2 # This file contains rules which are shared between multiple Makefiles.
6 # False targets.
8 .PHONY: dummy
11 # Special variables which should not be exported
13 unexport EXTRA_ASFLAGS
14 unexport EXTRA_CFLAGS
15 unexport EXTRA_LDFLAGS
16 unexport EXTRA_ARFLAGS
17 unexport SUBDIRS
18 unexport SUB_DIRS
19 unexport ALL_SUB_DIRS
20 unexport MOD_SUB_DIRS
21 unexport O_TARGET
22 unexport O_OBJS
23 unexport L_OBJS
24 unexport M_OBJS
25 # intermediate objects that form part of a module
26 unexport MI_OBJS
27 unexport ALL_MOBJS
28 # objects that export symbol tables
29 unexport OX_OBJS
30 unexport LX_OBJS
31 unexport MX_OBJS
32 unexport MIX_OBJS
33 unexport SYMTAB_OBJS
35 unexport MOD_LIST_NAME
38 # Get things started.
40 first_rule: sub_dirs
41 $(MAKE) all_targets
44 # Common rules
47 %.s: %.c
48 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@
50 %.i: %.c
51 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E $< > $@
53 %.o: %.c
54 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
56 %.o: %.s
57 $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $<
62 all_targets: $(O_TARGET) $(L_TARGET)
65 # Rule to compile a set of .o files into one .o file
67 ifdef O_TARGET
68 ALL_O = $(OX_OBJS) $(O_OBJS)
69 $(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h
70 rm -f $@
71 ifneq "$(strip $(ALL_O))" ""
72 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
73 else
74 $(AR) rcs $@
75 endif
76 endif # O_TARGET
79 # Rule to compile a set of .o files into one .a file
81 ifdef 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)
85 endif
88 # This make dependencies quickly
90 fastdep: dummy
91 $(TOPDIR)/scripts/mkdep *.[chS] > .depend
92 ifdef ALL_SUB_DIRS
93 set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
94 endif
97 # A rule to make subdirectories
99 sub_dirs: dummy
100 ifdef SUB_DIRS
101 set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done
102 endif
105 # A rule to make modules
107 ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
108 ifneq "$(strip $(ALL_MOBJS))" ""
109 PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
110 endif
111 modules: $(ALL_MOBJS) $(MIX_OBJS) $(MI_OBJS) dummy
112 ifdef MOD_SUB_DIRS
113 set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done
114 endif
115 ifdef MOD_IN_SUB_DIRS
116 set -e; for i in $(MOD_IN_SUB_DIRS); do $(MAKE) -C $$i modules; done
117 endif
118 ifneq "$(strip $(MOD_LIST_NAME))" ""
119 rm -f $$TOPDIR/modules/$(MOD_LIST_NAME)
120 ifdef MOD_SUB_DIRS
121 for i in $(MOD_SUB_DIRS); do \
122 echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done
123 endif
124 ifneq "$(strip $(ALL_MOBJS))" ""
125 echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
126 endif
127 ifneq "$(strip $(MOD_TO_LIST))" ""
128 echo $(MOD_TO_LIST) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
129 endif
130 endif
131 ifneq "$(strip $(ALL_MOBJS))" ""
132 echo $(PDWN)
133 cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
134 ln -sf ../$(PDWN)/$$i .; done
135 endif
138 # A rule to do nothing
140 dummy:
143 # This is useful for testing
145 script:
146 $(SCRIPT)
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
154 ifdef CONFIG_MODULES
156 SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS) $(MIX_OBJS)
158 ifdef CONFIG_MODVERSIONS
159 ifneq "$(strip $(SYMTAB_OBJS))" ""
161 MODINCL = $(TOPDIR)/include/linux/modules
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 $@
169 $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
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 ) > $@
183 dep fastdep: $(TOPDIR)/include/linux/modversions.h
185 endif # SYMTAB_OBJS
187 $(M_OBJS): $(TOPDIR)/include/linux/modversions.h
188 ifdef MAKING_MODULES
189 $(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h
190 endif
192 else
194 $(TOPDIR)/include/linux/modversions.h:
195 @echo "#include <linux/modsetver.h>" > $@
197 endif # CONFIG_MODVERSIONS
199 ifneq "$(strip $(SYMTAB_OBJS))" ""
200 $(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c)
201 $(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c)
202 endif
204 endif # CONFIG_MODULES
208 # include dependency files they exist
210 ifeq (.depend,$(wildcard .depend))
211 include .depend
212 endif
214 ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend))
215 include $(TOPDIR)/.hdepend
216 endif