tinycc/Makefile

200 lines
5.1 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
2002-01-05 22:57:08 +03:00
CFLAGS=-O2 -g -Wall
2001-11-11 21:01:29 +03:00
LIBS=-ldl
2001-12-18 00:57:01 +03:00
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
LIBS_P=
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
CFLAGS+=-m386 -malign-functions=0
2002-07-25 02:13:02 +04:00
CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\"
2002-01-05 22:57:08 +03:00
DISAS=objdump -d
2001-11-11 21:01:29 +03:00
INSTALL=install
2002-08-18 18:31:04 +04:00
VERSION=0.9.10
2001-10-28 02:48:39 +03:00
2002-07-25 02:13:02 +04:00
# run local version of tcc with local libraries and includes
TCC=./tcc -B. -I.
all: tcc libtcc1.o bcheck.o tcc-doc.html
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
2002-01-05 22:57:08 +03:00
tcctest.ref: tcctest.c
gcc $(CFLAGS) -I. -o $@ $<
2001-10-28 02:48:39 +03:00
2002-01-05 22:57:08 +03:00
test.ref: tcctest.ref
./tcctest.ref > $@
2001-11-11 21:01:29 +03:00
2002-01-05 22:57:08 +03:00
test.out: tcc tcctest.c
2002-07-25 02:13:02 +04:00
$(TCC) tcctest.c > $@
2001-11-11 21:01:29 +03:00
2002-01-05 22:57:08 +03:00
run: tcc tcctest.c
2002-07-25 02:13:02 +04:00
$(TCC) tcctest.c
2001-11-11 21:01:29 +03:00
2002-01-05 22:57:08 +03:00
# iterated test2 (compile tcc then compile tcctest.c !)
test2: tcc tcc.c tcctest.c test.ref
2002-07-25 02:13:02 +04:00
$(TCC) tcc.c -B. -I. tcctest.c > test.out2
2001-11-18 19:33:35 +03:00
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
2001-10-28 02:48:39 +03:00
2002-01-05 22:57:08 +03:00
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
test3: tcc tcc.c tcctest.c test.ref
2002-07-25 02:13:02 +04:00
$(TCC) tcc.c -B. -I. tcc.c -B. -I. tcctest.c > test.out3
2001-11-18 19:33:35 +03:00
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
2001-10-28 02:48:39 +03:00
2002-08-18 18:31:04 +04:00
# binary output test
test4: tcc test.ref
# dynamic output
$(TCC) -o tcctest1 tcctest.c
./tcctest1 > test1.out
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
# static output
$(TCC) -static -o tcctest2 tcctest.c
./tcctest2 > test2.out
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
# object + link output
$(TCC) -c -o tcctest3.o tcctest.c
$(TCC) -o tcctest3 tcctest3.o
./tcctest3 > test3.out
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
# dynamic output + bound check
$(TCC) -b -o tcctest4 tcctest.c
./tcctest4 > test4.out
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
2002-01-05 22:57:08 +03:00
# memory and bound check auto test
BOUNDS_OK = 1 4 8 10
2002-02-10 19:15:22 +03:00
BOUNDS_FAIL= 2 5 7 9 11 12 13
2002-01-05 22:57:08 +03:00
btest: boundtest.c tcc
@for i in $(BOUNDS_OK); do \
2002-07-25 02:13:02 +04:00
if $(TCC) -b boundtest.c $$i ; then \
2002-01-05 22:57:08 +03:00
/bin/true ; \
else\
echo Failed positive test $$i ; exit 1 ; \
fi ;\
done ;\
for i in $(BOUNDS_FAIL); do \
2002-07-25 02:13:02 +04:00
if $(TCC) -b boundtest.c $$i ; then \
2002-01-05 22:57:08 +03:00
echo Failed negative test $$i ; exit 1 ;\
else\
/bin/true ; \
fi\
done ;\
echo Bound test OK
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
2002-02-10 19:15:22 +03:00
# Native Tiny C Compiler
2001-11-11 21:01:29 +03:00
2002-08-18 18:31:04 +04:00
tcc_g: tcc.c i386-gen.c tccelf.c tcctok.h libtcc.h Makefile
2001-11-11 21:01:29 +03:00
gcc $(CFLAGS) -o $@ $< $(LIBS)
tcc: tcc_g
strip -s -R .comment -R .note -o $@ $<
2001-10-28 02:48:39 +03:00
2002-07-25 02:13:02 +04:00
# TinyCC runtime libraries
libtcc1.o: libtcc1.c
gcc -O2 -Wall -c -o $@ $<
bcheck.o: bcheck.c
gcc -O2 -Wall -c -o $@ $<
install: tcc libtcc1.o bcheck.o
2001-11-11 21:01:29 +03:00
$(INSTALL) -m755 tcc $(prefix)/bin
2002-08-18 18:31:04 +04:00
$(INSTALL) tcc.1 $(prefix)/share/man/man1
2001-11-11 21:01:29 +03:00
mkdir -p $(prefix)/lib/tcc
2002-07-25 02:13:02 +04:00
mkdir -p $(prefix)/lib/tcc/include
$(INSTALL) -m644 libtcc1.o bcheck.o $(prefix)/lib/tcc
2002-01-05 22:57:08 +03:00
$(INSTALL) -m644 stdarg.h stddef.h float.h stdbool.h \
2002-07-25 02:13:02 +04:00
tcclib.h $(prefix)/lib/tcc/include
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
clean:
2002-01-05 22:57:08 +03:00
rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
2002-03-04 01:44:31 +03:00
core gmon.out test.out test.ref a.out tcc_p \
2002-08-18 18:31:04 +04:00
*.exe iltcc iltcc_g tcc-doc.html \
tcctest[1234] test[1234].out
2001-12-18 00:57:01 +03:00
2002-02-10 19:15:22 +03:00
# IL TCC
iltcc_g: tcc.c il-gen.c bcheck.c Makefile
gcc $(CFLAGS) -DTCC_TARGET_IL -o $@ $< $(LIBS)
iltcc: iltcc_g
strip -s -R .comment -R .note -o $@ $<
# win32 TCC
2002-01-26 21:06:03 +03:00
tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
tcc.exe: tcc_g.exe
i386-mingw32msvc-strip -o $@ $<
2001-12-18 00:57:01 +03:00
# profiling version
tcc_p: tcc.c Makefile
gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
2001-10-28 02:48:39 +03:00
2002-05-14 02:58:22 +04:00
# libtcc generation and example
libinstall: libtcc.a
$(INSTALL) -m644 libtcc.a $(prefix)/lib
$(INSTALL) -m644 libtcc.h $(prefix)/include
libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
gcc $(CFLAGS) -DLIBTCC -c -o $@ $<
libtcc.a: libtcc.o
ar rcs $@ $^
libtcc_test: libtcc_test.c libtcc.a
gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
2002-01-05 22:57:08 +03:00
# targets for development
2001-10-28 02:48:39 +03:00
2001-11-18 19:33:35 +03:00
%.bin: %.c tcc
2002-07-25 02:13:02 +04:00
$(TCC) -g -o $@ $<
2001-11-11 21:01:29 +03:00
$(DISAS) $@
2001-10-28 18:20:24 +03:00
2001-12-18 00:57:01 +03:00
instr: instr.o
objdump -d instr.o
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
2002-07-25 02:13:02 +04:00
# documentation
tcc-doc.html: tcc-doc.texi
texi2html -monolithic -number $<
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 \
2002-03-04 01:44:31 +03:00
$(FILE)/Makefile $(FILE)/Makefile.uClibc \
$(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
2002-07-25 02:13:02 +04:00
$(FILE)/Changelog $(FILE)/tcc-doc.texi $(FILE)/tcc-doc.html \
$(FILE)/tcc.1 \
2002-08-18 18:31:04 +04:00
$(FILE)/tcc.c $(FILE)/i386-gen.c $(FILE)/tccelf.c $(FILE)/tcctok.h \
2002-07-25 02:13:02 +04:00
$(FILE)/bcheck.c $(FILE)/libtcc1.c \
2002-03-04 01:44:31 +03:00
$(FILE)/il-opcodes.h $(FILE)/il-gen.c \
$(FILE)/elf.h $(FILE)/stab.h $(FILE)/stab.def \
2001-12-18 00:57:01 +03:00
$(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \
2002-05-14 02:58:22 +04:00
$(FILE)/tcclib.h $(FILE)/libtcc.h $(FILE)/libtcc_test.c \
2002-01-05 22:57:08 +03:00
$(FILE)/ex*.c $(FILE)/tcctest.c $(FILE)/boundtest.c )
2001-11-11 21:01:29 +03:00
rm -rf /tmp/$(FILE)