What is the way to build C (not CPP) .dll?

There is no such thing as ‘c-library’ like ‘cpp-library’. If I use only ‘c’ plugin, it fails at
linkage = [Linkage.SHARED]

The value for property ‘linkage’ is final and cannot be changed any further.

Unfortunately, there is quite a bit of confusion around the core native plugins. The c plugin are the older native plugins based on the software model. They are more flexible than the newer plugins (e.g. cpp-library) such as providing plugins for C, Obj-C/C++, etc language but shouldn’t be used for newer projects as they are “essentially” deprecated. I would suggest that you use the Nokee plugins instead of core Gradle plugins. With the latest nightly it is possible to do everything you would be able to do with the core cpp-library plugin with the exception of publishing out-of-the-box. Some properties have different names but the functionality are the same.

In your example, you can configure a shared linkage C library as followed:

plugins {
  id 'dev.nokee.c-library'

library {
    targetLinkages = [linkages.shared] // see note 1

Note 1: By default, the target linkages are configured to shared for libraries.

Disclaimer: I originally helped sponsored the software model native plugins, worked on the newer native plugins and now working full time on building the Nokee plugins.

I’m more active on the Gradle community Slack so feel free to drop by and ask more questions on how to get started with Nokee, I will be happy to help.

Okay, figured it out by myself. I’m posting the answer in case someone else needs it.
First, you use ‘cpp-library’ plugin. In oder to prevent filtering out the files with “.c” extention, add the sources in tasks.withType(CppCompile).configureEach { section. It should look like this:

tasks.withType(CppCompile).configureEach {
    def sources = [ ]
    def ft_src = fileTree(dir: "myproject/src", include: sources)
    it.source.from ft_src