Adel ALLAM @apges01

makefile


makefile


CC=gcc
CFLAGS=-W -Wall -ansi -pedantic
LDFLAGS=
EXEC=bonjour

all: $(EXEC)

bonjour: bonjour.o main.o
	## $(CC) -o $(EXEC) bonjour.o main.o $(LDFLAGS) ##
	$(CC) -o $@ $^ $(LDFLAGS)

bonjour.o: bonjour.c
	## $(CC) -o bonjour.o -c bonjour.c $(CFLAGS) ##
	$(CC) -o $@ -c $< $(CFLAGS)

main.o: main.c bonjour.h
	## $(CC) -o main.o -c main.c $(CFLAGS) ##
	$(CC) -o $@ -c $< $(CFLAGS)

clean:
	rm -rf *.o

veryclean: clean
	rm -rf $(EXEC)

# $@ -> nom de la cible (avant les :)
# $< -> nom de la premiére dependance (juste apres les :)
# $^ -> liste des dependances (tout ce qu'il y a aprés les :)
# $? -> dependances plus récentes que la cible
# $* -> nom du fichier sans le suffixe

compilation steps


pre-processing

# supprime commentaires
# traite les directives (#include)
$ gcc -E main.cpp > main.i

compiling

# passage en assembleur
$ gcc -S main.i # -> main.s

assembling

# assembleur en binaire (.object)
$ gcc -c main.s

linking

# fusion des fichiers
$ gcc main.o outils.o -o a.out