OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [Rules.make] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#
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
#
13
unexport EXTRA_AFLAGS
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 ALL_MOBJS
23
 
24
unexport obj-y
25
unexport obj-m
26
unexport obj-n
27
unexport obj-
28
unexport export-objs
29
unexport subdir-y
30
unexport subdir-m
31
unexport subdir-n
32
unexport subdir-
33
 
34
comma   := ,
35
EXTRA_CFLAGS_nostdinc := $(EXTRA_CFLAGS) $(kbuild_2_4_nostdinc)
36
 
37
#
38
# Get things started.
39
#
40
first_rule: sub_dirs
41
        $(MAKE) all_targets
42
 
43
both-m          := $(filter $(mod-subdirs), $(subdir-y))
44
SUB_DIRS        := $(subdir-y)
45
MOD_SUB_DIRS    := $(sort $(subdir-m) $(both-m))
46
ALL_SUB_DIRS    := $(sort $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-))
47
 
48
 
49
#
50
# Common rules
51
#
52
 
53
%.s: %.c
54
        $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -S $< -o $@
55
 
56
%.i: %.c
57
        $(CPP) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) $< > $@
58
 
59
%.o: %.c
60
        $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
61
        @ ( \
62
            echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS_nostdinc) $$(CFLAGS_$@))))' ; \
63
            echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
64
            echo 'endif' \
65
        ) > $(dir $@)/.$(notdir $@).flags
66
 
