I have a project containing source and header files organized in N
folders (let's call them folder1
, folder2
, ..., folderN
)
I want to compile folder1
with -Wall
but the rest of them with -w
.
The problem is that the other folders (2 to N) contain only header files which are included in some of the sources in folder1.
When I compile folder1
, -Wall
will apply also to the headers in that folder and I do not want that.
This is the makefile I used so far:
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
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
folder1/source.c
to be compiled with-Wall
butfolder2/header.h
included by that file with-w
? – el.pescado