build system fixes, more cleanup

SVN-Revision: 8207
This commit is contained in:
Felix Fietkau 2007-07-28 13:29:03 +00:00
parent 9c88ba80b9
commit e143bed1f1
4 changed files with 45 additions and 79 deletions

View file

@ -1,7 +1,6 @@
# Makefile for OpenWrt # Makefile for OpenWrt
# #
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2007 OpenWrt.org
# Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name>
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
@ -9,22 +8,21 @@
all: world all: world
TOPDIR:=${CURDIR} TOPDIR:=${CURDIR}
LC_ALL:=C LC_ALL:=C
LANG:=C LANG:=C
IS_TTY:=${shell tty -s && echo 1 || echo 0} IS_TTY:=${shell tty -s && echo 1 || echo 0}
export TOPDIR LC_ALL LANG IS_TTY export TOPDIR LC_ALL LANG IS_TTY
include rules.mk
ifneq ($(OPENWRT_BUILD),1) ifneq ($(OPENWRT_BUILD),1)
export OPENWRT_BUILD:=1 export OPENWRT_BUILD:=1
include $(INCLUDE_DIR)/toplevel.mk include $(TOPDIR)/include/toplevel.mk
else else
include rules.mk
include $(INCLUDE_DIR)/depends.mk include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk include $(INCLUDE_DIR)/subdir.mk
include tools/Makefile include tools/Makefile
include toolchain/Makefile
clean: FORCE clean: FORCE
rm -rf build_* bin tmp rm -rf build_* bin tmp
@ -38,8 +36,7 @@ distclean: dirclean config-clean symlinkclean docs/clean
toolchain/% package/% target/%: FORCE toolchain/% package/% target/%: FORCE
$(MAKE) -C $(patsubst %/$*,%,$@) $* $(MAKE) -C $(patsubst %/$*,%,$@) $*
world: .config $(tools/stamp) FORCE world: .config $(tools/stamp) $(toolchain/stamp) FORCE
$(MAKE) toolchain/install
$(MAKE) target/compile $(MAKE) target/compile
$(MAKE) package/compile $(MAKE) package/compile
$(MAKE) package/install $(MAKE) package/install

View file

