qosaassets.blogg.se

How to make simple makefile for c program
How to make simple makefile for c program





how to make simple makefile for c program

However, if you want to change the name of the generated executable, libraries, or compiler flags, you can just modify the variables. h files in the current directory, meaning when you add new code files to your directory, you won't have to update the Makefile. It uses the wildcard and patsubst features of the make utility to automatically include. OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))

how to make simple makefile for c program

Here's the Makefile I like to use for C source. If you're interested in figuring that out, I hope I've given you a good start on that. I tried to make this as simple as possible by omitting variables like $(CC) and $(CFLAGS) that are usually seen in makefiles. Thus, to improve: HEADERS = program.h headers.h However, to support more C files, you'd have to make new rules for each of them. (bear in mind that make requires tab instead of space indentation, so be sure to fix that when copying) Interesting, I didn't know make would default to using the C compiler given rules regarding source files.Īnyway, a simple solution that demonstrates simple Makefile concepts would be: HEADERS = program.h headers.h







How to make simple makefile for c program