summaryrefslogtreecommitdiff
path: root/web/glasgow/lit2x-0.16/mkworld/macros-GEN.jm
blob: 42c950824d75bd3384b3d7bdb88cae2d29228bd9 (plain)
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
# line 19 "../../mkworld/macros-GEN.ljm"
#ifndef CDependTarget
#define CDependTarget(deps)                                     @@\
MkDependCNeededHere(depend)                                     @@\
                                                                @@\
depend:: deps                                                   @@\
        $(MKDEPENDC) $(MKDEPENDCFLAGS) -- $(CFLAGS) -- deps
#endif /* CDependTarget */
# line 31 "../../mkworld/macros-GEN.ljm"
#ifndef HaskellDependTarget
#define HaskellDependTarget(deps)                               @@\
MkDependHSNeededHere(depend)                                    @@\
                                                                @@\
depend:: deps                                                   @@\
        $(MKDEPENDHS) $(MKDEPENDHSFLAGS) -- $(HCFLAGS) -- deps
#endif /* HaskellDependTarget */
# line 43 "../../mkworld/macros-GEN.ljm"
#ifndef LitDependTarget
#define LitDependTarget(root,rootext)                           @@\
                                                                @@\
depend::                                                        @@\
        $(MKDEPENDLIT) $(MKDEPENDLITFLAGS) root.rootext
#endif /* LitDependTarget */
# line 61 "../../mkworld/macros-GEN.ljm"
#ifndef AllTarget
#define AllTarget(depends)                              @@\
all:: depends
#endif
# line 71 "../../mkworld/macros-GEN.ljm"
#ifndef LinkTarget
#define LinkTarget(target,linkto)                       @@\
AllTarget(target)                                       @@\
ExtraStuffToClean(target)                               @@\
target:: linkto                                         @@\
        RemoveTarget(target)                            @@\
        ${LN} linkto target
#endif
# line 101 "../../mkworld/macros-GEN.ljm"
#ifndef BuildPgm
#define BuildPgm(program,compiler,compileropts,objs,libs,deplibs)       @@\
AllTarget(program)                                                      @@\
ExtraStuffToClean(program)                                              @@\
program:: objs deplibs                                                  @@\
        RemoveTarget($@)                                                @@\
        compiler -o $@ compileropts $(LDOPTIONS) objs libs
#endif /* BuildPgm */
# line 121 "../../mkworld/macros-GEN.ljm"
#ifndef BuildPgmFromCFiles
#define BuildPgmFromCFiles(program,objs,libs,deplibs)           @@\
BuildPgm(program,$(CC),$(CFLAGS),objs,libs,deplibs)
#endif

#ifndef BuildPgmFromOneCFile
#define BuildPgmFromOneCFile(program)                           @@\
SRCS_C = program.c                                              @@\
OBJS_C = program.o                                              @@\
BuildPgm(program,$(CC),$(CFLAGS),$(OBJS_C),/**/,/**/)
#endif
# line 137 "../../mkworld/macros-GEN.ljm"
/*ToDo: cmp => $(CMP)*/

#ifndef YaccRunWithExpectMsg
#define YaccRunWithExpectMsg(srcfile,ss,rs)                     @@\
srcfile.tab.c : srcfile.y                                       @@\
        $(RM) srcfile.tab.c srcfile.tab.h-SAVE y.tab.c y.tab.h y.output         @@\
        @if [ -f srcfile.tab.h ] ; then $(MV) -f srcfile.tab.h srcfile.tab.h-SAVE ; fi @@\
        @echo expect ss shift/reduce conflicts and rs reduce/reduce conflicts @@\
        $(YACC) $(YFLAGS) srcfile.y                             @@\
        @if cmp -s srcfile.tab.h-SAVE y.tab.h ; then \          @@\
            $(MV) -f srcfile.tab.h-SAVE srcfile.tab.h ; \       @@\
        else \                                                  @@\
            echo $(MV) -f y.tab.h srcfile.tab.h ; \             @@\
            $(MV) -f y.tab.h srcfile.tab.h ; \                  @@\
            chmod 444 srcfile.tab.h ; \                         @@\
        fi                                                      @@\
        @$(RM) y.tab.h                                          @@\
        $(MV) y.tab.c srcfile.tab.c                             @@\
        @chmod 444 srcfile.tab.c                                @@\
                                                                @@\
srcfile.tab.h : srcfile.tab.c                                   @@\
        @echo -n "" /* no-op */
#endif
# line 182 "../../mkworld/macros-GEN.ljm"
#ifndef BuildPgmFromHaskellModules
#define BuildPgmFromHaskellModules(program,objs,libs,deplibs)   @@\
BuildPgm(program,$(HC),$(HCFLAGS),objs,libs,deplibs)
#endif

#ifndef BuildPgmFromOneHaskellModule
#define BuildPgmFromOneHaskellModule(program,module,isuf)       @@\
SRCS_HS = module.isuf                                           @@\
OBJS_HS = module.o                                              @@\
BuildPgm(program,$(HC),$(HCFLAGS),$(OBJS_HS),,)
#endif
# line 197 "../../mkworld/macros-GEN.ljm"
#if HaveGlasgowHaskell == YES && UseGlasgowHaskell == YES

#define _body_HaskellCompileWithSpecifiedFlags(module_isuf,module,isuf,flags) @@\
        $(RM) $@                                                \
        HaskellCompilePreProcessing(module_isuf,module,isuf)    @@\
        $(HC) flags module_isuf -o module.o                     \
        HaskellCompilePostProcessing(module_isuf,module,isuf)


#elif HaveChalmersHBC == YES && UseChalmersHBC == YES

#define _body_HaskellCompileWithSpecifiedFlags(module_isuf,module,isuf,flags) @@\
        @echo $(RM) $@; \                                       @@\
        $(RM) $@; \                                             \
        HaskellCompilePreProcessing(module_isuf,module,isuf)    @@\
        iface=`basename module_isuf .isuf`.hi ; \               @@\
        if [ -f $(@D)/$$iface ] ; then \                        @@\
            $(RM) $(@D)/$$iface-SAVE ; \                        @@\
            $(MV) -f $(@D)/$$iface $(@D)/$$iface-SAVE ; \       @@\
        fi ; \                                                  @@\
        set +e; \                                               @@\
        echo $(HC) flags module_isuf -o module.o; \             @@\
        $(HC) flags module_isuf -o module.o; \                  @@\
        if [ $$? -ne 0 ] ; then \                               @@\
            $(MV) -f $(@D)/$$iface-SAVE $(@D)/$$iface ; \       @@\
            exit 1; \                                           @@\
        fi ; \                                                  @@\
        if cmp -s $(@D)/$$iface-SAVE $(@D)/$$iface ; then \     @@\
            $(MV) -f $(@D)/$$iface-SAVE $(@D)/$$iface ;  \      @@\
        else \                                                  @@\
            if [ -f $(@D)/$$iface-SAVE ] ; then \               @@\
                diff -c1 $(@D)/$$iface-SAVE $(@D)/$$iface ;  \  @@\
                $(RM) $(@D)/$$iface-SAVE ;  \                   @@\
            fi ; \                                              @@\
        fi                                                      \
        HaskellCompilePostProcessing(module_isuf,module,isuf)
        
#else /* not GHC or HBC; presumably prototype Glasgow compiler (nhc) */

#define _body_HaskellCompileWithSpecifiedFlags(module_isuf,module,isuf,flags) @@\
        @echo $(RM) $@; \                                       @@\
        $(RM) $@; \                                             \
        HaskellCompilePreProcessing(module_isuf,module,isuf)    @@\
        iface=`basename module_isuf .isuf`.hi ; \               @@\
        if [ -f $(@D)/$$iface ] ; then \                        @@\
            $(RM) $(@D)/$$iface-SAVE ; \                        @@\
            $(MV) -f $(@D)/$$iface $(@D)/$$iface-SAVE ; \       @@\
            cp -p $(@D)/$$iface-SAVE $(@D)/$$iface ; \          @@\
            chmod u+w $(@D)/$$iface ; \                         @@\
        fi ; \                                                  @@\
        set +e; \                                               @@\
        echo $(HC) flags module_isuf -o module.o; \             @@\
        $(HC) flags module_isuf -o module.o; \                  @@\
        if [ $$? -ne 0 ] ; then \                               @@\
            $(RM) STAT ; \                                      @@\
            $(MV) -f $(@D)/$$iface-SAVE $(@D)/$$iface ; \       @@\
            exit 1; \                                           @@\
        fi ; \                                                  @@\
        if [ -f STAT ] ; then $(MV) STAT module.STAT ; fi ; \   @@\
        if [ \( $(@D) != '.' \) -a \( $(@D) != './' \) ] ; then \ @@\
            iface=`basename module_isuf .isuf`.hi ; \           @@\
            $(UPDATEIFACE) $$iface $(@D)/$$iface ; \            @@\
            $(RM) $(@D)/$$iface-SAVE ; \                        @@\
        fi                                                      \
        HaskellCompilePostProcessing(module_isuf,module,isuf)

#endif /* ! ChalmersHBC or GHC */
# line 270 "../../mkworld/macros-GEN.ljm"
#ifndef HaskellCompilePreProcessing
#define HaskellCompilePreProcessing(module_isuf,module,isuf) /* nothing */
#endif /* ! HaskellCompilePreProcessing */

#ifndef HaskellCompilePostProcessing
#define HaskellCompilePostProcessing(module_isuf,module,isuf) /* nothing */
#endif /* ! HaskellCompilePostProcessing */
# line 281 "../../mkworld/macros-GEN.ljm"
#ifndef HaskellCompileWithSpecifiedFlags
#define HaskellCompileWithSpecifiedFlags(module,isuf,flags)     @@\
module.o : module.isuf                                          \
_body_HaskellCompileWithSpecifiedFlags(module.isuf,module,isuf,flags)
#endif /* HaskellCompileWithSpecifiedFlags */

#ifndef HaskellCompileWithExtraFlags
#define HaskellCompileWithExtraFlags(module,isuf,flags)         @@\
HaskellCompileWithSpecifiedFlags(module,isuf,-c $(HCFLAGS) flags)
#endif /* HaskellCompileWithExtraFlags */

