File: rules.def

package info (click to toggle)
ivtools 0.6.2-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 10,236 kB
  • ctags: 31,595
  • sloc: ansic: 137,968; makefile: 20,655; cpp: 14,588; sh: 169
file content (934 lines) | stat: -rw-r--r-- 25,018 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
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
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
/* This is for the most part a copy of rules.def as distributed with InterViews 3.1
 * except for the rules that deal with ivmkcm make options (and references to them in
 * MakeInSubdirs and MakeInObjectCodeDir):
 * 	CmchkinSubdirs
 * 	CmtagSubdirs
 * 	CmaddSubdirs
 * 	CmupdateSubdirs
 *      CmcommitSubdirs 
 * 	CmchkinTarget
 * 	CmtagTarget
 *      CmaddTarget
 *      CmupdateTarget
 *      CmcommitTarget
 *      CheckRepository.
 */

/*
 * Print the name you should assign to CPU.
 */
#ifndef MakeCPU
#define MakeCPU()							@@\
CPU:									@@\
	@$(SHELL) $(SCRIPTSRC)/cpu.sh $(CONFIGSRC)/arch.def
#endif

/*
 * Make everything in the normal object code subdirectories.
 */
#ifndef MakeNormalWorld
#define MakeNormalWorld(flags)						@@\
World::									@@\
	@echo ""							@@\
	@echo "Building $(RELEASE) on `date`"				@@\
	@echo ""							@@\
	$(MAKE) Makefile CONFIGSRC=$(CONFIGSRC) XCONFIGDIR=$(XCONFIGDIR)@@\
	@echo ""							@@\
	$(MAKE) Makefiles						@@\
	@echo ""							@@\
	$(MAKE) depend							@@\
	@echo ""							@@\
	$(MAKE) flags all						@@\
	@echo ""							@@\
	@echo "$(RELEASE) build completed on `date`"			@@\
	@echo ""
#endif

/*
 * Make everything in special object code subdirectories.
 */
#ifndef MakeSpecialWorld
#define MakeSpecialWorld(special,flags)					@@\
Concat(World,special)::							@@\
	@echo ""							@@\
	@echo "Building $(RELEASE) on `date`"				@@\
	@echo ""							@@\
	$(MAKE) Makefile XCONFIGDIR=$(XCONFIGDIR)			@@\
	@echo ""							@@\
	$(MAKE) Concat(Makefiles,special)				@@\
	@echo ""							@@\
	$(MAKE) Concat(depend,special)					@@\
	@echo ""							@@\
	$(MAKE) flags Concat(all,special)				@@\
	@echo ""							@@\
	@echo "$(RELEASE) build completed on `date`"			@@\
	@echo ""
#endif

#ifndef MakeWorld
#if HasDynamicSharedLibraries
#define MakeWorld(flags)						@@\
MakeNormalWorld(flags)							@@\
MakeSpecialWorld(.debug,flags)						@@\
MakeSpecialWorld(.noshared,flags)
#else
#define MakeWorld(flags)						@@\
MakeNormalWorld(flags)							@@\
MakeSpecialWorld(.debug,flags)
#endif
#endif

/*
 * Make the Makefile in the current directory.
 */
#ifdef LinuxArchitecture
#define PWD_VAL shell pwd
#else
#define PWD_VAL PWD
#endif

#ifndef MakefileTarget
#define MakefileTarget()						@@\
Makefile::								@@\
	-@if [ -f Makefile ]; then \					@@\
		$(RM) Makefile.bak; \					@@\
		$(MV) Makefile Makefile.bak; \				@@\
	else exit 0; fi							@@\
	-@echo "Making Makefile"					@@\
	-@if [ $(TOP) = $(CURRENT_DIR) ]; then \                        @@\
	echo >.toplevel-make-makefile; else \				@@\
	echo >.not-toplevel-make-makefile; fi				@@\
	-@if [ -f .toplevel-make-makefile ]; then \                     @@\
	$(IMAKE) $(IMAKEFLAGS) -I$(PWD_VAL)/config \			@@\
	-DTOPDIR=$(PWD_VAL) -DRELTOPDIR=$(RELTOP) -DCURDIR=$(PWD_VAL);fi@@\
	-@if [ -f .not-toplevel-make-makefile ]; then \			@@\
	$(IMAKE) $(IMAKEFLAGS) -DTOPDIR=$(TOP) \                        @@\
		-DRELTOPDIR=$(RELTOP) -DCURDIR=$(PWD_VAL); fi		@@\
	-@if [ $(TOP) = $(CURRENT_DIR) ]; then \                        @@\
	$(RM) .toplevel-make-makefile; else \				@@\
	$(RM) .not-toplevel-make-makefile; fi				
