Giter VIP home page Giter VIP logo

arp-bs's Introduction

ARP-Buildsystem

Image build-system for settopboxes sh4 based remake of duckbox tdt

Please read the following readme carefully if you still have question create an issue with question tag на русском, in english, auf deutsch !

Start

Preparation

  1. To avoid data loss I recommend you to run this build system under individual user. So these build scripts have no chance to mess in your main home directory !
  2. Your host system requires some packages. Run sudo ./setuptdt.sh. If don't like to run unknown scripts under root install them manually

That's it, now start toolchain 2. Generate config: run make -f Makefile.setup xconfig or make -f Makefile.setup menuconfig 3. Generate core Makefile run make -f Makefile.setup 4. Add make compleshion by TAB: source make-completion.sh 5. To build image exec buildsystem with make target-image 6. A lot of make targets are available

This toolchain is based on GNU Make and small perl preporcessor for generating make files. The first section is about our preprocessor (Smart-rules) and the second one is about [(Makefile conventions)](#Makefile conventions)

Smart-rules

Smart-rules is Makefile preprocessor written in perl, it helps to write simpler Makefiles.

Makefile.pre --> |smart-rules.pl| --> Makefile

You must understand that firstly it expands all smart-rules macroses, and secondly make evaluates Makefile variables.

It has following features:

Rule section

example

rule[[
   extract:http://project.com/prog-${PV}.tar.gz
   file://hello_world.c
   patch:file://fixqq.diff
]]rule

format

Rules are separated by line break, all trailing white-spaces are ignored, use them for prettier indentation. Use # for comments, Makefile conditionals are not touched.

rule[[
  <rule1>  # this is comment
ifdef FEATURE_2
  <rule2>
endif
  ...
  ...
  ...
]]rule

purpose

This macro defines variables for future use in Makefile. They are DEPENDS , PREPARE , INSTALL and SRC_URI. Additional special targets and variables also printed to Makefile.

rules format

variants are

command:arg1:arg2:...:url:url-arg1:url-arg2:....
url:url-arg1:url-arg2:.... # default is extract command with no arguments
command:arg1:arg2:...      # some commands doesn't require url.

url is detected by protocol://path pattern. If ; is found in rule it becomes a separator instead of :.

stage prepare

Commands that result in PREPARE variable

nothing|extract|dirextract|patch(-(\d+))?|pmove|premove|plink|pdircreate

  • nothing
    copy file to ${DIR}. No arguments, url required
  • extract
    extract archive to $(workprefix). No arguments, url required
  • dirextract
    extract archive to ${DIR}. No arguments, url required
  • patch or patch-%d
    execute patch -p%d arg1 arg2 ... url required, default patch level is 1
  • pmove
    execute mv arg1 arg2 url not supported
  • premove
    execute rm -rf arg1 url not supported
  • plink
    execute ln -sf arg1 arg2. url not supported
  • pdircreate
    execute mkdir -p arg1 url is not supported

stage install

Commands that result in INSTALL variable

install|install_file|install_bin|make|move|remove|mkdir|link

  • install
    execute install arg1 arg2 ... If url is not provided
    or
    execute install file arg1 arg2 ... Where file is downloaded from url
  • install_file
    execute install file -m644 arg1 arg2 ... Where file is downloaded from url
  • install_bin
    execute install file -m755 arg1 arg2 ... Where file is downloaded from url
  • make
    execute make arg1 arg2 ... url is not supported
  • move
    execute mv arg1 arg2 url not supported
  • remove
    execute rm -rf arg1 url not supported
  • mkdir
    execute mkdir -p arg1 url is not supported
  • link
    execute ln -sf arg1 arg2 url not supported

these are most common tasks, see smart-rules.pl for details and feel free to add more.. However, some special rules is better to write directly to .mk file

fetch mechanisms

Now consider sources that are supported. Each url creates rule for downloading file, and append it to DEPENDS variable. Also url is appended to SRC_URI variable for future use in opkg CONTROL file.

https|http|ftp|file|git|svn|local|localwork

  • http:// - http wget download
  • https:// - https wget download
  • ftp:// - ftp wget download
  • git://www.gitserver.com/gitrepo:r=revision:b=branch:sub=subdir_in_git_tree:protocol=http
    • revision, branch and subdirectory to use (arguments are optional).
    • and protocol which git should use. (replaces 'git://' while fetch)
    • use protocol=ssh to replace "git://" with "git@"
  • svn://www.svnserver.com/svnrepo:r=revision
    • only revision option
  • file:// - file path prefixed with $(srcdir)/make/
  • localwork:// - temporary file in ${DIR}
  • local:// - not prefixed file name.

Package macro

example

input

package[[ example_lib
PV_${P} = 1
PR_${P} = 2

$(TARGET_${P}).do_package:
  echo ${PV}-${PR} > $(PKDIR)/etc/version
  touch $@
]]package

output

PV_example_lib = 1
PR_example_lib = 2

$(TARGET_example_lib).do_package:
  echo $(PV_example_lib)-$(PR_example_lib) > $(PKDIR)/etc/version
  touch $@

format

package[[ package_name
line1
line2
...
]]package

It does replacement in the body:

  • ${P} --> package_name
  • ${VARIABLE} --> $(VARIABLE_package_name)

purpose

In make all variables are global, but in buildsystem we have a lot of pacakges with similar properties like version, release etc. So we must name variables like in output example, but we have a lot of same code for different packages and I want it to look the same ! Furthermore see next chapter about functions.

Smart copy paste

example

function[[ common_code
$(TARGET_${P}).do_compile:
  cd ${DIR} && make
  touch $@
]]function

package[[ pkg1
call[[ common_code ]]
$(TARGET_${P}).do_package: $(TARGET_${P}).do_compile
  install data1 $(PKDIR)/usr/share
  touch $@
]]package

package[[ pkg2
call[[ common_code ]]
$(TARGET_${P}).do_package: $(TARGET_${P}).do_compile
  install 2.png $(PKDIR)/usr/share
  touch $@
]]package

purpose

This macroses allows to define chunks of code for future use. Code block inside function is saved in memory and pasted instead of call.

Makefile conventions

Every package usually have some standart targets with typical things to do:

  • do_prepare - Clean working directory, then sources extraction and patching.
  • do_compile - Configuring sources and building binaries.
  • do_package - Copying resulting files to $(PKDIR) tree
  • do_ipk - Building package from $(PKDIR) tree for futher installing in targetprefix root
  • do_install - Installing files to targetprefix by installing coresponding *.ipk

There are coresponding clean*_ targets... And more.

arp-bs's People

Contributors

2017397902 avatar andreyvys avatar atvcaptain avatar b4team avatar bpanther avatar crazycat69 avatar demmi avatar hellmaster1024 avatar j00zek avatar kpckpc avatar lareq avatar maxwiesel avatar osaiya avatar pachost avatar seife avatar sid8796 avatar smogm avatar t4ndeta avatar taapat avatar technic avatar teissler avatar titanobi avatar zakalibit avatar

Watchers

 avatar  avatar

Forkers

popazerty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.