-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathextract.mak
71 lines (61 loc) · 2.17 KB
/
extract.mak
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
# $Id: extract.mak,v 5.2 2018/03/12 21:10:07 albert Exp $
# Copyright (2018): Albert van der Horst {by GNU Public License}
# This defines the transformation from the generic file ci86.gnr
# into a diversity of Intel 86 assembly sources in behalf of Linux. 1)
# It is controlled by a configuration file with extension .cfg
# which lends its name to the assembler source.
# Configuration items are found in prelude.m4
# Configuration items present in postlude.m4 must be redefined
# after the inclusion of the postlude.
# Any change except for M4_RTS and M4_EM requires integral
# retesting of the forth and the library.
#
# 1) For MS-DOS etc. use
# https://github.com/albertvanderhorst/ciforth
#
# The target assemblers are coupled to the extension
# fasm .fas
# gas .s
# nasm .asm
# masm .msm
# How a binary is to be built is documented in the source file.
# Please increment de version number in VERSION if you change ci86.gnr,
# not for adaptations in .cfg file such as changing the memory size.
TARGETS= lina.cfg lina32.cfg lina64.cfg
INGREDIENTS = \
ciforth.m4 \
header.m4 \
postlude.m4 \
prelude.m4 \
width16.m4 \
width32.m4 \
width64.m4 \
# That's all folks!
# Normal use of m4, no gnu extension.
M4=m4 -G ciforth.m4
# Needed for gas and fasm where we need the patsubst macro.
M4_GNU=m4 ciforth.m4
# Building with fasm
% : ci86.%.fas ; fasm $+ -m256000; mv ${<:.fas=} $@
# Now that gas has the .Intel_syntax option, its source can be
# generated by m4 alone.
# In particular the order of operands was problematic.
ci86.%.s : VERSION %.cfg gas.m4 ci86.gnr ; \
cat $+ | $(M4_GNU) - |\
sed -e '/Split here /,$$d' >$@
# Extract for fasm assembler.
ci86.%.fas : VERSION %.cfg fasm.m4 ci86.gnr
cat $+ | $(M4_GNU) - |\
sed -e '/Split here /,$$d' >$@
# Extract for nasm assembler.
ci86.%.asm : %.cfg VERSION nasm.m4 ci86.gnr
cat $+ | $(M4) - |\
sed -e '/Split here /,$$d' >$@
# This is for masm and tasm.
# They can't handle 0x.
ci86.%.msm : VERSION %.cfg masm.m4 ci86.gnr
cat $+ | $(M4) - |\
sed -e '/Split here /,$$d' | \
sed -e 's/0x\([A-F0-9]*\)/0\1H/g' | \
sed -e 's/^\([_A-Za-z0-9]*:\) *\(D[BWD]\)/\1\n\
\2/g' >$@