It sounds as if you've obtained a copy of the kernel source. Ideally this source matches the kernel you're using.
In the kernel source tree, the simplest actions to do are:
This will remake the entire kernel; including driver modules. The GPIO library may or may not be "included" in your kernel. By that I mean whether or not it is compiled as a Module or Inline with the kernel. Either of those cases, running "make" will take care of it. However if it is a module, then you can avoid performing a full make and merely make just that module.
The way to be able to tell whether it is a Module or Inline is to view your
.config file. This is at the top level of your kernel source directory. You can view/edit that file and yes it does say that it is automatically generated and not to edit it. If you do manually edit the file, you're supposed to know what dangers you are risking. Viewing it of course perfectly fine. There are also varied ways to modify your config; not just manually editing, but also using a menu based modifier. When in the file, search for all instances of "gpio" and you're probably looking for CONFIG_GPIOLIB, if that says "=y" then it is INCLUDED in the kernel binary image and compiled Inline, if that says "=m" then it is a MODULE, therefore NOT included in the kernel binary image. It will be made by the make action, but it will become a load-able module; the benefit is that you can load or unload that during runtime, and you can also rebuild that module without performing a full kernel rebuild. There are other pros and cons which I'll skip right now. If it says something like "# CONFIG_GPIOLIB is not set" then it is NOT INCLUDED inline OR as a module, it's not included at all. Therefore change that line to say either "y" or "m" similar to how other lines show, via taking out the # comment and setting the text up appropriately by getting rid of the "is not set" part.
Not completely sure on this one, 50% sure that if it is specified as a module, that you can go to your "drivers" directory and then type "make gpio" and that will make the GPIO library. They keyword may be "make gpiolib" I'm not sure this isn't configured for my particular kernel. The result is that the GPIO library .ko file will be remade and you can copy that file to the same location where it is on your system, reboot, and then you'll be using your newly built module.
Some things to do to ensure you've got it right is to add a printk() in the init call to show something unique to indicate that you've not only entered the module, but also the rebuilt code you created is exactly what you're running.
NOTE that if there are issues related to "different target" for the kernel other than the system you're running on; then this subject grows by way of things like "configuration for your compilation tools so that they're set up to compile properly for your target", stuff like that. Or if things like "make" don't even work at all, then you may need to install the basic build tools. The first assumption is that you're building the kernel on the system you're working with and that build tools as well as kernel source are all set up already.