본문 바로가기
3. 개발 관련/정리 :: issue 와 resovle

Makefile 예제.

by kyuho.choi 2009. 7. 14.
728x90
반응형
vi Makefile

CC := gcc
CFLAGS := -W -Wall
TARGET := function
all : $(TARGET)
$(TARGET) : func1.o func2.o func3.o main.o 
$(CC) $(CFLAGS) -o $(TARGET) func1.o func2.o func3.o main.o
func1.o : func1.c
$(CC) $(CFLAGS) -c -o func1.o func1.c
func2.o : func2.c
$(CC) $(CFLAGS) -c -o func2.o func2.c
func3.o : func3.c
$(CC) $(CFLAGS) -c -o func3.o func3.c

main.o : main.c
$(CC) $(CFLAGS) -c -o main.o main.c
clean :
rm -rf *.o $(TARGET) debug
debug :
$(CC) -g func1.c func2.c func3.c main.c  -o debug
run :
./$(TARGET)
----------------------------------------
vi func1.c
#include "header.h"
int func1()
{
printf("function 1 is success!!\n");
return 0;
}
----------------------------------------
vi func2.c
#include "header.h"
int func2()
{
printf("function 2 is success!!\n");
return 0;
}
----------------------------------------
vi header.h
#include <stdio.h>
int func1();
int func2();
int func3();
----------------------------------------
vi func3.c
#include "header.h"
int func3()
{
printf("function 3 is success!!\n");
return 0;
}
----------------------------------------
vi main.c
#include "header.h"
int main()
{
func1();
func2();
func3();
return 0;
}
----------------------------------------
728x90
반응형

댓글