January 18, 2011 Making Sense of 'make' Back

Using 'make' to Compile C Source Code

[6exercise]

        #include <stdio.h>
        main()
        { printf("Hello world\n"); }
        CC      = gcc
        CFLAGS  = -g
        all:        hello
        hello:      hello.o
                $(CC) $(LDFLAGS) -o $@ $^
        hello.o:    hello.c
                $(CC) $(CFLAGS) -c -o $@ $<
        clean:
                rm -f hello hello.o
        .PHONY: clean


Home Last TOC Copyright © 2011 James E Keenan Back Next