File: program

package info (click to toggle)
cook 2.5-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,860 kB
  • ctags: 3,247
  • sloc: ansic: 41,260; sh: 10,022; yacc: 3,397; makefile: 3,244; awk: 136
file content (141 lines) | stat: -rw-r--r-- 2,697 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * NAME
 *	program - construct a program
 *
 * DESCRIPTION
 *	This cookbook defines how to construct a program.
 *
 *	If you program uses any libraries, you will have to append
 *	them to cc_link_flags in your Howto.cook file.
 *
 * VARIABLES
 *	all		targets of the all recipe
 *	install		targets of the install recipe
 *	me		the name of the program to be constructed.
 *			Defaults to the last component of the pathname
 *			of the current directory.
 *	install		targets of the install command.
 *	ld		The name of the linker program
 *	ld_flags	Command line arguments for the linker
 *	ld_libraries	Library command line arguments for the linker
 *
 * RECIPES
 *	all:		construct the targets defined in [all].
 *	clean:		remove the files named in [dot_clean].
 *	clobber:	remove the files name in [dot_clean] and [all].
 *
 * If the [lib] variable is defined
 *	install:	construct the files named in [install].
 *	uninstall:	remove the files named in [install].
 *
 * MANIFEST: cookbook for constructing programs
 */

#pragma once

if [not [defined me]] then
    me = [entryname [dir [pathname x]]];

all = [me];
if [find_command lint] then
if [defined dot_lint_obj] then
	all = [all] [me].lint;
dot_clean = [dot_clean] [me]~;

if [not [defined ld]] then
{
	if [defined cc] then
		ld = [cc];
	else if [defined f77] then
		ld = [f77];
	else
		ld = ld;
}

all: [all];

clean:
{
	rm -f [dot_clean]
		set clearstat;
}

clobber: clean
{
	rm -f [all]
		set clearstat;
}

if [defined bin] then
{
	install = [bin]/[me];

	install: [install];

	uninstall:
	{
		rm -f [install]
			set clearstat;
	}

	[bin]/%: %
	{
		cp % [bin]/%;
		chmod og-w [bin]/%;
	}

	[lib]/%: %
	{
		cp % [lib]/%;
		chmod og-w [lib]/%;
	}
}

find_libs = [find_command find_libs];

/*
 * The cc_link_flags are an historical accident.  They can't be removed
 * without breaking existing installed sites.	Sigh.
 */

if [find_libs] then
{
	if [not [defined ld_libraries]] then
		ld_libraries = ;
	[me]: [dot_obj] [collect [find_libs] [ld_libraries] [cc_link_flags]]
	{
		if [not [defined ld_flags]] then
			ld_flags = ;
		if [exists [me]~] then
			rm -f [me]~
				set clearstat;
		if [exists [me]] then
			mv [me] [me]~
				set clearstat;
		[ld] [ld_flags] [dot_obj] [ld_libraries] [cc_link_flags] -o [me];
	}
}
else
{
	[me]: [dot_obj]
	{
		if [not [defined ld_flags]] then
			ld_flags = ;
		if [exists [me]~] then
			rm -f [me]~
				set clearstat;
		if [exists [me]] then
			mv [me] [me]~
				set clearstat;
		[ld] [ld_flags] [dot_obj] [ld_libraries] [cc_link_flags] -o [me];
	}
}

if [find_command lint] then
if [defined dot_lint_obj] then
{
	[me].lint: [dot_lint_obj]
	{
		[lint] [dot_lint_obj] [ld_libraries] [cc_link_flags];
	}
}