16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Makefile の依存関係を gcc で生成する

16
Posted at

Makefile の依存関係を gcc で生成する

/* test.c */
# include <stdio.h>
# include "foo.h"
# include "bar.h"

のとき,下記のように gcc を呼び出すと

gcc -E -MM -w test.c

下記のように Makefile のルールが生成される.

test.o: test.c foo.h bar.h

このときシステムヘッダファイルは除外されることに注意.(上記例では,stdio.h は依存関係に入らない)

応用

depend:
	gcc -E -MM -w test.c >> Makefile.depends

-include Makefile.depends

などすると,依存関係の記述ミスが減って嬉しい.

16
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?