class caffe(Wig):
	git_uri = 'https://github.com/BVLC/caffe'
	config_access = ['PATH_TO_NVCC', 'PATH_TO_CUDNN_SO', 'PATH_TO_MATLAB']
	dependencies = ['boost', 'protobuf', 'glog', 'gflags', 'hdf5', 'snappy']
	optional_dependencies = ['openblas', 'leveldb', 'lmdb', 'opencv']
	supported_features = ['openblas', 'python', 'cuda', 'cudnn', 'lmdb', 'leveldb', 'opencv', 'matlab']
	default_features = ['+openblas', '-leveldb', '-lmdb', '+opencv', '+cuda', '+cudnn']
	
	def setup(self):
		self.skip('make parallel')
		self.config_fixes = ''
		
	def set_var_commented(self, var_name, var_value):
		self.config_fixes += '''| sed 's$# %s :=$%s := %s# %s :=$' ''' % (var_name, var_name, var_value, var_name)

	def set_var_uncommented(self, var_name, var_prepend, comment_rest = False):
		self.config_fixes += '''| sed 's$%s :=$%s := %s%s$' ''' % (var_name, var_name, var_prepend, '#' if comment_rest else '')

	def switch_openblas_on(self):
		self.require('openblas')
		self.set_var_uncommented('BLAS', 'open', comment_rest = True)
		self.set_var_commented('BLAS_INCLUDE', "'$PREFIX'/include")
		self.set_var_commented('BLAS_LIB', "'$PREFIX'/lib")
		
	def switch_opencv(self, on):
		if on:
			self.require('opencv')
			self.set_var_commented('OPENCV_VERSION', 3)
		self.set_var_commented('USE_OPENCV', 1 if on else 0)
		
	def switch_lmdb(self, on):
		if on:
			self.require('lmdb')
		self.set_var_commented('USE_LMDB', 1 if on else 0)
		
	def switch_leveldb(self, on):
		if on:
			self.require('leveldb')
		self.set_var_commented('USE_LEVELDB', 1 if on else 0)
		
	def switch_cudnn_on(self):
		self.lib_dirs += [os.path.dirname(self.cfg('PATH_TO_CUDNN_SO'))]
		self.set_var_commented('USE_CUDNN', 1)
		self.set_var_uncommented('LIBRARY_DIRS', os.path.dirname(self.cfg('PATH_TO_CUDNN_SO')))
		self.set_var_uncommented('INCLUDE_DIRS', os.path.join(os.path.dirname(self.cfg('PATH_TO_CUDNN_SO')), '../include'))
		
	def switch_cuda_on(self):
		self.lib_dirs += [os.path.join(os.path.dirname(self.cfg('PATH_TO_NVCC')), '../lib64')]
		self.set_var_commented('CUDA_DIR', os.path.join(os.path.dirname(self.cfg('PATH_TO_NVCC')), '..'))

	def switch_matlab_on(self):
		self.after_make += [S.make(self.make_flags + ['matcaffe'])]
		self.set_var_commented('MATLAB_DIR', os.path.join(os.path.dirname(self.cfg('PATH_TO_MATLAB')), '..'))
		
	def switch_python_on(self):
		self.python_dirs += [os.path.join(self.paths.src_dir, 'python')]
		self.after_make += [S.make(self.make_flags + ['pycaffe'])]
		self.set_var_commented('WITH_PYTHON_LAYER', 1)

	def gen_configure_snippet(self):
		return ['cat Makefile.config.example %s > Makefile.config' % self.config_fixes]

	def gen_install_snippet(self):
		return [S.ln('$(pwd)/build/lib/libcaffe.so', '$PREFIX/lib/libcaffe.so'), 
				S.ln('$(pwd)/build/lib/libcaffe.a', '$PREFIX/lib/libcaffe.a'),
				S.ln('$(pwd)/build/tools/caffe', '$PREFIX/bin/caffe')]

@@ -535,24 +535,40 @@
 %09%09%0A%09def set_
+makefile_config_
 var_commente
@@ -712,24 +712,40 @@
 )%0A%0A%09def set_
+makefile_config_
 var_uncommen
@@ -985,32 +985,48 @@
 as')%0A%09%09self.set_
+makefile_config_
 var_uncommented(
@@ -1065,32 +1065,48 @@
 rue)%0A%09%09self.set_
+makefile_config_
 var_commented('B
@@ -1143,32 +1143,48 @@
 de%22)%0A%09%09self.set_
+makefile_config_
 var_commented('B
@@ -1282,32 +1282,48 @@
 v')%0A%09%09%09self.set_
+makefile_config_
 var_commented('O
@@ -1344,32 +1344,48 @@
 , 3)%0A%09%09self.set_
+makefile_config_
 var_commented('U
@@ -1479,32 +1479,48 @@
 db')%0A%09%09self.set_
+makefile_config_
 var_commented('U
@@ -1618,32 +1618,48 @@
 db')%0A%09%09self.set_
+makefile_config_
 var_commented('U
@@ -1788,32 +1788,48 @@
 '))%5D%0A%09%09self.set_
+makefile_config_
 var_commented('U
@@ -1845,32 +1845,48 @@
 , 1)%0A%09%09self.set_
+makefile_config_
 var_uncommented(
@@ -1955,24 +1955,40 @@
 %0A%09%09self.set_
+makefile_config_
 var_uncommen
@@ -2204,32 +2204,48 @@
 4')%5D%0A%09%09self.set_
+makefile_config_
 var_commented('C
@@ -2412,32 +2412,48 @@
 '%5D)%5D%0A%09%09self.set_
+makefile_config_
 var_commented('M
@@ -2700,16 +2700,32 @@
 elf.set_
+makefile_config_
 var_comm

Update caffe.py