;; -*- mode: Scheme; tab-width: 2; -*- ;;

(define modules
	`(-j iup
		-j iup-base -j iup-controls -j iup-dialogs
		,@(cond-expand
			 [disable-iup-glcanvas
				'()]
			 [else
				'(-j iup-glcanvas)])
		,@(cond-expand
			 [disable-iup-pplot
				'()]
			 [else
				'(-j iup-pplot)])
		,@(cond-expand
			 [disable-iup-web
				'()]
			 [else
				'(-j iup-web)])))

(define import-libraries
	`("iup.import.so"
		"iup-base.import.so" "iup-controls.import.so" "iup-dialogs.import.so"
		,@(cond-expand
			 [disable-iup-glcanvas
				'()]
			 [else
				'("iup-glcanvas.import.so")])
		,@(cond-expand
			 [disable-iup-pplot
				'()]
			 [else
				'("iup-pplot.import.so")])
		,@(cond-expand
			 [disable-iup-web
				'()]
			 [else
				'("iup-web.import.so")])))

(define native-libraries
	`("-lcallback"
		"-liup" "-liupim" "-liupimglib" "-liupcontrols"
		,@(cond-expand
			 [disable-iup-glcanvas
				'()]
			 [else
				'("-liupgl")])
		,@(cond-expand
			 [disable-iup-pplot
				'()]
			 [else
				'("-liup_pplot")])
		,@(cond-expand
			 [disable-iup-web
				'()]
			 [else
				'("-liupweb")])))

(compile -s -O2 -d1 "iup.scm" ,@modules ,@native-libraries)
(compile -c -O2 -d1 "iup.scm" -unit iup)
(compile -s -O2 -d0 "iup.import.scm")
(compile -s -O2 -d0 "iup-base.import.scm")
(compile -s -O2 -d0 "iup-controls.import.scm")
(compile -s -O2 -d0 "iup-dialogs.import.scm")

(cond-expand
 [disable-iup-glcanvas]
 [else
	(compile -s -O2 -d0 "iup-glcanvas.import.scm")])
(cond-expand
 [disable-iup-pplot]
 [else
	(compile -s -O2 -d0 "iup-pplot.import.scm")])
(cond-expand
 [disable-iup-web]
 [else
	(compile -s -O2 -d0 "iup-web.import.scm")])

(install-extension
 'iup
 `("iup.so" "iup.o" "iup-types.scm" ,@import-libraries)
 `((version 1.2.1)
	 (static "iup-base.o")
	 (static-options ,(string-intersperse native-libraries))))

(compile -s -O2 -d1 "iup-dynamic.scm" -j iup-dynamic)
(compile -c -O2 -d1 "iup-dynamic.scm" -j iup-dynamic -unit iup-dynamic)
(compile -s -O2 -d0 "iup-dynamic.import.scm")

(install-extension
 'iup-dynamic
 '("iup-dynamic.so" "iup-dynamic.o" "iup-dynamic.import.so")
 '((version 1.2.1)
   (static "iup-dynamic.o")))
