Clarification.
[openssl.git] / crypto / perlasm / x86asm.pl
1 #!/usr/local/bin/perl
2
3 # require 'x86asm.pl';
4 # &asm_init("cpp","des-586.pl");
5 # XXX
6 # XXX
7 # main'asm_finish
8
9 sub main'asm_finish
10         {
11         &file_end();
12         &asm_finish_cpp() if $cpp;
13         print &asm_get_output();
14         }
15
16 sub main'asm_init
17         {
18         ($type,$fn,$i386)=@_;
19         $filename=$fn;
20
21         $cpp=$sol=$aout=$win32=0;
22         if (    ($type eq "elf"))
23                 { require "x86unix.pl"; }
24         elsif ( ($type eq "a.out"))
25                 { $aout=1; require "x86unix.pl"; }
26         elsif ( ($type eq "sol"))
27                 { $sol=1; require "x86unix.pl"; }
28         elsif ( ($type eq "cpp"))
29                 { $cpp=1; require "x86unix.pl"; }
30         elsif ( ($type eq "win32"))
31                 { $win32=1; require "x86ms.pl"; }
32         elsif ( ($type eq "win32n"))
33                 { $win32=1; require "x86nasm.pl"; }
34         else
35                 {
36                 print STDERR <<"EOF";
37 Pick one target type from
38         elf     - linux, FreeBSD etc
39         a.out   - old linux
40         sol     - x86 solaris
41         cpp     - format so x86unix.cpp can be used
42         win32   - Windows 95/Windows NT
43         win32n  - Windows 95/Windows NT NASM format
44 EOF
45                 exit(1);
46                 }
47
48         &asm_init_output();
49
50 &comment("Don't even think of reading this code");
51 &comment("It was automatically generated by $filename");
52 &comment("Which is a perl program used to generate the x86 assember for");
53 &comment("any of elf, a.out, BSDI,Win32, or Solaris");
54 &comment("eric <eay\@cryptsoft.com>");
55 &comment("");
56
57         $filename =~ s/\.pl$//;
58         &file($filename);
59         }
60
61 sub asm_finish_cpp
62         {
63         return unless $cpp;
64
65         local($tmp,$i);
66         foreach $i (&get_labels())
67                 {
68                 $tmp.="#define $i _$i\n";
69                 }
70         print <<"EOF";
71 /* Run the C pre-processor over this file with one of the following defined
72  * ELF - elf object files,
73  * OUT - a.out object files,
74  * BSDI - BSDI style a.out object files
75  * SOL - Solaris style elf
76  */
77
78 #define TYPE(a,b)       .type   a,b
79 #define SIZE(a,b)       .size   a,b
80
81 #if defined(OUT) || (defined(BSDI) && !defined(ELF))
82 $tmp
83 #endif
84
85 #ifdef OUT
86 #define OK      1
87 #define ALIGN   4
88 #endif
89
90 #if defined(BSDI) && !defined(ELF)
91 #define OK              1
92 #define ALIGN           4
93 #undef SIZE
94 #undef TYPE
95 #define SIZE(a,b)
96 #define TYPE(a,b)
97 #endif
98
99 #if defined(ELF) || defined(SOL)
100 #define OK              1
101 #define ALIGN           16
102 #endif
103
104 #ifndef OK
105 You need to define one of
106 ELF - elf systems - linux-elf, NetBSD and DG-UX
107 OUT - a.out systems - linux-a.out and FreeBSD
108 SOL - solaris systems, which are elf with strange comment lines
109 BSDI - a.out with a very primative version of as.
110 #endif
111
112 /* Let the Assembler begin :-) */
113 EOF
114         }
115
116 1;