#ifndef HaskellCompile
#define HaskellCompile(module,isuf)                             @@\
HaskellCompileWithSpecifiedFlags(module,isuf,-c $(HCFLAGS))
#endif /* HaskellCompile */
# line 301 "../../mkworld/macros-GEN.ljm"
#ifndef HaskellCompileWithMoreHeapAndStack
#define HaskellCompileWithMoreHeapAndStack(module,isuf,heapsize,stksize) @@\
HaskellCompileWithSpecifiedFlags(module,isuf,-c $(HCFLAGS) HaskellCompilerHeapSize(heapsize) HaskellCompilerStkSize(stksize))
#endif /* HaskellCompileWithMoreHeapAndStack */

#ifndef HaskellCompileWithMoreHeap
#define HaskellCompileWithMoreHeap(module,isuf,heapsize)        @@\
HaskellCompileWithSpecifiedFlags(module,isuf,-c $(HCFLAGS) HaskellCompilerHeapSize(heapsize))
#endif /* HaskellCompileWithMoreHeap */
# line 314 "../../mkworld/macros-GEN.ljm"
#if HaveGlasgowHaskell == YES && UseGlasgowHaskell == YES
#define HaskellCompilerHeapSize(size) -Rmax-heapsize size
#define HaskellCompilerStkSize(size)  -Rmax-stksize size
#define HaskellCompilerRunCpp() -cpp
#define HaskellEndRTSFlags()    /*none*/

#elif HaveChalmersHBC == YES && UseChalmersHBC == YES
#define HaskellCompilerHeapSize(size) CAT2(-H,size)
#define HaskellCompilerStkSize(size)  CAT2(-V,size)
#define HaskellCompilerRunCpp() -M
#define HaskellEndRTSFlags()    -

#else /* not GHC or HBC; assume nhc */
#define HaskellCompilerHeapSize(size) CAT2(-H,size)
#define HaskellCompilerStkSize(size)  /*cant set stksize*/
#define HaskellCompilerRunCpp() /*none*/
#define HaskellEndRTSFlags()    -

#endif /* not GHC or HBC */
# line 342 "../../mkworld/macros-GEN.ljm"
#ifndef ProgramScriptTarget
#if HasExecableScripts          /* can use #! */
#define ProgramScriptTarget(prog,dst,src,deplist)       @@\
AllTarget(dst)                                          @@\
ExtraStuffToClean(dst)                                  @@\
dst::  src deplist                                      @@\
        $(RM) $@                                        @@\
        echo "#!"prog > $@                              @@\
        cat src >> $@                                   @@\
        chmod a+x $@
#else
#define ProgramScriptTarget(prog,dst,src,deplist)       @@\
AllTarget(dst)                                          @@\
ExtraStuffToClean(dst)                                  @@\
dst::  src deplist                                      @@\
        $(RM) $@                                        @@\
        echo \: > $@                                    @@\
        echo 'x=/tmp/xx$$$$' >> $@                      @@\
        echo "cat > "'$$x'" << 'EOF'" >> $@             @@\
        cat src >> $@                                   @@\
        echo EOF >> $@                                  @@\
        echo prog '$$x' '$$@' >> $@                     @@\
        echo $(RM) '$$x' >> $@                          @@\
        chmod a+x $@
#endif /* HasExecableScripts */
#endif /* ProgramScriptTarget */
# line 372 "../../mkworld/macros-GEN.ljm"
#ifndef MsubTarget
#define MsubTarget(dst,src,flags,deplist)               @@\
AllTarget(dst)                                          @@\
ExtraStuffToClean(dst)                                  @@\
dst:: src deplist                                       @@\
        $(MSUB) flags src > dst
#endif
# line 388 "../../mkworld/macros-GEN.ljm"
#ifndef MsubProgramScriptTarget
#if HasExecableScripts          /* can use #! */
#define MsubProgramScriptTarget(prog,dst,src,flags,deplist)     @@\
AllTarget(dst)                                                  @@\
ExtraStuffToClean(dst)                                          @@\
dst::  src deplist                                              @@\
        $(RM) $@                                                @@\
        echo "#!"prog > $@                                      @@\
        ${MSUB} flags src >> $@                                 @@\
        chmod a+x $@
#else
#define MsubProgramScriptTarget(prog,dst,src,flags,deplist)     @@\
AllTarget(dst)                                                  @@\
ExtraStuffToClean(dst)                                          @@\
dst::  src deplist                                              @@\
        $(RM) $@                                                @@\
        echo \: > $@                                            @@\
        echo 'x=/tmp/xx$$$$' >> $@                              @@\
        echo "cat > "'$$x'" << 'EOF'" >> $@                     @@\
        ${MSUB} flags src >> $@                                 @@\
        echo EOF >> $@                                          @@\
        echo prog '$$x' '$$@' >> $@                             @@\
        echo $(RM) '$$x' >> $@                                  @@\
        chmod a+x $@
#endif /* HasExecableScripts */
#endif /* MsubProgramScriptTarget */
# line 420 "../../mkworld/macros-GEN.ljm"
#ifndef MsubMakefileDependentProgramScriptTarget
#define MsubMakefileDependentProgramScriptTarget(prog,dst,src,flags,deplist)    @@\
MsubProgramScriptTarget(prog,dst,src,flags,deplist)                     @@\
                                                                        @@\
Makefile::                                                              @@\
        $(RM) dst
#endif
# line 430 "../../mkworld/macros-GEN.ljm"
#ifndef MsubScriptTarget
#define MsubScriptTarget(dst,src,flags,deplist)                         @@\
MsubProgramScriptTarget(${SHELL},dst,src,flags,deplist)
#endif
# line 445 "../../mkworld/macros-GEN.ljm"
#ifndef NormalLibraryTarget
#define NormalLibraryTarget(libname,objlist)    @@\
AllTarget(CAT2(lib,libname.a))                  @@\
ExtraStuffToClean(CAT2(lib,libname.a))          @@\
CAT2(lib,libname.a):: objlist                   @@\
        $(RM) $@                                @@\
        $(AR) $@ objlist                        @@\
        $(RANLIB) $@
#endif /* NormalLibraryTarget */
# line 465 "../../mkworld/macros-GEN.ljm"
#ifndef RuntestsTarget
#define RuntestsTarget(depends)                 @@\
runtests:: CAT2(runtest_,depends)
#endif

#ifndef RunStdTestTimeCmd
#define RunStdTestTimeCmd /*none*/
#endif

#ifndef RunStdTest
#define RunStdTest(name,prog,teststuff)         @@\
RuntestsTarget(name)                            @@\
CAT2(runtest_,name)::                           @@\
        @RunStdTestTimeCmd $(RUNSTDTEST) prog $(RUNSTDTEST_FLAGS) teststuff
#endif /* RunStdTest */

#ifndef AsPartOfTest
#define AsPartOfTest(test,cmdline)              @@\
RuntestsTarget(test)                            @@\
CAT2(runtest_,test)::                           @@\
        cmdline
#endif /* AsPartOfTest */
# line 499 "../../mkworld/macros-GEN.ljm"
#ifndef InstallMsubbedScriptTarget
#if HasExecableScripts          /* can use #! */
#define InstallMsubbedScriptTarget(prog,dst,src,installdir)     @@\
dst-tmp:  src                                                   @@\
        $(RM) $@                                                @@\
        echo "#!"prog > $@                                      @@\
        ${MSUB} INSTALLING=1 src >> $@                          @@\
        chmod a+x $@                                            @@\
                                                                @@\
InstallTargetWithNameAndFlags(dst-tmp,installdir,dst,)          @@\
install::                                                       @@\
        $(RM) dst-tmp
#else
#define InstallMsubbedScriptTarget(prog,dst,src,installdir)     @@\
dst-tmp:  src                                                   @@\
        $(RM) $@                                                @@\
        echo \: > $@                                            @@\
        echo 'x=/tmp/xx$$$$' >> $@                              @@\
        echo "cat > "'$$x'" << 'EOF'" >> $@                     @@\
        ${MSUB} INSTALLING=1 src >> $@                          @@\
        echo EOF >> $@                                          @@\
        echo prog '$$x' '$$@' >> $@                             @@\
        echo $(RM) '$$x' >> $@                                  @@\
        chmod a+x $@                                            @@\
                                                                @@\
InstallTargetWithNameAndFlags(dst-tmp,installdir,dst,)          @@\
install::                                                       @@\
        $(RM) dst-tmp
#endif /* HasExecableScripts */
#endif /* InstallMsubbedScriptTarget */

/*
        INSTALLATION RULES.  InstallTarget() should be a part of nearly
        all of these, to add the target to the "install" rule.
*/

#ifndef InstallTarget
#define InstallTarget(depends)                                  @@\
install:: CAT2(install_,depends)
#endif

#ifndef InstallDocTarget
#define InstallDocTarget(depends)                               @@\
install_docs:: CAT2(install_doc_,depends)
#endif

/*
        Install a target specifying the flags to use.  Many of the following
        installation rules are instantiated as a particular expansion of this.
*/

#ifndef InstallTargetWithNameAndFlags
#define InstallTargetWithNameAndFlags(target,destdir,new_name,flags)    @@\
InstallTarget(new_name)                                                 @@\
CAT2(install_,new_name):: target                                        @@\
        $(INSTALL) -c flags target destdir/new_name
#endif

#ifndef InstallTargetWithFlags
#define InstallTargetWithFlags(target,dest,flags)                       @@\
InstallTargetWithNameAndFlags(target,dest,target,flags)
#endif

#ifndef InstallDocTargetWithFlags
#define InstallDocTargetWithFlags(src,presuff,target,postsuff,dest,flags) @@\
InstallDocTarget(CAT3(target,_,postsuff))                               @@\
CAT4(install_doc_,target,_,postsuff):: src.presuff                      @@\
        $(INSTALL) -c flags src.presuff dest/target.postsuff
#endif

/*
        Install a program
*/

#ifndef InstallBinaryTarget
#define InstallBinaryTarget(program,dest)                               @@\
InstallTargetWithFlags(program,dest,$(INSTBINFLAGS))
#endif

/*      Install a setuid/setgid/etc program -- DELETED (partain)
*/

/*
        Install an executable script
*/

#ifndef InstallScriptTarget
#define InstallScriptTarget(script,dest)                                @@\
InstallTargetWithFlags(script,dest,$(INSTSCRIPTFLAGS))
#endif

/*
        Install a library (platform-dependent)
*/

#ifndef InstallLibraryTarget
#define InstallLibraryTarget(libname,dest)                              @@\
InstallTargetWithFlags(CAT2(lib,libname).a,dest,$(INSTLIBFLAGS))        @@\
        ${RANLIB} dest/CAT2(lib,libname).a
#endif

/*
        Install an include file
*/

#ifndef InstallIncludeTarget
#define InstallIncludeTarget(file,dest)                                 @@\
InstallTargetWithFlags(file,dest,$(INSTINCFLAGS))
#endif

/*
        Install a non-executable or data file (these are equivalent)
*/

#ifndef InstallDataTarget
#define InstallDataTarget(file,dest)                                    @@\
InstallTargetWithFlags(file,dest,$(INSTDATAFLAGS))
#endif

/*
        Install a set of non-executable files

        DUMP THIS SOMETIME.
*/

#ifndef InstallMultNonExecTargets
#define InstallMultNonExecTargets(rule,targets,dest)                    @@\
CAT2(install_,rule):: rule                                              @@\
        @case '${MFLAGS}' in *[ik]*) set +e;; esac; \                   @@\
        for i in targets ;\                                             @@\
        do \                                                            @@\
                echo $(INSTALL) -c $(INSTDATAFLAGS) $$i dest/$$i; \     @@\
                $(INSTALL) -c $(INSTDATAFLAGS) $$i dest/$$i; \          @@\
        done
#endif

/*
        Install a man page.

        THIS IS WRONG - rules in Jmakefiles don't have suffix!

        file srcsuffix destdir dstsuffix ???
*/

#ifndef InstallManPageTarget
#define InstallManPageTarget(file,destdir,suffix)                       @@\
InstallDocTargetWithFlags(file,man,file,suffix,destdir,$(INSTMANFLAGS))
#endif

#ifndef InstallInfoFileTarget
#define InstallInfoFileTarget(src,target,destdir)                       @@\
InstallDocTargetWithFlags(src,info,target,info,destdir,$(INSTMANFLAGS))
#endif

#ifndef InstallLinkTarget
#define InstallLinkTarget(target, linkto, dir)                          @@\
InstallTarget(target)                                                   @@\
CAT2(install_,target):: CAT2(install_,linkto)                           @@\
        RemoveTarget(dir/target)                                        @@\
        ${LN} dir/linkto dir/target
#endif

/*
        Fake install rules for things not installed anywhere
*/

#ifndef FakeInstallTarget
#define FakeInstallTarget(target)                                       @@\
InstallTarget(target)                                                   @@\
CAT2(install_,target):: target                                          @@\
        @echo target is not installed anywhere.
#endif

#ifndef FakeInstallLibrary
#define FakeInstallLibrary(libname)                                     @@\
InstallTarget(CAT2(lib,libname).a)                                      @@\
CAT2(install_lib,libname).a:: CAT2(lib,libname).a                       @@\
        @echo CAT2(lib,libname).a is not installed anywhere.
#endif
# line 689 "../../mkworld/macros-GEN.ljm"
#ifndef DocsTarget
#define DocsTarget(depends)                                             @@\
docs:: depends
#endif

/* putting the InfoStuffNeededHere in semi-presumes that
   LitDocRootTarget is only used once per directory (?)
*/
#ifndef LitDocRootTargetWithNamedOutput
#define LitDocRootTargetWithNamedOutput(rootroot,rootext,rootout)       @@\
DocsTarget(rootroot.info rootroot.dvi)                                  @@\
ExtraStuffToClean(rootroot.info rootroot.dvi rootroot.texi rootroot.tex) @@\
LitDependTarget(rootroot,rootext)                                       @@\
                                                                        @@\
rootroot.info:: rootroot.texi                                           @@\
        RemoveTarget($@)                                                @@\
        $(MAKEINFO) $(MAKEINFOFLAGS) rootroot.texi \                    @@\
        && $(POSTMAKEINFO) rootroot.info                                @@\
                                                                        @@\
rootroot.dvi:: rootroot.tex                                             @@\
        RemoveTarget($@)                                                @@\
        $(LTX) rootroot.tex                                             @@\
                                                                        @@\
rootroot.texi: rootout.itxi                                             @@\
        RemoveTarget($@)                                                @@\
        $(LIT2TEXI) -S $(LIT2TEXIFLAGS) -N rootroot.info -o rootroot.texi rootout.itxi  @@\
                                                                        @@\
rootout.itxi: rootroot.rootext                                          @@\
        RemoveTarget($@)                                                @@\
        $(LIT2TEXI) -S -c $(LIT2TEXIFLAGS) -o rootout.itxi rootroot.rootext @@\
                                                                        @@\
rootroot.tex: rootout.itex                                              @@\
        RemoveTarget($@)                                                @@\
        $(LIT2LATEX) -S $(LIT2LATEXFLAGS) -o rootroot.tex rootout.itex  @@\
                                                                        @@\
rootout.itex: rootroot.rootext                                          @@\
        RemoveTarget($@)                                                @@\
        $(LIT2LATEX) -S -c $(LIT2LATEXFLAGS) -o rootout.itex rootroot.rootext
#endif /* LitDocRootTargetWithNamedOutput */

#ifndef LitDocRootTarget
#define LitDocRootTarget(rootroot,rootext) \
LitDocRootTargetWithNamedOutput(rootroot,rootext,rootroot)
#endif /* LitDocRootTarget */

#ifndef VerbatimAndTibTarget
#define VerbatimAndTibTarget(root)                                      @@\
VerbatimNeededHere(docs root.tex)                                       @@\
DocsTarget(root.dvi)                                                    @@\
ExtraStuffToClean(root.dvi root.tex)
#endif /* VerbatimAndTibTarget */
# line 755 "../../mkworld/macros-GEN.ljm"
#ifndef ExtraStuffToClean
#define ExtraStuffToClean(extra)                                        @@\
clean::                                                                 @@\
        $(RM) extra
#endif /* ExtraStuffToClean */

#ifndef ExtraStuffToBeVeryClean
#define ExtraStuffToBeVeryClean(extra)                                  @@\
veryclean::                                                             @@\
        $(RM) extra
#endif /* ExtraStuffToBeVeryClean */

#ifndef RemoveTarget
#if RemoveTargetByMoving
#define RemoveTarget(program) \
$(RM) program; if [ -f program ]; then $(MV) program CAT2(program,~); fi
#else
#define RemoveTarget(program) $(RM) program
#endif /* ! RemoveTargetByMoving */
#endif /* RemoveTarget */
/*
 * CleanTarget - generate rules to remove any garbage files; the #* is here
 * instead of in the definition of CLEAN_CMD because System V would treat a
 * pound sign in the CLEAN_CMD variable as a comment.
 */
#ifndef CleanTarget
#define CleanTarget()                                                   @@\
clean::                                                                 @@\
        $(CLEAN_CMD) \#*
#endif /* CleanTarget */

/*
 * VeryCleanTarget - generate rules for "make veryclean"; the idea is
 * that "make clean" does what "you almost always want" and "make
 * veryclean" removes ALL generated files.
 */
#ifndef VeryCleanTarget
#define VeryCleanTarget()                                               @@\
veryclean::                                                             @@\
        $(CLEAN_CMD) \#*
#endif /* VeryCleanTarget */
# line 805 "../../mkworld/macros-GEN.ljm"
/* this should normally precede <>TagsTarget commands */
/* those commands *append* to the TAGS file */
#ifndef ClearTagsFile
#define ClearTagsFile()                                                 @@\
tags::                                                                  @@\
        $(RM) TAGS; touch TAGS
#endif

/*
 * CTagsTarget - generate rules to compute tags files for C source code.
 *      (specified as an arg)
 *      partain: we really expect "etags" to be used...
 */
#ifndef CTagsTarget
#define CTagsTarget(srcs)                                               @@\
tags::                                                                  @@\
        $(CTAGS) -a $(CTAGSFLAGS) srcs
#endif /* CTagsTarget */

/* Similarly for Perl and Haskell */
#ifndef PerlTagsTarget
#define PerlTagsTarget(srcs)                                            @@\
tags::                                                                  @@\
        $(PERLTAGS) $(PERLTAGSFLAGS) srcs
#endif /* PerlTagsTarget */

#ifndef HsTagsTarget
#define HsTagsTarget(srcs)                                              @@\
tags::                                                                  @@\
        $(HSTAGS) $(HSTAGSFLAGS) srcs
#endif /* HsTagsTarget */
# line 850 "../../mkworld/macros-GEN.ljm"
#ifndef BuildMakefileTarget
#define BuildMakefileTarget()                                           @@\
JmakeNeededHere(Makefile)                                               @@\
                                                                        @@\
Makefile:: $(MYJCONFIGFILES)                                            @@\
                                                                        @@\
Makefile::                                                              @@\
        -@if [ -f Makefile ]; then \                                    @@\
                echo "  $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ @@\
                $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \      @@\
        else exit 0; fi                                                 @@\
        $(JMAKE_CMD) -DTopDirPwd=$(TOP_PWD) -DTopDir=$(TOP) -DCurDir=$(CURRENT_DIR) @@\
        $(JRESTOREDEPS)                                                 @@\
        @if cmp -s Makefile Makefile.bak; then $(RM) Makefile.bak ; fi  @@\
        @chmod 444 Makefile                                             @@\
        @echo ==== The new Makefile is for\: ====                       @@\
        @$(MAKE) whoami || \                                            @@\
        ( echo 'Putting old Makefile back (see Makefile.bad)...' && \   @@\
        $(MV) Makefile Makefile.bad &&          \                       @@\
        $(MV) Makefile.bak Makefile )                                   @@\
                                                                        @@\
whoami::                                                                @@\
        @echo $(PROJECTNAME), version $(PROJECTVERSION)                 @@\
        @echo project\: $(PROJECTLABEL)\; setup\: $(SETUPLABEL)         @@\
        @echo now building on a \`$(BUILDPLATFORM)\' host               @@\
        @echo hoping to run on a \`$(HOSTPLATFORM)\' host
#endif /* BuildMakefileTarget */
# line 881 "../../mkworld/macros-GEN.ljm"
#ifndef MakefileTarget
#define MakefileTarget()                                                @@\
BuildMakefileTarget()
#endif /* MakefileTarget */
# line 894 "../../mkworld/macros-GEN.ljm"
#ifndef GenerateOptionsMakeVars
#define GenerateOptionsMakeVars(PGM,THINGS,AllProjectsPgmThings,PlatformPgmThings,ProjectPgmThings,SetupPgmThings) @@\
CAT4(GLUED_,PGM,_,THINGS) = AllProjectsPgmThings PlatformPgmThings ProjectPgmThings SetupPgmThings $(CAT3(PGM,_,THINGS)) $(CAT4(EXTRA_,PGM,_,THINGS))
#endif
# line 912 "../../mkworld/macros-GEN.ljm"
#ifndef NamedTargetSubdirs
#define NamedTargetSubdirs(name,dirs,verb,flags,subname)                @@\
name::                                                                  @@\
        @case '${MFLAGS}' in *[ik]*) set +e;; esac; \                   @@\
        for i in dirs ;\                                                @@\
        do \                                                            @@\
                (cd $$i ; echo verb "in $(CURRENT_DIR)/$$i..."; \       @@\
                        $(MAKE) $(MFLAGS) flags subname); \             @@\
        done
#endif
# line 935 "../../mkworld/macros-GEN.ljm"
#ifndef NamedMakeSubdirs
#define NamedMakeSubdirs(name,dirs) \
NamedTargetSubdirs(name,dirs,"making" name,PassCDebugFlags,all)
#endif /* NamedMakeSubdirs */
# line 947 "../../mkworld/macros-GEN.ljm"
#ifndef DependSubdirs
#define DependSubdirs(dirs) \
NamedTargetSubdirs(depend,dirs,"making dependencies",/**/,depend)
#endif /* DependSubdirs */
# line 962 "../../mkworld/macros-GEN.ljm"
#ifndef ProjectMakeVarsForAllinSubdirs
#define ProjectMakeVarsForAllinSubdirs /*none*/
#endif

#ifndef SetupMakeVarsForAllinSubdirs
#define SetupMakeVarsForAllinSubdirs /*none*/
#endif

#ifndef DoAllinSubdirs
#define DoAllinSubdirs(dirs) \
NamedTargetSubdirs(all,dirs,"making all",ProjectMakeVarsForAllinSubdirs SetupMakeVarsForAllinSubdirs,all)
#endif /* DoAllinSubdirs */
# line 979 "../../mkworld/macros-GEN.ljm"
#ifndef DoDocsinSubdirs
#define DoDocsinSubdirs(dirs) \
NamedTargetSubdirs(docs,dirs,"making docs",/*no make flags*/,docs)
#endif /* DoDocsinSubdirs */
# line 990 "../../mkworld/macros-GEN.ljm"
#ifndef ProjectMakeVarsForRunTestsinSubdirs
#define ProjectMakeVarsForRunTestsinSubdirs /*none*/
#endif

#ifndef SetupMakeVarsForRunTestsinSubdirs
#define SetupMakeVarsForRunTestsinSubdirs /*none*/
#endif

#ifndef RunTestsSubdirs
#define RunTestsSubdirs(dirs) \
NamedTargetSubdirs(runtests,dirs,"running tests",ProjectMakeVarsForRunTestsinSubdirs SetupMakeVarsForRunTestsinSubdirs,runtests)
#endif /* RunTestsSubdirs */
# line 1007 "../../mkworld/macros-GEN.ljm"
#ifndef InstallSubdirs
#define InstallSubdirs(dirs) \
NamedTargetSubdirs(install,dirs,"installing",INSTROOT='$(INSTROOT)',install)
#endif /* InstallSubdirs */
# line 1016 "../../mkworld/macros-GEN.ljm"
#ifndef InstallDocsSubdirs
#define InstallDocsSubdirs(dirs) \
NamedTargetSubdirs(install_docs,dirs,"installing documentation",INSTROOT='$(INSTROOT)',install_docs)
#endif /* InstallDocsSubdirs */
# line 1025 "../../mkworld/macros-GEN.ljm"
#ifndef NamedCleanSubdirs
#define NamedCleanSubdirs(name,dirs) \
NamedTargetSubdirs(name,dirs,"cleaning",RM='$(RM)',clean)
#endif /* NamedCleanSubdirs */

#ifndef CleanSubdirs
#define CleanSubdirs(dirs) \
NamedCleanSubdirs(clean,dirs)
#endif
# line 1039 "../../mkworld/macros-GEN.ljm"
#ifndef NamedVeryCleanSubdirs
#define NamedVeryCleanSubdirs(name,dirs) \
NamedTargetSubdirs(name,dirs,"being veryclean",RM='$(RM)',veryclean)
#endif /* NamedCleanSubdirs */

#ifndef VeryCleanSubdirs
#define VeryCleanSubdirs(dirs) \
NamedVeryCleanSubdirs(veryclean,dirs)
#endif
# line 1053 "../../mkworld/macros-GEN.ljm"
#ifndef NamedTagSubdirs
#define NamedTagSubdirs(name,dirs) \
NamedTargetSubdirs(name,dirs,"making tags",,tags)
#endif /* TagSubdirs */

#ifndef TagSubdirs
#define TagSubdirs(dirs) \
NamedTagSubdirs(tags,dirs)
#endif
# line 1072 "../../mkworld/macros-GEN.ljm"
#ifndef MakeMakeSubdirs
#define MakeMakeSubdirs(dirs,target)                                    @@\
target::                                                                @@\
        @case '${MFLAGS}' in *[ik]*) set +e;; esac; \                   @@\
        for i in dirs ;\                                                @@\
        do \                                                            @@\
                echo "making Makefiles in $(CURRENT_DIR)/$$i..."; \     @@\
                case "$$i" in \                                         @@\
                ./?*/?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \ @@\
                ./?*/?*/?*) newtop=../../../ sub=subsubsub;; \          @@\
                ./?*/?*)    newtop=../../ sub=subsub;; \                @@\
                ./?*)       newtop=../ sub=sub;; \                      @@\
                */?*/?*/?*)    newtop=../../../../ sub=subsubsubsub;; \ @@\
                */?*/?*)    newtop=../../../ sub=subsubsub;; \          @@\
                */?*)       newtop=../../ sub=subsub;; \                @@\
                *)          newtop=../ sub=sub;; \                      @@\
                esac; \                                                 @@\
                case "$(TOP)" in \                                      @@\
                /?*) newtop=  upprefix=  ;; \                           @@\
                *) upprefix=../ ;; \                                    @@\
                esac; \                                                 @@\
                $(MAKE) $${sub}dirMakefiles UPPREFIX=$$upprefix NEWTOP=$$newtop \               @@\
                MAKEFILE_SUBDIR=$$i NEW_CURRENT_DIR=$(CURRENT_DIR)/$$i;\ @@\
        done
#endif /* MakeMakeSubdirs */
# line 1104 "../../mkworld/macros-GEN.ljm"
#ifndef MakeNsubdirMakefiles
#define MakeNsubdirMakefiles()                                          @@\
subdirMakefiles:                                                        @@\
        $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                           @@\
        -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \                 @@\
        echo "  $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \ @@\
        $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
        else exit 0; fi                                                 @@\
        cd $(MAKEFILE_SUBDIR); $(JMAKE_CMD) -DTopDirPwd=$(TOP_PWD) -DTopDir=$(UPPREFIX)$(TOP) -DCurDir=$(NEW_CURRENT_DIR); \ @@\
        $(NEWTOP)$(JRESTOREDEPS); \                                     @@\
        $(MAKE) $(MFLAGS) NEWTOP= Makefile Makefiles                    @@\
                                                                        @@\
subsubdirMakefiles:                                                     @@\
        $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                           @@\
        -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \                 @@\
        echo "  $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \ @@\
        $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
        else exit 0; fi                                                 @@\
        cd $(MAKEFILE_SUBDIR); $(JMAKE_CMD) -DTopDirPwd=$(TOP_PWD) -DTopDir=$(UPPREFIX)$(UPPREFIX)$(TOP) -DCurDir=$(NEW_CURRENT_DIR); \ @@\
        $(NEWTOP)$(JRESTOREDEPS); \                                     @@\
        $(MAKE) $(MFLAGS) NEWTOP= Makefile Makefiles                    @@\
                                                                        @@\
subsubsubdirMakefiles:                                                  @@\
        $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                           @@\
        -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \                 @@\
        echo "  $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \ @@\
        $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
        else exit 0; fi @@\
        cd $(MAKEFILE_SUBDIR); $(JMAKE_CMD) -DTopDirPwd=$(TOP_PWD) -DTopDir=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCurDir=$(NEW_CURRENT_DIR); \ @@\
        $(NEWTOP)$(JRESTOREDEPS); \                                     @@\
        $(MAKE) $(MFLAGS) NEWTOP= Makefile Makefiles                    @@\
                                                                        @@\
subsubsubsubdirMakefiles:                                               @@\
        $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak                           @@\
        -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \                 @@\
        echo "  $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \ @@\
        $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \ @@\
        else exit 0; fi                                                 @@\
        cd $(MAKEFILE_SUBDIR); $(JMAKE_CMD) -DTopDirPwd=$(TOP_PWD) -DTopDir=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCurDir=$(NEW_CURRENT_DIR); \ @@\
        $(NEWTOP)$(JRESTOREDEPS); \                                     @@\
        $(MAKE) $(MFLAGS) NEWTOP= Makefile Makefiles
#endif /* MakeNsubdirMakefiles */
# line 1153 "../../mkworld/macros-GEN.ljm"
#ifndef MakefileSubdirs
#define MakefileSubdirs(dirs)                                           @@\
MakeMakeSubdirs(dirs,Makefiles)                                         @@\
                                                                        @@\
MakeNsubdirMakefiles()
#endif /* MakefileSubdirs */
# line 1162 "../../mkworld/macros-GEN.ljm"
#ifndef MakeDirectories
#define MakeDirectories(step,dirs)                                      @@\
step::                                                                  @@\
        $(MKDIRHIER) dirs
#endif
# line 1170 "../../mkworld/macros-GEN.ljm"
#ifndef LinkDirectories
#define LinkDirectories(step,dirs,todir)                                @@\
step::                                                                  @@\
        @case '${MFLAGS}' in *[ik]*) set +e;; esac; \                   @@\
        for i in dirs ; \                                               @@\
        do \                                                            @@\
                echo "linking $$i to" todir; \                          @@\
                $(LNDIR) todir $$i; \                                   @@\
        done
#endif