use #ifdef's in yourlib
#ifdef MYLIB_SLAVE
// slave code
#endif
#ifdef MYLIB_MASTER
//master code
#endif
// common code
then in your sketch state
#define MYLIB_SLAVE 1
#include "mylib"
etc
to just include the SLAVE part and the common part.
use #ifdef's in yourlib
#ifdef MYLIB_SLAVE
// slave code
#endif
#ifdef MYLIB_MASTER
//master code
#endif
// common code
then in your sketch state
#define MYLIB_SLAVE 1
#include "mylib"
etc
to just include the SLAVE part and the common part.