---
title: "Makefile例子"
author: "月下独酌"
date: "2012-01-17T11:05:06Z"
tags: []
categories: ["非技术"]
slug: "makefile"
draft: false
lastmod: "2012-01-17T11:05:06Z"
id: 1354210
url: "https://fatalove.iteye.com/blog/1354210"
---

```java

DIR=./out/
BIN=$(DIR)bin/
INCLUDE=
SRC=$(wildcard *.cpp *.c)
OBJECTS=$(patsubst %.cpp, $(DIR)%.o,$(SRC))

target=test
CC=g++
$(target):$(SRC)
        -mkdir $(BIN) -p
        $(info $(SRC))
        $(CC)  $(SRC) $(INCLUDE) -o $(BIN)$@
        -$(BIN)$@
clean:
        -rm -fr $(DIR)


```