title: C Makefile, Compile parts of the project with different rules
body: <p>I have a project containing source and header files organized in <code>N</code> folders (let's call them <code>folder1</code>, <code>folder2</code>, ..., <code>folderN</code>)</p>
  
  <p>I want to compile <code>folder1</code> with <code>-Wall</code> but the rest of them with <code>-w</code>.
  The problem is that the other folders (2 to N) contain only header files which are included in some of the sources in folder1.</p>
  
  <p>When I compile <code>folder1</code>, <code>-Wall</code> will apply also to the headers in that folder and I do not want that.</p>
  
  <p>This is the makefile I used so far:</p>
  
  <pre><code>CC=gcc
  LIBS=-iquotefolder2 ... -iquotefoldern
  
  SOURCES=$(wildcard folder1/*.c) $(wildcard folder2/*.c) ... $(wildcard foldern/*.c)
  OBJECTS=$(SOURCES:.c=.o)
  
  folder1/%.o: folder1/%.c
      $(CC) -Wall $(LIBS) -c -o $@ $^
  
  folder2/%.o: folder2/%.c
      @$(CC) -w $(LIBS) -c -o $@ $^
  ...
  
  folderN/%.o: folderN/%.c
      @$(CC) -w $(LIBS) -c -o $@ $^
  
  lib.dll: $(OBJECTS)
      @$(CC) -w -shared -Wl,-soname,$@ -o $@ $^
  
  all: lib.dll
  </code></pre>
  
  <p>Is there any way to achieve this? 
  I also tried to compile folder2 to folderN in a lib.a and link that library while compiling folder1 but gcc will (obviously) try to include the headers</p>