Issue #4026: Make the fcntl extension build under AIX.
Patch by Sébastien Sablé.
diff --git a/setup.py b/setup.py
index 2b5d4cb..85cd605 100644
--- a/setup.py
+++ b/setup.py
@@ -499,7 +499,11 @@
         # supported...)
 
         # fcntl(2) and ioctl(2)
-        exts.append( Extension('fcntl', ['fcntlmodule.c']) )
+        libs = []
+        if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
+            # May be necessary on AIX for flock function
+            libs = ['bsd']
+        exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
         # pwd(3)
         exts.append( Extension('pwd', ['pwdmodule.c']) )
         # grp(3)