File: unix

package info (click to toggle)
icmake 6.22-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,148 kB
  • ctags: 1,042
  • sloc: ansic: 9,241; makefile: 1,134; sh: 235; asm: 126
file content (355 lines) | stat: -rwxr-xr-x 8,350 bytes parent folder | download
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/usr/local/bin/icmake -qt /tmp/unix

/*

    If you want to use this file, it is assumed that you have icmake (at
    least version 6.20) installed in /usr/local/bin. If it's somewhere else,
    please adapt the path /usr/local/bin in the line above.
    
    Also, check the file destinations.im for proper path settings !

        FBB
*/

#include "def/programs"
#include "def/destinations"

/*      
        The remainder of this script should not be altered, unless
    you know what you're doing
*/

#define VERSION     "6.22"

#define LIB_ICRSS   "libicrss.a"
#define LIB_ICMAKE  "libicmake.a"
#define LIB_ICMPP   "libicmpp.a"
#define LIB_ICMCOMP "libicmcomp.a"
#define LIB_ICMEXEC "libicmexec.a"
#define LIB_ICMUN   "libicmun.a"
#define ZIP     "icmake.zip"

list
        examples;
    
void check(string subdir)
{
    if (!exists(subdir))
    {
        printf("Creating subdirectory: ");
        exec(MKDIR, subdir);
    }
}    

void initialize()
{
    examples = 
    (list)"am"      +
    (list)"backup"  +
    (list)"bup"     +
    (list)"ftpxfer" +
    (list)"ds"      +
    (list)"idir"    +
    (list)"keep"    +
        (list)"r"       +
    (list)"tolower";

    check("bin");
    check("binlinux");
    check("bindos");
}           
            
void makelib (string dir, string lib)
{
    list
        cfiles,
        ofiles;
    string
        ofile,
        cfile;
    int
        i;

    printf ("---- Directory: ", dir, " ----\n");
    chdir (dir);

    printf ("Checking .c files against library ", lib, "\n");       
    cfiles = makelist ("*.c");
    for (i = sizeof (cfiles) - 1; i >= 0; i--)
    {
        cfile = element (i, cfiles);
        ofile = change_ext (cfile, ".o");
        if 
    (
        cfile older lib 
        ||
            (exists (ofile) && ofile younger cfile)
        )
            cfiles -= (list) cfile;
    }
    for (i = 0; i < sizeof (cfiles); i++)
        exec (CC, CFLAGS, element (i, cfiles));
    
    printf ("Checking .o files against library ", lib, "\n");
    ofiles = makelist ("*.o");
    if (ofiles)
    {
        exec (AR, ARFLAGS, lib, "*.o");
    exec (RM, "*.o");
    }
    
    chdir ("..");
}

void makelibs ()
{
    printf ("\nMaking Run Time Support System library\n");
    makelib ("rss", LIB_ICRSS);
    
    printf ("\nMaking lib for shell program icmake\n");
    makelib ("make", LIB_ICMAKE);
    
    printf ("\nMaking lib for preprocessor icm-pp\n");
    makelib ("pp", LIB_ICMPP);
    
    printf ("\nMaking lib for compiler icm-comp\n");
    makelib ("comp", LIB_ICMCOMP);
    
    printf ("\nMaking lib for executor icm-exec\n");
    makelib ("exec", LIB_ICMEXEC);
    
    printf ("\nMaking lib for unassembler icmun\n");
    makelib ("un", LIB_ICMUN);
}

void makeprog (string dir, string lib, string prog)
{
    string
        rsslib;
        
    rsslib = "../rss/libicrss.a";

    printf ("---- Directory: ", dir, " ----\n");
    chdir (dir);
    
    printf ("Checking prog ", prog, " against libs ", lib, 
            " and ", rsslib, "\n");

    if (lib younger prog || rsslib younger prog)
    {
        exec (CC, "-o ../bin/" + prog, lib, rsslib);
        exec (STRIP, "../bin/" + prog);
    printf("Stripped version of ", prog, " in icmake/bin\n");
    }           
        
    chdir ("..");
}

void makeprogs ()
{
    makelibs ();
    
    printf ("\nMaking shell program icmake\n");
    makeprog ("make", LIB_ICMAKE, "icmake");
    
    printf ("\nMaking unassembler program icmun\n");
    makeprog ("un", LIB_ICMUN, "icmun");

    printf ("\nMaking unassembler program icm-pp\n");
    makeprog ("pp", LIB_ICMPP, "icm-pp");
    
    printf ("\nMaking compiler program icm-comp\n");
    makeprog ("comp", LIB_ICMCOMP, "icm-comp");
    
    printf ("\nMaking executor program icm-exec\n");
    makeprog ("exec", LIB_ICMEXEC, "icm-exec");
}

