2017-09-12 14 views
-3

J'essaye de produire un simple makefile pour un projet, mais j'ai des problèmes car je m'y habitue toujours. J'ai un dossier contenant 3 fichiers séparés, le fichier d'en-tête LinkedListAPI.h, LinkedListAPI.c et StructListDemo.c.Comment faire un makefile?

doivent utiliser les drapeaux:

-Wall -std=c11 

Répondre

1

Celui-ci semble OK, mais rappelez-vous de remplacer tous les indentations avec onglets:

.PHONY: all clean 
CFLAGS:=$(CFLAGS) -std=c11 -Wall 
OBJ=./src 
INCLUDE=./include 
objStringListDemo=$(OBJ)/LinkedListAPI.o $(OBJ)/StringListDemo.o 
objStructListDemo=$(OBJ)/LinkedListAPI.o $(OBJ)/StructListDemo.o 

all: StringListDemo StructListDemo 

StringListDemo: $(objStringListDemo) $(INCLUDE)/LinkedListAPI.h 
    ${CC} -o $< [email protected] 

StructListDemo: $(objStructListDemo) $(INCLUDE)/LinkedListAPI.h 
    ${CC} -o $< [email protected] 

%.o: %.c 
    ${CC} $(CFLAGS) $< -o [email protected] 

clean: 
    rm -rf $(objStringListDemo) $(objStructListDemo) StringListDemo StructListDemo