Skip to content

Commit

Permalink
next round of build system cleanup - convert package/ to new structure
Browse files Browse the repository at this point in the history
SVN-Revision: 8236
  • Loading branch information
Felix Fietkau committed Jul 30, 2007
1 parent 2e072cf commit 49e628f
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 138 deletions.
35 changes: 28 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@
# See /LICENSE for more information.
#

all: world

TOPDIR:=${CURDIR}
LC_ALL:=C
LANG:=C
IS_TTY:=${shell tty -s && echo 1 || echo 0}
export TOPDIR LC_ALL LANG IS_TTY

world:

include $(TOPDIR)/include/debug.mk
include $(TOPDIR)/include/host.mk

ifneq ($(OPENWRT_BUILD),1)
export OPENWRT_BUILD:=1
override OPENWRT_BUILD=1
export OPENWRT_BUILD
include $(TOPDIR)/include/toplevel.mk
else
include $(TOPDIR)/include/host.mk

include rules.mk
include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk
include package/Makefile
include tools/Makefile
include toolchain/Makefile

Expand All @@ -35,14 +38,32 @@ dirclean: clean
distclean: dirclean config-clean symlinkclean docs/clean
rm -rf dl

package/% target/%: FORCE
target/%: FORCE
$(MAKE) -C $(patsubst %/$*,%,$@) $*

world: .config $(tools/stamp) $(toolchain/stamp) FORCE
# check prerequisites before starting to build
prereq: tmp/.prereq-target $(package/stamp-prereq) ;

world: .config $(tools/stamp-install) $(toolchain/stamp-install) FORCE
$(MAKE) target/compile
$(MAKE) package/compile
$(MAKE) package/install
$(MAKE) target/install
$(MAKE) package/index

package/symlinks:
$(SCRIPT_DIR)/feeds.sh $(CONFIG_SOURCE_FEEDS) $(CONFIG_SOURCE_FEEDS_REV)

# FIXME: remove after converting target/ to new structure
tmp/.prereq-target: tmp/.targetinfo .config
tmp/.prereq-target: include/prereq.mk
mkdir -p tmp
rm -f tmp/.host.mk
@+$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \
false; \
}
touch $@
.SILENT: tmp/.prereq-target

endif
34 changes: 34 additions & 0 deletions include/debug.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

# debug flags:
#
# d: show subdirectory tree
# t: show added targets
# l: show legacy targets
# v: verbose (no .SILENCE for common targets)

ifeq ($(DEBUG),all)
build_debug:=dltv
else
build_debug:=$(DEBUG)
endif

define debug
$$(findstring $(2),$$(if $$(DEBUG_DIR),$$(if $$(filter $$(DEBUG_DIR)%,$(1)),$(build_debug)),$(build_debug)))
endef

define warn
$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
endef

define warn_eval
$(call warn,$(1),$(2),$(3) $(4))
$(4)
endef


5 changes: 3 additions & 2 deletions include/host.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

TMP_DIR ?= $(TOPDIR)/tmp
-include $(TMP_DIR)/.host.mk

export TAR
TMP_DIR ?= $(TOPDIR)/tmp

ifneq ($(__host_inc),1)
__host_inc:=1
.PRECIOUS: $(TMP_DIR)/.host.mk
$(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
@mkdir -p $(TMP_DIR)
@( \
Expand Down
4 changes: 4 additions & 0 deletions include/quilt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ ifeq ($(KERNEL_BUILD),1)
endif
PATCH_DIR?=./patches

ifeq ($(MAKECMDGOALS),refresh)
override QUILT=1
endif

define Quilt/Patch
@for patch in $$$$( (cd $(1) && ls) 2>/dev/null ); do ( \
cp "$(1)/$$$$patch" $(PKG_BUILD_DIR); \
Expand Down
56 changes: 19 additions & 37 deletions include/subdir.mk
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
# debug flags:
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# d: show subdirectory tree
# t: show added targets
# l: show legacy targets

ifeq ($(DEBUG),all)
build_debug:=dlt
else
build_debug:=$(DEBUG)
endif

define debug
$$(findstring $(2),$$(if $$(DEBUG_DIR),$$(if $$(filter $$(DEBUG_DIR)%,$(1)),$(build_debug)),$(build_debug)))
endef

define warn
$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
endef

define warn_eval
$(call warn,$(1),$(2),$(3) $(4))
$(4)
endef

SUBTARGETS:=clean download prepare compile install update refresh prereq

define subtarget
$(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(if $($(1)/builddirs-$(2)),$($(1)/builddirs-$(2)),$($(1)/builddirs)),$(1)/$(bd)/$(2)))
$(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(if $($(1)/builddirs-$(2)),$(filter-out .,$($(1)/builddirs-$(2))),$($(1)/builddirs)),$(1)/$(bd)/$(2)))

endef

Expand All @@ -46,19 +28,19 @@ define subdir
$(foreach target,$(SUBTARGETS),$(call subtarget,$(1),$(target)))
endef

# Parameters: <subdir> <name>
# Parameters: <subdir> <name> <target>
define stampfile
$(1)/stamp:=$(STAGING_DIR)/stampfiles/.$(2)_installed
$(call rdep,$(1),$$($(1)/stamp))

$$($(1)/stamp):
@+$(MAKE) $(1)/install
@mkdir -p $$$$(dirname $$($(1)/stamp))
@touch $$($(1)/stamp)
.PRECIOUS: $$($(1)/stamp) # work around a make bug

$(1)//clean:=$(1)/stamp/clean
$(1)/stamp/clean: FORCE
@rm -f $$($(1)/stamp)
$(1)/stamp-$(3):=$(STAGING_DIR)/stampfiles/.$(2)_$(3)
$(call rdep,$(1),$$($(1)/stamp-$(3)),)

$$($(1)/stamp-$(3)):
@+$(MAKE) $(1)/$(3)
@mkdir -p $$$$(dirname $$($(1)/stamp-$(3)))
@touch $$($(1)/stamp-$(3))
.PRECIOUS: $$($(1)/stamp-$(3)) # work around a make bug

$(1)//clean:=$(1)/stamp-$(3)/clean
$(1)/stamp-$(3)/clean: FORCE
@rm -f $$($(1)/stamp-$(3))

endef
42 changes: 16 additions & 26 deletions include/toplevel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
RELEASE:=Kamikaze
#VERSION:=2.0 # uncomment for final release

all: world

SHELL:=/usr/bin/env bash
OPENWRTVERSION:=$(RELEASE)
PREP_MK= OPENWRT_BUILD= QUIET=0
include $(TOPDIR)/include/verbose.mk
ifneq ($(VERSION),)
OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
Expand All @@ -26,27 +25,26 @@ export OPENWRTVERSION

ifeq ($(FORCE),)
.config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
world: prereq
endif

SCAN_COOKIE?=$(shell echo $$$$)
export SCAN_COOKIE

tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo:
@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="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 \
tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo: FORCE
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="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 \
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; }; \
done
./scripts/metadata.pl package_mk < tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }

.config: ./scripts/config/conf prepare-tmpinfo
@+if [ \! -f .config ]; then \
[ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
$(NO_TRACE_MAKE) menuconfig QUIET=0 OPENWRT_BUILD=; \
$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
fi
$< -D .config Config.in &> /dev/null

scripts/config/mconf:
@+$(MAKE) -C scripts/config all
Expand Down Expand Up @@ -88,20 +86,6 @@ tmp/.prereq-build: include/prereq-build.mk
}
touch $@

tmp/.prereq-package: tmp/.packageinfo .config
tmp/.prereq-target: tmp/.targetinfo .config
tmp/.prereq-package tmp/.prereq-target: include/prereq.mk
mkdir -p tmp
rm -f tmp/.host.mk
@+$(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \
echo "Prerequisite check failed. Use FORCE=1 to override."; \
false; \
}
touch $@

prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE
@true

