# | # |
# Copyright (C) 2006 OpenWrt.org | # Copyright (C) 2006 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. |
# | # |
ifneq ($(DUMP),) | ifneq ($(DUMP),) |
define Dumpinfo | define Config |
preconfig_$$(1) += echo "Preconfig: $(1)"; echo "Preconfig-Type: $(2)"; echo "Preconfig-Default: $(3)"; echo "Preconfig-Label: $(4)"; | |
endef | |
define Dumpinfo | |
dumpinfo: dumpinfo-$(1) | dumpinfo: dumpinfo-$(1) |
dumpinfo-$(1): FORCE | dumpinfo-$(1): FORCE |
@echo "Package: $(1)" ; \ | @echo "Package: $(1)" ; \ |
$(if $(MENU),echo "Menu: $(MENU)";) \ | $(if $(MENU),echo "Menu: $(MENU)";) \ |
$(if $(SUBMENU),echo "Submenu: $(SUBMENU)";) \ | $(if $(SUBMENU),echo "Submenu: $(SUBMENU)";) \ |
$(if $(SUBMENUDEP),echo "Submenu-Depends: $(SUBMENUDEP)";) \ | $(if $(SUBMENUDEP),echo "Submenu-Depends: $(SUBMENUDEP)";) \ |
$(if $(DEFAULT),echo "Default: $(DEFAULT)";) \ | $(if $(DEFAULT),echo "Default: $(DEFAULT)";) \ |
if [ "$$$$PREREQ_CHECK" = 1 ]; then echo "Prereq-Check: 1"; fi; \ | if [ "$$$$PREREQ_CHECK" = 1 ]; then echo "Prereq-Check: 1"; fi; \ |
echo "Version: $(VERSION)"; \ | echo "Version: $(VERSION)"; \ |
echo "Depends: $(DEPENDS)"; \ | echo "Depends: $(DEPENDS)"; \ |
echo "Provides: $(PROVIDES)"; \ | echo "Provides: $(PROVIDES)"; \ |
echo "Build-Depends: $(PKG_BUILD_DEPENDS)"; \ | echo "Build-Depends: $(PKG_BUILD_DEPENDS)"; \ |
echo "Section: $(SECTION)"; \ | echo "Section: $(SECTION)"; \ |
echo "Category: $(CATEGORY)"; \ | echo "Category: $(CATEGORY)"; \ |
echo "Title: $(TITLE)"; \ | echo "Title: $(TITLE)"; \ |
echo "Maintainer: $(MAINTAINER)"; \ | echo "Maintainer: $(MAINTAINER)"; \ |
echo -n "Description: "; \ | echo -n "Description: "; \ |
getvar $(call shvar,Package/$(1)/description); \ | getvar $(call shvar,Package/$(1)/description); \ |
$(if $(URL),echo;echo "$(URL)";) \ | $(if $(URL),echo;echo "$(URL)";) \ |
echo "@@" ; \ | echo "@@" ; \ |
$$(if $$(Package/$(1)/config),echo "Config: "; getvar $(call shvar,Package/$(1)/config); echo "@@") | $$(if $$(Package/$(1)/config),echo "Config: "; getvar $(call shvar,Package/$(1)/config); echo "@@") |
$(if $$(preconfig_$(1)),@$$(preconfig_$(1)) echo "") | |
endef | endef |
endif | endif |
# | # |
# Copyright (C) 2006,2007 OpenWrt.org | # Copyright (C) 2006,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. |
# | # |
define BuildIPKGVariable | define BuildIPKGVariable |
$(call shexport,Package/$(1)/$(2)) | $(call shexport,Package/$(1)/$(2)) |
$(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2); | $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2); |
endef | endef |
ifeq ($(DUMP),) | ifeq ($(DUMP),) |
define BuildIPKG | define BuildIPKG |
IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk | IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk |
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1) | IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1) |
INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list | INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list |
ifdef Package/$(1)/install | ifdef Package/$(1)/install |
ifeq ($(CONFIG_PACKAGE_$(1)),y) | ifeq ($(CONFIG_PACKAGE_$(1)),y) |
install: $$(INFO_$(1)) | install: $$(INFO_$(1)) |
endif | endif |
ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),) | ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),) |
compile: $$(IPKG_$(1)) | compile: $$(IPKG_$(1)) |
else | else |
compile: $(1)-disabled | compile: $(1)-disabled |
$(1)-disabled: | $(1)-disabled: |
@echo "WARNING: skipping $(1) -- package not selected" | @echo "WARNING: skipping $(1) -- package not selected" |
endif | endif |
endif | endif |
ifeq ($(FORCEREBUILD),y) | ifeq ($(FORCEREBUILD),y) |
$$(IPKG_$(1)): FORCE | $$(IPKG_$(1)): FORCE |
endif | endif |
IDEPEND_$(1):=$$(strip $$(DEPENDS)) | IDEPEND_$(1):=$$(strip $$(DEPENDS)) |
$(eval $(call BuildIPKGVariable,$(1),conffiles)) | $(eval $(call BuildIPKGVariable,$(1),conffiles)) |
$(eval $(call BuildIPKGVariable,$(1),preinst)) | $(eval $(call BuildIPKGVariable,$(1),preinst)) |
$(eval $(call BuildIPKGVariable,$(1),postinst)) | $(eval $(call BuildIPKGVariable,$(1),postinst)) |
$(eval $(call BuildIPKGVariable,$(1),prerm)) | $(eval $(call BuildIPKGVariable,$(1),prerm)) |
$(eval $(call BuildIPKGVariable,$(1),postrm)) | $(eval $(call BuildIPKGVariable,$(1),postrm)) |
$$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH) | $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH) |
@rm -f $(PACKAGE_DIR)/$(1)_* | @rm -f $(PACKAGE_DIR)/$(1)_* |
mkdir -p $$(IDIR_$(1))/CONTROL | mkdir -p $$(IDIR_$(1))/CONTROL |
echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control | echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control |
echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control | echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control |
( \ | ( \ |
DEPENDS='$(EXTRA_DEPENDS)'; \ | DEPENDS='$(EXTRA_DEPENDS)'; \ |
for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \ | for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \ |
DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \ | DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \ |
done; \ | done; \ |
echo "Depends: $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \ | echo "Depends: $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \ |
) | ) |
echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control | ( \ |
echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control | echo "Source: $(SOURCE)"; \ |
echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control | echo "Section: $(SECTION)"; \ |
echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control | echo "Priority: $(PRIORITY)"; \ |
echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control | echo "Maintainer: $(MAINTAINER)"; \ |
echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g' | sed -e 's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_$(1))/CONTROL/control | echo "Architecture: $(PKGARCH)"; \ |
echo -n "Description: "; getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \ | |
) >> $$(IDIR_$(1))/CONTROL/control | |
chmod 644 $$(IDIR_$(1))/CONTROL/control | chmod 644 $$(IDIR_$(1))/CONTROL/control |
(cd $$(IDIR_$(1))/CONTROL; \ | (cd $$(IDIR_$(1))/CONTROL; \ |
$($(1)_COMMANDS) \ | $($(1)_COMMANDS) \ |
) | ) |
$$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control | $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control |
$(call Package/$(1)/install,$$(IDIR_$(1))) | $(call Package/$(1)/install,$$(IDIR_$(1))) |
mkdir -p $(PACKAGE_DIR) | mkdir -p $(PACKAGE_DIR) |
-find $$(IDIR_$(1)) -name CVS | xargs rm -rf | -find $$(IDIR_$(1)) -name CVS | xargs rm -rf |
-find $$(IDIR_$(1)) -name .svn | xargs rm -rf | -find $$(IDIR_$(1)) -name .svn | xargs rm -rf |
-find $$(IDIR_$(1)) -name '.#*' | xargs rm -f | -find $$(IDIR_$(1)) -name '.#*' | xargs rm -f |
$(RSTRIP) $$(IDIR_$(1)) | $(RSTRIP) $$(IDIR_$(1)) |
$(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR) | $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR) |
@[ -f $$(IPKG_$(1)) ] || false | @[ -f $$(IPKG_$(1)) ] || false |
$$(INFO_$(1)): $$(IPKG_$(1)) | $$(INFO_$(1)): $$(IPKG_$(1)) |
$(IPKG) install $$(IPKG_$(1)) | $(IPKG) install $$(IPKG_$(1)) |
$(1)-clean: | $(1)-clean: |
rm -f $(PACKAGE_DIR)/$(1)_* | rm -f $(PACKAGE_DIR)/$(1)_* |
clean: $(1)-clean | clean: $(1)-clean |
$(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared | $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared |
-@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null | -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null |
@touch $$@ | @touch $$@ |
$$(eval $$(call Build/DefaultTargets,$(1))) | $$(eval $$(call Build/DefaultTargets,$(1))) |
ifdef Package/$(1)/install | ifdef Package/$(1)/install |
ifneq ($$(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),) | ifneq ($$(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),) |
ifneq ($(MAKECMDGOALS),prereq) | ifneq ($(MAKECMDGOALS),prereq) |
ifneq ($(DUMP),1) | ifneq ($(DUMP),1) |
ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1))) | ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1))) |
$(PKG_BUILD_DIR)/.built: package-rebuild | $(PKG_BUILD_DIR)/.built: package-rebuild |
$$(info Rebuilding $(subst $(TOPDIR)/,,$$(IPKG_$(1)))) | $$(info Rebuilding $(subst $(TOPDIR)/,,$$(IPKG_$(1)))) |
endif | endif |
endif | endif |
endif | endif |
endif | endif |
endif | endif |
endef | endef |
endif | endif |
# | # |
# Copyright (C) 2006 OpenWrt.org | # Copyright (C) 2006 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. |
# | # |
# $Id$ | # $Id$ |
include $(TOPDIR)/rules.mk | include $(TOPDIR)/rules.mk |
include $(TOPDIR)/.config | include $(TOPDIR)/.config |
include $(INCLUDE_DIR)/host.mk | |
all: compile | |
include $(TMP_DIR)/.pkgdeps | include $(TMP_DIR)/.pkgdeps |
include $(INCLUDE_DIR)/host.mk | |
PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m)) | PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m)) |
DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m)) | DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m)) |
COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m)) | COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m)) |
INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y)) | INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y)) |
$(STAMP_DIR) $(TARGET_DIR): | $(STAMP_DIR) $(TARGET_DIR): |
mkdir -p $@ | mkdir -p $@ |
%-prereq: $(STAMP_DIR) $(TARGET_DIR) | %-prereq: $(STAMP_DIR) $(TARGET_DIR) |
$(MAKE) -C $(patsubst %-prereq,%,$@) prereq | $(MAKE) -C $(patsubst %-prereq,%,$@) prereq |
$(eval $(call default_subtargets,$(TARGET_DIR))) | $(eval $(call default_subtargets,$(TARGET_DIR))) |
ifeq ($(SDK),1) | ifeq ($(SDK),1) |
GENDEP_OPTS := -s | GENDEP_OPTS := -s |
endif | endif |
$(TMP_DIR)/.pkgdeps: $(TMP_DIR)/.pkginfo | $(TMP_DIR)/.pkgdeps: $(TMP_DIR)/.pkginfo |
@$(TOPDIR)/scripts/gen_deps.pl $(GENDEP_OPTS) < $< > $@ || rm -f $@ | @$(TOPDIR)/scripts/metadata.pl package_mk $(GENDEP_OPTS) < $< > $@ || rm -f $@ |
all: compile | preconfig: |
clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m)) | clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m)) |
prereq: $(PREREQ_PACKAGES) | prereq: $(PREREQ_PACKAGES) |
download: $(DOWNLOAD_PACKAGES) | download: $(DOWNLOAD_PACKAGES) |
compile: $(COMPILE_PACKAGES) | compile: $(COMPILE_PACKAGES) |
install-targets: $(INSTALL_PACKAGES) | install-targets: $(INSTALL_PACKAGES) |
install: | install: |
rm -rf $(BUILD_DIR)/root | rm -rf $(BUILD_DIR)/root |
$(MAKE) install-targets | $(MAKE) install-targets |
$(MAKE) preconfig | |
@if [ -d $(TOPDIR)/files ]; then \ | @if [ -d $(TOPDIR)/files ]; then \ |
$(CP) $(TOPDIR)/files/. $(BUILD_DIR)/root; \ | $(CP) $(TOPDIR)/files/. $(BUILD_DIR)/root; \ |
fi | fi |
@( \ | @( \ |
cd $(BUILD_DIR)/root; \ | cd $(BUILD_DIR)/root; \ |
for script in ./etc/init.d/*; do \ | for script in ./etc/init.d/*; do \ |
grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ | grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ |
IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \ | IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \ |
done; \ | done || true \ |
) | ) |
index: $(PACKAGE_DIR)/Packages | index: $(PACKAGE_DIR)/Packages |
$(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk | $(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk |
(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages) | (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages) |
symlinks: | symlinks: |
../scripts/feeds.sh $(CONFIG_SOURCE_FEEDS) | ../scripts/feeds.sh $(CONFIG_SOURCE_FEEDS) |
ifeq ($(MAKECMDGOALS),compile) | ifeq ($(MAKECMDGOALS),compile) |
MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL) | MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL) |
else | else |
.NOTPARALLEL: | .NOTPARALLEL: |
endif | endif |
#!/bin/sh | #!/bin/sh |
# Shell script for interacting with config files | # Shell script for interacting with config files |
# | # |
# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> | # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> |
# Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org> | # Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org> |
# | # |
# This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by | # it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 2 of the License, or | # the Free Software Foundation; either version 2 of the License, or |
# (at your option) any later version. | # (at your option) any later version. |
# | # |
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
# General Public License for more details. | # General Public License for more details. |
# | # |
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License |
# along with this program; if not, write to the Free Software | # along with this program; if not, write to the Free Software |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
. $UCI_ROOT/etc/functions.sh | . $UCI_ROOT/etc/functions.sh |
include $UCI_ROOT/lib/config | include $UCI_ROOT/lib/config |
SEP="[^0-9A-Za-z_]" | SEP="[^0-9A-Za-z_]" |
do_get() { | do_get() { |
local PACKAGE | local PACKAGE |
local CONFIG | local CONFIG |
local OPTION | local OPTION |
local DUMMY | local DUMMY |
strtok "$*" PACKAGE . CONFIG . OPTION $SEP DUMMY | strtok "$*" PACKAGE . CONFIG . OPTION $SEP DUMMY |
[ $? -ne 3 ] && { | [ $? -ne 3 ] && { |
uci_usage get | uci_usage get |
exit 1 | exit 1 |
} | } |
uci_load "$PACKAGE" | uci_load "$PACKAGE" |
config_get "$CONFIG" "$OPTION" | config_get "$CONFIG" "$OPTION" |
} | } |
do_set() { | do_set() { |
local PACKAGE | local PACKAGE |
local CONFIG | local CONFIG |
local OPTION | local OPTION |
local VALUE | local VALUE |
strtok "$1" PACKAGE . CONFIG = VALUE | strtok "$1" PACKAGE . CONFIG = VALUE |
[ $? -ne 3 ] && { | [ $? -ne 3 -a $? -ne 2 ] && { |
uci_usage set | uci_usage set |
exit 1 | exit 1 |
} | } |
strtok "$CONFIG" CONFIG . OPTION | strtok "$CONFIG" CONFIG . OPTION |
if [ $? -eq 1 ]; then | if [ $? -eq 1 ]; then |
uci_add "$PACKAGE" "$VALUE" "$CONFIG" | uci_add "$PACKAGE" "$VALUE" "$CONFIG" |
else | else |
uci_set "$PACKAGE" "$CONFIG" "$OPTION" "$VALUE" | uci_set "$PACKAGE" "$CONFIG" "$OPTION" "$VALUE" |
fi | fi |
} | } |
do_rename() { | do_rename() { |
[ $# -ne 3 ] && { | [ $# -ne 3 ] && { |
uci_usage rename | uci_usage rename |
exit 1 | exit 1 |
} | } |
uci_rename "$@" | uci_rename "$@" |
} | } |
do_remove() { | do_remove() { |
local PACKAGE | local PACKAGE |
local CONFIG | local CONFIG |
local OPTION | local OPTION |
local DUMMY | local DUMMY |
strtok "$*" PACKAGE . CONFIG . OPTION $SEP DUMMY | strtok "$*" PACKAGE . CONFIG . OPTION $SEP DUMMY |
[ $? -ne 3 -a $? -ne 2 ] && { | [ $? -ne 3 -a $? -ne 2 ] && { |
uci_usage rename | uci_usage rename |
exit 1 | exit 1 |
} | } |
uci_remove "$PACKAGE" "$CONFIG" ${OPTION:+"$OPTION"} | uci_remove "$PACKAGE" "$CONFIG" ${OPTION:+"$OPTION"} |
} | } |
do_commit() { | do_commit() { |
local PACKAGE="$1" | local PACKAGE="$1" |
for package in ${PACKAGE:-$(cd /tmp/.uci; ls)}; do | for package in ${PACKAGE:-$(cd /tmp/.uci; ls)}; do |
[ "${package##.*}" != "$package" ] && continue # ignore .lock files | |
uci_commit "$package" | uci_commit "$package" |
done | done |
} | } |
do_show() { | do_show() { |
local PACKAGE | local PACKAGE |
local CONFIG | local CONFIG |
local DUMMY | local DUMMY |
strtok "$*" PACKAGE . CONFIG $SEP DUMMY | strtok "$*" PACKAGE . CONFIG $SEP DUMMY |
[ $? -gt 2 ] && { | [ $? -gt 2 ] && { |
uci_usage show | uci_usage show |
exit 1 | exit 1 |
} | } |
for package in ${PACKAGE:-$(cd $UCI_ROOT/etc/config; ls)}; do | for package in ${PACKAGE:-$(cd $UCI_ROOT/etc/config; ls)}; do |
SECTION="" | SECTION="" |
config_cb() { | config_cb() { |
if [ -z "$CONFIG" -o "$CONFIG" = "$2" ]; then | if [ -z "$CONFIG" -o "$CONFIG" = "$2" ]; then |
append SECTION "$2" | append SECTION "$2" |
option_cb() { | option_cb() { |
append "${CONFIG_SECTION}_VARS" "$1" | append "${CONFIG_SECTION}_VARS" "$1" |
} | } |
else | else |
option_cb() { | option_cb() { |
return 0 | return 0 |
} | } |
fi | fi |
} | } |
uci_load "$package" | uci_load "$package" |
for section in $SECTION; do | for section in $SECTION; do |
config_get type "$section" TYPE | config_get type "$section" TYPE |
[ -z "$type" ] && continue | [ -z "$type" ] && continue |
echo "$package.$section=$type" | echo "$package.$section=$type" |
eval "VARS=\"\${${section}_VARS}\"" | eval "VARS=\"\${${section}_VARS}\"" |
for var in $VARS; do | for var in $VARS; do |
config_get val "$section" "$var" | config_get val "$section" "$var" |
[ -n "$val" ] && { | [ -n "$val" ] && { |
echo "$package.$section.$var=$val" | echo "$package.$section.$var=$val" |
config_set "$section" "$var" "" | config_set "$section" "$var" "" |
} | } |
done | done |
config_set "$section" TYPE "" | config_set "$section" TYPE "" |
done | done |
done | done |
} | } |
do_validate() { | do_validate() { |
[ "$#" -ne 1 ] && { | [ "$#" -ne 1 ] && { |
uci_usage validate | uci_usage validate |
exit 1 | exit 1 |
} | } |
uci_validate "$1" || exit "$?" | uci_validate "$1" || exit "$?" |
} | } |
uci_usage() { | uci_usage() { |
case "$1" in | case "$1" in |
show) echo "$0 show [<package>[.<config>]]";; | show) echo "$0 show [<package>[.<config>]]";; |
get) echo "$0 get <package>.<config>.<option>";; | get) echo "$0 get <package>.<config>.<option>";; |
set) echo "$0 set <package>.<config>[.<option>]=<value>";; | set) echo "$0 set <package>.<config>[.<option>]=<value>";; |
del) echo "$0 del <package>.<config>[.<option>]";; | del) echo "$0 del <package>.<config>[.<option>]";; |
rename) echo "$0 rename <package> <config> <name>";; | rename) echo "$0 rename <package> <config> <name>";; |
commit) echo "$0 commit [<package> ... ]";; | commit) echo "$0 commit [<package> ... ]";; |
validate) echo "$0 validate <package>";; | validate) echo "$0 validate <package>";; |
*) | *) |
echo "Syntax: $0 <command> <arguments...>" | echo "Syntax: $0 <command> <arguments...>" |
echo | echo |
uci_usage show | uci_usage show |
uci_usage get | uci_usage get |
uci_usage set | uci_usage set |
uci_usage del | uci_usage del |
uci_usage rename | uci_usage rename |
uci_usage commit | uci_usage commit |
uci_usage validate | uci_usage validate |
echo | echo |
exit 1 | exit 1 |
;; | ;; |
esac | esac |
} | } |
if [ $# -eq 0 ] ; then | if [ $# -eq 0 ] ; then |
uci_usage | uci_usage |
exit 0 | exit 0 |
fi | fi |
CMD="$1" | CMD="$1" |
shift | shift |
case "$CMD" in | case "$CMD" in |
set) do_set "$@";; | set) do_set "$@";; |
del) do_remove "$@";; | del) do_remove "$@";; |
rename) do_rename "$@";; | rename) do_rename "$@";; |
get) do_get "$@";; | get) do_get "$@";; |
show) do_show "$@";; | show) do_show "$@";; |
commit) do_commit "$@";; | commit) do_commit "$@";; |
validate) do_validate "$@";; | validate) do_validate "$@";; |
*) uci_usage;; | *) uci_usage;; |
esac | esac |
exit 0 | exit 0 |
#!/bin/sh /etc/rc.common | |
# Copyright (C) 2006 OpenWrt.org | |
START=15 | |
start() { | |
include /lib/config | |
uci_apply_defaults | |
} | |
#!/bin/sh | #!/bin/sh |
# Shell script defining macros for manipulating config files | # Shell script defining macros for manipulating config files |
# | # |
# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> | # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> |
# Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org> | # Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org> |
# | # |
# This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by | # it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 2 of the License, or | # the Free Software Foundation; either version 2 of the License, or |
# (at your option) any later version. | # (at your option) any later version. |
# | # |
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
# General Public License for more details. | # General Public License for more details. |
# | # |
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License |
# along with this program; if not, write to the Free Software | # along with this program; if not, write to the Free Software |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
uci_load() { | uci_load() { |
local PACKAGE="$1" | local PACKAGE="$1" |
config_load "$PACKAGE" | config_load "$PACKAGE" |
local PACKAGE_BASE="$(basename "$PACKAGE")" | local PACKAGE_BASE="$(basename "$PACKAGE")" |
[ -f "/tmp/.uci/${PACKAGE_BASE}" ] && { | [ -f "/tmp/.uci/${PACKAGE_BASE}" ] && { |
. "/tmp/.uci/${PACKAGE_BASE}" 2>/dev/null >/dev/null | . "/tmp/.uci/${PACKAGE_BASE}" 2>/dev/null >/dev/null |
config_cb | config_cb |
} | } |
} | } |
uci_apply_defaults() {( | |
cd /etc/uci-defaults || return 0 | |
files="$(ls)" | |
[ -z "$files" ] && return 0 | |
mkdir -p /tmp/.uci | |
for file in $files; do | |
( . "./$(basename $file)" ) && rm -f "$file" | |
done | |
uci commit | |
)} | |
uci_do_update() { | uci_do_update() { |
local FILENAME="$1" | local FILENAME="$1" |
local UPDATE="$2" | local UPDATE="$2" |
awk -f $UCI_ROOT/lib/config/uci-update.awk -f - <<EOF | awk -f $UCI_ROOT/lib/config/uci-update.awk -f - <<EOF |
BEGIN { | BEGIN { |
config = read_file("$FILENAME") | config = read_file("$FILENAME") |
$UPDATE | $UPDATE |
print config | print config |
} | } |
EOF | EOF |
} | } |
uci_add_update() { | uci_add_update() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local UPDATE="$2" | local UPDATE="$2" |
local PACKAGE_BASE="$(basename "$PACKAGE")" | local PACKAGE_BASE="$(basename "$PACKAGE")" |
# FIXME: add locking? | # FIXME: add locking? |
mkdir -p "/tmp/.uci" | mkdir -p "/tmp/.uci" |
echo "$UPDATE" >> "/tmp/.uci/${PACKAGE_BASE}" | echo "$UPDATE" >> "/tmp/.uci/${PACKAGE_BASE}" |
} | } |
uci_set() { | uci_set() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local CONFIG="$2" | local CONFIG="$2" |
local OPTION="$3" | local OPTION="$3" |
local VALUE="$4" | local VALUE="$4" |
( # spawn a subshell so you don't mess up the current environment | ( # spawn a subshell so you don't mess up the current environment |
uci_load "$PACKAGE" | uci_load "$PACKAGE" |
config_get type "$CONFIG" TYPE | config_get type "$CONFIG" TYPE |
[ -z "$type" ] | [ -z "$type" ] |
) || uci_add_update "$PACKAGE" "CONFIG_SECTION='$CONFIG'${N}option '$OPTION' '$VALUE'" | ) || uci_add_update "$PACKAGE" "CONFIG_SECTION='$CONFIG'${N}option '$OPTION' '$VALUE'" |
} | } |
uci_add() { | uci_add() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local TYPE="$2" | local TYPE="$2" |
local CONFIG="$3" | local CONFIG="$3" |
uci_add_update "$PACKAGE" "config '$TYPE' '$CONFIG'" | uci_add_update "$PACKAGE" "config '$TYPE' '$CONFIG'" |
} | } |
uci_rename() { | uci_rename() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local CONFIG="$2" | local CONFIG="$2" |
local VALUE="$3" | local VALUE="$3" |
uci_add_update "$PACKAGE" "config_rename '$CONFIG' '$VALUE'" | uci_add_update "$PACKAGE" "config_rename '$CONFIG' '$VALUE'" |
} | } |
uci_remove() { | uci_remove() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local CONFIG="$2" | local CONFIG="$2" |
local OPTION="$3" | local OPTION="$3" |
if [ -z "$OPTION" ]; then | if [ -z "$OPTION" ]; then |
uci_add_update "$PACKAGE" "config_clear '$CONFIG'" | uci_add_update "$PACKAGE" "config_clear '$CONFIG'" |
else | else |
uci_add_update "$PACKAGE" "config_unset '$CONFIG' '$OPTION'" | uci_add_update "$PACKAGE" "config_unset '$CONFIG' '$OPTION'" |
fi | fi |
} | } |
uci_commit() { | uci_commit() { |
local PACKAGE="$1" | local PACKAGE="$1" |
local PACKAGE_BASE="$(basename "$PACKAGE")" | local PACKAGE_BASE="$(basename "$PACKAGE")" |
mkdir -p /tmp/.uci | mkdir -p /tmp/.uci |
LOCK=`which lock` || LOCK=: | LOCK=`which lock` || LOCK=: |
$LOCK "/tmp/.uci/$PACKAGE_BASE.lock" | $LOCK "/tmp/.uci/$PACKAGE_BASE.lock" |
[ -f "/tmp/.uci/$PACKAGE_BASE" ] && ( | [ -f "/tmp/.uci/$PACKAGE_BASE" ] && ( |
updatestr="" | updatestr="" |
# replace handlers | # replace handlers |
config() { | config() { |
append updatestr "config = update_config(config, \"@$2=$1\")" "$N" | append updatestr "config = update_config(config, \"@$2=$1\")" "$N" |
} | } |
option() { | option() { |
append updatestr "config = update_config(config, \"$CONFIG_SECTION.$1=$2\")" "$N" | append updatestr "config = update_config(config, \"$CONFIG_SECTION.$1=$2\")" "$N" |
} | } |
config_rename() { | config_rename() { |
append updatestr "config = update_config(config, \"&$1=$2\")" "$N" | append updatestr "config = update_config(config, \"&$1=$2\")" "$N" |
} | } |
config_unset() { | config_unset() { |
append updatestr "config = update_config(config, \"-$1.$2\")" "$N" | append updatestr "config = update_config(config, \"-$1.$2\")" "$N" |
} | } |
config_clear() { | config_clear() { |
append updatestr "config = update_config(config, \"-$1\")" "$N" | append updatestr "config = update_config(config, \"-$1\")" "$N" |
} | } |
. "/tmp/.uci/$PACKAGE_BASE" | . "/tmp/.uci/$PACKAGE_BASE" |
# completely disable handlers so that they don't get in the way | # completely disable handlers so that they don't get in the way |
config() { | config() { |
return 0 | return 0 |
} | } |
option() { | option() { |
return 0 | return 0 |
} | } |
config_load "$PACKAGE" | config_load "$PACKAGE" |
CONFIG_FILENAME="${CONFIG_FILENAME:-$UCI_ROOT/etc/config/$PACKAGE_BASE}" | CONFIG_FILENAME="${CONFIG_FILENAME:-$UCI_ROOT/etc/config/$PACKAGE_BASE}" |
uci_do_update "$CONFIG_FILENAME" "$updatestr" > "/tmp/.uci/$PACKAGE_BASE.new" && { | uci_do_update "$CONFIG_FILENAME" "$updatestr" > "/tmp/.uci/$PACKAGE_BASE.new" && { |
mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \ | mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \ |
rm -f "/tmp/.uci/$PACKAGE_BASE" | rm -f "/tmp/.uci/$PACKAGE_BASE" |
} | } |
) | ) |
$LOCK -u "/tmp/.uci/$PACKAGE_BASE.lock" | $LOCK -u "/tmp/.uci/$PACKAGE_BASE.lock" |
} | } |
#!/usr/bin/perl | |
# | |
# Copyright (C) 2006 OpenWrt.org | |
# | |
# This is free software, licensed under the GNU General Public License v2. | |
# See /LICENSE for more information. | |
# | |
use strict; | |
my $name; | |
my $src; | |
my $makefile; | |
my %conf; | |
my %pkg; | |
my %prereq; | |
my %dep; | |
my %options; | |
my $opt; | |
while ($opt = shift @ARGV) { | |
$opt =~ /^-s/ and $options{SDK} = 1; | |
} | |
my $line; | |
while ($line = <>) { | |
chomp $line; | |
$line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do { | |
$makefile = $1; | |
$src = $2; | |
defined $pkg{$src} or $pkg{$src} = {}; | |
$pkg{$src}->{src} = $src; | |
}; | |
$line =~ /^Package: \s*(.+)\s*$/ and do { | |
$name = $1; | |
defined $pkg{$name} or $pkg{$name} = {}; | |
$pkg{$name}->{src} = $src; | |
}; | |
$line =~ /^Provides: \s*(.+)\s*$/ and do { | |
foreach my $vpkg (split /\s+/, $1) { | |
defined $pkg{$vpkg} or $pkg{$vpkg} = {}; | |
$pkg{$vpkg}->{virtual} = 1; | |
} | |
}; | |
$line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do { | |
$pkg{$name}->{prereq} = 1; | |
}; | |
$line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do { | |
$pkg{$name}->{depends} ||= []; | |
foreach my $v (split /\s+/, $2) { | |
next if $v =~ /^[\+]?@/; | |
$v =~ s/^\+//; | |
push @{$pkg{$name}->{depends}}, $v; | |
} | |
}; | |
} | |
$line=""; | |
foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) { | |
my $config; | |
next if defined $pkg{$name}->{virtual}; | |
if ($options{SDK}) { | |
$conf{$pkg{$name}->{src}} or do { | |
$config = 'm'; | |
$conf{$pkg{$name}->{src}} = 1; | |
}; | |
} else { | |
$config = "\$(CONFIG_PACKAGE_$name)" | |
} | |
if ($config) { | |
print "package-$config += $pkg{$name}->{src}\n"; | |
$pkg{$name}->{prereq} and print "prereq-$config += $pkg{$name}->{src}\n"; | |
} | |
my $hasdeps = 0; | |
my $depline = ""; | |
foreach my $dep (@{$pkg{$name}->{depends}}) { | |
my $idx; | |
next if defined $pkg{$dep}->{virtual}; | |
if (defined $pkg{$dep}->{src}) { | |
($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src}; | |
} elsif (defined($pkg{$dep}) && !$options{SDK}) { | |
$idx = $dep; | |
} | |
undef $idx if $idx =~ /^(kernel)|(base-files)$/; | |
if ($idx) { | |
next if $dep{$pkg{$name}->{src}."->".$idx}; | |
$depline .= " $idx\-compile"; | |
$dep{$pkg{$name}->{src}."->".$idx} = 1; | |
} | |
} | |
if ($depline ne "") { | |
$line .= "$pkg{$name}->{src}-compile: $depline\n"; | |
} | |
} | |
if ($line ne "") { | |
print "\n$line"; | |
} | |
#!/usr/bin/perl | #!/usr/bin/perl |
use strict; | use strict; |
my %preconfig; | |
my %package; | my %package; |
my %srcpackage; | |
my %category; | my %category; |
sub parse_target_metadata() { | sub parse_target_metadata() { |
my ($target, @target, $profile); | my ($target, @target, $profile); |
while (<>) { | while (<>) { |
chomp; | chomp; |
/^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do { | /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do { |
my $conf = uc $3.'_'.$2; | my $conf = uc $3.'_'.$2; |
$conf =~ tr/\.-/__/; | $conf =~ tr/\.-/__/; |
$target = { | $target = { |
id => $1, | id => $1, |
conf => $conf, | conf => $conf, |
board => $2, | board => $2, |
kernel => $3, | kernel => $3, |
profiles => [] | profiles => [] |
}; | }; |
push @target, $target; | push @target, $target; |
}; | }; |
/^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1; | /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1; |
/^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1; | /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1; |
/^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1; | /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1; |
/^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ]; | /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ]; |
/^Target-Description:/ and do { | /^Target-Description:/ and do { |
my $desc; | my $desc; |
while (<>) { | while (<>) { |
last if /^@@/; | last if /^@@/; |
$desc .= $_; | $desc .= $_; |
} | } |
$target->{desc} = $desc; | $target->{desc} = $desc; |
}; | }; |
/^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1; | /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1; |
/^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1; | /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1; |
/^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1; | /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1; |
/^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ]; | /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ]; |
/^Target-Profile:\s*(.+)\s*$/ and do { | /^Target-Profile:\s*(.+)\s*$/ and do { |
$profile = { | $profile = { |
id => $1, | id => $1, |
name => $1, | name => $1, |
packages => [] | packages => [] |
}; | }; |
push @{$target->{profiles}}, $profile; | push @{$target->{profiles}}, $profile; |
}; | }; |
/^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1; | /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1; |
/^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ]; | /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ]; |
/^Target-Profile-Description:/ and do { | /^Target-Profile-Description:/ and do { |
my $desc; | my $desc; |
while (<>) { | while (<>) { |
last if /^@@/; | last if /^@@/; |
$desc .= $_; | $desc .= $_; |
} | } |
$profile->{desc} = $desc; | $profile->{desc} = $desc; |
}; | }; |
/^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1; | /^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1; |
} | } |
foreach my $target (@target) { | foreach my $target (@target) { |
@{$target->{profiles}} > 0 or $target->{profiles} = [ | @{$target->{profiles}} > 0 or $target->{profiles} = [ |
{ | { |
id => 'Default', | id => 'Default', |
name => 'Default', | name => 'Default', |
packages => [] | packages => [] |
} | } |
]; | ]; |
} | } |
return @target; | return @target; |
} | } |
sub parse_package_metadata() { | sub parse_package_metadata() { |
my $pkg; | my $pkg; |
my $makefile; | my $makefile; |
my $preconfig; | |
my $src; | my $src; |
while (<>) { | while (<>) { |
chomp; | chomp; |
/^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do { | /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do { |
$makefile = $1; | $makefile = $1; |
$src = $2; | $src = $2; |
$srcpackage{$src} = []; | |
undef $pkg; | undef $pkg; |
}; | }; |
/^Package: \s*(.+)\s*$/ and do { | /^Package:\s*(.+?)\s*$/ and do { |
$pkg = {}; | $pkg = {}; |
$pkg->{src} = $src; | $pkg->{src} = $src; |
$pkg->{makefile} = $makefile; | $pkg->{makefile} = $makefile; |
$pkg->{name} = $1; | $pkg->{name} = $1; |
$pkg->{default} = "m if ALL"; | $pkg->{default} = "m if ALL"; |
$pkg->{depends} = []; | |
$pkg->{builddepends} = []; | |
$package{$1} = $pkg; | $package{$1} = $pkg; |
push @{$srcpackage{$src}}, $pkg; | |
}; | }; |
/^Version: \s*(.+)\s*$/ and $pkg->{version} = $1; | /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1; |
/^Title: \s*(.+)\s*$/ and $pkg->{title} = $1; | /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1; |
/^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1; | /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1; |
/^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1; | /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1; |
/^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1; | /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1; |
/^Default: \s*(.+)\s*$/ and $pkg->{default} = $1; | /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1; |
/^Provides: \s*(.+)\s*$/ and do { | /^Provides: \s*(.+)\s*$/ and do { |
my @vpkg = split /\s+/, $1; | my @vpkg = split /\s+/, $1; |
foreach my $vpkg (@vpkg) { | foreach my $vpkg (@vpkg) { |
$package{$vpkg} or $package{$vpkg} = { vdepends => [] }; | $package{$vpkg} or $package{$vpkg} = { vdepends => [] }; |
push @{$package{$vpkg}->{vdepends}}, $pkg->{name}; | push @{$package{$vpkg}->{vdepends}}, $pkg->{name}; |
} | } |
}; | }; |
/^Depends: \s*(.+)\s*$/ and do { | /^Depends: \s*(.+)\s*$/ and do { |
my @dep = split /\s+/, $1; | my @dep = split /\s+/, $1; |
$pkg->{depends} = \@dep; | $pkg->{depends} = \@dep; |
}; | }; |
/^Build-Depends: \s*(.+)\s*$/ and do { | |
my @dep = split /\s+/, $1; | |
$pkg->{builddepends} = \@dep; | |
}; | |
/^Category: \s*(.+)\s*$/ and do { | /^Category: \s*(.+)\s*$/ and do { |
$pkg->{category} = $1; | $pkg->{category} = $1; |
defined $category{$1} or $category{$1} = {}; | defined $category{$1} or $category{$1} = {}; |
defined $category{$1}->{$src} or $category{$1}->{$src} = []; | defined $category{$1}->{$src} or $category{$1}->{$src} = []; |
push @{$category{$1}->{$src}}, $pkg; | push @{$category{$1}->{$src}}, $pkg; |
}; | }; |
/^Description: \s*(.*)\s*$/ and do { | /^Description: \s*(.*)\s*$/ and do { |
my $desc = "\t\t$1\n\n"; | my $desc = "\t\t$1\n\n"; |
my $line; | my $line; |
while ($line = <>) { | while ($line = <>) { |
last if $line =~ /^@@/; | last if $line =~ /^@@/; |
$desc .= "\t\t$line"; | $desc .= "\t\t$line"; |
} | } |
$pkg->{description} = $desc; | $pkg->{description} = $desc; |
}; | }; |
/^Config: \s*(.*)\s*$/ and do { | /^Config: \s*(.*)\s*$/ and do { |
my $conf = "$1\n"; | my $conf = "$1\n"; |
my $line; | my $line; |
while ($line = <>) { | while ($line = <>) { |
last if $line =~ /^@@/; | last if $line =~ /^@@/; |
$conf .= "$line"; | $conf .= "$line"; |
} | } |
$pkg->{config} = $conf; | $pkg->{config} = $conf; |
} | }; |
/^Prereq-Check:/ and $pkg->{prereq} = 1; | |
/^Preconfig:\s*(.+)\s*$/ and do { | |
my $pkgname = $pkg->{name}; | |
$preconfig{$pkgname} or $preconfig{$pkgname} = []; | |
$preconfig = { | |
id => $1 | |
}; | |
push @{$preconfig{$pkgname}}, $preconfig; | |
}; | |
/^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1; | |
/^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1; | |
/^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1; | |
} | } |
return %category; | return %category; |
} | } |
sub gen_target_mk() { | sub gen_target_mk() { |
my @target = parse_target_metadata(); | my @target = parse_target_metadata(); |
@target = sort { | @target = sort { |
$a->{id} cmp $b->{id} | $a->{id} cmp $b->{id} |
} @target; | } @target; |
foreach my $target (@target) { | foreach my $target (@target) { |
my ($profiles_def, $profiles_eval); | my ($profiles_def, $profiles_eval); |
my $conf = uc $target->{kernel}.'_'.$target->{board}; | my $conf = uc $target->{kernel}.'_'.$target->{board}; |
$conf =~ tr/\.-/__/; | $conf =~ tr/\.-/__/; |
foreach my $profile (@{$target->{profiles}}) { | foreach my $profile (@{$target->{profiles}}) { |
$profiles_def .= " | $profiles_def .= " |
define Profile/$conf\_$profile->{id} | define Profile/$conf\_$profile->{id} |
ID:=$profile->{id} | ID:=$profile->{id} |
NAME:=$profile->{name} | NAME:=$profile->{name} |
PACKAGES:=".join(" ", @{$profile->{packages}})."\n"; | PACKAGES:=".join(" ", @{$profile->{packages}})."\n"; |
$profile->{kconfig} and $profiles_def .= " KCONFIG:=1\n"; | $profile->{kconfig} and $profiles_def .= " KCONFIG:=1\n"; |
$profiles_def .= " endef"; | $profiles_def .= " endef"; |
$profiles_eval .= " | $profiles_eval .= " |
\$(eval \$(call AddProfile,$conf\_$profile->{id}))" | \$(eval \$(call AddProfile,$conf\_$profile->{id}))" |
} | } |
print " | print " |
ifeq (\$(CONFIG_LINUX_$conf),y) | ifeq (\$(CONFIG_LINUX_$conf),y) |
define Target | define Target |
KERNEL:=$target->{kernel} | KERNEL:=$target->{kernel} |
BOARD:=$target->{board} | BOARD:=$target->{board} |
BOARDNAME:=$target->{name} | BOARDNAME:=$target->{name} |
LINUX_VERSION:=$target->{version} | LINUX_VERSION:=$target->{version} |
LINUX_RELEASE:=$target->{release} | LINUX_RELEASE:=$target->{release} |
LINUX_KARCH:=$target->{karch} | LINUX_KARCH:=$target->{karch} |
DEFAULT_PACKAGES:=".join(" ", @{$target->{packages}})." | DEFAULT_PACKAGES:=".join(" ", @{$target->{packages}})." |
endef$profiles_def | endef$profiles_def |
endif$profiles_eval | endif$profiles_eval |
" | " |
} | } |
print "\$(eval \$(call Target))\n"; | print "\$(eval \$(call Target))\n"; |
} | } |
sub target_config_features(@) { | sub target_config_features(@) { |
my $ret; | my $ret; |
while ($_ = shift @_) { | while ($_ = shift @_) { |
/broken/ and $ret .= "\tdepends BROKEN\n"; | /broken/ and $ret .= "\tdepends BROKEN\n"; |
/pci/ and $ret .= "\tselect PCI_SUPPORT\n"; | /pci/ and $ret .= "\tselect PCI_SUPPORT\n"; |
/usb/ and $ret .= "\tselect USB_SUPPORT\n"; | /usb/ and $ret .= "\tselect USB_SUPPORT\n"; |
/atm/ and $ret .= "\tselect ATM_SUPPORT\n"; | /atm/ and $ret .= "\tselect ATM_SUPPORT\n"; |
/pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; | /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; |
/video/ and $ret .= "\tselect VIDEO_SUPPORT\n"; | /video/ and $ret .= "\tselect VIDEO_SUPPORT\n"; |
/squashfs/ and $ret .= "\tselect USES_SQUASHFS\n"; | /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n"; |
/jffs2/ and $ret .= "\tselect USES_JFFS2\n"; | /jffs2/ and $ret .= "\tselect USES_JFFS2\n"; |
/ext2/ and $ret .= "\tselect USES_EXT2\n"; | /ext2/ and $ret .= "\tselect USES_EXT2\n"; |
} | } |
return $ret; | return $ret; |
} | } |
sub gen_target_config() { | sub gen_target_config() { |
my @target = parse_target_metadata(); | my @target = parse_target_metadata(); |
@target = sort { | @target = sort { |
$a->{name} cmp $b->{name} | $a->{name} cmp $b->{name} |
} @target; | } @target; |
print <<EOF; | print <<EOF; |
choice | choice |
prompt "Target System" | prompt "Target System" |
default LINUX_2_4_BRCM | default LINUX_2_4_BRCM |
reset if !DEVEL | reset if !DEVEL |
EOF | EOF |
foreach my $target (@target) { | foreach my $target (@target) { |
my $features = target_config_features(@{$target->{features}}); | my $features = target_config_features(@{$target->{features}}); |
my $help = $target->{desc}; | my $help = $target->{desc}; |
my $kernel = $target->{kernel}; | my $kernel = $target->{kernel}; |
$kernel =~ tr/./_/; | $kernel =~ tr/./_/; |
chomp $features; | chomp $features; |
$features .= "\n"; | $features .= "\n"; |
if ($help =~ /\w+/) { | if ($help =~ /\w+/) { |
$help =~ s/^\s*/\t /mg; | $help =~ s/^\s*/\t /mg; |
$help = "\thelp\n$help"; | $help = "\thelp\n$help"; |
} else { | } else { |
undef $help; | undef $help; |
} | } |
print <<EOF | print <<EOF |
config LINUX_$target->{conf} | config LINUX_$target->{conf} |
bool "$target->{name}" | bool "$target->{name}" |
select $target->{arch} | select $target->{arch} |
select LINUX_$kernel | select LINUX_$kernel |
$features$help | $features$help |
EOF | EOF |
} | } |
print <<EOF; | print <<EOF; |
if DEVEL | if DEVEL |
config LINUX_2_6_ARM | config LINUX_2_6_ARM |
bool "UNSUPPORTED little-endian arm platform" | bool "UNSUPPORTED little-endian arm platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select arm | select arm |
config LINUX_2_6_CRIS | config LINUX_2_6_CRIS |
bool "UNSUPPORTED cris platform" | bool "UNSUPPORTED cris platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select cris | select cris |
config LINUX_2_6_M68K | config LINUX_2_6_M68K |
bool "UNSUPPORTED m68k platform" | bool "UNSUPPORTED m68k platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select m68k | select m68k |
config LINUX_2_6_SH3 | config LINUX_2_6_SH3 |
bool "UNSUPPORTED little-endian sh3 platform" | bool "UNSUPPORTED little-endian sh3 platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select sh3 | select sh3 |
config LINUX_2_6_SH3EB | config LINUX_2_6_SH3EB |
bool "UNSUPPORTED big-endian sh3 platform" | bool "UNSUPPORTED big-endian sh3 platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select sh3eb | select sh3eb |
config LINUX_2_6_SH4 | config LINUX_2_6_SH4 |
bool "UNSUPPORTED little-endian sh4 platform" | bool "UNSUPPORTED little-endian sh4 platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select sh4 | select sh4 |
config LINUX_2_6_SH4EB | config LINUX_2_6_SH4EB |
bool "UNSUPPORTED big-endian sh4 platform" | bool "UNSUPPORTED big-endian sh4 platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select sh4eb | select sh4eb |
config LINUX_2_6_SPARC | config LINUX_2_6_SPARC |
bool "UNSUPPORTED sparc platform" | bool "UNSUPPORTED sparc platform" |
depends BROKEN | depends BROKEN |
select LINUX_2_6 | select LINUX_2_6 |
select sparc | select sparc |
endif | endif |
endchoice | endchoice |
choice | choice |
prompt "Target Profile" | prompt "Target Profile" |
EOF | EOF |
foreach my $target (@target) { | foreach my $target (@target) { |
my $profiles = $target->{profiles}; | my $profiles = $target->{profiles}; |
foreach my $profile (@$profiles) { | foreach my $profile (@$profiles) { |
print <<EOF; | print <<EOF; |
config LINUX_$target->{conf}_$profile->{id} | config LINUX_$target->{conf}_$profile->{id} |
bool "$profile->{name}" | bool "$profile->{name}" |
depends LINUX_$target->{conf} | depends LINUX_$target->{conf} |
EOF | EOF |
$profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n"; | $profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n"; |
my %pkgs; | my %pkgs; |
foreach my $pkg (@{$target->{packages}}, @{$profile->{packages}}) { | foreach my $pkg (@{$target->{packages}}, @{$profile->{packages}}) { |
$pkgs{$pkg} = 1; | $pkgs{$pkg} = 1; |
} | } |
foreach my $pkg (keys %pkgs) { | foreach my $pkg (keys %pkgs) { |
print "\tselect DEFAULT_$pkg\n" unless ($pkg =~ /^-/ or $pkgs{"-$pkg"}); | print "\tselect DEFAULT_$pkg\n" unless ($pkg =~ /^-/ or $pkgs{"-$pkg"}); |
} | } |
print "\n"; | print "\n"; |
} | } |
} | } |
print "endchoice\n"; | print "endchoice\n"; |
} | } |
sub find_package_dep($$) { | sub find_package_dep($$) { |
my $pkg = shift; | my $pkg = shift; |
my $name = shift; | my $name = shift; |
my $deps = ($pkg->{vdepends} or $pkg->{depends}); | my $deps = ($pkg->{vdepends} or $pkg->{depends}); |
return 0 unless defined $deps; | return 0 unless defined $deps; |
foreach my $dep (@{$deps}) { | foreach my $dep (@{$deps}) { |
return 1 if $dep eq $name; | return 1 if $dep eq $name; |
return 1 if ($package{$dep} and (find_package_dep($package{$dep},$name) == 1)); | return 1 if ($package{$dep} and (find_package_dep($package{$dep},$name) == 1)); |
} | } |
return 0; | return 0; |
} | } |
sub package_depends($$) { | sub package_depends($$) { |
my $a = shift; | my $a = shift; |
my $b = shift; | my $b = shift; |
my $ret; | my $ret; |
return 0 if ($a->{submenu} ne $b->{submenu}); | return 0 if ($a->{submenu} ne $b->{submenu}); |
if (find_package_dep($a, $b->{name}) == 1) { | if (find_package_dep($a, $b->{name}) == 1) { |
$ret = 1; | $ret = 1; |
} elsif (find_package_dep($b, $a->{name}) == 1) { | } elsif (find_package_dep($b, $a->{name}) == 1) { |
$ret = -1; | $ret = -1; |
} else { | } else { |
return 0; | return 0; |
} | } |
return $ret; | return $ret; |
} | } |
sub mconf_depends($$) { | sub mconf_depends($$) { |
my $depends = shift; | my $depends = shift; |
my $only_dep = shift; | my $only_dep = shift; |
my $res; | my $res; |
$depends or return; | $depends or return; |
my @depends = @$depends; | my @depends = @$depends; |
foreach my $depend (@depends) { | foreach my $depend (@depends) { |
my $m = "depends"; | my $m = "depends"; |
$depend =~ s/^([@\+]+)//; | $depend =~ s/^([@\+]+)//; |
my $flags = $1; | my $flags = $1; |
my $vdep; | my $vdep; |
if ($vdep = $package{$depend}->{vdepends}) { | if ($vdep = $package{$depend}->{vdepends}) { |
$depend = join("||", map { "PACKAGE_".$_ } @$vdep); | $depend = join("||", map { "PACKAGE_".$_ } @$vdep); |
} else { | } else { |
$flags =~ /\+/ and do { | $flags =~ /\+/ and do { |
next if $only_dep; | next if $only_dep; |
$m = "select"; | $m = "select"; |
# Menuconfig will not treat 'select FOO' as a real dependency | # Menuconfig will not treat 'select FOO' as a real dependency |
# thus if FOO depends on other config options, these dependencies | # thus if FOO depends on other config options, these dependencies |
# will not be checked. To fix this, we simply emit all of FOO's | # will not be checked. To fix this, we simply emit all of FOO's |
# depends here as well. | # depends here as well. |
$package{$depend} and $res .= mconf_depends($package{$depend}->{depends}, 1); | $package{$depend} and $res .= mconf_depends($package{$depend}->{depends}, 1); |
}; | }; |
$flags =~ /@/ or $depend = "PACKAGE_$depend"; | $flags =~ /@/ or $depend = "PACKAGE_$depend"; |
} | } |
$res .= "\t\t$m $depend\n"; | $res .= "\t\t$m $depend\n"; |
} | } |
return $res; | return $res; |
} | } |
sub print_package_config_category($) { | sub print_package_config_category($) { |
my $cat = shift; | my $cat = shift; |
my %menus; | my %menus; |
my %menu_dep; | my %menu_dep; |
return unless $category{$cat}; | return unless $category{$cat}; |
print "menu \"$cat\"\n\n"; | print "menu \"$cat\"\n\n"; |
my %spkg = %{$category{$cat}}; | my %spkg = %{$category{$cat}}; |
foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) { | foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) { |
foreach my $pkg (@{$spkg{$spkg}}) { | foreach my $pkg (@{$spkg{$spkg}}) { |
my $menu = $pkg->{submenu}; | my $menu = $pkg->{submenu}; |
if ($menu) { | if ($menu) { |
$menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep}; | $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep}; |
} else { | } else { |
$menu = 'undef'; | $menu = 'undef'; |
} | } |
$menus{$menu} or $menus{$menu} = []; | $menus{$menu} or $menus{$menu} = []; |
push @{$menus{$menu}}, $pkg; | push @{$menus{$menu}}, $pkg; |
print "\tconfig DEFAULT_".$pkg->{name}."\n"; | print "\tconfig DEFAULT_".$pkg->{name}."\n"; |
print "\t\tbool\n\n"; | print "\t\tbool\n\n"; |
} | } |
} | } |
my @menus = sort { | my @menus = sort { |
($a eq 'undef' ? 1 : 0) or | ($a eq 'undef' ? 1 : 0) or |
($b eq 'undef' ? -1 : 0) or | ($b eq 'undef' ? -1 : 0) or |
($a cmp $b) | ($a cmp $b) |
} keys %menus; | } keys %menus; |
foreach my $menu (@menus) { | foreach my $menu (@menus) { |
my @pkgs = sort { | my @pkgs = sort { |
package_depends($a, $b) or | package_depends($a, $b) or |
($a->{name} cmp $b->{name}) | ($a->{name} cmp $b->{name}) |
} @{$menus{$menu}}; | } @{$menus{$menu}}; |
if ($menu ne 'undef') { | if ($menu ne 'undef') { |
$menu_dep{$menu} and print "if $menu_dep{$menu}\n"; | $menu_dep{$menu} and print "if $menu_dep{$menu}\n"; |
print "menu \"$menu\"\n"; | print "menu \"$menu\"\n"; |
} | } |
foreach my $pkg (@pkgs) { | foreach my $pkg (@pkgs) { |
my $title = $pkg->{name}; | my $title = $pkg->{name}; |
my $c = (72 - length($pkg->{name}) - length($pkg->{title})); | my $c = (72 - length($pkg->{name}) - length($pkg->{title})); |
if ($c > 0) { | if ($c > 0) { |
$title .= ("." x $c). " ". $pkg->{title}; | $title .= ("." x $c). " ". $pkg->{title}; |
} | } |
print "\t"; | print "\t"; |
$pkg->{menu} and print "menu"; | $pkg->{menu} and print "menu"; |
print "config PACKAGE_".$pkg->{name}."\n"; | print "config PACKAGE_".$pkg->{name}."\n"; |
print "\t\ttristate \"$title\"\n"; | print "\t\ttristate \"$title\"\n"; |
print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n"; | print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n"; |
foreach my $default (split /\s*,\s*/, $pkg->{default}) { | foreach my $default (split /\s*,\s*/, $pkg->{default}) { |
print "\t\tdefault $default\n"; | print "\t\tdefault $default\n"; |
} | } |
print mconf_depends($pkg->{depends}, 0); | print mconf_depends($pkg->{depends}, 0); |
print "\t\thelp\n"; | print "\t\thelp\n"; |
print $pkg->{description}; | print $pkg->{description}; |
print "\n"; | print "\n"; |
$pkg->{config} and print $pkg->{config}."\n"; | $pkg->{config} and print $pkg->{config}."\n"; |
} | } |
if ($menu ne 'undef') { | if ($menu ne 'undef') { |
print "endmenu\n"; | print "endmenu\n"; |
$menu_dep{$menu} and print "endif\n"; | $menu_dep{$menu} and print "endif\n"; |
} | } |
} | } |
print "endmenu\n\n"; | print "endmenu\n\n"; |
undef $category{$cat}; | undef $category{$cat}; |
} | } |
sub gen_package_config() { | sub gen_package_config() { |
parse_package_metadata(); | parse_package_metadata(); |
print "menu \"Image configuration\"\n"; | |
foreach my $preconfig (keys %preconfig) { | |
print "\tcomment \"$preconfig\"\n"; | |
foreach my $cfg (@{$preconfig{$preconfig}}) { | |
my $conf = $cfg->{id}; | |
$conf =~ tr/\.-/__/; | |
print <<EOF | |
config UCI_PRECONFIG_$conf | |
string "$cfg->{label}" | |
depends PACKAGE_$preconfig | |
default "$cfg->{default}" | |
EOF | |
} | |
} | |
print "endmenu\n\n"; | |
print_package_config_category 'Base system'; | print_package_config_category 'Base system'; |
foreach my $cat (keys %category) { | foreach my $cat (keys %category) { |
print_package_config_category $cat; | print_package_config_category $cat; |
} | } |
} | } |
sub gen_package_mk() { | |
my %conf; | |
my %dep; | |
my $line; | |
parse_package_metadata(); | |
foreach my $name (sort {uc($a) cmp uc($b)} keys %package) { | |
my $config; | |
my $pkg = $package{$name}; | |
next if defined $pkg->{vdepends}; | |
if ($ENV{SDK}) { | |
$conf{$pkg->{src}} or do { | |
$config = 'm'; | |
$conf{$pkg->{src}} = 1; | |
}; | |
} else { | |
$config = "\$(CONFIG_PACKAGE_$name)" | |
} | |
if ($config) { | |
print "package-$config += $pkg->{src}\n"; | |
$pkg->{prereq} and print "prereq-$config += $pkg->{src}\n"; | |
} | |
my $hasdeps = 0; | |
my $depline = ""; | |
foreach my $dep (@{$pkg->{depends}}, @{$pkg->{builddepends}}) { | |
next if $dep =~ /@/; | |
$dep =~ s/\+//; | |
my $idx; | |
my $pkg_dep = $package{$dep}; | |
$pkg_dep or $pkg_dep = $srcpackage{$dep}->[0]; | |
next unless defined $pkg_dep; | |
next if defined $pkg_dep->{vdepends}; | |
if (defined $pkg_dep->{src}) { | |
($pkg->{src} ne $pkg_dep->{src}) and $idx = $pkg_dep->{src}; | |
} elsif (defined($pkg_dep) && !defined($ENV{SDK})) { | |
$idx = $dep; | |
} | |
undef $idx if $idx =~ /^(kernel)|(base-files)$/; | |
if ($idx) { | |
next if $dep{$pkg->{src}."->".$idx}; | |
$depline .= " $idx\-compile"; | |
$dep{$pkg->{src}."->".$idx} = 1; | |
} | |
} | |
if ($depline) { | |
$line .= "$pkg->{src}-compile: $depline\n"; | |
} | |
} | |
if ($line ne "") { | |
print "\n$line"; | |
} | |
foreach my $preconfig (keys %preconfig) { | |
my $cmds; | |
foreach my $cfg (@{$preconfig{$preconfig}}) { | |
my $conf = $cfg->{id}; | |
$conf =~ tr/\.-/__/; | |
$cmds .= "\techo \"uci set '$cfg->{id}=\$(subst \",,\$(CONFIG_UCI_PRECONFIG_$conf))'\"; \\\n"; | |
} | |
next unless $cmds; | |
print <<EOF | |
\$(TARGET_DIR)/etc/uci-defaults/$preconfig: FORCE | |
( \\ | |
$cmds \\ | |
) > \$@ | |
preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig | |
EOF | |
} | |
} | |
sub parse_command() { | sub parse_command() { |
my $cmd = shift @ARGV; | my $cmd = shift @ARGV; |
for ($cmd) { | for ($cmd) { |
/^target_mk$/ and return gen_target_mk(); | /^target_mk$/ and return gen_target_mk(); |
/^target_config$/ and return gen_target_config(); | /^target_config$/ and return gen_target_config(); |
/^package_mk$/ and return gen_package_mk(); | |
/^package_config$/ and return gen_package_config(); | /^package_config$/ and return gen_package_config(); |
} | } |
print <<EOF | print <<EOF |
Available Commands: | Available Commands: |
$0 target_mk [file] Target metadata in makefile format | $0 target_mk [file] Target metadata in makefile format |
$0 target_config [file] Target metadata in Kconfig format | $0 target_config [file] Target metadata in Kconfig format |
$0 package_mk [file] Package metadata in makefile format | |
$0 package_config [file] Package metadata in Kconfig format | $0 package_config [file] Package metadata in Kconfig format |
EOF | EOF |
} | } |
parse_command(); | parse_command(); |
# Makefile for OpenWrt | # Makefile for OpenWrt |
# | # |
# Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name> | # Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name> |
# | # |
# This program is free software; you can redistribute it and/or modify | # This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by | # it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 2 of the License, or | # the Free Software Foundation; either version 2 of the License, or |
# (at your option) any later version. | # (at your option) any later version. |
# | # |
# This program is distributed in the hope that it will be useful, | # This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
# General Public License for more details. | # General Public License for more details. |
# | # |
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License |
# along with this program; if not, write to the Free Software | # along with this program; if not, write to the Free Software |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# | # |
RELEASE:=Kamikaze | RELEASE:=Kamikaze |
#VERSION:=2.0 # uncomment for final release | #VERSION:=2.0 # uncomment for final release |
#-------------------------------------------------------------- | #-------------------------------------------------------------- |
# Just run 'make menuconfig', configure stuff, then run 'make'. | # Just run 'make menuconfig', configure stuff, then run 'make'. |
# You shouldn't need to mess with anything beyond this point... | # You shouldn't need to mess with anything beyond this point... |
#-------------------------------------------------------------- | #-------------------------------------------------------------- |
TOPDIR=${shell pwd} | TOPDIR=${shell pwd} |
export TOPDIR | export TOPDIR |
DEVELOPER=1 | DEVELOPER=1 |
export DEVELOPER | export DEVELOPER |
SDK=1 | |
export SDK | |
all: world | all: world |
.pkginfo: FORCE | .pkginfo: FORCE |
ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo) | ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo) |
@echo Collecting package info... | @echo Collecting package info... |
@-for dir in package/*/; do \ | @-for dir in package/*/; do \ |
echo Source-Makefile: $${dir}Makefile; \ | echo Source-Makefile: $${dir}Makefile; \ |
$(MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \ | $(MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \ |
done > $@ | done > $@ |
endif | endif |
pkginfo-clean: FORCE | pkginfo-clean: FORCE |
-rm -f .pkginfo .config.in | -rm -f .pkginfo .config.in |
package/%: .pkginfo FORCE | package/%: .pkginfo FORCE |
$(MAKE) -C package $(patsubst package/%,%,$@) SDK=1 | $(MAKE) -C package $(patsubst package/%,%,$@) SDK=1 |
download: FORCE | download: FORCE |
$(MAKE) package/download | $(MAKE) package/download |
world: FORCE | world: FORCE |
$(MAKE) package/compile | $(MAKE) package/compile |
-( \ | -( \ |
cd package; \ | cd package; \ |
find . -maxdepth 2 -name Config.in | \ | find . -maxdepth 2 -name Config.in | \ |
sed -e 's,/Config.in,,g' | \ | sed -e 's,/Config.in,,g' | \ |
xargs -r -n1 make compile -C; \ | xargs -r -n1 make compile -C; \ |
) | ) |
clean: FORCE | clean: FORCE |
rm -rf build_* bin | rm -rf build_* bin |
distclean: clean | distclean: clean |
rm -rf dl .pkg* | rm -rf dl .pkg* |
.PHONY: FORCE | .PHONY: FORCE |
FORCE: | FORCE: |