PIXNET Logo登入

nix

跳到主文

Seize...

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 1月 24 週四 200823:10
  • make - 4. Functions

GNU make supports both built-in and user-defined functions.Most built-in functions expand to some value that is then assigned to a variable or passed to a subshell.A user-defined function is stored in a variable or macro and expects one or more parameters to be passed by the caller.4.1 User-Defined Functions
Storing command sequences in variables opens the door to a wide range of applications.AWK := awk
KILL := kill
KILL_FLAGS := -f
PS := ps
PS_FLAGS := -W
PS_FIELDS := "9 47 100"
# $(call kill-program,awk-pattern)
define kill-program
           @ $(PS) $(PS_FLAGS) |                                                    \
           $(AWK) 'BEGIN { FIELDWIDTHS = $(PS_FIELDS) }    \
                     /$1/  {                                                                         \          /* $1 stands for the first argument passed to the macro */
                                print "Killing " $$3;                                         \          /* $$3 stands for the value of the third field comes from print */
                                system( "$(KILL) $(KILL_FLAGS) " $$1 )  \
                     }'         /* Notice that awk command are quoted */
endef
(繼續閱讀...)
文章標籤

nix 發表在 痞客邦 留言(0) 人氣(706)

  • 個人分類:make
▲top
  • 1月 22 週二 200800:41
  • make - 3. Variables and Macros

make is sort of two languages in one:
  • The first language describes dependency graphs consisting of targets and prerequisites.
  • The second language is a macro language for performing textual substitution.
The only characters actually disallowed in a variable name are :, #, and =.To get the value of a variable, enclose the variable name in $() or ${}, but single-letter variable names can omit the parentheses.The value of a variable consists of all the words to the right of the assignment symbol with leading space trimmed. Trailing spaces are not trimmed.3.1 What Variables Are Used For
(繼續閱讀...)
文章標籤

nix 發表在 痞客邦 留言(0) 人氣(819)

  • 個人分類:make
▲top
  • 1月 20 週日 200817:15
  • make - 2. Rules

Building and processing the dependency graph to update the requested target is what make is all about.There are a number of different kinds of rules:
  • Explicit rules indicate a specific target to be updated if it is out of date with respect to any of its prerequisites.
  • Implicit rules are either pattern rules or suffix rules found in the rules database built-in to make.
  • Pattern rules use wildcards instead of explicit filenames. This allows make to apply the rule any time a target file matching the pattern needs to updated.
  • Static pattern rules are like regular pattern rules except they apply only to a specific list of target files.
2.1 Explicit Rules
A rule does not have to be defined "all at once." Each time make sees a target file it adds the target and prerequisites to the dependency graph. If a target has already been seen and exists in the graph, any additional prerequisites are appended to the target file entry in make's dependency graph.make supports wildcards (also known as globbing).make's wildcards are identical to the Bourne shell's: ~, *, ?, [...], and [^...].Wildcard expansion is performed by make when the pattern appears as a target or prerequisite, when the pattern appears in a command, the expansion is performed by the subshell.In other contexts, wildcards can be expanded explicitly by calling a function.In more controlled environments using wildcards to select the files in a program is considered bad practice because a rogue source file might be accidentally linked into a program.GNU make includes a special target, .PHONY, to tell make that a target is not a real file. Any target can be declared phony by including it as a prerequisite of .PHONY:
(繼續閱讀...)
文章標籤

nix 發表在 痞客邦 留言(0) 人氣(604)

  • 個人分類:make
▲top
  • 1月 18 週五 200817:48
  • make - 1. How to Write a Simple Makefile


這是讀"Managing Projects with GNU Make"的筆記,make真的是非常的有趣呀。

1.1 Targets and Prerequisites
A rule consists of three parts: the target, its prerequisites, and the command(s) to perform: One or more targets appear to the left of the colon and zero or more prerequisites can appear to the right of the colon.target1 target2 target3: prereq1 prereq2
[tab]commands1
[tab]commands1
…
(繼續閱讀...)
文章標籤

nix 發表在 痞客邦 留言(0) 人氣(755)

  • 個人分類:make
▲top
1

GNU

Firefox

Ubuntu

Free Software Foundation

Pentax 645D

我的地盤

nix
暱稱:
nix
分類:
數位生活
好友:
累積中
地區:

文章分類

  • Algorithms (3)
  • Compiler (5)
  • Computer Architecture (1)
  • Computer Language (1)
  • Funny Story (6)
  • GNU (2)
  • Life (112)
  • Linux (8)
  • make (4)
  • Operating System (16)
  • Reading (18)
  • Share (15)
  • Uboot (1)
  • VirtualBox 2.0.2 (1)
  • VMware Workstation 6 (4)
  • Memory Diary (0)
  • 未分類文章 (1)

近期文章

  • 20120226 - 古坑華山50公里超馬
  • 20120107 - 泰雅盃大腳丫森林馬拉松
  • 20111231 - 中潭公路馬拉松
  • 20111101 - 大阪馬拉松第4天
  • 20111030 - 大阪馬拉松第3天
  • 20111029 - 大阪馬拉松第2天
  • 20111028 - 大阪馬拉松第1天
  • 20111023 - Finger Lakes & Watkins Glen State Park
  • 20111022 - Letchworth State Park
  • 20111016 - Niagara Falls

參觀人氣

  • 本日人氣:
  • 累積人氣:

文章彙整