#!/bin/sh

# [Gedit Tool]
# Name=Build
# Name[af]=Bou
# Name[ar]=ابنِ
# Name[as]=বিল্ড
# Name[ast]=Construcción
# Name[be@latin]=Buduj
# Name[bg]=Компилиране
# Name[bn]=বিল্ড
# Name[bn_IN]=বিল্ড
# Name[ca]=Munta
# Name[ca@valencia]=Munta
# Name[crh]=İnşa
# Name[cs]=Sestavit
# Name[cy]=Adeiladu
# Name[da]=Byg
# Name[de]=Alles kompilieren
# Name[dz]=བཟོ་བརྩིགས་
# Name[el]=Χτίσιμο
# Name[en_GB]=Build
# Name[eo]=Munti
# Name[es]=Construir
# Name[et]=Ehitamine
# Name[eu]=Eraiki
# Name[fi]=Käännös
# Name[fr]=Construire
# Name[ga]=Tóg
# Name[gl]=Compilación
# Name[gu]=Build
# Name[he]=בנה
# Name[hi]=बिल्ड
# Name[hu]=Összeállítás
# Name[it]=Crea
# Name[ja]=ビルド
# Name[kn]=ನಿರ್ಮಾಣ
# Name[ko]=컴파일하기
# Name[lt]=Sukurti
# Name[lv]=Būvējums
# Name[mai]=निर्मित
# Name[mk]=Изгради
# Name[ml]=ബിള്‍ഡ്
# Name[mr]=बील्ड
# Name[nb]=Bygg
# Name[ne]=निर्माण गर्नुहोस्
# Name[nl]=Bouwen
# Name[oc]=Version
# Name[or]=ନିର୍ମାଣ କରନ୍ତୁ
# Name[pa]=Build
# Name[pl]=Zbuduj
# Name[ps]=جوړول
# Name[pt]=Compilação
# Name[pt_BR]=Compilar
# Name[ro]=Build
# Name[ru]=Сборка
# Name[si]=සාදන්න
# Name[sl]=Zgradi
# Name[sq]=Gjenero
# Name[sr]=Изгради
# Name[sr@latin]=Izgradi
# Name[sv]=Bygg
# Name[ta]=உருவாக்கு
# Name[te]=బుల్ట్
# Name[th]=ประกอบสร้าง
# Name[tr]=Derle
# Name[uk]=Збірка
# Name[vi]=Xây dựng
# Name[zh_CN]=构建
# Name[zh_HK]=建立
# Name[zh_TW]=建立
# Comment=Run "make" in the document directory
# Comment[ar]=شغّل "make" في دليل المستند
# Comment[as]=আলেখ্যন ধাৰণকাৰী পঞ্জিকাত "make" আদেশ সঞ্চালন কৰক
# Comment[ast]=Executar «make» nel direutoriu del documentu
# Comment[be@latin]=Uruchom "make" u katalohu dakumentu
# Comment[bg]=Стартиране на „make“ в папката на документа
# Comment[bn]=নথি ধারণকারী ডিরেক্টরির মধ্যে "make" কমান্ড সঞ্চালন করুন
# Comment[bn_IN]=ডকুমেন্ট ধারণকারী ডিরেক্টরির মধ্যে "make" কমান্ড সঞ্চালন করুন
# Comment[ca]=Executa «make» al directori del document
# Comment[ca@valencia]=Executa «make» al directori del document
# Comment[crh]=Vesiqa fihristinde "make" çaptır
# Comment[cs]=Spustit „make” v adresáři dokumentu
# Comment[cy]=Rhedeg "make" yng nghyfeiriadur y ddogfen
# Comment[da]=Start "make" i dokumentmappen
# Comment[de]=»make« im Dokumentenordner ausführen
# Comment[dz]=ཡིག་ཆའི་སྣོད་ཐོ་ནང་ "make" གཡོག་བཀོལ།
# Comment[el]=Εκτέλεση "make" στον κατάλογο εγγράφου
# Comment[en_GB]=Run "make" in the document directory
# Comment[eo]=Lanĉi "make"-on en la dokumenta dosierujo
# Comment[es]=Ejecutar «make» en el directorio del documento
# Comment[et]="make" käivitamine dokumendikataloogis
# Comment[eu]=Exekutatu 'make' dokumentuen direktorioan
# Comment[fi]=Suorita "make" asiakirjahakemistossa
# Comment[fr]=Exécuter « make » dans le répertoire du document
# Comment[gl]=Executar "make" no directorio de documentos
# Comment[gu]=દસ્તાવેજ ડિરેક્ટરીમાં "make" ચલાવો
# Comment[he]=הרץ "make" בספרייה הנוכחית
# Comment[hi]=दस्तावेज़ निर्देशिका में "make" चलाएँ
# Comment[hu]=A „make” futtatása a dokumentum könyvtárában
# Comment[it]=Esegue «make» nella cartella del documento
# Comment[ja]=ドキュメントのあるフォルダで "make" を実行します
# Comment[kn]=ದಸ್ತಾವೇಜು ಕೋಶದಲ್ಲಿ "make" ಅನ್ನು ಚಲಾಯಿಸಿ
# Comment[ko]=문서 디렉터리에서 "make"를 실행합니다
# Comment[lt]=Paleisti „make“ dokumento aplanke
# Comment[lv]=Palaist "make" dokumenta mapē
# Comment[mai]=दस्ताबेज निर्देशिकामे "make" चलाबू
# Comment[mk]=Изврши „make“ во директориумот на документот
# Comment[ml]=ഡോക്യുമെന്റ് ഡയറക്ടറിയില്‍ "make" പ്രവര്‍ത്തിപ്പിക്കുക
# Comment[mr]=दस्तऐवज संचयीका मध्ये "make" चालवा
# Comment[nb]=Kjør «make» i dokumentkatalogen
# Comment[ne]=कागजात डाइरेक्टरीमा "make" चलाउनुहोस्
# Comment[nl]=‘make’ uitvoeren in de documentmap
# Comment[or]=ଦଲିଲ ଡିରେକ୍ଟୋରୀରେ  "make"କୁ ଚଲାନ୍ତୁ
# Comment[pa]=ਡੌਕੂਮੈਂਟ਼ ਡਾਇਰੈਕਟਰੀ 'ਚ "make" ਚਲਾਓ
# Comment[pl]=Wykonuje "make" w katalogu dokumentu
# Comment[pt]=Executar "make" no directório do documento
# Comment[pt_BR]=Executa "make" no diretório do documento
# Comment[ro]=Execută „make” în dosarul documentului
# Comment[ru]=Выполнить "make" в каталоге с документом
# Comment[sl]=Zaženi "make" v imeniku dokumenta
# Comment[sq]=Ekzekuton "make" në directory e dokumentit
# Comment[sr]=Изврши наредбу „make“ у фасцикли докумената
# Comment[sr@latin]=Izvrši naredbu „make“ u fascikli dokumenata
# Comment[sv]=Kör "make" i dokumentkatalogen
# Comment[ta]=ஆவண அடைவில் “make”ஐ இயக்கு
# Comment[te]=నడుపు పత్రము సంచయంలో "తయారు" చేయి
# Comment[th]=เรียก “make” ในไดเรกทอรีของเอกสาร
# Comment[tr]=Belge dizininde "make" çalıştır
# Comment[uk]=Виконати “make” у каталозі з документом
# Comment[vi]=Chạy « make » trong thư mục tài liệu
# Comment[zh_CN]=在文档目录中运行“make”
# Comment[zh_HK]=在文件資料夾中執行“make”指令
# Comment[zh_TW]=在文件資料夾中執行“make”指令
# Input=nothing
# Output=output-panel
# Shortcut=<Control>F8
# Applicability=local
# Save-files=nothing
# Languages=

EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
while test "$DIR" != "/"; do
    for m in GNUmakefile makefile Makefile; do
        if [ -f "${DIR}/${m}" ]; then
            echo "Using ${m} from ${DIR}" | sed "s#$EHOME#~#" > /dev/stderr
            make -C "${DIR}"
            exit
        fi
    done
    DIR=`dirname "${DIR}"`
done
echo "No Makefile found!" > /dev/stderr