download: .config FORCE
$(MAKE) -j1 tools/download
$(MAKE) -j1 toolchain/download
Expand All @@ -111,8 +95,12 @@ download: .config FORCE
clean dirclean distclean:
@$(MAKE) $@

prereq:: .config
@+$(SUBMAKE) -s tmp/.prereq-build $(PREP_MK)
@$(NO_TRACE_MAKE) -s $@

%::
@$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD=
@+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq
@+$(MAKE) $@

help:
Expand All @@ -128,7 +116,9 @@ symlinkclean:
-find package -type l | xargs rm -f
rm -rf tmp

.SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target
ifeq ($(findstring v,$(DEBUG)),)
.SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo
endif
.PHONY: help FORCE
.NOTPARALLEL:

2 changes: 1 addition & 1 deletion include/verbose.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ifneq ($(KBUILD_VERBOSE),99)
MAKE:=&>/dev/null $(MAKE)
endif
export QUIET:=1
MAKE:=cmd() { $(MAKE) $$* || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
MAKE:=cmd() { $(MAKE) -s $$* || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
endif

.SILENT: $(MAKECMDGOALS)
Expand Down
73 changes: 15 additions & 58 deletions package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,18 @@
#
# $Id$

include $(TOPDIR)/rules.mk
include $(TOPDIR)/.config
include $(INCLUDE_DIR)/host.mk

all: compile

include $(TMP_DIR)/.packagedeps

PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m))
DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))

$(STAMP_DIR) $(TARGET_DIR):
mkdir -p $@

ifeq ($(QUIET),1)
%-compile %-install: FORCE
$(MAKE) -j1 -C $* $(patsubst $*-%,%,$@) || { $(call MESSAGE, "*** $* $(patsubst $*-%,%,$@) failed"); false; }

%-prepare %-prereq %-download %-clean: FORCE
else
%-prepare %-prereq %-download %-clean %-compile %-install: FORCE
endif
$(MAKE) -j1 -C $* $(patsubst $*-%,%,$@)

%-refresh %-update:
-$(MAKE) -C $* $(patsubst $*-%,%,$@)

%-autorefresh:
-$(MAKE) -C $* clean refresh QUILT=1


# .IGNORE: $(COMPILE_PACKAGES)

$(TMP_DIR)/.packagedeps: $(TMP_DIR)/.packageinfo
@$(TOPDIR)/scripts/metadata.pl package_mk < $< > $@ || rm -f $@

preconfig:
clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
prereq: $(PREREQ_PACKAGES)
download: $(DOWNLOAD_PACKAGES)
compile: $(COMPILE_PACKAGES)
refresh: $(patsubst %,%-autorefresh,$(package-y) $(package-m) $(package-))

install-targets: $(INSTALL_PACKAGES)
install:
curdir:=package

include .config
-include $(TMP_DIR)/.packagedeps
$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
$(curdir)/builddirs-compile:=$(sort $(package-y) $(package-m))
$(curdir)/builddirs-install:=. $(sort $(package-y))
$(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))

$(curdir)//compile:=.config prereq
$(curdir)/install:=$(curdir)/install-cleanup
$(curdir)/install-cleanup:
rm -rf $(BUILD_DIR)/root
$(MAKE) install-targets
$(MAKE) preconfig
Expand All @@ -71,16 +36,8 @@ install:
@-find $(BUILD_DIR)/root -name .svn | $(XARGS) rm -rf
@-find $(BUILD_DIR)/root -name '.#*' | $(XARGS) rm -f

index: $(PACKAGE_DIR)/Packages

$(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk
$(curdir)/index: FORCE
(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)

symlinks:
../scripts/feeds.sh $(CONFIG_SOURCE_FEEDS) $(CONFIG_SOURCE_FEEDS_REV)

ifeq ($(MAKECMDGOALS),compile)
MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL)
else
.NOTPARALLEL:
endif
$(eval $(call stampfile,$(curdir),package,prereq))
$(eval $(call subdir,$(curdir)))
Loading

0 comments on commit 49e628f

Please sign in to comment.