Hi,
I'm beginning with C and makefiles.
I'm trying to compile a list of C files with GNU Make.
My code should compile all the C files in the folder into .o files along with few flags and then use these .o files to compile an executable file 'main'.
and my code is this
CC=gcc
FLAGS=-l./-O3 -Wall -c
CFILES:=$(shell ls | grep .c)
OBJS:=$(CFILES:%.c=%.o)
all:$(OBJS)
$(CC) $(OBJS) -o main
$(OBJS):$(CFILES)
$(CC) $(FLAGS) $(CFILES)
Don't laugh please. This is not going to work as make is not going to compile each C file separately to build the final file main.
So please help.
Thanks in advance.