Import 2.1.28pre1
[davej-history.git] / Rules.make
blob87a0d671dec7f223cb0b7b7f37a428d86c420863
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 unexport ALL_MOBJS
26 # objects that export symbol tables
27 unexport OX_OBJS
28 unexport LX_OBJS
29 unexport MX_OBJS
30 unexport SYMTAB_OBJS
32 unexport MOD_LIST_NAME
35 # Get things started.
37 first_rule: sub_dirs
38 $(MAKE) all_targets
41 # Common rules
44 %.s: %.c
45 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -S $< -o $@
47 %.o: %.c
48 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
50 %.o: %.s
51 $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $<
56 all_targets: $(O_TARGET) $(L_TARGET)
59 # Rule to compile a set of .o files into one .o file
61 ifdef O_TARGET
62 ALL_O = $(OX_OBJS) $(O_OBJS)
63 $(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h
64 rm -f $@
65 ifneq "$(strip $(ALL_O))" ""
66 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
67 else
68 $(AR) rcs $@
69 endif
70 endif # O_TARGET
73 # Rule to compile a set of .o files into one .a file
75 ifdef 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)
79 endif
82 # This make dependencies quickly
84 fastdep: dummy
85 if [ -n "$(wildcard *.[chS])" ]; then \
86 $(TOPDIR)/scripts/mkdep *.[chS] > .depend; fi
87 ifdef ALL_SUB_DIRS
88 set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
89 endif
92 # A rule to make subdirectories
94 sub_dirs: dummy
95 ifdef SUB_DIRS
96 set -e; for i in $(SUB_DIRS); do $(MAKE) -C $$i; done
97 endif
100 # A rule to make modules
102 ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
103 ifneq "$(strip $(ALL_MOBJS))" ""
104 PDWN=$(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
105 endif
106 modules: $(ALL_MOBJS) dummy
107 ifdef MOD_SUB_DIRS
108 set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done
109 endif
110 ifdef MOD_IN_SUB_DIRS
111 set -e; for i in $(MOD_IN_SUB_DIRS); do $(MAKE) -C $$i modules; done
112 endif
113 ifneq "$(strip $(MOD_LIST_NAME))" ""
114 rm -f $$TOPDIR/modules/$(MOD_LIST_NAME)
115 ifdef MOD_SUB_DIRS
116 for i in $(MOD_SUB_DIRS); do \
117 echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done
118 endif
119 ifneq "$(strip $(ALL_MOBJS))" ""
120 echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
121 endif
122 ifneq "$(strip $(MOD_TO_LIST))" ""
123 echo $(MOD_TO_LIST) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
124 endif
125 endif
126 ifneq "$(strip $(ALL_MOBJS))" ""
127 echo $(PDWN)
128 cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
129 ln -sf ../$(PDWN)/$$i .; done
130 endif
133 # A rule to do nothing
135 dummy:
138 # This is useful for testing
140 script:
141 $(SCRIPT)
144 # This sets version suffixes on exported symbols
145 # Uses SYMTAB_OBJS
146 # Separate the object into "normal" objects and "exporting" objects
147 # Exporting objects are: all objects that define symbol tables
149 ifdef CONFIG_MODULES
151 SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS)
153 ifdef CONFIG_MODVERSIONS
154 ifneq "$(strip $(SYMTAB_OBJS))" ""
156 MODINCL = $(TOPDIR)/include/linux/modules
158 # The -w option (enable warnings) for genksyms will return here in 2.1
159 $(MODINCL)/%.ver: %.c
160 $(CC) $(CFLAGS) -E -D__GENKSYMS__ $<\
161 | $(GENKSYMS) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp
162 mv $@.tmp $@
164 $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
166 $(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
167 @echo updating $(TOPDIR)/include/linux/modversions.h
168 @(echo "#ifndef _LINUX_MODVERSIONS_H";\
169 echo "#define _LINUX_MODVERSIONS_H"; \
170 echo "#include <linux/modsetver.h>"; \
171 cd $(TOPDIR)/include/linux/modules; \
172 for f in *.ver; do \
173 if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \
174 done; \
175 echo "#endif"; \
176 ) > $@
178 dep fastdep: $(TOPDIR)/include/linux/modversions.h
180 endif # SYMTAB_OBJS
182 $(M_OBJS): $(TOPDIR)/include/linux/modversions.h
183 ifdef MAKING_MODULES
184 $(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h
185 endif
187 else
189 $(TOPDIR)/include/linux/modversions.h:
190 @echo "#include <linux/modsetver.h>" > $@
192 endif # CONFIG_MODVERSIONS
194 ifneq "$(strip $(SYMTAB_OBJS))" ""
195 $(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h
196 $(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c)
197 endif
199 endif # CONFIG_MODULES
203 # include dependency files they exist
205 ifeq (.depend,$(wildcard .depend))
206 include .depend
207 endif
209 ifeq ($(TOPDIR)/.hdepend,$(wildcard $(TOPDIR)/.hdepend))
210 include $(TOPDIR)/.hdepend
211 endif