<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _lib(self, name, only_if_have=False):
 """Specify a linker library. Example: LDFLAGS={{ lib("rt") }} {{ lib("pthread", True) }} Will unconditionally add `-lrt` and check the environment if the key `HAVE_LIBPTHREAD` is set to be true, then add `-lpthread`. """

        emit = True
        if only_if_have:
            emit = self.env.get('HAVE_LIB' + self.env_key(name))
        if emit:
            return '-l' + name
        return ''