In this RFC I want to describe a way to get rid of mk/pkg-depend.mk
and build the "build dependecy tree" dynamicly.
I like the Gentoo way of build packages because you have total control
over everthing and this is done only with one file.

To support dependencies in the Makefile of our packages we need to
introduce something like "PKG_DEPENDS" where we define a list of space
seperated dependensies.

For instance, this is how our Subverson Makefile could look like:

# $FreeWRT$
#-
# This file is part of the FreeWRT project. FreeWRT is copyrighted
# material, please see the LICENCE file in the top-level directory
# or at http://www.freewrt.org/licence for details.

include ${TOPDIR}/rules.mk

PKG_NAME:=              subversion
PKG_VERSION:=           1.4.3
PKG_RELEASE:=           1
PKG_MD5SUM:=            6b991b63e3e1f69670c9e15708e40176
PKG_SOURCE_URL:=        http://subversion.tigris.org/downloads
PKG_DEPENDS:=           apr-utils libiconv zlib

include ${TOPDIR}/mk/package.mk

$(eval $(call 
PKG_template,SUBVERSION,$(PKG_NAME),${PKG_VERSION}-${PKG_RELEASE},${ARCH}))

CONFIGURE_STYLE:=       gnu
CONFIGURE_ARGS+=        --with-apr=${STAGING_DIR}/usr/bin/apr-config
CONFIGURE_ARGS+=        --with-apr-util=${STAGING_DIR}/usr/bin/apr-config
CONFIGURE_ARGS+=        --disable-mod-activation
CONFIGURE_ARGS+=        --disable-keychain
CONFIGURE_ARGS+=        --without-neon
CONFIGURE_ARGS+=        --without-apxs
CONFIGURE_ARGS+=        --without-swig
CONFIGURE_ARGS+=        --disable-experimental-libtool
CONFIGURE_ARGS+=        --without-jikes
CONFIGURE_ARGS+=        --without-jdk
CONFIGURE_ARGS+=        --disable-javahl
CONFIGURE_ARGS+=        --without-berkeley-db

LIBS=                   -laprutil-0 -lapr-0 -lexpat -liconv

ifeq ($(FWRT_PACKAGE_APR_THREADING),y)
LIBS+=                  -pthread
endif

CONFIGURE_ENV+=         LIBS='${LIBS}'

BUILD_STYLE:=           auto
INSTALL_STYLE:=         auto
INSTALL_TARGET:=        external-install local-install

post-install:
       ${INSTALL_DIR} ${IDIR_SUBVERSION}/usr/bin
       ${INSTALL_DIR} ${IDIR_SUBVERSION}/usr/lib
       ${CP} ${WRKINST}/usr/lib/* ${IDIR_SUBVERSION}/usr/lib
       ${CP} ${WRKINST}/usr/bin/* ${IDIR_SUBVERSION}/usr/bin

include ${TOPDIR}/mk/pkg-bottom.mk



I will show you how our build-system could dynamicly generate the
dependencie tree when calling e.b. make package=subversion clean
install V=99


subversion needs
* apr-utils
* libiconv
* zlib

apr-utils needs
* apr
* expact

apr needs
* libpthread


libiconv needs
* -

zlib needs
* -

So we have a list of packages we need to have, to get subversion
build, but we need to build them in the correct order.
We can use the a very simple algorithem to sort them - its a bubblesort :)

List:
subversion
apr-utils
libiconv
zlib
apr
expact
libpthread

Create a copy of the original list

ListCopy := List

Iterate over List and modify order in ListCopy. We use the following
rule: Move all dependencies of a package in front
of the package.

So lets do a dry run:

Item := List[0]

List[] deps := get_deps_of_item(item)
Move all dep items before item

After the first run we get the following result

ListCopy:
apr-utils
libiconv
zlib
subversion
apr
expact
libpthread

We do this in a loop, until no more items left in List:

ListCopy:
apr
expact
apr-utils
libiconv
zlib
subversion
libpthread

ListCopy:
libpthread
apr
expact
apr-utils
libiconv
zlib
subversion

As a result we know the exact build order and our build-system can
start compiling the packages.
I want all your opinons about my idea and maybe i am allowed to make a
branch for testing and if everything works like expacted, we can merge
it back to trunk.

Thanks,
austriancoder
_______________________________________________
freewrt-developers mailing list
[email protected]
https://www.freewrt.org/lists/listinfo/freewrt-developers

Reply via email to