# in template nach �nderungen suchen und template die Zeit der letzten �nderung geben indent = $(shell s=" "; s=$${s:0:${MAKELEVEL}}; echo -n "$$s$$s") color_gray := \\033[1;30m color_red := \\033[1;31m color_green := \\033[1;32m color_yellow := \\033[1;33m color_blue := \\033[1;34m color_purple := \\033[1;35m color_cyan := \\033[1;36m color_white := \\033[1;37m color_black := \\033[1;38m color_reset := \\033[0;39m _all: dep ../INITRAMFS echo -e "$(indent)$(echoprefix)$(color_black)$(name)$(color_reset):" if [ -e template ]; then \ find template -newer template -prune ! -path '*/.svn' -exec touch -r {} template ';'; \ if [ INSTALL -nt template ]; then touch -r INSTALL template; fi; \ if [ Makefile -nt template ]; then touch -r Makefile template; fi; \ fi $(MAKE) all svn status 2>/dev/null | grep -e "^M" -e "^A" -e "^D" -e "^\? \+template/" || true _clean: rm -rf $(modul) rm -f $(modul).$(suffix) rm -f $(modulname) rm -f depends rm -f src/locale/*.pot clean_depends: cd ..; \ if [ "$(name)" = "kernel" -o "$(name)" = "KERNEL" ]; then \ grep -e "group.*=.*kernel" */Makefile -l; \ else \ grep "$(name)" */depends -l; \ fi | cut -d / -f1 | while read name; do \ echo -e "\t clean up addon: $$name"; \ $(MAKE) -C $$name clean; \ done clean_src: $(MAKE) -f ../Makefile.getfile clean name=$(name) # Lib und Mod abh�ngigkeiten aufl�sen update_dep: modules_dep libs_dep # abh�ngige Module zusammensuchen modules_dep: @if [ -e $(modul)/lib/modules ]; then \ find `if [ -n "$(filename)" ]; then echo $(filename); else echo $(modul)/lib/modules; fi` -type f -name '*.ko' ! -path '*/.svn/*' | while read modul; do \ base=$${modul%%/*}; \ mod=$${modul##*/}; \ OLDIFS=$$IFS; \ IFS=,; \ for mod in `/sbin/modinfo $$modul 2>/dev/null | grep depends: | cut -b 17-`; do \ IFS=$$OLDIFS; \ if [ -z "$$mod" ]; then \ continue; \ fi; \ mod=$$mod.ko; \ if [ -x INSTALL ]; then \ if [ -n "`./INSTALL depend`" ]; then \ depend="`./INSTALL depend | sed "s/|/ /g"` "; \ if [ -n "`cd ../; find $${depend// //$$base} -name $$mod`" ]; then \ find $$base -name $$mod | while read f; do \ echo -e "\t Entferne Modul: $$f"; \ rm -f $$f; \ rmdir --ignore-fail-on-non-empty -p $${f%/*}; \ done; \ continue; \ fi; \ fi; \ fi; \ new=`find lib/modules/ -name $$mod 2>/dev/null`; \ if [ -z "$$new" ]; then \ new=`find ../KERNEL/lib/modules/ -name $$mod`; \ if [ -z "$$new" ]; then \ echo -e "\t Modul nicht gefunden: $(color_red)$$mod$(color_reset)"; \ echo -e "\t Benötigt von: $$modul"; \ continue; \ fi; \ fi; \ path=$${new%/*}; \ path=/$${path#../KERNEL/}; \ if [ ! -e $$base$$path/$$mod ]; then \ true || echo -e "\t Kopiere Modul: $$new"; \ true || echo -e "\t Benötigt von: $$modul"; \ mkdir -p $$base$$path; \ cp -p $$new $$base$$path/; \ $(MAKE) -s modules_dep filename="$$base/$$path/$$mod"; \ fi; \ done; \ done; \ fi depends: touch $@.tmp deps="INITRAMFS $$(test -e ./INSTALL && ./INSTALL depend | sed "s/\(|\| \|\$$\)\+/ /g")"; \ for dep in $$deps; do \ if pwd | grep -v -q "$$dep$$"; then \ if [ -z "$(filename)" -a ! -d ../$$dep/$(modul) ]; then \ $(MAKE) ../$$dep; \ if [ -d ../$$dep ]; then \ $(MAKE) -C ../$$dep; \ echo "$(indent)Build $(nameprefix)$(name)..."; \ fi; \ fi; \ if [ -d ../$$dep ]; then \ $(MAKE) -C ../$$dep $@; \ cat ../$$dep/$@ >> $@.tmp; \ fi; \ echo $$dep >> $@.tmp; \ fi; \ done sort -u $@.tmp >> $@ rm $@.tmp # von 'filename' ben�tigte Librarys zusammensuchen und nach $(modul)/ kopieren libs_dep: depends @depends="$(addprefix ../,$(addsuffix /$(modul),$(shell cat depends)))"; \ find `if [ -n "$(filename)" ]; then echo $(filename); else echo $(modul); fi` -type f ! -path '*/.svn/*' 2>/dev/null | while read filename; do \ if ldd $$filename >/dev/null 2>&1; then \ { echo "$${filename##*/} /$${filename#*/}"; ldd $$filename 2>/dev/null | cut -d" " -f1,3; } | while read lib; do \ name=$${lib%% *}; \ name=$${name##*/}; \ lib=$${lib##* }; \ if [ -n "$$lib" -a "$$lib" != "$$name" ]; then \ continue=0; \ for dep in $$depends; do \ if [ -e $$dep/$$lib ]; then \ if [ -e $(modul)/$$lib ]; then \ echo -e "\t Entferne Library: $(color_yellow)$$lib$(color_reset)"; \ echo -e "\t Bereits enthalten in: $${dep%/*}"; \ rm -f $(modul)/$$lib; \ rmdir --ignore-fail-on-non-empty -p $(modul)/$${lib%/*}; \ fi; \ continue=1; \ fi; \ done; \ if [ "$$continue" = "0" -a "$(modul)$$lib" != "$$filename" ]; then \ if [ $$lib = "not" ]; then \ if [ -z "`find $(modul) $$depends -name $$name`" ]; then \ echo -e "\t Library fehlet: $(color_red)$${name}$(color_reset)"; \ echo -e "\t Benötigt von: $$filename"; \ fi; \ elif [ -z "$${lib##/*}" ]; then \ libname=`basename $$lib`; \ libpath=`dirname $$lib`; \ if [ -z "`find $(modul) -name $$libname`" ]; then \ echo -e "\t Kopiere Library: $$lib"; \ echo -e "\t Benötigt von: /$${filename#*/}"; \ mkdir -p $(modul)$$libpath; \ cp -p $$lib $(modul)$$libpath/; \ \ list="$$(find ../* -maxdepth 1 -name addon | while read path; do ls $$path/$$lib 2>/dev/null; done | grep -v "../$(name)")"; \ if [ -n "$$list" ]; then \ echo -e "\t Library existiert ebenfalls in: $(color_yellow)"; \ echo "$$list" | sed "s/..\/\([^\/]*\).*/\t - \1/"; \ echo -e -n "$(color_reset)"; \ fi; \ update=0; \ \ $(MAKE) -s libs_dep filename="$(modul)$$libpath/$$libname"; \ fi; \ fi;\ fi; \ fi; \ done; \ fi; \ done # ersätze links auf bynaries (inclusive libs) die auf das root Filesystem verweisen copy_from_host: @find $(modul) -lname '/*' -printf "%P %l\n" | while read from to; do \ to="$${to%/}"; \ if [ "/$$from" = "$$to" ]; then \ if [ ! -e $$to ]; then \ if [ -e $${to/i386-linux-gnu\//$(arch_lib)/} ]; then \ to=$${to/i386-linux-gnu\//$(arch_lib)/}; \ elif [ -e /usr$$to ]; then \ to=/usr$$to; \ elif [ -e /usr$${to/i386-linux-gnu\//$(arch_lib)/} ]; then \ to=/usr$${to/i386-linux-gnu\//$(arch_lib)/}; \ fi; \ if [ -e "$$to" ]; then \ rm $(modul)/$$from; \ rmdir -p --ignore-fail-on-non-empty $(modul)/$${from%/*}; \ mkdir -p $(modul)$${to%/*}; \ from=$$to; \ fi; \ fi; \ if [ -e $$to ]; then \ true echo -e "\t Kopiere vom Host System: $$to"; \ rm -f $(modul)/$$from; \ cp -dr $$to $(modul)/$$from || true; \ while [ -L $$to ]; do \ link=$$(readlink $$to); \ if [ -z "$${link##/*}" ]; then \ to=$$link; \ else \ to=$${to%/*}/$$link; \ fi; \ mkdir -p $(modul)$${to%/*}; \ cp -dr $$to $(modul)$${to%/*} || true; \ done; \ else \ echo -e "\t Defekter Link: $(color_red)template/$${to}$(color_reset)"; \ fi; \ fi; \ done # Module zusammensuchen modules: if [ -n "$(modules)" ]; then \ $(MAKE) -C ../KERNEL lib; \ mkdir -p $(modul)/lib/modules; \ for modul in $(modules); do \ file=`find lib/modules -name $$modul.ko 2>/dev/null`; \ if [ -z "$$file" ]; then \ file=`find ../KERNEL/lib/modules -name $$modul.ko`; \ if [ -z "$$file" ]; then \ echo -e "\t Modul nicht gefunden: $$modul"; \ fi; \ fi; \ if [ -n "$$file" ]; then \ file_to=$${file#../KERNEL/}; \ mkdir -p $(modul)/$${file_to%/*}; \ cp -up $$file $(modul)/$$file_to; \ fi; \ done; \ fi if [ -n "$(modulesDir)" ]; then \ $(MAKE) -C ../KERNEL lib; \ mkdir -p $(modul)/lib/modules; \ for modulDir in $(modulesDir); do \ path=lib/modules/$(KERNEL)/kernel/$$modulDir; \ if [ ! -d "$$path" ]; then \ path=../KERNEL/$$path; \ if [ ! -d "$$path" ]; then \ echo -e "\t Modul Verzeichnis nicht gefunden: $(color_red)$$modulDir$(color_reset)"; \ fi; \ fi; \ if [ -n "$$path" ]; then \ path_to=$${path#../KERNEL/}; \ mkdir -p $(modul)/$$path_to; \ cp -upr $$path/* $(modul)/$$path_to; \ fi; \ done; \ fi modules_firmware: @if [ -e $(modul)/lib/modules ]; then \ find $(modul)/lib/modules -name "*.ko" | while read mod; do \ modinfo $$mod | grep ^firmware | sed 's/.* //' | while read firmware; do \ file=lib/firmware/$$firmware; \ test -e $$file || file=../KERNEL/lib/firmware/$$firmware;\ test -e $$file || file=/lib/firmware/$$firmware;\ if [ -e $$file ]; then \ path=$(modul)/lib/firmware/$${firmware%$${firmware##*/}}; \ mkdir -p $$path; \ cp $$file $$path; \ else \ echo -e "\t Firmware nicht gefunden: $(color_red)$$firmware$(color_reset)"; \ fi; \ done; \ done; \ fi modules_map: @if [ -e $(modul)/lib/modules/$(KERNEL) ]; then \ test -e lib && depmod -m -b . $(KERNEL); \ mapfile=lib/modules/$(KERNEL)/modules; \ find $(modul)/lib/modules -name *.ko | while read mod; do \ mod=$${mod##*/}; \ mod=$${mod%.ko}; \ test -e lib && grep "^$$mod " $$mapfile.pcimap >> $(modul)/$$mapfile.pcimap.$(name) || true; \ grep "^$$mod " ../KERNEL/$$mapfile.pcimap >> $(modul)/$$mapfile.pcimap.$(name) || true; \ test -e lib && grep "^$$mod " $$mapfile.usbmap >> $(modul)/$$mapfile.usbmap.$(name) || true; \ grep "^$$mod " ../KERNEL/$$mapfile.usbmap >> $(modul)/$$mapfile.usbmap.$(name) || true; \ done; \ cat $(modul)/lib/modules/modules.pcimap.$(name) 2>/dev/null >> $(modul)/$$mapfile.pcimap.$(name) || true; \ cat $(modul)/lib/modules/modules.usbmap.$(name) 2>/dev/null >> $(modul)/$$mapfile.usbmap.$(name) || true; \ test ! -e $(modul)/lib/modules/modules.pcimap.$(name) || rm -f $(modul)/lib/modules/modules.pcimap.$(name); \ test ! -e $(modul)/lib/modules/modules.usbmap.$(name) || rm -f $(modul)/lib/modules/modules.usbmap.$(name); \ test -s $(modul)/$$mapfile.pcimap.$(name) || rm -f $(modul)/$$mapfile.pcimap.$(name); \ test -s $(modul)/$$mapfile.usbmap.$(name) || rm -f $(modul)/$$mapfile.usbmap.$(name); \ fi ../KERNEL/%: ../KERNEL $(MAKE) -C $(@D) $(@F) ../LOGO/%: ../LOGO $(MAKE) -C $(@D) $(@F) # fehlende, abh�ngige Module auschecken ../%: $(MAKE) -C .. checkout name=$* 2>/dev/null || { echo "Unknown Addon '$*'"; exit 1; } ; \ # svn Datein und Debug infos l�schen, lib und modul Abhängigkeiten auflösen $(addon): template INSTALL echo "$(indent)Build $(nameprefix)$(name)..." rm -rf $(modul) mkdir -p $(modul) cp -rf template/* $(modul) find $(modul) -path '*/.svn' -exec rm -rf {} ';' 2>/dev/null; true if [ -e INSTALL ]; then \ mkdir -p $(modul)/var/spool/apm; \ cp INSTALL $(modul)/var/spool/apm/$(basename $(name)); \ sed "s/^\t\*)/\tversion)\n\t\techo \"$(version)-$(modul_version)-$(make_version)\"\n\t\t;;\n\t*)/" -i $(modul)/var/spool/apm/$(basename $(name)); \ fi $(MAKE) tr $(MAKE) modules $(MAKE) history INSTALL: ; history: history=$(modul)/usr/share/doc/$(name)/history; \ mkdir -p $${history%/*}; \ rm -f $$history; \ state=0; \ { svn log; echo "MLD2"; svn log $(svn_old_url)/$(name)/trunk; } 2>/dev/null | while read line; do \ if [ "$$line" = "MLD2" ]; then \ echo "" >>$$history; \ echo "MLD 2.0.0" >>$$history; \ echo "" >>$$history; \ state=0; \ elif [ "$$line" = "------------------------------------------------------------------------" ]; then \ if [ $$state = 3 ]; then \ echo "" >>$$history; \ fi; \ state=1; \ elif [ $$state = 1 ]; then \ state=2; \ head=`echo "$$line" | sed "s/r\(.*\) | \(.*\) | \(....-..-..\) .*/Version \1 at \3 by \2/"`; \ elif [ $$state = 2 -a -n "$$line" ]; then \ state=3; \ echo "$$head" >>$$history; \ echo -e "\t$$line" >>$$history; \ elif [ $$state = 3 -a -n "$$line" ]; then \ echo -e "\t$$line" >>$$history; \ fi; \ done tr: rm -f src/locale/*.pot cd $(modul); \ find . -type f | while read file; do \ if [ -z "$${file#./etc/setup/*.xml}" ]; then \ grep 'name="[^"]*[()]' "$$file" && echo -e "\tUnerlaubte Klammer im Attribut 'name' der Datei: $$file"; \ grep 'help1="[^"]*[()]' "$$file" && echo -e "\tUnerlaubte Klammer im Attribut 'help1' der Datei: $$file"; \ sed 's/ name="\([^"]*\)"/ name="$$(tr '"'"'\1'"'"')"/' -i "$$file"; \ sed 's/ help1="\([^"]*\)"/ help1="$$(tr '"'"'\1'"'"')"/' -i "$$file"; \ fi; \ if grep -Iq '$$(tr' "$$file"; then \ mkdir -p ../src/locale; \ pot_file=../src/locale/$$(test -z "$${file#./var/www/*.sh}" && echo "www" || echo "$${file##*/}").pot; \ xgettext $$(test -e $$pot_file && echo '-j') -F -ktr -L shell --from-code=utf-8 -d "$(name)-$${file##*/}" --copyright-holder='Claus Muus ' --package-name=MLD --package-version=3 --msgid-bugs-address='' -o $$pot_file "$$file"; \ if [ -z "$${file#./var/www/*.sh}" ]; then \ sed "s/\$$(tr /\$$(TEXTDOMAIN=\"$(name)-www\" tr /" -i "$$file"; \ else \ sed "s/\(\s*\)\(.*rc.functions\)/\1\2\n\1TEXTDOMAIN=\"$(name)-$${file##*/}\"/" -i "$$file"; \ fi; \ fi; \ done ls -1 src/locale/*.pot 2>/dev/null | while read file; do \ for lc in $(LANGUAGES); do \ po_file=$${file%.*}.$$lc.po; \ if [ -e $$po_file ]; then \ msgmerge -q -U $$po_file $$file; \ else \ echo -en "\tÜbersetzungs Datei "; \ msginit --no-translator -l $$lc -i $$file -o $$po_file >/dev/null; \ sed 's/\(Content\-Type\: text\/plain\; charset\=\).*/\1utf-8\\n"/' -i $$po_file; \ fi; \ done; \ done ls -1 src/locale/*.po 2>/dev/null | while read file; do \ name=$${file%.*.*}; \ name=$${name##*/}; \ lc=$${file%.*}; \ lc=$${lc##*.}; \ mkdir -p $(modul)/usr/share/locale/$$lc/LC_MESSAGES/; \ msgfmt -o $(modul)/usr/share/locale/$$lc/LC_MESSAGES/$(name)-$$name.mo $$file; \ done copy_deps: $(MAKE) libs_dep $(MAKE) modules_dep $(MAKE) modules_firmware $(MAKE) modules_map find $(modul) -perm -1 -type f | while read f; do \ if [ ! -e "$${f%/*}/.dont-strip-unneeded" ]; then \ strip --strip-unneeded "$$f" 2>/dev/null; \ fi; \ done; true version: @echo $(version)_$(modul_version) deps: @echo $(deps) $(modul).sfs: $(modulname) ln -fs $^ $@ $(modulname): $(modul) $(MAKE) copy_from_host $(MAKE) copy_deps $(MAKE) $(modul).post find $(modul) -path '*/.svn' -exec rm -rf {} ';' 2>/dev/null; true rm -f $@ cd $(modul); mksquashfs * ../$@ -all-root >/dev/null chmod 644 $@ $(modul).post: patch: cd $(src_path); ls ../*.patch 2>/dev/null | sort | while read patch; do \ echo -e "\tUse patch $$patch"; \ patch -p1 -i $$patch || exit 1; \ done upload: rsync -acv -e ssh $(modulname) nightbuild@minidvblinux.dyndns.org:download/$(DISTRI_VER)/devel/$(shell whoami)/ clean_upload: if [ "$(shell whoami)" != "nightbuild" ]; then \ lftp -e "rm -r -f $(shell whoami); exit" -u nightbuild@minidvblinux.org,nightbuild minidvblinux.dyndns.org; \ fi dep: if type -P dpkg >/dev/null; then \ for dep in $(deps); do \ if ! dpkg --get-selections | grep -q -e "^$$dep[^a-zA-Z0-9-]\+install"; then \ echo -e "Das für $(name) benötigtes Ubuntu Paket $(color_red)$${dep}$(color_reset) fehlt."; \ deps="$$deps $$dep"; \ fi; \ done; \ fi; \ test -n "$$deps" && echo -e "Sie können es durch folgende Eingabe installieren:"; \ test -n "$$deps" && echo -e "sudo apt-get install$$deps\n"; \ test -n "$$deps" -a -n "$(deps_message)" && echo -e "$(deps_message)\n"; \ test -z "$$deps"