Makefile-example
提供:Dev Guides
Makefile-例
これは、helloプログラムをコンパイルするためのMakefileの例です。 このプログラムは、3つのファイル_main.cpp 、 factorial.cpp_、および_hello.cpp_で構成されています。
# Define required macros here
SHELL =/bin/sh
OBJS = main.o factorial.o hello.o
CFLAG = -Wall -g
CC = gcc
INCLUDE =
LIBS = -lm
hello:${OBJ}
${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
clean:
-rm -f *.o core *.core
.cpp.o:
${CC} ${CFLAGS} ${INCLUDES} -c $<
これで、 make を使用してプログラム hello をビルドできます。 コマンド make clean を発行すると、現在のディレクトリで使用可能なすべてのオブジェクトファイルとコアファイルが削除されます。