c - How to make a makefile? -
this question has answer here:
- how make simple makefile gcc on linux? 6 answers
i trying produce simple makefile project, having trouble because still getting used them.
i have file folder containing 3 separate files, header file linkedlistapi.h
, linkedlistapi.c
, structlistdemo.c
.
have use flags:
-wall -std=c11
this 1 looks ok, remember replace all indentations tabs:
.phony: 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 $< $@ structlistdemo: $(objstructlistdemo) $(include)/linkedlistapi.h ${cc} -o $< $@ %.o: %.c ${cc} $(cflags) $< -o $@ clean: rm -rf $(objstringlistdemo) $(objstructlistdemo) stringlistdemo structlistdemo
Comments
Post a Comment