It sounds to me that you think you can somehow automate the inclusion of dependencies for either DirectX or OpenGL in a generated C file (or project)?... or get rid of them completely?
You won't be able to do that.
You will have to at least include the OpenGL or DirectX headers in your generated C code, and then link the compiled .obj with the the .lib files for DirectX/OpenGL.
So you have two problems to tackle:
1) Using the header files with any C compiler - the problems here are mostly due to different pre-processor definitions being supported by different compilers. Microsoft's C compiler also adds some extensions on top of the ANSI C standard which may not be supported by any other C compiler. I don't think any of these are used in the DirectX headers though.
2) Linking the compiled code against the DirectX/OpenGL libraries - you have not specified anything about how you expect to link your code, but if you can't use .lib files (or the older .DEF files) for imported function tables, then you'll have to come up with another way to do this. Like I said before, form this point of view, it should be easier to use DirectX, because it only has one function to import (and a few more for things like enumerating display adapters and such, but I don't think it has more than 10 API functions, and you will probably only need to use at most one or two in your project)... You do not even have to link to any .lib files for this... you can use the LoadLibrary/GetProcAddres Win32 functions to get a pointer to the DirectX API functions. OpenGL is not a COM-based API, so it requires linking (or using a lot of LoadLibrary/GetProcAddress calls) in order to get it's API functions imported within your project.