ICMAKE Part 4
Three examples will be given in this final section, completing our discussion of icmake. The first example illustrates a `traditional make script', used with icmake. The example was taken from the `callback utility', developed by Karel (and also available from beatrix.icce.rug.bl). The second example is a simple dos2unix script which may be used to convert DOS textfiles to Unix textfiles: it uses awk to do the hard work. Finally, the attic-move script is presented, implementing a non-destructive remove, by moving files into an `attic.zip'. More examples can be found in the icmake distribution tar.gz file. The examples are annotated by their own comment, and are presented as they are currently used.
#!/usr/local/bin/icmake -qi
#define CC "gcc"
#define CFLAGS "-c -Wall"
#define STRIP "strip"
#define AR "ar"
#define ARREPLACE "rvs"
#define DEBUG ""
#define CALLBACKDIR "/conf/callback"
#define BINDIR "/usr/local/bin"
#define VER "1.05v
int compdir (string dir)
{
int
i,
ret;
list
ofiles,
cfiles;
string
hfile,
curdir,
cfile,
ofile,
libfile;
curdir = chdir (".");
libfile = "lib" + dir + ".a";
hfile = dir + ".h";
chdir (dir);
if (hfile younger libfile)
cfiles = makelist ("*.c");
else
cfiles = makelist ("*.c", younger, libfile);
for (i = 0; i < sizeof (cfiles); i++)
{
cfile = element (i, cfiles);
ofile = change_ext (cfile, ".o");
if (! exists (ofile) || ofile older cfile)
exec (CC, DEBUG, CFLAGS, cfile);
}
if (ofiles = makelist ("*.o"))
{
exec (AR, ARREPLACE, libfile, "*.o");
exec ("rm", "*.o");
ret = 1;
}
chdir (curdir);
return (ret);
}
void linkprog (string dir)
{
chdir (dir);
exec (CC, DEBUG, "-o", dir, "-l" + dir, "-lrss", "-L. -L../rss");
chdir ("..");
}
void buildprogs ()
{
int
cblogin,
cbstat,
rss;
chdir ("src");
cblogin = compdir ("cblogin");
cbstat = compdir ("cbstat");
rss = compdir ("rss");
if (cblogin || rss)
linkprog ("cblogin");
if (cbstat || rss)
linkprog ("cbstat");
chdir ("..");
}
void instprog (string prog, string destdir)
{
chdir ("src/" + prog);
exec (STRIP, prog);
exec ("chmod", "700", prog);
exec ("cp", prog, destdir);
chdir ("../..");
}
void install ()
{
buildprogs ();
instprog ("cblogin", CALLBACKDIR);
instprog ("cbstat", BINDIR);
}
void cleandir (string dir)
{
chdir ("src/" + dir);
exec ("rm", "-f", "*.o lib*.a", dir);
chdir ("../..");
}
void clean ()
{
exec ("rm", "-f", "build.bim");
cleandir ("cblogin");
cleandir ("cbstat");
cleandir ("rss");
}
void makedist ()
{
list
examples;
int
i;
clean ();
chdir ("examples");
examples = makelist ("*");
for (i = 0; i < sizeof (examples); i++)
if (exists ("/conf/callback/" + element (i, examples)) &&
"/conf/callback/" + element (i, examples) younger
element (i, examples))
exec ("cp", "/conf/callback/" + element (i, examples),
element (i, examples));
chdir ("..");
exec ("rm", "-f", "callback-" + VER + ".tar*");
exec ("tar", "cvf", "callback-" + VER + ".tar", "*");
exec ("gzip", "callback-" + VER + ".tar");
exec ("mv", "callback-" + VER + ".tar.z",
"callback-" + VER + ".tar.gz");
}
void main (int argc, list argv)
{
if (element (1, argv) == "progs")
buildprogs ();
else if (element (1, argv) == "install")
install ();
else if (element (1, argv) == "clean")
clean ();
else if (element (1, argv) == "dist")
makedist ();
else
{
printf ("\n"
"Usage: build progs - builds programs\n"
" build install - installs program\n"
" build clean - cleanup .o files etc.\n"
"\n"
" build dist - makes .tar.gz distrib file\n"
"\n");
exit (1);
}
exit (0);
}
#!/usr/local/bin/icmake -qi
/*
DOS2UNIX
This script is used to change dos textfiles into unix textfiles.
*/
string
pidfile;
void usage(string prog)
{
prog = change_ext(get_base(prog), ""); // keep the scriptname
printf("\n"
"ICCE ", prog,
": Dos to Unix textfile conversion. Version 1.00\n"
"Copyright (c) ICCE 1993, 1994. All rights reserved\n"
"\n",
prog, " by Frank B. Brokken\n"
"\n"
"Usage: ", prog, " file(s)\n" // give help
"Where:\n"
"file(s): MS-DOS textfiles to convert to UNIX textfiles\n"
"\n");
exit (1); // and exit
}
void dos2unix(string file)
{
if (!exists(file))
printf("'", file, "' does not exist: skipped\n");
else
{
printf("converting: ", file, "\n");
exec("/bin/mv", file, pidfile);
system("/usr/bin/awk 'BEGIN {FS=\"\\r\"}; {print $1}' " +
pidfile + " > " + file);
}
}
void process(list argv)
{
int
i;
// make general scratchname
pidfile = "/tmp/dos2unix." + (string)getpid();
echo(OFF); // no echoing of exec-ed progs
for (i = 1; i < sizeof(argv); i++)
dos2unix(element(i, argv)); // convert dos 2 unix
if (exists(pidfile))
exec("/bin/rm", pidfile); // remove final junk
}
int main(int argc, list argv)
{
if (argc == 1)
usage(element(0, argv));
process(argv); // process all arguments
return (0); // return when ready
}
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- Designing Electronics with Linux
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




8 hours 17 min ago
8 hours 51 min ago
9 hours 49 min ago
10 hours 40 min ago
14 hours 41 min ago
18 hours 29 min ago
18 hours 37 min ago
20 hours 51 min ago
23 hours 21 min ago
1 day 9 hours ago