void inst (string prog)
{
    string
        dest;

    printf ("---- Directory: icmake/bin ----\n");
    chdir ("bin");
    dest = BINDIR + "/" + prog;
    
    if (dest older prog)
    {
        if (prog == "icm-exec")
        printf("Since icm-exec itself is running, you have to copy\n"
            "icm-exec by hand.\n"
        "Give the command\n"
            "\t", CP, " bin/icm-exec ", BINDIR, "\n"
        "on completion of 'icmake unix -- install'\n");
    else
        exec (CP, prog, BINDIR);
    }
    
    chdir ("..");
}

void install ()
{
    makeprogs ();
    
    printf ("\nInstalling shell program icmake\n");
    inst ("icmake");
    
    printf ("\nInstalling unassembler program icmun\n");
    inst ("icmun");
    
    printf ("\nInstalling unassembler program icm-pp\n");
    inst ("icm-pp");
    
    printf ("\nInstalling compiler program icm-comp\n");
    inst ("icm-comp");
    
    printf ("\nUSE HAND-INSTALLATION OF EXECUTOR PROGRAM ICM-EXEC\n");
    inst ("icm-exec");
}

void clean (string dir)       
{
    printf ("---- Directory: ", dir, " ----\n");
    chdir (dir);
    exec (RM, "-f", "*.o");
    chdir ("..");
}

void cleanup ()
{
    clean ("rss"); 
    clean ("make");
    clean ("pp"); 
    clean ("comp");
    clean ("exec");
    clean ("un"); 
}

void realclean (string dir, string lib)
{
    printf ("---- Directory: ", dir, " ----\n");
    chdir (dir);
    exec (RM, "-f", lib,  "*.o");
    chdir ("..");
}

void realcleanup ()
{
    realclean ("rss",  LIB_ICRSS); 
    realclean ("make", LIB_ICMAKE);
    realclean ("pp", LIB_ICMPP);
    realclean ("comp", LIB_ICMCOMP);
    realclean ("exec", LIB_ICMEXEC);
    realclean ("un", LIB_ICMUN);
}

void zip ()
{
    cleanup ();
    
    exec (RM, "-f", "bin/*", "../icmake.zip");
    chdir ("..");
    exec ("zip", "-r", ZIP, "icmake/*");
}

void makedist ()
{
    string
        tar,
        example;
    int
        i;
        
    printf ("Have you updated the version number (if things have changed)?\n"
            "Also, check distribution numbers in doc/icmake.1, icmake.doc,\n"
            "CHANGES, INSTALL*, upload*\n"
        "\n"
            "The version used now is: ", VERSION, ".\n"
        "Do you want to continue [y/n] ");
    if (getch () != "y")
        return;

    printf ("\nOk..\n");
    
    chdir ("examples");
    for (i = 0; i < sizeof (examples); i++)
    {
        example = element (i, examples);
        if ("/home/karel/bin/" + example younger example)
            exec (CP, "/home/karel/bin/" + example, example);
        else if ("/usr/local/bin/" + example younger example)
            exec (CP, "/usr/local/bin/" + example, example);
    }

    chdir ("../..");

    tar = "icmake-" + VERSION + ".tgz";
    exec (RM, "-f", tar);
    exec ("tar", "-c -z -v --exclude-from icmake/distrib.no -f", 
                        tar, "icmake");
            
    tar = "icmake-" + VERSION + ".bin.tgz";
    exec (RM, "-f", tar);
    exec ("tar", "-c -z -v --files-from icmake/bindist.yes -f", 
                        tar, "icmake");
}

void doc2man ()
{
    string
        src,
    dest,
    zdest;
        
    src   = "doc"   + "/" + "icmake.1";
    dest  = CATDIR  + "/" + "icmake.1";
    zdest = CATDIR  + "/" + "icmake.1.Z";
    
    if (zdest older src)
    {
        exec (CP, src, CATDIR);
    exec (COMPRESS, "-f", dest);
    }
}

void main (int argc, list argv)
{
    string
        av1;
    
    initialize();   
        
    av1 = element (1, argv);
    if (av1 == "libs")
        makelibs ();
    else if (av1 == "progs")
        makeprogs ();
    else if (av1 == "install")
        install ();
    else if (av1 == "clean")
        cleanup ();
    else if (av1 == "realclean")
        realcleanup ();
    else if (av1 == "doc2man")
        doc2man ();
    else if (av1 == "zip")
        zip ();
    else if (av1 == "dist")
    makedist ();
    else
        printf ("\n"
            "Select one of the following:\n"
            "    \"unix libs\" to make libraries\n"
            "    \"unix progs\" to make programs\n"
            "    \"unix install\" to install programs to ",
                                BINDIR, "\n"
        "    \"unix clean\" to remove old mush (libs are kept)\n"
        "    \"unix realclean\" to remove old mush (including libs)\n"
        "    \"unix doc2man\" to install crude docs to cat\n"
        "\n"
        "    \"unix zip\" to clean up (keeping libs) and zip it up\n"
        "    \"unix dist\" to make distribution\n"
            "\n");
}