Presentation is loading. Please wait.

Presentation is loading. Please wait.

Makefile 2000. 03. 25..

Similar presentations


Presentation on theme: "Makefile 2000. 03. 25.."— Presentation transcript:

1 Makefile

2 make utility의 필요성 다수의 소스파일 컴파일 소스간의 의존성 자동으로 인식하여 컴파일

3 make의 옵션과 파라미터 용법 ] 옵션 ] make Makefile or make makefile
n : 가상으로 동작을 실행 f <filename> : Makefile 또는 makefile 외의 make파일 지정 p : 내장 매크로 보기

4 Makefile myapp: main.o 2.o 3.o gcc –o myapp main.o 2.o 3.o
main.o: main.c a.h gcc –c main.c 2.o: 2.c a.h b.h gcc –c 2.c 3.o: 3.c b.h c.h

5 예제 소스 /* main.c */ #include "a.h" #include <stㅇdlib.h>
extern void function_two(); extern void function_three(); int main() { function_two(); function_three(); exit(EXIT_SUCCESS); } /* 2.c */ #include "a.h" #include "b.h" void function_two() { } /* 3.c */ #include "c.h" void function_three() {

6 내부 매크로 $@ : 현재 대상의 이름 $< : 현재 필수 조건의 이름 $* : 확장자 제외한 현재 필수조건
: 현재 대상의 이름 $< : 현재 필수 조건의 이름 $* : 확장자 제외한 현재 필수조건 - : make로 하여금 에러 무시 @ : make가 에러출력 하지 않게함

7 all: myapp CC = gcc INSTDIR = /usr/local/bin INCLUDE =
all: myapp CC = gcc INSTDIR = /usr/local/bin INCLUDE = . CFLAGS = -g –Wall –ansi myapp: main.o 2.o 3.o $(CC) –o myapp main.o 2.o 3.o main.o: main.c a.h $(CC) –I$(INCLUDE) $(CFLAGS) –c main.c 2.o: 2.c a.h b.h $(CC) –IS(INCLUDE) $(CFLAGS) –c 2.c 3.o: 3.c b.h c.h $(CC) –IS(INCLUDE) $(CFLAGS) –c 3.c clean: -rm main.o 2.o 3.o install: myapp @if [ -d $(INSTDIR) ]; \ then \ cp myapp $(INSTDIR) ; \ chmod a+x $(INSTDIR) /myapp; \ chmod og-w $(INSTDIR) /myapp; \ echo “Installed in $INSTDIR)”; \ else \ echo “Sorry, $(INSTDIR) does not exist”; \ fi


Download ppt "Makefile 2000. 03. 25.."

Similar presentations


Ads by Google