67
%.o: %.s
68
        $(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
69
 
70
# Old makefiles define their own rules for compiling .S files,
71
# but these standard rules are available for any Makefile that
72
# wants to use them.  Our plan is to incrementally convert all
73
# the Makefiles to these standard rules.  -- rmk, mec
74
ifdef USE_STANDARD_AS_RULE
75
 
76
%.s: %.S
77
        $(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
78
 
79
%.o: %.S
80
        $(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
81
 
82
endif
83
 
84
%.lst: %.c
85
        $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$@) -g -c -o $*.o $<
86
        $(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
87
#
88
#
89
#
90
all_targets: $(O_TARGET) $(L_TARGET)
91
 
92
#
93
# Rule to compile a set of .o files into one .o file
94
#
95
ifdef O_TARGET
96
$(O_TARGET): $(obj-y)
97
        rm -f $@
98
    ifneq "$(strip $(obj-y))" ""
99
        $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
100
    else
101
        $(AR) rcs $@
102
    endif
103
        @ ( \
104
            echo 'ifeq ($(strip $(subst $(comma),:,$(LDFLAGS) $(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(LDFLAGS) $$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
105
            echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
106
            echo 'endif' \
107
        ) > $(dir $@)/.$(notdir $@).flags
108
endif # O_TARGET
109
 
110
#
111
# Rule to compile a set of .o files into one .a file
112
#
113
ifdef L_TARGET
114
$(L_TARGET): $(obj-y)
115
        rm -f $@
116
        $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
117
        @ ( \
118
            echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
119
            echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
120
            echo 'endif' \
121
        ) > $(dir $@)/.$(notdir $@).flags
122
endif
123
 
124
 
125
#
126
# This make dependencies quickly
127
#
128
fastdep: dummy
129
        $(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- $(wildcard *.[chS]) > .depend
130
ifdef ALL_SUB_DIRS
131
        $(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
132
endif
133
 
134
ifdef _FASTDEP_ALL_SUB_DIRS
135
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
136
        $(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
137
endif
138
 
139
 
140
#
141
# A rule to make subdirectories
142
#
143
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
144
sub_dirs: dummy $(subdir-list)
145
 
146
ifdef SUB_DIRS
147
$(subdir-list) : dummy
148
        $(MAKE) -C $(patsubst _subdir_%,%,$@)
149
endif
150
 
151
#
152
# A rule to make modules
153
#
154
ALL_MOBJS = $(filter-out $(obj-y), $(obj-m))
155
ifneq "$(strip $(ALL_MOBJS))" ""
156
MOD_DESTDIR := $(shell $(CONFIG_SHELL) $(TOPDIR)/scripts/pathdown.sh)
157
endif
158
 
159
unexport MOD_DIRS
160
MOD_DIRS := $(MOD_SUB_DIRS) $(MOD_IN_SUB_DIRS)
161
ifneq "$(strip $(MOD_DIRS))" ""
162
.PHONY: $(patsubst %,_modsubdir_%,$(MOD_DIRS))
163
$(patsubst %,_modsubdir_%,$(MOD_DIRS)) : dummy
164
        $(MAKE) -C $(patsubst _modsubdir_%,%,$@) modules
165
 
166
.PHONY: $(patsubst %,_modinst_%,$(MOD_DIRS))
167
$(patsubst %,_modinst_%,$(MOD_DIRS)) : dummy
168
        $(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
169
endif
170
 
171
.PHONY: modules
172
modules: $(ALL_MOBJS) dummy \
173
         $(patsubst %,_modsubdir_%,$(MOD_DIRS))
174
 
175
.PHONY: _modinst__
176
_modinst__: dummy
177
ifneq "$(strip $(ALL_MOBJS))" ""
178
        mkdir -p $(MODLIB)/kernel/$(MOD_DESTDIR)
179
        cp $(sort $(ALL_MOBJS)) $(MODLIB)/kernel/$(MOD_DESTDIR)
180
endif
181
 
182
.PHONY: modules_install
183
modules_install: _modinst__ \
184
         $(patsubst %,_modinst_%,$(MOD_DIRS))
185
 
186
#
187
# A rule to do nothing
188
#
189
dummy:
190
 
191
#
192
# This is useful for testing
193
#
194
script:
195
        $(SCRIPT)
196
 
197
#
198
# This sets version suffixes on exported symbols
199
# Separate the object into "normal" objects and "exporting" objects
200
# Exporting objects are: all objects that define symbol tables
201
#
202
ifdef CONFIG_MODULES
203
 
204
multi-used      := $(filter $(list-multi), $(obj-y) $(obj-m))
205
multi-objs      := $(foreach m, $(multi-used), $($(basename $(m))-objs))
206
active-objs     := $(sort $(multi-objs) $(obj-y) $(obj-m))
207
 
208
ifdef CONFIG_MODVERSIONS
209
ifneq "$(strip $(export-objs))" ""
210
 
211
MODINCL = $(TOPDIR)/include/linux/modules
212
 
213
# The -w option (enable warnings) for genksyms will return here in 2.1
214
# So where has it gone?
215
#
216
# Added the SMP separator to stop module accidents between uniprocessor
217
# and SMP Intel boxes - AC - from bits by Michael Chastain
218
#
219
 
220
ifdef CONFIG_SMP
221
        genksyms_smp_prefix := -p smp_
222
else
223
        genksyms_smp_prefix :=
224
endif
225
 
226
$(MODINCL)/%.ver: %.c
227
        @if [ ! -r $(MODINCL)/$*.stamp -o $(MODINCL)/$*.stamp -ot $< ]; then \
228
                echo '$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -E -D__GENKSYMS__ $<'; \
229
                echo '| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
230
                $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -E -D__GENKSYMS__ $< \
231
                | $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp; \
232
                if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; rm -f $@.tmp; \
233
                else echo mv $@.tmp $@; mv -f $@.tmp $@; fi; \
234
        fi; touch $(MODINCL)/$*.stamp
235
 
236
$(addprefix $(MODINCL)/,$(export-objs:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
237
 
238
# updates .ver files but not modversions.h
239
fastdep: $(addprefix $(MODINCL)/,$(export-objs:.o=.ver))
240
 
241
# updates .ver files and modversions.h like before (is this needed?)
242
dep: fastdep update-modverfile
243
 
244
endif # export-objs
245
 
246
# update modversions.h, but only if it would change
247
update-modverfile:
248
        @(echo "#ifndef _LINUX_MODVERSIONS_H";\
249
          echo "#define _LINUX_MODVERSIONS_H"; \
250
          echo "#include "; \
251
          cd $(TOPDIR)/include/linux/modules; \
252
          for f in *.ver; do \
253
            if [ -f $$f ]; then echo "#include "; fi; \
254
          done; \
255
          echo "#endif"; \
256
        ) > $(TOPDIR)/include/linux/modversions.h.tmp
257
        @if [ -r $(TOPDIR)/include/linux/modversions.h ] && cmp -s $(TOPDIR)/include/linux/modversions.h $(TOPDIR)/include/linux/modversions.h.tmp; then \
258
                echo $(TOPDIR)/include/linux/modversions.h was not updated; \
259
                rm -f $(TOPDIR)/include/linux/modversions.h.tmp; \
260
        else \
261
                echo $(TOPDIR)/include/linux/modversions.h was updated; \
262
                mv -f $(TOPDIR)/include/linux/modversions.h.tmp $(TOPDIR)/include/linux/modversions.h; \
263
        fi
264
 
265
$(active-objs): $(TOPDIR)/include/linux/modversions.h
266
 
267
else
268
 
269
$(TOPDIR)/include/linux/modversions.h:
270
        @echo "#include " > $@
271
 
272
endif # CONFIG_MODVERSIONS
273
 
274
ifneq "$(strip $(export-objs))" ""
275
$(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h
276
        $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
277
        @ ( \
278
            echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS_nostdinc) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
279
            echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
280
            echo 'endif' \
281
        ) > $(dir $@)/.$(notdir $@).flags
282
endif
283
 
284
endif # CONFIG_MODULES
285
 
286
 
287
#
288
# include dependency files if they exist
289
#
290
ifneq ($(wildcard .depend),)
291
include .depend
292
endif
293
 
294
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
295
include $(TOPDIR)/.hdepend
296
endif
297
 
298
#
299
# Find files whose flags have changed and force recompilation.
300
# For safety, this works in the converse direction:
301
#   every file is forced, except those whose flags are positively up-to-date.
302
#
303
FILES_FLAGS_UP_TO_DATE :=
304
 
305
# For use in expunging commas from flags, which mung our checking.
306
comma = ,
307
 
308
FILES_FLAGS_EXIST := $(wildcard .*.flags)
309
ifneq ($(FILES_FLAGS_EXIST),)
310
include $(FILES_FLAGS_EXIST)
311
endif
312
 
313
FILES_FLAGS_CHANGED := $(strip \
314
    $(filter-out $(FILES_FLAGS_UP_TO_DATE), \
315
        $(O_TARGET) $(L_TARGET) $(active-objs) \
316
        ))
317
 
318
# A kludge: .S files don't get flag dependencies (yet),
319
#   because that will involve changing a lot of Makefiles.  Also
320
#   suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
321
#   This allows handling of assembly files that get translated into
322
#   multiple object files (see arch/ia64/lib/idiv.S, for example).
323
FILES_FLAGS_CHANGED := $(strip \
324
    $(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
325
    $(FILES_FLAGS_CHANGED)))
326
 
327
ifneq ($(FILES_FLAGS_CHANGED),)
328
$(FILES_FLAGS_CHANGED): dummy
329
endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.