tinycc/Makefile

252 lines
6.6 KiB
Makefile
Raw Normal View History

2001-11-11 21:01:29 +03:00
#
# Tiny C Compiler Makefile
#
2003-04-13 23:48:19 +04:00
include config.mak
2001-10-28 02:48:39 +03:00
2002-01-05 22:57:08 +03:00
CFLAGS=-O2 -g -Wall
2004-10-08 01:11:43 +04:00
ifndef CONFIG_WIN32
2001-11-11 21:01:29 +03:00
LIBS=-ldl
2004-10-08 01:11:43 +04:00
BCHECK_O=bcheck.o
endif
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
2003-04-13 23:48:19 +04:00
CFLAGS+=-mpreferred-stack-boundary=2
ifeq ($(GCC_MAJOR),2)
CFLAGS+=-m386 -malign-functions=0
else
2004-11-07 21:08:15 +03:00
CFLAGS+=-march=i386 -falign-functions=0 -fno-strict-aliasing
2003-04-13 23:48:19 +04:00
endif
2002-01-05 22:57:08 +03:00
DISAS=objdump -d
2001-11-11 21:01:29 +03:00
INSTALL=install
2005-04-11 01:46:58 +04:00
PROGS=tcc$(EXESUF) c67-tcc$(EXESUF) arm-tcc$(EXESUF) i386-win32-tcc$(EXESUF)
2002-07-25 02:13:02 +04:00
# run local version of tcc with local libraries and includes
TCC=./tcc -B. -I.
2004-10-08 01:11:43 +04:00
all: $(PROGS) \
libtcc1$(LIBSUF) $(BCHECK_O) tcc-doc.html tcc.1 libtcc$(LIBSUF) \
libtcc_test$(EXESUF)
2003-04-13 23:48:19 +04:00
Makefile: config.mak
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
2003-04-13 23:48:19 +04:00
$(CC) $(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
2003-04-14 01:55:08 +04:00
$(TCC) -run tcctest.c > $@
2001-11-11 21:01:29 +03:00
2002-01-05 22:57:08 +03:00
run: tcc tcctest.c
2003-04-14 01:55:08 +04:00
$(TCC) -run 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
2003-04-14 01:55:08 +04:00
$(TCC) -run tcc.c -B. -I. -run 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
2003-04-14 01:55:08 +04:00
$(TCC) -run tcc.c -B. -I. -run tcc.c -B. -I. -run 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 \
2003-04-14 01:55:08 +04:00
if $(TCC) -b -run 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 \
2003-04-14 01:55:08 +04:00
if $(TCC) -b -run 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
2003-04-13 23:48:19 +04:00
$(CC) $(CFLAGS) -o $@ $<
2001-10-28 02:48:39 +03:00
2001-11-11 21:01:29 +03:00
ex3: ex3.c
2003-04-13 23:48:19 +04:00
$(CC) $(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
2004-10-08 01:11:43 +04:00
tcc_g$(EXESUF): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
2003-04-13 23:48:19 +04:00
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
2001-11-11 21:01:29 +03:00
2004-10-08 01:11:43 +04:00
tcc$(EXESUF): tcc_g$(EXESUF) Makefile
$(STRIP) -o $@ $<
2001-10-28 02:48:39 +03:00
2004-10-08 01:11:43 +04:00
c67-tcc$(EXESUF): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c Makefile
2004-10-05 01:57:35 +04:00
$(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS)
2004-10-08 01:11:43 +04:00
arm-tcc$(EXESUF): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
2004-10-05 02:19:21 +04:00
$(CC) $(CFLAGS) -DTCC_TARGET_ARM -o $@ $< $(LIBS)
2005-04-11 01:46:58 +04:00
i386-win32-tcc$(EXESUF): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c Makefile
$(CC) $(CFLAGS) -DTCC_TARGET_PE -o $@ $< $(LIBS)
2002-07-25 02:13:02 +04:00
# TinyCC runtime libraries
libtcc1.o: libtcc1.c
2003-04-13 23:48:19 +04:00
$(CC) -O2 -Wall -c -o $@ $<
2002-07-25 02:13:02 +04:00
2004-10-08 01:11:43 +04:00
libtcc1$(LIBSUF): libtcc1.o
$(AR) rcs $@ $^
2002-07-25 02:13:02 +04:00
bcheck.o: bcheck.c
2003-04-13 23:48:19 +04:00
$(CC) -O2 -Wall -c -o $@ $<
install: tcc_install libinstall
2004-10-08 01:11:43 +04:00
tcc_install: $(PROGS) tcc.1 libtcc1$(LIBSUF) $(BCHECK_O) tcc-doc.html tcc.1
mkdir -p "$(bindir)"
$(INSTALL) -s -m755 $(PROGS) "$(bindir)"
ifndef CONFIG_WIN32
mkdir -p "$(mandir)/man1"
$(INSTALL) tcc.1 "$(mandir)/man1"
endif
mkdir -p "$(libdir)/tcc"
mkdir -p "$(libdir)/tcc/include"
$(INSTALL) -m644 libtcc1$(LIBSUF) $(BCHECK_O) "$(libdir)/tcc"
2002-11-24 18:58:28 +03:00
$(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
2004-10-08 01:11:43 +04:00
tcclib.h "$(libdir)/tcc/include"
mkdir -p "$(docdir)"
$(INSTALL) -m644 tcc-doc.html "$(docdir)"
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 \
2004-10-08 01:11:43 +04:00
*.exe tcc-doc.html tcc.pod tcc.1 libtcc$(LIBSUF) libtcc_test \
tcctest[1234] test[1234].out c67-tcc arm-tcc
2001-12-18 00:57:01 +03:00
2003-04-13 23:48:19 +04:00
distclean: clean
2003-04-14 01:55:08 +04:00
rm -f config.h config.mak config.texi
2003-04-13 23:48:19 +04:00
2001-12-18 00:57:01 +03:00
# profiling version
tcc_p: tcc.c Makefile
2003-04-13 23:48:19 +04:00
$(CC) $(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
2004-10-08 01:11:43 +04:00
libinstall: libtcc$(LIBSUF)
mkdir -p "$(libdir)"
$(INSTALL) -m644 libtcc$(LIBSUF) "$(libdir)"
mkdir -p "$(includedir)"
$(INSTALL) -m644 libtcc.h "$(includedir)"
2002-05-14 02:58:22 +04:00
2004-10-08 01:11:43 +04:00
libtcc.o: tcc.c i386-gen.c Makefile
2003-04-13 23:48:19 +04:00
$(CC) $(CFLAGS) -DLIBTCC -c -o $@ $<
2002-05-14 02:58:22 +04:00
2004-10-08 01:11:43 +04:00
libtcc$(LIBSUF): libtcc.o
2003-04-13 23:48:19 +04:00
$(AR) rcs $@ $^
2002-05-14 02:58:22 +04:00
2004-10-08 01:11:43 +04:00
libtcc_test$(EXESUF): libtcc_test.c libtcc$(LIBSUF)
$(CC) $(CFLAGS) -o $@ $< libtcc$(LIBSUF) $(LIBS)
2002-05-14 02:58:22 +04:00
2002-12-08 17:34:02 +03:00
libtest: libtcc_test
./libtcc_test
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
2003-01-06 23:19:20 +03:00
# tiny assembler testing
asmtest.ref: asmtest.S
2003-04-13 23:48:19 +04:00
$(CC) -c -o asmtest.ref.o asmtest.S
2003-01-06 23:19:20 +03:00
objdump -D asmtest.ref.o > $@
# XXX: we compute tcc.c to go faster during development !
asmtest.out: asmtest.S tcc
# ./tcc tcc.c -c asmtest.S
#asmtest.out: asmtest.S tcc
./tcc -c asmtest.S
objdump -D asmtest.o > $@
asmtest: asmtest.out asmtest.ref
@if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
2001-10-28 18:20:24 +03:00
instr.o: instr.S
2003-04-13 23:48:19 +04:00
$(CC) -O2 -Wall -g -c -o $@ $<
2001-10-28 02:48:39 +03:00
2002-11-24 18:58:28 +03:00
cache: tcc_g
cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
vg_annotate tcc.c > /tmp/linpack.cache.log
# documentation and man page
2002-07-25 02:13:02 +04:00
tcc-doc.html: tcc-doc.texi
texi2html -monolithic -number $<
tcc.1: tcc-doc.texi
./texi2pod.pl $< tcc.pod
pod2man --section=1 --center=" " --release=" " tcc.pod > $@
2003-04-13 23:48:19 +04:00
FILES= Makefile Makefile.uClibc configure VERSION \
2002-08-31 16:44:16 +04:00
README TODO COPYING \
Changelog tcc-doc.texi tcc-doc.html \
tcc.1 \
2004-10-08 01:11:43 +04:00
tcc.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h \
tcccoff.c coff.h \
i386-gen.c c67-gen.c arm-gen.c \
2002-08-31 16:44:16 +04:00
bcheck.c libtcc1.c \
elf.h stab.h stab.def \
2002-11-24 18:58:28 +03:00
stddef.h stdarg.h stdbool.h float.h varargs.h \
2002-08-31 16:44:16 +04:00
tcclib.h libtcc.h libtcc_test.c \
ex1.c ex2.c ex3.c ex4.c ex5.c \
2003-05-24 22:31:27 +04:00
tcctest.c boundtest.c gcctestsuite.sh texi2pod.pl
2002-08-31 16:44:16 +04:00
2001-11-11 21:01:29 +03:00
FILE=tcc-$(VERSION)
tar:
rm -rf /tmp/$(FILE)
2002-08-31 16:44:16 +04:00
mkdir -p /tmp/$(FILE)
cp -P $(FILES) /tmp/$(FILE)
( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
2001-11-11 21:01:29 +03:00
rm -rf /tmp/$(FILE)