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

(define modules
	`(-j canvas-draw
		-j canvas-draw-base -j canvas-draw-primitives -j canvas-draw-play
		-j canvas-draw-picture -j canvas-draw-client
		-j canvas-draw-ps -j canvas-draw-svg -j canvas-draw-metafile
		-j canvas-draw-cgm -j canvas-draw-dgn -j canvas-draw-dxf
		-j canvas-draw-emf -j canvas-draw-wmf
		,@(cond-expand
			 [disable-canvas-draw-iup
				'()]
			 [else
				'(-j canvas-draw-iup)])
		,@(cond-expand
			 [disable-canvas-draw-gl
				'()]
			 [else
				'(-j canvas-draw-gl)])
		,@(cond-expand
			 [disable-canvas-draw-native
				'()]
			 [else
				'(-j canvas-draw-native -j canvas-draw-server
					-j canvas-draw-clipboard -j canvas-draw-printer)])
		,@(cond-expand
			 [disable-canvas-draw-pdf
				'()]
			 [else
				'(-j canvas-draw-pdf)])
		,@(cond-expand
			 [enable-canvas-draw-debug
				'(-j canvas-draw-debug)]
			 [else
				'()])))

(define import-libraries
	`("canvas-draw.import.so"
		"canvas-draw-base.import.so" "canvas-draw-primitives.import.so" "canvas-draw-play.import.so"
		"canvas-draw-picture.import.so" "canvas-draw-client.import.so"
		"canvas-draw-ps.import.so" "canvas-draw-svg.import.so" "canvas-draw-metafile.import.so"
		"canvas-draw-cgm.import.so" "canvas-draw-dgn.import.so" "canvas-draw-dxf.import.so"
		"canvas-draw-emf.import.so" "canvas-draw-wmf.import.so"
		,@(cond-expand
			 [disable-canvas-draw-iup
				'()]
			 [else
				'("canvas-draw-iup.import.so")])
		,@(cond-expand
			 [disable-canvas-draw-gl
				'()]
			 [else
				'("canvas-draw-gl.import.so")])
		,@(cond-expand
			 [disable-canvas-draw-native
				'()]
			 [else
				'("canvas-draw-native.import.so" "canvas-draw-server.import.so"
					"canvas-draw-clipboard.import.so" "canvas-draw-printer.import.so")])
		,@(cond-expand
			 [disable-canvas-draw-pdf
				'()]
			 [else
				'("canvas-draw-pdf.import.so")])
		,@(cond-expand
			 [enable-canvas-draw-debug
				'("canvas-draw-debug.import.so")]
			 [else
				'()])))

(define native-libraries
	`("-lcd"
		,@(cond-expand
			 [disable-canvas-draw-iup
				'()]
			 [else
				'("-liupcd")])
		,@(cond-expand
			 [disable-canvas-draw-gl
				'()]
			 [else
				'("-lcdgl")])
		,@(cond-expand
			 [disable-canvas-draw-native
				'()]
			 [else
				(append
				 (if (find-library "cdx11" "cdContextNativeWindow")
						 '("-lcdx11") '())
				 (if (find-library "cdcontextplus" "cdInitContextPlus")
						 '("-lcdcontextplus") '()))])
		,@(cond-expand
			 [disable-canvas-draw-pdf
				'()]
			 [else
				'("-lcdpdf")])))

(compile -s -O2 -d1 "canvas-draw.scm" ,@modules ,@native-libraries)
(compile -c -O2 -d1 "canvas-draw.scm" -unit canvas-draw)
(compile -s -O2 -d0 "canvas-draw.import.scm")
(compile -s -O2 -d0 "canvas-draw-base.import.scm")
(compile -s -O2 -d0 "canvas-draw-primitives.import.scm")
(compile -s -O2 -d0 "canvas-draw-play.import.scm")
(compile -s -O2 -d0 "canvas-draw-picture.import.scm")
(compile -s -O2 -d0 "canvas-draw-client.import.scm")
(compile -s -O2 -d0 "canvas-draw-ps.import.scm")
(compile -s -O2 -d0 "canvas-draw-svg.import.scm")
(compile -s -O2 -d0 "canvas-draw-metafile.import.scm")
(compile -s -O2 -d0 "canvas-draw-cgm.import.scm")
(compile -s -O2 -d0 "canvas-draw-dgn.import.scm")
(compile -s -O2 -d0 "canvas-draw-dxf.import.scm")
(compile -s -O2 -d0 "canvas-draw-emf.import.scm")
(compile -s -O2 -d0 "canvas-draw-wmf.import.scm")

(cond-expand
 [disable-canvas-draw-iup]
 [else
	(compile -s -O2 -d0 "canvas-draw-iup.import.scm")])
(cond-expand
 [disable-canvas-draw-gl]
 [else
	(compile -s -O2 -d0 "canvas-draw-gl.import.scm")])
(cond-expand
 [disable-canvas-draw-native]
 [else
	(compile -s -O2 -d0 "canvas-draw-native.import.scm")
	(compile -s -O2 -d0 "canvas-draw-server.import.scm")
	(compile -s -O2 -d0 "canvas-draw-clipboard.import.scm")
	(compile -s -O2 -d0 "canvas-draw-printer.import.scm")])
(cond-expand
 [disable-canvas-draw-pdf]
 [else
	(compile -s -O2 -d0 "canvas-draw-pdf.import.scm")])
(cond-expand
 [enable-canvas-draw-debug
	(compile -s -O2 -d0 "canvas-draw-debug.import.scm")]
 [else])

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