#endif

/*
 * Make the Makefiles in the list of subdirectories.
 */
#ifndef MakefilesSubdirs
#define MakefilesSubdirs(dirs)						@@\
Makefiles::								@@\
	-@for i in dirs; \						@@\
	do \								@@\
		if [ -d $$i ]; then ( \					@@\
			echo "Making Makefiles" \			@@\
			"for $(ARCH) in $(CURRENT_DIR)/$$i"; \		@@\
			if [ -f $$i/Makefile ]; then \			@@\
				$(RM) $$i/Makefile.bak; \		@@\
				$(MV) $$i/Makefile $$i/Makefile.bak; \	@@\
			fi; \						@@\
			$(IMAKE) $(IMAKEFLAGS) \			@@\
			-DTOPDIR=$(TOP) -DRELTOPDIR=../$(RELTOP) \      @@\
			-DCURDIR=$(CURRENT_DIR)/$$i \                   @@\
			-f $$i/Imakefile -s $$i/Makefile; \		@@\
			cd $$i; \					@@\
			$(MAKE) $(PASSARCH) Makefiles; \		@@\
		) else continue; fi; \					@@\
	done
#endif

/*
 * Make the Makefile in the appropriate object code subdirectory.
 */
#ifndef MakefileObjectCodeDir
#define MakefileObjectCodeDir(dir)					@@\
Makefiles::								@@\
	@echo "Making Makefiles" \					@@\
	"for $(ARCH) in $(CURRENT_DIR)/dir"				@@\
	-@if [ ! -d dir ]; then \					@@\
		mkdir dir; \						@@\
		chmod g+w dir; \					@@\
	fi; \								@@\
	if [ -f dir/Makefile ]; then \					@@\
		$(RM) dir/Makefile.bak; \				@@\
		$(MV) dir/Makefile dir/Makefile.bak; \			@@\
	fi; \								@@\
	if [ ! -f dir/Makefile ]; then \				@@\
		touch dir/Makefile.depend; \				@@\
	fi; \								@@\
	$(IMAKE) $(IMAKEFLAGS) \					@@\
	-DTOPDIR=$(TOP) -DRELTOPDIR=../$(RELTOP) \                      @@\
	-DCURDIR=$(CURRENT_DIR)/dir \		  			@@\
	-DInObjectCodeDir -s dir/Makefile
#endif

/*
 * Make the given target in the list of subdirectories.
 */
#ifndef IntoSubdirs
#define IntoSubdirs(name,dirs,verb)					@@\
name::									@@\
	-@for i in dirs; \						@@\
	do \								@@\
		if [ -d $$i ]; then ( \					@@\
			echo verb \					@@\
			"for $(ARCH) in $(CURRENT_DIR)/$$i"; \		@@\
			cd $$i; \					@@\
			$(MAKE) $(PASSARCH) name; \			@@\
		) else continue; fi; \					@@\
	done
#endif

#ifndef DependSubdirs
#define DependSubdirs(dirs)						@@\
IntoSubdirs(depend,dirs,"depending")
#endif

#ifndef MakeSubdirs
#define MakeSubdirs(dirs)						@@\
IntoSubdirs(all,dirs,"making all")
#endif

#ifndef InstallSubdirs
#define InstallSubdirs(dirs)						@@\
IntoSubdirs(install,dirs,"installing")
#endif

#ifndef CleanSubdirs
#define CleanSubdirs(dirs)						@@\
IntoSubdirs(clean,dirs,"cleaning")
#endif

#ifndef FormatSubdirs
#define FormatSubdirs(dirs)						@@\
IntoSubdirs(format,dirs,"formatting")
#endif

#ifndef PrintSubdirs
#define PrintSubdirs(dirs)						@@\
IntoSubdirs(print,dirs,"printing")
#endif

#ifndef CmchkinSubdirs
#define CmchkinSubdirs(dirs)						@@\
IntoSubdirs(cmchkin,dirs,"checking into the repository")
#endif

#ifndef CmtagSubdirs
#define CmtagSubdirs(dirs)						@@\
IntoSubdirs(cmtag,dirs,"tagging the repository")
#endif

#ifndef CmaddSubdirs
#define CmaddSubdirs(dirs)						@@\
IntoSubdirs(cmadd,dirs,"adding to the repository")
#endif

#ifndef CmupdateSubdirs
#define CmupdateSubdirs(dirs)						@@\
IntoSubdirs(cmupdate,dirs,"updating from repository")
#endif

#ifndef CmcommitSubdirs
#define CmcommitSubdirs(dirs)						@@\
IntoSubdirs(cmcommit,dirs,"committing to repository")
#endif

/*
 * Make the above targets in specialized versions of the appropriate
 * object code subdirectories.
 */
#ifndef SpecialTargets
#define SpecialTargets(special,imakeflags)				@@\
Makefiles.special:							@@\
	@$(MAKE) ARCH="$(ARCH).special" \				@@\
	SPECIAL_IMAKEFLAGS="$(SPECIAL_IMAKEFLAGS) imakeflags" \		@@\
	Makefiles							@@\
depend.special:								@@\
	@$(MAKE) ARCH="$(ARCH).special" \				@@\
	SPECIAL_IMAKEFLAGS="$(SPECIAL_IMAKEFLAGS) imakeflags" \		@@\
	depend								@@\
all.special:								@@\
	@$(MAKE) ARCH="$(ARCH).special" \				@@\
	SPECIAL_IMAKEFLAGS="$(SPECIAL_IMAKEFLAGS) imakeflags" \		@@\
	all								@@\
install.special:							@@\
	@$(MAKE) ARCH="$(ARCH).special" \				@@\
	SPECIAL_IMAKEFLAGS="$(SPECIAL_IMAKEFLAGS) imakeflags" \		@@\
	install								@@\
clean.special:								@@\
	@$(MAKE) ARCH="$(ARCH).special" \				@@\
	SPECIAL_IMAKEFLAGS="$(SPECIAL_IMAKEFLAGS) imakeflags" \		@@\
	clean
#endif

/*
 * Shorthand for making all targets in a list of subdirectories.
 */
#ifndef MakeInSubdirs
#if HasDynamicSharedLibraries
#define MakeInSubdirs(dirs)						@@\
MakefilesSubdirs(dirs)							@@\
DependSubdirs(dirs)							@@\
MakeSubdirs(dirs)							@@\
InstallSubdirs(dirs)							@@\
CleanSubdirs(dirs)							@@\
SpecialTargets(debug,-DUseDebug)					@@\
SpecialTargets(noshared,-DUseNonShared)					@@\
CmscriptsTargets($(PACKAGE))						@@\
CmscriptsSubdirs(dirs)
#else
#define MakeInSubdirs(dirs)						@@\
MakefilesSubdirs(dirs)							@@\
DependSubdirs(dirs)							@@\
MakeSubdirs(dirs)							@@\
InstallSubdirs(dirs)							@@\
CleanSubdirs(dirs)							@@\
SpecialTargets(debug,-DUseDebug)					@@\
CmscriptsTargets($(PACKAGE))						@@\
CmscriptsSubdirs(dirs)
#endif
#endif

/*
 * Shorthand for making all targets in the appropriate object code
 * subdirectory.
 */
#ifndef MakeInObjectCodeDir
#if HasDynamicSharedLibraries
#define MakeInObjectCodeDir()						@@\
MakefileObjectCodeDir($(ARCH))						@@\
DependSubdirs($(ARCH))							@@\
MakeSubdirs($(ARCH))							@@\
InstallSubdirs($(ARCH))							@@\
CleanSubdirs($(ARCH))							@@\
SpecialTargets(debug,-DUseDebug)					@@\
SpecialTargets(noshared,-DUseNonShared)					@@\
CmscriptsTargets($(PACKAGE))
#else
#define MakeInObjectCodeDir()						@@\
MakefileObjectCodeDir($(ARCH))						@@\
DependSubdirs($(ARCH))							@@\
MakeSubdirs($(ARCH))							@@\
InstallSubdirs($(ARCH))							@@\
CleanSubdirs($(ARCH))							@@\
SpecialTargets(debug,-DUseDebug)					@@\
CmscriptsTargets($(PACKAGE))
#endif
#endif

/*
 * All the cmscripts targets for any directory
 */
#define CmscriptsTargets(package)					@@\
CmchkinTarget(package)							@@\
CmtagTarget()								@@\
CmaddTarget()								@@\
CmupdateTarget()							@@\
CmcommitTarget()							

/*
 * All the cmscripts targets for sub-directories
 */
#define CmscriptsSubdirs(dirs)						@@\
CmchkinSubdirs(dirs)							@@\
CmtagSubdirs(dirs)							@@\
CmaddSubdirs(dirs)							@@\
CmupdateSubdirs(dirs)							@@\
CmcommitSubdirs(dirs)							

/*
 * Make the given dependencies during make all.
 */
#ifndef AllTarget
#define AllTarget(deps)							@@\
all:: deps
#endif

/*
 * Add automatically generated dependencies to the Makefile.
 */
#ifndef DependTarget
#define DependTarget()							 @@\
depend::								 @@\
	gcc -M $(DEPEND_CCFLAGS) $(SRCS) >Makefile.depend
#endif

/*
 * include Makefile.depend
 */
#ifndef IncludeDependencies
#define IncludeDependencies()						 @@\
Makefile.depend:							 @@\
	touch Makefile.depend						 @@\
									 @@\
include Makefile.depend
#endif

/*
 * Remove garbage files.  The #* cannot go in the definition of RM_CMD
 * because System V will treat the pound sign as a comment.
 */
#ifndef CleanTarget
#define CleanTarget()							@@\
clean::									@@\
	@$(RM_CMD) "#"*
#endif

/*
 * Checkin this directory to the repository.
 */
#ifndef CmchkinTarget
#define CmchkinTarget(package)							@@\
cmchkin:: 									@@\
	-@if [ ! -d $(TOP)/cm ]; then \						@@\
	(cd $(TOP); cminstall); fi						@@\
	@csh -c '(setenv REPOSITORY_FILES "$(REPOSITORY_FILES)"; cmchkin package $(TOP)/cm $(TOP) $(CURRENT_DIR))';
#endif

/*
 * Tag this directoryCheckin this directory to the repository.
 */
#ifndef CmtagTarget
#define CmtagTarget()								@@\
cmtag:: 									@@\
	cmtag $(CMFLAGS) $(CMARGS)
#endif

/*
 * Check to see the repository for this directory exists
 */
#ifndef CheckRepository
#define CheckRepository()\
-@if [ ! -d $(TOP)/cm ]; then \						@@\
	(echo "Build repository first with cmchkin"; exit 0;); fi		@@\
	-@if [ ! -d $(CURRENT_DIR)/CVS ]; then \		@@\
	(echo "Build repository first with cmchkin"; exit 0;); fi
#endif

/*
 * Add new files in this directory to the repository.
 */
#ifndef CmaddTarget
#define CmaddTarget()								@@\
cmadd:: 									@@\
	CheckRepository()							@@\
	@csh -c '(setenv REPOSITORY_FILES "$(REPOSITORY_FILES)";cmadd -m null_message)'
#endif

/*
 * Update this directory from the repository.
 */
#ifndef CmupdateTarget
#define CmupdateTarget()							@@\
cmupdate:: 									@@\
	CheckRepository()							@@\
	cmupdate
#endif

/*
 * Commit this directory to the repository.
 */
#ifndef CmcommitTarget
#define CmcommitTarget()							@@\
cmcommit:: 									@@\
	CheckRepository()							@@\
	-@if [ -z "$(CMMSG)" ]; then cmcommit $(CMFLAGS); \			@@\
	else cmcommit $(CMFLAGS) -m "$(CMMSG)"; fi 	                                              	
#endif

/*
 * Set up $(CCDEPLIBS) and $(CCLDLIBS) for a program using libIV.
 */
#ifndef Use_libInterViews
#define Use_libInterViews() 						@@\
         DEPLIBIV = Dep_libIV						@@\
        DEPLIBX11 = Dep_libX11						@@\
          DEPLIBM = Dep_libm						@@\
									@@\
       LIBDIRPATH = LibDirPath						@@\
          LDLIBIV = Ld_libIV						@@\
      XLIBDIRPATH = XLibDirPath						@@\
         LDLIBX11 = Ld_libX11						@@\
           LDLIBM = Ld_libm						@@\
    ABSLIBDIRPATH = AbsLibDirPath
#endif

/*
 * Set up $(CCDEPLIBS) and $(CCLDLIBS) for a program using libUnidraw.
 */
#ifndef Use_libUnidraw
#define Use_libUnidraw() 						@@\
    DEPLIBUNIDRAW = Dep_libUnidraw					@@\
         DEPLIBIV = Dep_libIV						@@\
        DEPLIBX11 = Dep_libX11						@@\
          DEPLIBM = Dep_libm						@@\
									@@\
       LIBDIRPATH = LibDirPath						@@\
     LDLIBUNIDRAW = Ld_libUnidraw					@@\
          LDLIBIV = Ld_libIV						@@\
      XLIBDIRPATH = XLibDirPath						@@\
         LDLIBX11 = Ld_libX11						@@\
           LDLIBM = Ld_libm						@@\
    ABSLIBDIRPATH = AbsLibDirPath
#endif

/*
 * Set up $(CCDEPLIBS) and $(CCLDLIBS) for a program using libgraphic.
 */
#ifndef Use_libgraphic
#define Use_libgraphic() 						@@\
    DEPLIBGRAPHIC = Dep_libgraphic					@@\
         DEPLIBIV = Dep_libIV						@@\
        DEPLIBX11 = Dep_libX11						@@\
          DEPLIBM = Dep_libm						@@\
									@@\
       LIBDIRPATH = LibDirPath						@@\
     LDLIBGRAPHIC = Ld_libgraphic					@@\
          LDLIBIV = Ld_libIV						@@\
      XLIBDIRPATH = XLibDirPath						@@\
         LDLIBX11 = Ld_libX11						@@\
           LDLIBM = Ld_libm						@@\
    ABSLIBDIRPATH = AbsLibDirPath
#endif

/*
 * Set up all make variables for a program using 2.6 compatibility.
 */
#ifndef Use_2_6
#define Use_2_6()							@@\
 BACKWARD_CCDEFINES = BackwardCompatibilityCCDefines			@@\
BACKWARD_CCINCLUDES = BackwardCompatibilityCCIncludes
#endif

/*
 * Make an object file.  $(AOUT) is either a.out or a library and the
 * dependency allows Imakefiles to avoid having to define OBJS.
 */
#ifndef MakeObjectRule
#define MakeObjectRule(dst,src,flags)					@@\
$(AOUT): dst.o								@@\
dst.o: src.$(CCSUFFIX)							@@\
	@$(RM) dst.o dst..c						@@\
	$(CCDRIVER) flags $(CCFLAGS) -c src.$(CCSUFFIX)
#endif

#ifndef MakeObjectRule2
#define MakeObjectRule2(dst,src,flags1,flags2)				@@\
$(AOUT): dst.o								@@\
dst.o: src.$(CCSUFFIX)							@@\
	@$(RM) dst.o dst..c						@@\
	$(CCDRIVER) flags1 $(CCFLAGS) flags2 -c src.$(CCSUFFIX)
#endif

/*
 * Shorthands for making an object file.
 */
#ifndef MakeObjectFromSrcFlags
#define MakeObjectFromSrcFlags(file,flags)				@@\
MakeObjectRule(file,$(SRC)/file,flags)
#endif

#ifndef MakeObjectFromSrcFlags2
#define MakeObjectFromSrcFlags2(file,flags1,flags2)			@@\
MakeObjectRule2(file,$(SRC)/file,flags1,flags2)
#endif

#ifndef MakeObjectFromSrc
#define MakeObjectFromSrc(file)						@@\
MakeObjectFromSrcFlags(file,NullParameter)
#endif

#ifndef MakeObjectFromSrc2_6
#define MakeObjectFromSrc2_6(file)					@@\
MakeObjectFromSrcFlags(file,\
BackwardCompatibilityCCDefines BackwardCompatibilityCCIncludes)
#endif

/*
 * Convert an archive to a random library.
 */
#ifndef RanLibrary
#if HasRanlibCmd
#define RanLibrary(args) $(RANLIB) args
#else
#define RanLibrary(args) ar s args
#endif
#endif

/* 
 * Shared library command
 */
#ifndef SharedLibraryCmd
#if defined(SunArchitecture)
#if OSMajorVersion < 5
#define SharedLibraryCmd(ldobjs, extra_args)\
$(LD) -o $@~ -assert pure-text ldobjs
#else
#define SharedLibraryCmd(ldobjs, extra_args)\
$(LD) -o $@~ -G ldobjs
#endif
#else
#define SharedLibraryCmd(ldobjs, extra_args)\
$(LD) -o $@ $(SHARED_CCLDFLAGS) ldobjs $(SHARED_CCLDLIBS)
#endif
#endif

/*
 * Make a shared library.
 */
#ifndef NormalDynamicSharedLibraryTarget
#if defined(HPArchitecture)
#define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
AOUT = Concat(lib,libname.so.rev)					@@\
SHARED_CCFLAGS = SharedCCFlags						@@\
									@@\
AllTarget(Concat(lib,libname.sl.rev))					@@\
									@@\
Concat(lib,libname.sl.rev): depobjs					@@\
	@echo "building $@"						@@\
	$(RM) $@							@@\
	SharedLibraryCmd(ldobjs,)					@@\
	chmod 555 $@							@@\
	$(LN) Concat(lib,libname.sl.rev) Concat(lib,libname.sl)		@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.sl.rev)
#else

#if defined(SunArchitecture)
#if OSMajorVersion < 5
#define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
AOUT = Concat(lib,libname.so.rev)					@@\
SHARED_CCFLAGS = SharedCCFlags						@@\
									@@\
AllTarget(Concat(lib,libname.so.rev))					@@\
									@@\
Concat(lib,libname.so.rev): depobjs					@@\
	@echo "building $@"						@@\
	$(RM) $@~							@@\
	SharedLibraryCmd(ldobjs,-Wl\,-soname=Concat(lib\,libname.so.rev))@@\
	$(RM) $@							@@\
	$(MV) $@~ $@							@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.so.rev)
#else
#define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
AOUT = Concat(lib,libname.so.rev)					@@\
SHARED_CCFLAGS = SharedCCFlags						@@\
									@@\
AllTarget(Concat(lib,libname.so.rev))					@@\
									@@\
Concat(lib,libname.so.rev): depobjs					@@\
	@echo "building $@"						@@\
	$(RM) $@~							@@\
	$(RM) Concat(lib,libname.so)					@@\
	SharedLibraryCmd(ldobjs,-Wl\,-soname=Concat(lib\,libname.so.rev))@@\
	$(RM) $@							@@\
	$(MV) $@~ $@							@@\
 	$(LN) $@ Concat(lib,libname.so)					@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.so.rev)
#endif /* defined(SunArchitecture) */

#else
#define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
AOUT = Concat(lib,libname.so.rev)					@@\
SHARED_CCFLAGS = SharedCCFlags						@@\
									@@\
AllTarget(Concat(lib,libname.so.rev))					@@\
									@@\
Concat(lib,libname.so.rev): depobjs					@@\
	@echo "building $@"						@@\
	$(RM) $@							@@\
	SharedLibraryCmd(ldobjs,)					@@\
	$(RM) Concat(lib,libname.so)					@@\
	$(LN) $@ Concat(lib,libname.so)					@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.so.rev)
#endif
#endif
#endif

/*
 * Make a non-shared library archive.
 */
#ifndef NormalNonSharedLibraryTarget
#define NormalNonSharedLibraryTarget(libname,depobjs,ldobjs)		@@\
AOUT = Concat(lib,libname.a)						@@\
									@@\
AllTarget(Concat(lib,libname.a))					@@\
									@@\
Concat(lib,libname.a): depobjs						@@\
	@echo "building $@"						@@\
	$(RM) $@							@@\
	$(AR) $@ ldobjs							@@\
	RanLibrary($@)
#endif

/*
 * Make either a shared library or a non-shared library.
 */
#ifndef NormalLibraryTarget
#if HasDynamicSharedLibraries
#define NormalLibraryTarget(libname,rev,depobjs,ldobjs)			@@\
NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)
#else
#define NormalLibraryTarget(libname,rev,depobjs,ldobjs)			@@\
NormalNonSharedLibraryTarget(libname,depobjs,ldobjs)
#endif
#endif

/*
 * Shorthand for building and installing a library.
 */
#ifndef MakeLibrary
#define MakeLibrary(name,rev)						@@\
NormalLibraryTarget(name,rev,NullParameter,$(OBJS))			@@\
InstallLibrary(name,rev,$(LIBDIR))					@@\
DependTarget()
#endif

/*
 * Removing an executable before relinking it wastes time if the user's using
 * an incremental linker smart enough to write only the modified sections.
 */
#ifndef RemoveIfUnwritable
#define RemoveIfUnwritable(program) \
-@if [ ! -w program ]; then $(RM) program; else exit 0; fi
#endif

/*
 * Build a program.
 */
#ifndef BuildProgram
#define BuildProgram(program,depobjs,ldobjs,deplibs,ldlibs)		@@\
program: depobjs deplibs						@@\
	RemoveIfUnwritable($@)						@@\
	$(CCDRIVER) $(CCLDFLAGS) -o $@ ldobjs ldlibs
#endif

/*
 * Shorthand for building and installing a complex program.
 */
#ifndef ComplexProgramTarget
#define ComplexProgramTarget(program)					@@\
PROGRAM	= program							@@\
									@@\
AllTarget($(AOUT))							@@\
BuildProgram($(AOUT),NullParameter,$(OBJS),$(CCDEPLIBS),$(CCLDLIBS))	@@\
InstallProgram($(AOUT),$(BINDIR),$(PROGRAM))				@@\
DependTarget()
#endif

/*
 * Shorthand for building and not installing a complex program.
 */
#ifndef ComplexProgramTargetNoInstall
#define ComplexProgramTargetNoInstall(program)				@@\
PROGRAM	= program							@@\
									@@\
AllTarget($(AOUT))							@@\
BuildProgram($(AOUT),NullParameter,$(OBJS),$(CCDEPLIBS),$(CCLDLIBS))	@@\
DependTarget()
#endif

/*
 * Shorthand for building and installing a simple program.
 */
#ifndef SimpleProgramTarget
#define SimpleProgramTarget(program)					@@\
SRCS	= $(SRC)/program.$(CCSUFFIX)					@@\
OBJS	= program.o							@@\
									@@\
ComplexProgramTarget(program)						@@\
MakeObjectFromSrc(program)
#endif

/*
 * Format or print troff sources.
 */
#ifndef TroffSources
#define TroffSources(formatted)						@@\
print:									@@\
	$(TROFF) $(TROFFFLAGS) $(TROFFSRCS)				@@\
									@@\
format: formatted							@@\
									@@\
formatted: $(TROFFSRCS)							@@\
	$(RM) formatted							@@\
	$(TROFF) -t $(TROFFFLAGS) $(TROFFSRCS) > formatted		@@\
									@@\
clean::									@@\
	$(RM) formatted
#endif

/*
 * Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
 * to cpp, because that trick does not work on all ANSI C preprocessors.
 * Also delete line numbers from the cpp output (-P is not portable, I guess).
 */
#ifndef CppSedMagic
#define CppSedMagic sed -e '/^#  *[0-9][0-9]*  *.*$$/d' \
		     -e '/^XCOMM$$/s//#/' \
		     -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/'
#endif /* CppSedMagic */

/*
 * Generate a script using cpp.
 */
#ifndef CppScriptTarget
#if ExecableScripts		/* can use #! instead of colon */
#define CppScriptTarget(dst,src,defs,deplist)				@@\
dst::  src deplist							@@\
	$(RM) $@							@@\
	$(CPP) defs <src | CppSedMagic >$@				@@\
	chmod a+x $@
#else
#define CppScriptTarget(dst,src,defs,deplist)				@@\
dst::  src deplist							@@\
	$(RM) $@							@@\
	echo \: >$@							@@\
	sed '1d' src | $(CPP) defs | CppSedMagic >>$@			@@\
	chmod a+x $@
#endif
#endif

/*
 * Create directories if necessary at a step in the build (now
 * superseded by MakeDir in each of the individual install rules).
 */
#ifndef MakeDirectories
#define MakeDirectories(step,dirs)					@@\
step::									@@\
	$(MKDIRHIER) dirs
#endif

/*
 * Create a directory if necessary.
 */
#ifndef MakeDir
#define MakeDir(dir) -@if [ -d dir ]; then exit 0; \			@@\
		else (set -x; $(MKDIRHIER) dir); fi
#endif

/*
 * Install a library.
 */
#ifndef InstallDynamicSharedLibrary
#define InstallDynamicSharedLibrary(libname,rev,dest)			@@\
install:: Concat(lib,libname.so.rev)					@@\
	MakeDir(dest)							@@\
	$(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.so.rev) dest
#endif

#ifndef InstallNonSharedLibrary
#define InstallNonSharedLibrary(libname,dest)				@@\
install:: Concat(lib,libname.a)						@@\
	MakeDir(dest)							@@\
	$(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.a) dest	@@\
	RanLibrary($(RANLIBINSTFLAGS) Concat(dest/lib,libname.a))
#endif

#ifndef InstallLibrary
#if HasDynamicSharedLibraries
#define InstallLibrary(libname,rev,dest)				@@\
InstallDynamicSharedLibrary(libname,rev,dest)
#else
#define InstallLibrary(libname,rev,dest)				@@\
InstallNonSharedLibrary(libname,dest)
#endif
#endif

/*
 * Install a program with renaming of the installed program.
 */
#ifndef InstallProgramWithFlags
#if RemoveAfterInstall
#define InstallProgramWithFlags(program,destdir,destname,flags)		@@\
install:: program							@@\
	MakeDir(destdir)						@@\
	$(INSTALL) -c $(INSTPGMFLAGS) flags program destdir/destname	@@\
	$(RM) program
#else
#define InstallProgramWithFlags(program,destdir,destname,flags)		@@\
install:: program							@@\
	MakeDir(destdir)						@@\
	$(INSTALL) -c $(INSTPGMFLAGS) flags program destdir/destname
#endif
#endif

#ifndef InstallProgram
#define InstallProgram(program,destdir,destname)			@@\
InstallProgramWithFlags(program,destdir,destname,$(INSTBINFLAGS))
#endif

/*
 * Install a script (which cannot be stripped like a program).
 */
#ifndef InstallScript
#define InstallScript(script,dest)					@@\
install:: script							@@\
	MakeDir(dest)							@@\
	$(INSTALL) -c $(INSTBINFLAGS) script dest
#endif

/*
 * Install and rename a script (which cannot be stripped like a program).
 */
#ifndef InstallScriptAs
#define InstallScriptAs(script,dest,destname)				@@\
install:: script							@@\
	MakeDir(dest)							@@\
	$(INSTALL) -c $(INSTBINFLAGS) script dest/destname
#endif

/*
 * Install multiple files.
 */
#ifndef InstallMultipleFlags
#define InstallMultipleFlags(list,dest,flags)				@@\
install:: list								@@\
	MakeDir(dest)							@@\
	@for i in list; do \						@@\
		(set -x; $(INSTALL) -c flags $$i dest); \		@@\
	done
#endif

#ifndef InstallMultiple
#define InstallMultiple(list,dest)					@@\
InstallMultipleFlags(list,dest,$(INSTALLFLAGS))
#endif

/*
 * Install symbolic link to a library
 */
#ifndef InstallLibLink
#define InstallLibLink(libdir,libbase,dest)				@@\
install::  								@@\
	@if [ -f libdir/libbase ]; then \				@@\
	if [ ! -f dest/libbase ]; then \				@@\
		 $(LN) libdir/libbase dest/; \				@@\
		 echo $(LN) libdir/libbase dest/ \			@@\
	;fi ;fi
#endif

/*
 * Install header files on Linux.
 */


#ifndef InstallIncludes
#if InstallRelative
#define InstallIncludes(dir)						@@\
install::								@@\
	-@if [ -L $(TOP)/include ]; then exit 0; else \                 @@\
        (cd $(TOP) && $(LN) src/include include); fi
#else
#define InstallIncludes(dir)						@@\
install::								@@\
	MakeDir($(INCDIR)/dir)						@@\
	$(INSTALL) $(INSTINCFLAGS) *.h $(INCDIR)/dir		    
#endif
#endif