gcc - makefile for multiple .c files, same directory -


i need create makefile 4 files: q4.c, q3.c, q2.c, q1.c format of makefile these 4 like? know necessary flags all, preprocess, compile, assemble, , clean, format of file 4 programs?

side notes: programs in same directory.

thank help- dave l

makefile comprehensive , flexible way of describing build process actions, dependencies etc. there lot of possible ways of writing , there never simple single answer question. sake of example, here how makefile simple case:

bin = q1 q2 q3 q4  all: $(bin)  clean:     $(rm) $(bin) 

it if add , remove source files , each file should compiled standalone executable:

src = $(wildcard *.c) bin = $(patsubst %.c,%,$(src))  all: $(bin)  clean:     $(rm) $(bin) 

and can more , more complex depending on size , requirements of project.

i'd recommend start simple above example , read make documentation feeling of can do.

also, make quite old, complicated technology. takes lot of time , practise master , gives little in response. there alternatives. recommend cmake - lot easier, bit higher level system can generate build scripts you. supports makefiles, xcode , lot more. it's worse taking look.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -