Commit 99fd37ec authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Introduce $(obj), $(src)

For separate source and object directories, Rules.make needs
to know where the files live.

For all the normal variables, $(obj-[ymn]) etc, it can figure that
out by itself, but for explicit rules to generate files it needs
help. 

So there $(obj)/target.o indicates that this file lives in the 
object directory, as opposed to $(src)/target.c, which lives in
the source dir.

For now $(obj) = $(src) = ., but convert some Makefiles to it
already.
parent ba7bf6a2
...@@ -549,6 +549,7 @@ CLEAN_FILES += \ ...@@ -549,6 +549,7 @@ CLEAN_FILES += \
drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c \ drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c \
drivers/char/conmakehash \ drivers/char/conmakehash \
drivers/char/drm/*-mod.c \ drivers/char/drm/*-mod.c \
drivers/char/defkeymap.c drivers/char/qtronixmap.c \
drivers/pci/devlist.h drivers/pci/classlist.h drivers/pci/gen-devlist \ drivers/pci/devlist.h drivers/pci/classlist.h drivers/pci/gen-devlist \
drivers/zorro/devlist.h drivers/zorro/gen-devlist \ drivers/zorro/devlist.h drivers/zorro/gen-devlist \
sound/oss/bin2hex sound/oss/hex2hex \ sound/oss/bin2hex sound/oss/hex2hex \
......
...@@ -22,6 +22,30 @@ else ...@@ -22,6 +22,30 @@ else
TOPDIR_REL := $(subst $(space),,$(foreach d,$(subst /, ,$(RELDIR)),../)) TOPDIR_REL := $(subst $(space),,$(foreach d,$(subst /, ,$(RELDIR)),../))
endif endif
# Some paths for the Makefiles to use
# ---------------------------------------------------------------------------
# Usage:
#
# $(obj)/target.o : target.o in the build dir
# $(src)/target.c : target.c in the source dir
# $(objtree)/include/linux/version.h : Some file relative to the build
# dir root
# $(srctree)/include/linux/module.h : Some file relative to the source
# dir root
#
# Those can only be used in the section after
# include $(TOPDIR)/Rules.make, i.e for generated files and the like.
# Intentionally.
#
# We don't support separate source / object yet, so these are just
# placeholders for now
obj := .
src := .
objtree := $(TOPDIR)
srctree := $(TOPDIR)
# Figure out what we need to build from the various variables # Figure out what we need to build from the various variables
# =========================================================================== # ===========================================================================
......
...@@ -216,13 +216,11 @@ host-progs := conmakehash ...@@ -216,13 +216,11 @@ host-progs := conmakehash
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
consolemap_deftbl.c: $(FONTMAPFILE) conmakehash $(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE) $(obj)/conmakehash
./conmakehash $< > $@ $(obj)/conmakehash $< > $@
.DELETE_ON_ERROR: $(obj)/defkeymap.c: $(src)/defkeymap.map
defkeymap.c: defkeymap.map
set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@ set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@
qtronixmap.c: qtronixmap.map $(obj)/qtronixmap.c: $(src)/qtronixmap.map
set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@ set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@
This diff is collapsed.
...@@ -23,14 +23,14 @@ include $(TOPDIR)/Rules.make ...@@ -23,14 +23,14 @@ include $(TOPDIR)/Rules.make
# Dependencies on generates files need to be listed explicitly # Dependencies on generates files need to be listed explicitly
sm_afsk1200.o: sm_tbl_afsk1200.h $(obj)/sm_afsk1200.o: $(obj)/sm_tbl_afsk1200.h
sm_afsk2400_7.o: sm_tbl_afsk2400_7.h $(obj)/sm_afsk2400_7.o: $(obj)/sm_tbl_afsk2400_7.h
sm_afsk2400_8.o: sm_tbl_afsk2400_8.h $(obj)/sm_afsk2400_8.o: $(obj)/sm_tbl_afsk2400_8.h
sm_afsk2666.o: sm_tbl_afsk2666.h $(obj)/sm_afsk2666.o: $(obj)/sm_tbl_afsk2666.h
sm_psk4800.o: sm_tbl_psk4800.h $(obj)/sm_psk4800.o: $(obj)/sm_tbl_psk4800.h
sm_hapn4800.o: sm_tbl_hapn4800.h $(obj)/sm_hapn4800.o: $(obj)/sm_tbl_hapn4800.h
sm_fsk9600.o: sm_tbl_fsk9600.h $(obj)/sm_fsk9600.o: $(obj)/sm_tbl_fsk9600.h
sm_tbl_%: gentbl $(obj)/sm_tbl_%: $(obj)/gentbl
./gentbl $<
...@@ -34,7 +34,13 @@ host-progs := gen-devlist ...@@ -34,7 +34,13 @@ host-progs := gen-devlist
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
names.o: devlist.h classlist.h # Dependencies on generated files need to be listed explicitly
devlist.h classlist.h: pci.ids gen-devlist $(obj)/names.o: $(obj)/devlist.h $(obj)/classlist.h
./gen-devlist <pci.ids
# And that's how to generate them
$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
$(obj)/gen-devlist < $<
$(obj)/classlist.h: $(obj)/devlist.h
...@@ -122,17 +122,12 @@ obj-$(CONFIG_FBCON_HGA) += fbcon-hga.o ...@@ -122,17 +122,12 @@ obj-$(CONFIG_FBCON_HGA) += fbcon-hga.o
obj-$(CONFIG_FBCON_STI) += fbcon-sti.o obj-$(CONFIG_FBCON_STI) += fbcon-sti.o
obj-$(CONFIG_FBCON_ACCEL) += fbcon-accel.o obj-$(CONFIG_FBCON_ACCEL) += fbcon-accel.o
host-progs := ../conmakehash host-progs := ../char/conmakehash
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
clean: $(obj)/promcon_tbl.c: $(src)/prom.uni $(obj)/../char/conmakehash
rm -f core *.o *.a *.s $(obj)/../char/conmakehash $< | \
promcon_tbl.c: prom.uni ../char/conmakehash
../char/conmakehash prom.uni | \
sed -e '/#include <[^>]*>/p' -e 's/types/init/' \ sed -e '/#include <[^>]*>/p' -e 's/types/init/' \
-e 's/dfont\(_uni.*\]\)/promfont\1 __initdata/' > promcon_tbl.c -e 's/dfont\(_uni.*\]\)/promfont\1 __initdata/' > $@
promcon_tbl.o: promcon_tbl.c $(TOPDIR)/include/linux/types.h
...@@ -11,7 +11,11 @@ host-progs := gen_devlist ...@@ -11,7 +11,11 @@ host-progs := gen_devlist
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
names.o: devlist.h # Dependencies on generated files need to be listed explicitly
devlist.h: zorro.ids gen-devlist $(obj)/names.o: $(obj)/devlist.h
./gen-devlist <zorro.ids
# And that's how to generate them
$(obj)/devlist.h: $(src)/zorro.ids $(obj)/gen-devlist
$(obj)/gen-devlist < $<
...@@ -10,17 +10,13 @@ include $(TOPDIR)/Rules.make ...@@ -10,17 +10,13 @@ include $(TOPDIR)/Rules.make
# dependencies on generated files need to be listed explicitly # dependencies on generated files need to be listed explicitly
version.o: ../include/linux/compile.h $(obj)/version.o: $(objtree)/include/linux/compile.h
# 'make dep' may add a dependency on $(TOPDIR)/include/linux/compile.h
$(TOPDIR)/include/linux/compile.h: ../include/linux/compile.h ;
# compile.h changes depending on hostname, generation number, etc, # compile.h changes depending on hostname, generation number, etc,
# so we regenerate it always. # so we regenerate it always.
# mkcompile_h will make sure to only update the # mkcompile_h will make sure to only update the
# actual file if its content has changed. # actual file if its content has changed.
../include/linux/compile.h: FORCE $(objtree)/include/linux/compile.h: FORCE
@echo -n ' Generating $@' @echo -n ' Generating $@'
@../scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)" @../scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment