Move makefile hierarchy to debian/rules.d; use debian/build for output only

By passing both -C and -f options to make, we can separate makefiles
from the output directory without adding prefixes to all targets.

We can also reduce the 'clean' commands to little more than 'rm -rf'.
This commit is contained in:
Ben Hutchings 2016-02-19 20:05:58 +00:00
parent e1fd4b6f1e
commit 0033746862
38 changed files with 62 additions and 106 deletions

1
debian/.gitignore vendored
View File

@ -8,6 +8,7 @@
.#*
/*.substvars
/*-tmp/
/build/
/control
/control.md5sum
/files

View File

@ -1,3 +0,0 @@
*.o
/include/
out/

View File

@ -1,7 +0,0 @@
*.hash.c
*.lex.c
*.tab.[ch]
/conmakehash
/kallsyms
/pnmtologo
/recordmcount

View File

@ -1,2 +0,0 @@
/bin2c
/fixdep

View File

@ -1,5 +0,0 @@
PROGS = \
bin2c \
fixdep
include ../../Makefile.inc

View File

@ -1 +0,0 @@
/genksyms

View File

@ -1 +0,0 @@
/conf

View File

@ -1,4 +0,0 @@
/modpost
/modpost.h
/modpost.real-*
devicetable-offsets.[hs]

View File

@ -1,22 +0,0 @@
PROGS = \
modpost \
modpost.real-lsb-32 \
modpost.real-lsb-64 \
modpost.real-msb-32 \
modpost.real-msb-64
include ../../Makefile.inc
modpost.real-%:
$(MAKE) -f Makefile.real TYPE=$* SOURCEDIR=$(top_srcdir)/scripts/mod
%: %.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
modpost.h: $(top_srcdir)/scripts/mod/modpost.c
python ./gendef.py $< > $@
modpost.o: modpost.c modpost.h
clean:
rm -f modpost.h real-*/devicetable-offsets.*

View File

@ -1 +0,0 @@
/hv_*_daemon

5
debian/rules vendored
View File

@ -40,8 +40,9 @@ maintainerclean:
clean: debian/control
dh_testdir
$(MAKE) -C $(BUILD_DIR) clean top_srcdir=$(CURDIR) OUTDIR=.
rm -rf $(STAMPS_DIR) debian/lib/python/debian_linux/__pycache__ debian/*-tmp
mkdir -p $(BUILD_DIR)
$(MAKE) -C $(BUILD_DIR) -f $(CURDIR)/debian/rules.d/Makefile top_srcdir=$(CURDIR) top_rulesdir=$(CURDIR)/debian/rules.d OUTDIR=. clean
rm -rf $(STAMPS_DIR) $(BUILD_DIR) debian/lib/python/debian_linux/__pycache__ debian/*-tmp
dh_clean
binary-indep:

View File

@ -6,14 +6,11 @@ SUBDIRS = \
scripts \
tools
include Makefile.inc
include $(top_rulesdir)/Makefile.inc
# Build userland headers first
unexport VERSION
all-local:
$(MAKE) -C $(top_srcdir) O=$(CURDIR)/out \
$(MAKE) -C $(top_srcdir) O=$(CURDIR) \
INSTALL_HDR_PATH=$(CURDIR) headers_install
all-recursive: all-local
clean-local::
rm -rf generated include out

View File

@ -1,5 +1,3 @@
top_srcdir = $(dir $(lastword $(MAKEFILE_LIST)))/../..
# Normalise OUTDIR to avoid triggering rebuilds
override OUTDIR := $(patsubst ./%,%,$(OUTDIR))
@ -17,22 +15,19 @@ CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) -Wall
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
all: all-local all-recursive
clean: clean-local clean-recursive
clean: clean-recursive
install: install-local install-recursive
%-recursive:
+@list='$(SUBDIRS)'; \
for subdir in $$list; do \
echo "Making $* in $$subdir"; \
$(MAKE) -C $$subdir OUTDIR=$(OUTDIR)/$$subdir $* \
|| exit 1; \
mkdir -p $$subdir; \
$(MAKE) -C $$subdir -f $(top_rulesdir)/$(OUTDIR)/$$subdir/Makefile OUTDIR=$(OUTDIR)/$$subdir $*; \
done
all-local: $(PROGS)
clean-local::
rm -f $(PROGS) *.o
install-local: install-local-progs install-local-scripts install-local-data
install-local-progs: $(PROGS)

View File

@ -44,6 +44,6 @@ SUBDIRS = \
kconfig \
mod
include ..//Makefile.inc
include $(top_rulesdir)/Makefile.inc
CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64

5
debian/rules.d/scripts/basic/Makefile vendored Normal file
View File

@ -0,0 +1,5 @@
PROGS = \
bin2c \
fixdep
include $(top_rulesdir)/Makefile.inc

View File

@ -1,6 +1,6 @@
PROGS = genksyms
include ../../Makefile.inc
include $(top_rulesdir)/Makefile.inc
genksyms: genksyms.o parse.tab.o lex.lex.o
@ -11,6 +11,3 @@ lex.lex.o: keywords.hash.c parse.tab.h
%.h: %.h_shipped
ln -s $< $@
clean:
rm -f keywords.hash.c parse.tab.c parse.tab.h

View File

@ -1,6 +1,6 @@
PROGS = conf
include ../../Makefile.inc
include $(top_rulesdir)/Makefile.inc
conf: conf.o zconf.tab.o
@ -11,6 +11,3 @@ zconf.tab.c: zconf.hash.c zconf.lex.c
%.h: %.h_shipped
ln -sf $< $@
clean:
rm -f zconf.tab.c zconf.hash.c zconf.lex.c

22
debian/rules.d/scripts/mod/Makefile vendored Normal file
View File

@ -0,0 +1,22 @@
PROGS = \
modpost \
modpost.real-lsb-32 \
modpost.real-lsb-64 \
modpost.real-msb-32 \
modpost.real-msb-64
include $(top_rulesdir)/Makefile.inc
wrapperdir = $(top_rulesdir)/$(OUTDIR)
modpost.real-%:
$(MAKE) -f $(wrapperdir)/Makefile.real TYPE=$* SOURCEDIR=$(top_srcdir)/scripts/mod
%: %.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
modpost-opts.h: $(top_srcdir)/scripts/mod/modpost.c
python $(wrapperdir)/gendef.py $< > $@
modpost.o: $(wrapperdir)/modpost.c modpost-opts.h
$(CC) $(CFLAGS) -I $(CURDIR) -c -o $@ $<

View File

@ -1,17 +1,19 @@
PROGS = modpost.real-$(TYPE)
top_srcdir = ../..
include $(top_rulesdir)/Makefile.inc
include $(top_srcdir)/debian/build/Makefile.inc
wrapperdir = $(top_rulesdir)/$(OUTDIR)
CFLAGS += -I $(CURDIR)/real-$(TYPE) -I $(wrapperdir)/real-$(TYPE)
modpost.real-$(TYPE): file2alias.real-$(TYPE).o modpost.real-$(TYPE).o sumversion.real-$(TYPE).o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
%.real-$(TYPE).o: $(SOURCEDIR)/%.c real-$(TYPE)/devicetable-offsets.h
$(CC) -I real-$(TYPE) $(CFLAGS) -c -o $@ $<
$(CC) $(CFLAGS) -c -o $@ $<
real-$(TYPE)/devicetable-offsets.s: $(SOURCEDIR)/devicetable-offsets.c
$(CC) -include real-$(TYPE)/types.h $(CFLAGS) -nostdinc -I$(top_srcdir)/include -S -o $@ $<
mkdir -p real-$(TYPE)
$(CC) -include $(wrapperdir)/real-$(TYPE)/types.h $(CFLAGS) -nostdinc -I$(top_srcdir)/include -S -o $@ $<
real-$(TYPE)/devicetable-offsets.h: real-$(TYPE)/devicetable-offsets.s
echo >$@ "#define __DEVICEVTABLE_OFFSETS_H__"

View File

@ -6,7 +6,7 @@
#include <string.h>
#include <unistd.h>
#include "modpost.h"
#include "modpost-opts.h"
int main (int argc, char *argv[])
{

View File

@ -4,4 +4,4 @@ SUBDIRS = \
perf \
usb/usbip
include ../Makefile.inc
include $(top_rulesdir)/Makefile.inc

View File

@ -5,7 +5,7 @@ PROGS = \
prefix = /usr/sbin
include ../../Makefile.inc
include $(top_rulesdir)/Makefile.inc
install-local-progs: $(PROGS)
@for p in $^; do \

View File

@ -1,8 +1,8 @@
include ../../../Makefile.inc
include $(top_rulesdir)/Makefile.inc
DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
MAKE_LOCKDEP := $(MAKE) -C $(top_srcdir)/$(OUTDIR) O=$(CURDIR)/out V=1 \
MAKE_LOCKDEP := $(MAKE) -C $(top_srcdir)/$(OUTDIR) O=$(CURDIR) V=1 \
prefix=/usr libdir_relative=lib/$(DEB_HOST_MULTIARCH) \
LIBLOCKDEP_VERSION=$(VERSION) \
CONFIG_FLAGS='$(CFLAGS) $(filter -D%,$(CPPFLAGS))' LDFLAGS='$(LDFLAGS)'
@ -10,7 +10,6 @@ MAKE_LOCKDEP := $(MAKE) -C $(top_srcdir)/$(OUTDIR) O=$(CURDIR)/out V=1 \
unexport CFLAGS
all:
mkdir -p out
$(MAKE_LOCKDEP)
install:
@ -19,6 +18,3 @@ install:
cp -R $(top_srcdir)/$(OUTDIR)/include/liblockdep $(DESTDIR)/usr/include/
ln -s liblockdep.so.$(VERSION) \
$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/liblockdep.so
clean:
rm -rf out

View File

@ -1,4 +1,4 @@
include ../../Makefile.inc
include $(top_rulesdir)/Makefile.inc
DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
@ -27,7 +27,7 @@ else ifneq ($(filter amd64 i386,$(DEB_HOST_ARCH_CPU)),)
endif
endif
MAKE_PERF := $(MAKE) prefix=/usr V=1 ARCH=$(KERNEL_ARCH_PERF) EXTRA_WARNINGS=-Wno-error EXTRA_CFLAGS='$(CFLAGS) $(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
MAKE_PERF := $(MAKE) O=$(CURDIR) prefix=/usr V=1 ARCH=$(KERNEL_ARCH_PERF) EXTRA_WARNINGS=-Wno-error EXTRA_CFLAGS='$(CFLAGS) $(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
# Disable Gtk UI until it's more usable
MAKE_PERF += NO_GTK2=1
@ -43,22 +43,21 @@ MAKE_PERF += feature-libbfd=0 HAVE_CPLUS_DEMANGLE_SUPPORT=1
all:
ifdef KERNEL_ARCH_PERF
-mkdir out
# perf changes some default directories depending on whether DESTDIR is
# set. We must define it even when building to avoid a rebuild when we
# run 'make install'.
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf -f Makefile.perf O=$(CURDIR)/out all VERSION=$(VERSION) DESTDIR=dummy
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf/Documentation O=$(CURDIR)/out man VERSION=$(VERSION)
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf -f Makefile.perf all VERSION=$(VERSION) DESTDIR=dummy
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf/Documentation man VERSION=$(VERSION)
# Check that perf didn't get linked against libbfd
type ldd
! ldd $(CURDIR)/out/perf | grep '\blibbfd'
! ldd $(CURDIR)/perf | grep '\blibbfd'
# Check that it includes cplus_demangle from libiberty
grep cplus_demangle $(CURDIR)/out/perf
grep cplus_demangle $(CURDIR)/perf
endif
install:
ifdef KERNEL_ARCH_PERF
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf -f Makefile.perf O=$(CURDIR)/out install VERSION=$(VERSION)
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf -f Makefile.perf install VERSION=$(VERSION)
# Don't install a 'trace' alias yet:
# - We need a wrapper for it anyway, so there's little point adding a
# versioned link
@ -71,10 +70,3 @@ endif
mv $(DESTDIR)/etc/bash_completion.d \
$(DESTDIR)/usr/share/bash-completion/completions
rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc
clean:
ifdef KERNEL_ARCH_PERF
mkdir -p out
+$(MAKE_PERF) -C $(top_srcdir)/tools/perf -f Makefile.perf O=$(CURDIR)/out clean
rm -rf out
endif

View File

@ -7,19 +7,16 @@ unexport MAKEFLAGS
all:
cd $(srcdir) && ./autogen.sh
mkdir -p out
cd out && \
$(shell dpkg-buildflags --export=cmdline) $(srcdir)/configure \
--prefix=/usr \
--with-tcp-wrappers \
--with-usbids-dir=/usr/share/misc \
--disable-shared
$(MAKE) -C out
$(MAKE)
install:
$(MAKE) -C out install
$(MAKE) install
clean:
rm -rf $(addprefix $(srcdir)/,autom4te.cache aclocal.m4 compile config.guess config.h.in config.sub configure depcomp install-sh ltmain.sh missing)
find $(srcdir)/ -name Makefile.in -delete
rm -rf out

6
debian/rules.real vendored
View File

@ -4,7 +4,7 @@ export KBUILD_BUILD_TIMESTAMP := $(shell dpkg-parsechangelog | sed -ne 's,^Date:
include debian/rules.defs
define submake
+$(MAKE) -C $(BUILD_DIR)/$(1) top_srcdir=$(CURDIR) OUTDIR=$(1)
+mkdir -p $(BUILD_DIR)/$(1) && $(MAKE) -C $(BUILD_DIR)/$(1) -f $(CURDIR)/debian/rules.d/$(1)/Makefile top_srcdir=$(CURDIR) top_rulesdir=$(CURDIR)/debian/rules.d OUTDIR=$(1)
endef
binary-arch: install-kbuild install-usbip install-liblockdep
@ -70,7 +70,7 @@ install-perf: $(STAMPS_DIR)/build
install-usbip: DH_OPTIONS = -plibusbip-dev -pusbip
install-usbip: DIR = $(CURDIR)/debian/usbip-tmp
install-usbip: override VERSION := $(shell sed -ne 's,^#define PACKAGE_VERSION "\(.*\)"$$,\1,p' $(BUILD_DIR)/tools/usb/usbip/out/config.h)
install-usbip: override VERSION := $(shell sed -ne 's,^#define PACKAGE_VERSION "\(.*\)"$$,\1,p' $(BUILD_DIR)/tools/usb/usbip/config.h)
install-usbip: $(STAMPS_DIR)/build
dh_testdir
dh_testroot
@ -145,7 +145,7 @@ install-lockdep:
dh_prep
dh_installdirs
# Upstream lockdep preload script is not suitable for installation
sed 's/@VERSION@/$(VERSION)/' $(BUILD_DIR)/tools/lib/lockdep/lockdep.in \
sed 's/@VERSION@/$(VERSION)/' debian/rules.d/tools/lib/lockdep/lockdep.in \
> $(DIR)/usr/bin/lockdep
chmod 755 $(DIR)/usr/bin/lockdep
dh_installchangelogs