diff -ur a/SConstruct b/SConstruct
--- a/SConstruct	2011-07-22 06:05:25.000000000 +0400
+++ b/SConstruct	2020-02-24 10:57:40.928869698 +0300
@@ -3,7 +3,8 @@
 sys.dont_write_bytecode = True
 from regfi_version import REGFI_VERSION
 
-cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
+cflags = os.environ['CFLAGS']
+cflags += ' -std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
 cflags += ' -DREGFI_VERSION=\'"%s"\'' % REGFI_VERSION
 cflags += ' -ggdb'
 
@@ -21,6 +22,8 @@
                   LIBPATH=['lib', '/usr/local/lib'],
                   LIBS=['m', 'pthread', 'regfi', 'talloc'])
 
+env.Append( SHLINKFLAGS=" -Wl,-soname=libregfi.so " )
+
 # Libraries
 libregfi_static = env.Library(lib_src)
 libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'])
