Funzioni: Makefile
|
---- Build: calcolo, esempio.o, main.o
|
---- src: esempio.c, main.c
|
---- include: esempio.h
I don't know how to tell the Makefile to put the object files example.o and main.o and the compute executable in the build directory and to read the sources placed in src. The Makefile I wrote is:
Code: Select all
INC_PATH = -I./include -I/usr/local/include
LIB_PATH = -L./lib
LIBS =
CC = gcc
CFLAGS = -Wall -g -O2 -D_DEBUG
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst %.c, %.o, $(SOURCES))
vpath %.c src
vpath %.o build
EXECUTABLE = calcolo
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIB_PATH) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c $(INC_PATH) $< $(LIB_PATH) $(LIBS)