1Panotools::Makefile(3)User Contributed Perl DocumentationPanotools::Makefile(3)
2
3
4
6 Panotools::Makefile - Makefile creation
7
9 Simple object interface for generating Makefiles
10
12 Writing Makefiles directly from perl scripts with print and "\t" etc...
13 is prone to error, this library provides a simple perl interface for
14 assembling Makefiles.
15
16 Note GNU make syntax is assumed, i.e. on BSD systems where pmake is the
17 default you will have to switch to gmake if you want to work with
18 weirdly named targets containing special characters such as spaces or
19 parentheses.
20
22 use Panotools::Makefile;
23
24 Create a new Makefile object:
25
26 my $makefile = new Panotools::Makefile;
27
28 Start adding items to the Makefile:
29
30 Rule() returns a new Panotools::Makefile::Rule object, Variable()
31 returns a new Panotools::Makefile::Variable object and Comment()
32 returns a new Panotools::Makefile::Comment object:
33
34 my $var_user = $makefile->Variable ('USER');
35 $var_user->Values ("Dr. Largio d'Apalansius (MB)");
36
37 my $rule_all = $makefile->Rule ('all');
38 $rule_all->Command ('echo', '$(USER_SHELL)', '>', 'My File.txt');
39
40 $makefile->Comment ('.PHONY target isn't strictly necessary in this case');
41 my $rule_phony = $makefile->Rule;
42 $rule_phony->Targets ('.PHONY');
43 $rule_phony->Prerequisites ('all');
44
45 Assemble all this into string that can be written to a Makefile:
46
47 my $string = $makefile->Assemble;
48
49 ..or write the Makefile:
50
51 $makefile->Write ('/path/to/Makefile');
52
53 ..or let the module execute rules with 'make' directly:
54
55 $makefile->DoIt ('all') || warn "Didn't work :-(";
56
57 The following command will be executed, something that isn't possible
58 with perl system() or exec(), and would otherwise require careful
59 assembly with backticks:
60
61 echo Dr.\ Largio\ d\'Apalansius\ \(MB\) > My\ File.txt
62
63 On the Windows platform you get appropriate quoting:
64
65 echo "Dr. Largio d'Apalansius (MB)" > "My File.txt"
66
67
68
69perl v5.38.0 2023-07-21 Panotools::Makefile(3)