C言語は魅惑の言語でした。
CPUが16bitから32bitへの発展に貢献した言語。
UNIXが16bitから32bitへの発展に貢献した言語。
この2つの事象を経験していない人には、
C言語の意味も、役割も直感的には理解できないかもしれない。
そこでPortable C Compilerから始めようと思った。
$ docker run -it gcc /bin/bash
まずGCCを使う。
# cd /home
# mkdir cc
# cd cc
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/code.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/local.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/local2.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/order.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/table.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/order.c
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/makefile
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/INDEX
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/macdefs
# wget https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/pcc/mac2defs
# make
make: *** No targets specified and no makefile found. Stop.
あれ?何があったし。
# ls
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Fcode.c' 'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Forder.c'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Flocal.c'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Flocal2.c' 'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Ftable.c'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Fmakefile'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2FINDEX'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Fmac2defs'
'utree.pl?file=V7%2Fusr%2Fsrc%2Fcmd%2Fpcc%2Fmacdefs'
# mv *code.c code.c
# mv *local.c local.c
# mv *local2.c local2.c
# mv *makefile makefile
# mv *order.c order.c
# mv *table.c table.c
# mv *INDEX INDEX
# mv *mac2defs mac2defs
# mv *macdefs macdefs
# make
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="white">
<h1>V7/usr/src/cmd/pcc/makefile</h1>
<p>
<pre>
INSTALL=/usr/lib/ccom
M=/usr/src/cmd/mip
CFLAGS=-O
head: ccom ;
all: ccom
cp: ccom
cp ccom /usr/lib/ccom
rm *.o cgram.c ccom
cmp: ccom
cmp ccom /usr/lib/ccom
rm *.o cgram.c ccom
ccom: cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
cc $(CFLAGS) -s -o ccom -i cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
cc -c $(CFLAGS) -I$M -I. $M/trees.c
optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
cc -c $(CFLAGS) -I$M -I. $M/optim.c
pftn.o: $M/manifest macdefs $M/mfile1 $M/pftn.c
cc -c $(CFLAGS) -I$M -I. $M/pftn.c
code.o: $M/manifest macdefs $M/mfile1
cc -c $(CFLAGS) -I$M -I. code.c
local.o: $M/manifest macdefs $M/mfile1
cc -c $(CFLAGS) -I$M -I. local.c
scan.o: $M/manifest macdefs $M/mfile1 $M/scan.c
cc -c $(CFLAGS) -I$M -I. $M/scan.c
xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
cgram.o: $M/manifest $M/mfile1 macdefs cgram.c
cc -c $(CFLAGS) -I$M -I. cgram.c
cgram.c: $M/cgram.y
yacc $M/cgram.y
mv y.tab.c cgram.c
comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
cc -c $(CFLAGS) -I. -I$M $M/comm1.c
table.o: $M/manifest $M/mfile2 mac2defs macdefs table.c
cc -c $(CFLAGS) -I$M -I. table.c
reader.o: $M/manifest $M/mfile2 mac2defs macdefs $M/reader.c
cc -c $(CFLAGS) -I$M -I. $M/reader.c
local2.o: $M/manifest $M/mfile2 mac2defs macdefs
cc -c $(CFLAGS) -I$M -I. local2.c
order.o: $M/manifest $M/mfile2 mac2defs macdefs
cc -c $(CFLAGS) -I$M -I. order.c
match.o: $M/manifest $M/mfile2 mac2defs macdefs $M/match.c
cc -c $(CFLAGS) -I$M -I. $M/match.c
allo.o: $M/manifest $M/mfile2 mac2defs macdefs $M/allo.c
cc -c $(CFLAGS) -I$M -I. $M/allo.c
shrink:
rm *.o ccom
lintall:
lint -hpv -I. -I$M cgram.c xdefs.c $M/scan.c $M/pftn.c $M/trees.c $M/optim.c code.c local.c $M/reader.c local2.c order.c $M/match.c $M/allo.c $M/comm1.c table.c
fort: ccom fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
cc -i $(CFLAGS) fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
mv a.out fort
fort.o: fort.h $M/fort.c
cc -c $(CFLAGS) -I$M -I. $M/fort.c
freader.o: reader.o
cc -c $(CFLAGS) -I$M -I. $M/freader.c
fallo.o: allo.o
cc -c $(CFLAGS) -I$M -I. $M/fallo.c
fmatch.o: match.o
cc -c $(CFLAGS) -I$M -I. $M/fmatch.c
ftable.o: table.o
cc -c $(CFLAGS) -I$M -I. $M/ftable.c
forder.o: order.o
cc -c $(CFLAGS) -I$M -I. $M/forder.c
flocal2.o: local2.o
cc -c $(CFLAGS) -I$M -I. $M/flocal2.c
fcomm2.o: $M/common
cc -c $(CFLAGS) -I$M -I. $M/fcomm2.c
fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o: $M/mfile2 $M/manifest macdefs mac2defs
install:
cp ccom $(INSTALL)
cp macdefs mac2defs local.c code.c local2.c order.c table.c /usr/src/cmd/pcc
</pre>
</body>
</html>
最初の版は、機械依存の部分の移植が必要なのかも。
PDP-11用なのだろう。
(失敗編)
最後までおよみいただきありがとうございました。
いいね 💚、フォローをお願いします。
Thank you very much for reading to the last sentence.
Please press the like icon 💚 and follow me for your happy life.