Commits

Anonymous committed 23f2803

Issue 1234

Comments (0)

Files changed (2)

 
 top = '.'
 
-from waflib import Configure, Logs
+from waflib import Configure, Logs, Utils
 #Configure.autoconfig = True
 
 def options(opt):
 	bld.install_as('${PREFIX}/gnigni.txt', 'wscript')
 	bld.symlink_as('${PREFIX}/libfoo.so', 'wscript')
 
+	p = Utils.subst_vars('${PREFIX}/gnigni.txt', bld.env)
+	bld.symlink_as('${PREFIX}/share/gnigni-abs.txt', p, relative_trick=False)
+	bld.symlink_as('${PREFIX}/share/gnigni-rel.txt', p, relative_trick=True)
+
 	bld.env.FOO =['m', 'ncurses']
 	bld.env.ST = '-L%s'
 	bld(rule='echo ${ST:FOO}', always=True, shell=1)
 		Predefined method for installing a symlink
 		"""
 		destfile = self.get_install_path()
-		self.generator.bld.do_link(self.link, destfile)
+		src = self.link
+		if self.relative_trick:
+			src = os.path.relpath(src, os.path.dirname(destfile))
+		self.generator.bld.do_link(src, destfile)
 
 class InstallContext(BuildContext):
 	'''installs the targets on the system'''
 		self.run_task_now(tsk, postpone)
 		return tsk
 
-	def symlink_as(self, dest, src, env=None, cwd=None, add=True, postpone=True):
+	def symlink_as(self, dest, src, env=None, cwd=None, add=True, postpone=True, relative_trick=False):
 		"""
 		Create a task to install a symlink::
 
 		:type add: bool
 		:param postpone: execute the task immediately to perform the installation
 		:type postpone: bool
+		:param relative_trick: make the symlink relative (default: ``False``)
+		:type relative_trick: bool
 		"""
 
 		if Utils.is_win32:
 		tsk.path = cwd or self.path
 		tsk.source = []
 		tsk.link = src
+		tsk.relative_trick = relative_trick
 		tsk.exec_task = tsk.exec_symlink_as
 		if add: self.add_to_group(tsk)
 		self.run_task_now(tsk, postpone)