@ -13,6 +13,7 @@ all: world
SHELL:=/usr/bin/env bash SHELL:=/usr/bin/env bash
OPENWRTVERSION:=$(RELEASE) OPENWRTVERSION:=$(RELEASE)
include $(TOPDIR)/include/verbose.mk
ifneq ($(VERSION),) ifneq ($(VERSION),)
OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION)) OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
else else
@ -33,25 +34,25 @@ export SCAN_COOKIE
tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo: tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo:
@mkdir -p tmp/info @mkdir -p tmp/info
@$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA="" @+$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA=""
@$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA="" @+$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA=""
@for type in package target; do \ @for type in package target; do \
f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \ f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
[ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config < "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \ [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config < "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
done done
.config: ./scripts/config/conf prepare-tmpinfo .config: ./scripts/config/conf prepare-tmpinfo
if [ \! -f .config ]; then \ @+if [ \! -f .config ]; then \
[ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \ [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
$(NO_TRACE_MAKE) menuconfig; \ $(NO_TRACE_MAKE) menuconfig QUIET=0 OPENWRT_BUILD=; \
fi fi
$< -D .config Config.in &> /dev/null $< -D .config Config.in &> /dev/null
scripts/config/mconf: scripts/config/mconf:
$(MAKE) -C scripts/config all @+$(MAKE) -C scripts/config all
scripts/config/conf: scripts/config/conf:
$(MAKE) -C scripts/config conf @+$(MAKE) -C scripts/config conf
config: scripts/config/conf prepare-tmpinfo FORCE config: scripts/config/conf prepare-tmpinfo FORCE
$< Config.in $< Config.in
@ -81,24 +82,25 @@ kernel_menuconfig: .config FORCE
tmp/.prereq-build: include/prereq-build.mk tmp/.prereq-build: include/prereq-build.mk
mkdir -p tmp mkdir -p tmp
rm -f tmp/.host.mk rm -f tmp/.host.mk
$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \ @+$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \ echo "Prerequisite check failed. Use FORCE=1 to override."; \
false; \ false; \
} }
touch $@ touch $@
tmp/.prereq-package: tmp/.packageinfo tmp/.prereq-package: tmp/.packageinfo .config
tmp/.prereq-target: tmp/.targetinfo .config tmp/.prereq-target: tmp/.targetinfo .config
tmp/.prereq-package tmp/.prereq-target: include/prereq.mk tmp/.prereq-package tmp/.prereq-target: include/prereq.mk
mkdir -p tmp mkdir -p tmp
rm -f tmp/.host.mk rm -f tmp/.host.mk
$(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \ @+$(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \ echo "Prerequisite check failed. Use FORCE=1 to override."; \
false; \ false; \
} }
touch $@ touch $@
prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE ; prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE
@true
download: .config FORCE download: .config FORCE
$(MAKE) -j1 tools/download $(MAKE) -j1 tools/download
@ -111,7 +113,7 @@ clean dirclean distclean:
%:: %::
@$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD= @$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD=
@$(MAKE) $@ @+$(MAKE) $@
help: help:
cat README cat README

View file

@ -1,63 +1,30 @@
# #
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2007 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
# #
# Main makefile for the toolchain # Main makefile for the toolchain
# #
include $(TOPDIR)/rules.mk
TARGETS-y:=kernel-headers # subdirectories to descend into
TARGETS-$(CONFIG_GDB) += gdb toolchain/builddirs := kernel-headers $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_NATIVE_TOOLCHAIN),,binutils gcc uClibc)
# builddir dependencies
toolchain/uClibc/prepare:=toolchain/kernel-headers/prepare
ifeq ($(CONFIG_NATIVE_TOOLCHAIN),) ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
TARGETS-y+=binutils gcc uClibc toolchain/binutils/prepare:=toolchain/uClibc/prepare
toolchain/gcc/prepare:=toolchain/binutils/install
toolchain/uClibc/compile:=toolchain/gcc/compile
endif endif
toolchain/gcc/install:=toolchain/uClibc/install
TARGETS_DOWNLOAD:=$(patsubst %,%-download,$(TARGETS-y)) # prerequisites for the individual targets
TARGETS_PREPARE:=$(patsubst %,%-prepare,$(TARGETS-y)) toolchain/ := .config $(tools/stamp)
TARGETS_COMPILE:=$(patsubst %,%-compile,$(TARGETS-y)) toolchain//prepare = $(STAGING_DIR)/include-host/.done
TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS-y)) toolchain//compile = $(1)/prepare
TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS-y)) toolchain//install = $(1)/compile
STAMP:=$(STAGING_DIR)/stampfiles/.toolchain_installed
all: install $(eval $(call stampfile,toolchain,toolchain))
download: $(TARGETS_DOWNLOAD) $(eval $(call subdir,toolchain))
compile: $(TARGETS_COMPILE)
install: $(STAMP)
clean: $(TARGETS_CLEAN)
ifneq ($(shell $(SCRIPT_DIR)/timestamp.pl -p . $(STAMP)),$(STAMP))
$(STAMP): $(TARGETS_INSTALL)
endif
uClibc-prepare: kernel-headers-prepare
ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
binutils-prepare: uClibc-prepare
gcc-prepare: binutils-install
uClibc-compile: gcc-compile
endif
gcc-install: uClibc-install
$(STAMP):
mkdir -p $(shell dirname $@)
touch $@
$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME):
@mkdir -p $@
@ln -sf ../lib $@/lib
$(TOOLCHAIN_BUILD_DIR):
@mkdir -p $@
%-prereq %-download %-clean %-refresh %-update: FORCE
$(MAKE) -C $* $(patsubst $*-%,%,$@)
%-prepare: $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME) $(TOOLCHAIN_BUILD_DIR)
$(MAKE) -C $* $(patsubst $*-%,%,$@)
%-compile: %-prepare FORCE
$(MAKE) -C $* $(patsubst $*-%,%,$@)
%-install: %-compile FORCE
$(MAKE) -C $* $(patsubst $*-%,%,$@)

View file

@ -7,25 +7,25 @@
# Main makefile for the host tools # Main makefile for the host tools
# #
curdir:=$(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST))) curdir:=tools
# subdirectories to descend into # subdirectories to descend into
$(curdir)/builddirs := sed sstrip ipkg-utils ext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline $(if $(CONFIG_CCACHE),ccache) tools/builddirs := sed sstrip ipkg-utils ext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline $(if $(CONFIG_CCACHE),ccache)
# builddir dependencies # builddir dependencies
$(curdir)/squashfs/compile := $(curdir)/lzma/install tools/squashfs/compile := tools/lzma/install
# preparatory work # preparatory work
$(STAGING_DIR)/include-host/.done: $(STAGING_DIR)/include-host/.done:
@mkdir -p $$(dirname $@) @mkdir -p $$(dirname $@)
@cp $(curdir)/include/*.h $$(dirname $@)/ @cp tools/include/*.h $$(dirname $@)/
@touch $@ @touch $@
# prerequisites for the individual targets # prerequisites for the individual targets
$(curdir)/ := .config tools/ := .config
$(curdir)//prepare = $(STAGING_DIR)/include-host/.done tools//prepare = $(STAGING_DIR)/include-host/.done
$(curdir)//compile = $(1)/prepare tools//compile = $(1)/prepare
$(curdir)//install = $(1)/compile tools//install = $(1)/compile
$(eval $(call stampfile,$(curdir),tools)) $(eval $(call stampfile,tools,tools))
$(eval $(call subdir,$(curdir))) $(eval $(call subdir,tools))