# Tanım: Nim bir sistem ve uygulama programlama dilidir.
# URL: https://nim-lang.org/
# Paketçi: milisarge
# Gerekler: python3 
# Grup: geliştirme

isim=nim
_isim=Nim
surum=0.17.2
devir=1
kaynak=(https://github.com/nim-lang/Nim/archive/v$surum.tar.gz::${_name}-$surum.tar.gz
		https://github.com/nim-lang/csources/archive/v$surum.tar.gz::csources-$surum.tar.gz)

derle() {
	cd ${_name}-${surum}
	mv ../csources-${surum} csources
	rm bin/empty.txt
	
	export PATH="${SRC}/${_name}-${surum}/bin:${PATH}"
	cd csources
	sh build.sh
	cd ..
	nim c -d:release koch
	./koch boot -d:release -d:nativeStacktrace -d:useGnuReadline
	cd lib
	nim c --app:lib -d:createNimRtl -d:release nimrtl.nim
	cd ..
	cd tools
	nim c -d:release nimgrep.nim
	cd ..
	export PATH="${SRC}/${_name}-${surum}/bin:${PATH}"
	./koch install "${PKG}"
	install -d "${PKG}/usr/lib"
	cp -a lib "${PKG}/usr/lib/nim"
	cp -a compiler "${PKG}/usr/lib/nim"
	install -Dm 644 compiler.nimble "${PKG}/usr/lib/nim/compiler"
	install -m 755 lib/libnimrtl.so "${PKG}/usr/lib/libnimrtl.so"
	# Fix FS#48118, related to the doc2 command
	ln -s /usr/share/nim/doc "${PKG}/usr/lib/nim/doc"
	install -Dm 644 config/* -t "${PKG}/etc"
	install -Dm 755 bin/* tools/nimgrep -t "${PKG}/usr/bin"
	# Fix FS#50252, unusual placement of header files
	install -d "${PKG}/usr/include"
	cp -a "${PKG}/usr/lib/nim/"*.h "${PKG}/usr/include"
	install -d "${PKG}/usr/share/nim/doc"
	cp -a examples web doc/* "${PKG}/usr/share/nim/doc"
	install -Dm 644 copying.txt "${PKG}/usr/share/licenses/${isim}/LICENSE"
	rm -r "${PKG}/nim" "${PKG}/usr/lib/nim/lib/nimcache"
	rm -r "${PKG}/usr/share/nim/doc/web/"
}
