Praveen Chandrashekar

Centre for Applicable Mathematics, TIFR, Bangalore

[ People | News | Codes | Talks | Teaching | Publications | Calendar | Hiking | Contact ]

Make files

Create .o from .c file

%.o: %.c
    $(CC) -c $<

Specify dependency on some include files

%.o: %.c a.h b.h c.h
    $(CC) -c $<

Per file dependency can be specified

a.o: a.c x.h y.h
b.o: b.c y.h z.h

Create executable from each .c file

%: %.c
    $(CC) $< -o $@

Compile several files into an executable (not optimal as it compiles all files each time)

exe: a.c b.c c.c
    $(CC) $^ -o $@

List of all .c files

SRC = $(wildcard *.c)

Create list of .o files for each .c file

OBJ = $(SRC:.c=.o)