Make抓頭檔案裡的變量 - Linux

Table of Contents


是這樣的 有個頭檔案叫 version.h

#ifndef _VERSION_H_
#define _VERSION_H_
#define VERSION 0.1.16
#endif


在makefile 裡想去抓取VERSION的數值( 0.1.16),然後存在一個變量裡

(好比叫VERSION好了)

那請問要怎做呢?

試了很久還是不太行啊,對shell很不熟

有沒大大能幫一下的呢 謝謝





--

All Comments

Kama avatarKama2013-02-06
VER = $(shell grep '^#define VERSION' version.h | sed
's/#define VERSION[ \t]*//g') 之類的...
Ethan avatarEthan2013-02-07
謝樓上
Selena avatarSelena2013-02-08
awk '/^#define VERSION/{print $3}' version.h