2017-09-12 5 views
-3

Ich versuche ein einfaches Makefile für ein Projekt zu erstellen, habe aber Probleme, weil ich mich immer noch daran gewöhne.Wie mache ich ein Makefile?

Ich habe einen Dateiordner mit 3 separaten Dateien, Header-Datei LinkedListAPI.h, LinkedListAPI.c und StructListDemo.c.

Haben die Fahnen verwenden:

-Wall -std=c11 

Antwort

1

Dieses OK aussieht, aber denken Sie daran alle Vertiefungen mit Tabs zu ersetzen:

.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