Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
battle_c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
이장원
battle_c
Commits
823bb74c
Commit
823bb74c
authored
4 years ago
by
이장원
Browse files
Options
Downloads
Patches
Plain Diff
Make, Makefile
parent
2311d707
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
8.7/README.md
+79
-0
79 additions, 0 deletions
8.7/README.md
with
79 additions
and
0 deletions
8.7/README.md
0 → 100644
+
79
−
0
View file @
823bb74c
# Make
### make란?
*
프로그램 그룹 중에서 어느 부분이 새롭게 컴파일 되어야 하는지를 자동적으로 판단해서 필
요한 커맨드를 사용해서 그들을 재 컴파일 시킴
*
많은 프로그램 모듈들로 구성된 대규모 프로그램을 효율적으로 유지하고, 일관성 있게 관리
하도록 도와주는 도구
*
소스 수정 시 유관 파일들을 재컴파일 & 링크하는 반복적인 작업을 간단하게 처리함
*
선결조건(prerequisites)으로부터 대상(target)을 만들어 내는 다목적 프로그램
### make의 동작
*
make는 여러 파일들 간의 의존성을 저장하고 수정된 파일에 연관된 소스 파일들만을 재
컴파일 하도록 해줌
*
수정한 소스 파일들만 자동적으로 재 컴파일하고 링크하도록 함
*
소스 수정 시 유관 파일들을 재컴파일 & 링크하는 반복적인 작업을 간단하게 처리함
*
make 유틸리티는 이전에 make 명령을 실행했던 시점 이후에 이뤄진 프로젝트 작업들에
대해서만 갱신 작업을 수행함
### make의 필요성
*
프로그램 개발 및 유지보수의 편리성을 지원
*
명령어의 배치 처리 가능, 자주 쓰는 명령어를 자동화할 수 있음
*
입력파일 변경 시 자동적으로 결과 파일이 바뀌기를 원할 때
# Makefile
`대상(target) : 의존하는 파일들(prerequisites)`
`<tab> 명령어(command)`
`<tab> 명령어(command)`
*
clean
주로 make하는 과정에서 생긴 .o 파일이나 실행 파일을 삭제하는 역할
*
dep
gccmakedep 명령어를 통해 의존 관계를 자동으로 생성한다.
`<identifier> = <files>`
identifier를 통해 여러 개의 파일들을 간단하게 부를 수 있는 매크로
코드 상에서 쓸 때는
`$(<identifier>)`
로 써야 한다.
*
내장매크로(Internal macro)
| 매크로 | 의미 |
|:--:|--|
| $@ | 현재의 목표 (Target) 파일명 |
| $? | 현재의 목표파일(Target)보다 더 최근에 갱신된 의존 파일 명단 |
| $
*
| 현재의 목표파일(Target)보다 더 최근에 갱신된 확장자를 제외한 의존 파일 명단 |
| $< | 의존 파일(전제 조건) 중 첫번째 파일명 |
| $^ | 현재 모든 의존 파일들의 명단 |
| $+ | '$^'과 같지만, 두 번 이상 나열된 전제 조건은 makefile에 나열된 순서대로 복제됨 |
| $% | 타깃이 라이브러리 모듈일 때 멤버에 대응되는 파일명 |
*
내장매크로(Pre-defined macro)
| 매크로 | 의미 |
|:--:|--|
| AR | Archive-maintaining program; default ‘ar’. |
| ARFLAGS | ar 명령어의 옵션 설정 |
| AS | Program for compiling assembly files; default ‘as’. |
| ASFLAGS | as 명령어의 옵션 설정 |
| CC | Program for compiling C programs; default ‘cc’. |
| CFLAGS | cc 명령어의 옵션 설정 |
| CXX | Program for compiling C++ programs; default ‘g++’. |
| CXXFLAGS | g++ 명령어의 옵션 설정 |
| LDFLAGS | ld 명령어의 옵션 설정 |
*
확장자 규칙 (Suffix Rules)
확장자 규칙은 미리 정의해 놓은 일반화한 기술 파일 항목을 가리킴
```
.SUFFIXES : .o .c .s
.c.o :
$(CC) $(CFLAGS) -c $<
.s.o :
$(AS) $(ASFLAGS) -o $@ $<
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment