forked from rafael2k/8086-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathecc
More file actions
executable file
·112 lines (100 loc) · 2.27 KB
/
ecc
File metadata and controls
executable file
·112 lines (100 loc) · 2.27 KB
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
#!/usr/bin/env bash
#
# ecc - wrapper script for ELKS C86 toolchain
# Preprocesses, compiles, assembles and links passed .c files
#
# Usage: ecc [-c] [-{option}] file.c ...
#
# 27 Dec 24 Greg Haerr
#
set -e
if [ -z "$TOPDIR" ]
then
echo "ELKS TOPDIR= environment variable not set"
exit
fi
#if [ -z "$C86" ]
# then
# echo "C86= environment variable not set"
# exit
#fi
INCLUDES="-I$TOPDIR/libc/include -I$TOPDIR/elks/include -I$TOPDIR/libc/include/c86"
#DEFINES="-D__HAS_NO_FLOATS__=1 -D__HAS_NO_LONGONG__"
CPP=cpp86
CC=c86
AS=as86
AR=ar86
LD=ld86
CPPFLAGS="\
-0 \
$INCLUDES \
$DEFINES \
"
# -trace=yes
CFLAGS="\
-g \
-O \
-bas86 \
-warn=4 \
-lang=c99 \
-align=yes \
-separate=yes \
-stackopt=minimum \
-peep=all \
-stackcheck=no \
-obsolete=yes \
-icode \
"
ASFLAGS="\
-0 \
-j \
-O \
-w- \
"
LDFLAGS="\
-0 \
-i \
-L$TOPDIR/libc \
"
DOLINK=1
while true; do
case "$1" in
-c)
DOLINK=0
shift ;;
-*)
CFLAGS="$CFLAGS $1"
shift ;;
*) break ;;
esac
done
if [ $# -eq 0 ]
then
echo "Usage: ecc [-c] [-{option}] file.c ..."
exit
fi
OUT=$1
if [ ${OUT%.c} == $OUT ]
then
echo "Must specify .c file(s)"
exit
fi
OUT=${OUT%.c}
OBJS=
for PROG in $@
do
echo $CPP $CPPFLAGS -o ${PROG%.c}.i ${PROG%.i}
$CPP $CPPFLAGS -o ${PROG%.c}.i ${PROG%.i}
echo $CC $CFLAGS ${PROG%.c}.i ${PROG%.c}.as
$CC $CFLAGS ${PROG%.c}.i ${PROG%.c}.as
echo $AS $ASFLAGS -o ${PROG%.c}.o ${PROG%.c}.as
$AS $ASFLAGS -o ${PROG%.c}.o -l ${PROG%.c}.lst ${PROG%.c}.as
OBJS="$OBJS ${PROG%.c}.o"
if [ $DOLINK -eq 1 ]; then rm ${PROG%.c}.i ${PROG%.c}.as; fi
done
if [ $DOLINK -eq 1 ]
then
echo $LD $LDFLAGS -o $OUT $OBJS -lc86
$LD $LDFLAGS -o $OUT $OBJS -lc86
rm ${PROG%.c}.o
fi