tinycc/Makefile

93 lines
1.7 KiB
Makefile
Raw Normal View History

2001-11-11 21:01:29 +03:00
#
# Tiny C Compiler Makefile
#
prefix=/usr/local
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
CFLAGS=-O2 -g -Wall -Wno-parentheses -I.
LIBS=-ldl
#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE
#LIBS=
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
CFLAGS+=-m386 -malign-functions=0
DISAS=objdump -D -b binary -m i386
INSTALL=install
VERSION=0.9
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
all: tcc
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
# auto test
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
test: test.ref test.out
@if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
prog.ref: prog.c
gcc $(CFLAGS) -o $@ $<
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
test.ref: prog.ref
./prog.ref > $@
test.out: tcc prog.c
./tcc -I. prog.c > $@
run: tcc prog.c
./tcc -I. prog.c
run2: tcc tcc.c prog.c
./tcc -I. tcc.c -I. prog.c
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
run3: tcc tcc.c prog.c
./tcc -I. tcc.c -I. tcc.c -I. prog.c
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
# speed test
speed: tcc ex2 ex3
time ./ex2 1238 2 3 4 10 13 4
time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
time ./ex3 35
time ./tcc -I. ./ex3.c 35
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
ex2: ex2.c
gcc $(CFLAGS) -o $@ $<
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
ex3: ex3.c
gcc $(CFLAGS) -o $@ $<
2001-10-28 18:20:24 +03:00
2001-11-11 21:01:29 +03:00
# Tiny C Compiler
tcc_g: tcc.c Makefile
gcc $(CFLAGS) -o $@ $< $(LIBS)
tcc: tcc_g
strip -s -R .comment -R .note -o $@ $<
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
install: tcc
$(INSTALL) -m755 tcc $(prefix)/bin
mkdir -p $(prefix)/lib/tcc
$(INSTALL) -m644 stdarg.h stddef.h tcclib.h $(prefix)/lib/tcc
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
clean:
rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \
core gmon.out test.out test.ref a.out
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
# target for development
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
%.bin: %.c tcct
./tcct -I. $< $@
$(DISAS) $@
2001-10-28 18:20:24 +03:00
2001-11-11 21:01:29 +03:00
tcct: tcc.c
gcc -DTEST $(CFLAGS) -o $@ $< -ldl
2001-10-28 18:20:24 +03:00
instr.o: instr.S
gcc -O2 -Wall -g -c -o $@ $<
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
FILE=tcc-$(VERSION)
tar:
rm -rf /tmp/$(FILE)
cp -r ../tcc /tmp/$(FILE)
( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
$(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
$(FILE)/tcc.c $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/tcclib.h \
$(FILE)/ex*.c $(FILE)/prog.c )
rm -rf /tmp/$(FILE)