Mercurial > hg > tinycc
changeset 519:ff406be3015d
The old build system doesn't apply to the current source anymore, remove it.
Also rename libtcc.h to libtinycc.h, plus more in-progress changes.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 30 Nov 2007 01:59:34 -0600 |
parents | b69ff9e2578a |
children | 647f1a3feb8b |
files | Makefile configure libtcc.h libtinycc.h tcc.c tcc.h tccelf.c tests/tcctest.c |
diffstat | 8 files changed, 140 insertions(+), 738 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Nov 26 16:54:15 2007 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -# -# Tiny C Compiler Makefile -# -include config.mak - -CFLAGS+=-g -Wall -fsigned-char -Os -fno-strict-aliasing - -ifndef CONFIG_WIN32 -LIBS=-lm -ifndef CONFIG_NOLDL -LIBS+=-ldl -endif -BCHECK_O=bcheck.o -endif - -INSTALL=install - -ifdef CONFIG_WIN32 -PROGS=tcc$(EXESUF) -ifdef CONFIG_CROSS -PROGS+=c67-tcc$(EXESUF) arm-tcc$(EXESUF) -endif -PROGS+=tiny_impdef$(EXESUF) -else -ifeq ($(ARCH),i386) -PROGS=tcc$(EXESUF) -ifdef CONFIG_CROSS -PROGS+=arm-tcc$(EXESUF) -endif -endif -ifeq ($(ARCH),arm) -PROGS=tcc$(EXESUF) -ifdef CONFIG_CROSS -PROGS+=i386-tcc$(EXESUF) -endif -endif -ifdef CONFIG_CROSS -PROGS+=c67-tcc$(EXESUF) i386-win32-tcc$(EXESUF) -endif -endif - -# run local version of tcc with local libraries and includes -TCC=./tcc -B. -I./include -I. - -all: $(PROGS) libtcc1.a $(BCHECK_O) libtcc.a libtcc_test$(EXESUF) \ - tcc-doc.html tcc.1 - -Makefile: config.mak - -# auto test - -test: test.ref test.out - @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi - -tcctest.ref: tests/tcctest.c - $(CC) $(CFLAGS) -I. -Iinclude -o $@ $< - -test.ref: tcctest.ref - ./tcctest.ref > $@ - -test.out: tcc libtcc1.a tests/tcctest.c - $(TCC) -run tests/tcctest.c > $@ - -run: tcc tests/tcctest.c - $(TCC) -run tests/tcctest.c - -# iterated test2 (compile tcc then compile tcctest.c !) -test2: tcc tcc.c tests/tcctest.c test.ref - $(TCC) -run tcc.c -B. -I. -run tests/tcctest.c > test.out2 - @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi - -# iterated test3 (compile tcc then compile tcc then compile tcctest.c !) -test3: tcc tcc.c tests/tcctest.c test.ref - $(TCC) -run tcc.c -B. -I. -run tcc.c -B. -I. -run tests/tcctest.c > test.out3 - @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi - -# binary output test -test4: tcc test.ref -# dynamic output - $(TCC) -o tcctest1 tests/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 tests/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 tests/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 tests/tcctest.c - ./tcctest4 > test4.out - @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi - -# memory and bound check auto test -BOUNDS_OK = 1 4 8 10 -BOUNDS_FAIL= 2 5 7 9 11 12 13 - -btest: boundtest.c tcc - @for i in $(BOUNDS_OK); do \ - if $(TCC) -b -run boundtest.c $$i ; then \ - /bin/true ; \ - else\ - echo Failed positive test $$i ; exit 1 ; \ - fi ;\ - done ;\ - for i in $(BOUNDS_FAIL); do \ - if $(TCC) -b -run boundtest.c $$i ; then \ - echo Failed negative test $$i ; exit 1 ;\ - else\ - /bin/true ; \ - fi\ - done ;\ - echo Bound test OK - -# 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 - -ex2: ex2.c - $(CC) $(CFLAGS) -o $@ $< - -ex3: ex3.c - $(CC) $(CFLAGS) -o $@ $< - -# Host Tiny C Compiler -ifdef CONFIG_WIN32 -tcc$(EXESUF): tcc.c i386/* tccelf.c tccasm.c tcctok.h libtcc.h win32/tccpe.c - $(CC) $(CFLAGS) -DTCC_TARGET_PE -o $@ $< $(LIBS) -else -ifeq ($(ARCH),i386) -tcc$(EXESUF): tcc.c i386/* tccelf.c tccasm.c tcctok.h libtcc.h - $(CC) $(CFLAGS) -o $@ $< $(LIBS) -endif -ifeq ($(ARCH),arm) -tcc$(EXESUF): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h - $(CC) $(CFLAGS) -DTCC_TARGET_ARM -o $@ $< $(LIBS) -endif -endif - -# Cross Tiny C Compilers -i386-tcc$(EXESUF): tcc.c i386/* tccelf.c tccasm.c tcctok.h libtcc.h - $(CC) $(CFLAGS) -o $@ $< $(LIBS) - -c67-tcc$(EXESUF): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c - $(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS) - -arm-tcc$(EXESUF): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h - $(CC) $(CFLAGS) -DTCC_TARGET_ARM -DTCC_ARM_EABI -o $@ $< $(LIBS) - -i386-win32-tcc$(EXESUF): tcc.c i386/* tccelf.c tccasm.c tcctok.h libtcc.h win32/tccpe.c - $(CC) $(CFLAGS) -DTCC_TARGET_PE -o $@ $< $(LIBS) - -# windows utilities -tiny_impdef$(EXESUF): win32/tiny_impdef.c - $(CC) $(CFLAGS) -o $@ $< -lkernel32 - -# TinyCC runtime libraries -ifdef CONFIG_WIN32 -# for windows, we must use TCC because we generate ELF objects -LIBTCC1_OBJS=$(addprefix win32/lib/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o) libtcc1.o -LIBTCC1_CC=./tcc.exe -Bwin32 -else -LIBTCC1_OBJS=libtcc1.o -ifeq ($(ARCH),i386) -LIBTCC1_OBJS+=i386/alloca86.o i386/bound-alloca86.o -endif -LIBTCC1_CC=$(CC) -endif - -%.o: %.c - $(LIBTCC1_CC) -O2 -Wall -c -o $@ $< - -%.o: %.S - $(LIBTCC1_CC) -c -o $@ $< - -libtcc1.a: $(LIBTCC1_OBJS) - $(AR) rcs $@ $^ - -bcheck.o: bcheck.c - $(CC) -O2 -Wall -c -o $@ $< - -install: tcc_install libinstall - -tcc_install: $(PROGS) libtcc1.a $(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 "$(tccdir)" - mkdir -p "$(tccdir)/include" -ifdef CONFIG_WIN32 - mkdir -p "$(tccdir)/lib" - $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib" - cp -r win32/include/. "$(tccdir)/include" - cp -r win32/examples/. "$(tccdir)/examples" -else - $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(tccdir)" - $(INSTALL) -m644 include/* "$(tccdir)/include" -endif - mkdir -p "$(docdir)" - -$(INSTALL) -m644 tcc-doc.html "$(docdir)" -ifdef CONFIG_WIN32 - $(INSTALL) -m644 win32/readme.txt "$(docdir)" -endif - -clean: - rm -f *~ *.o *.a tcc tcc.1 tcct tcc_g tcctest.ref *.bin *.i ex2 \ - core gmon.out test.out test.ref a.out tcc_p \ - *.exe *.lib tcc.pod libtcc_test i386/*.o \ - tcctest[1234] test[1234].out $(PROGS) win32/lib/*.o - -distclean: clean - rm -f config.h config.mak config.texi - -# profiling version -tcc_p: tcc.c Makefile - $(CC) $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -o $@ $< - -# libtcc generation and example -libinstall: libtcc.a - mkdir -p "$(libdir)" - $(INSTALL) -m644 libtcc.a "$(libdir)" - mkdir -p "$(includedir)" - $(INSTALL) -m644 libtcc.h "$(includedir)" - -libtcc.o: tcc.c i386/i386-gen.c Makefile - $(CC) $(CFLAGS) -DLIBTCC -c -o $@ $< - -libtcc.a: libtcc.o - $(AR) rcs $@ $^ - -libtcc_test$(EXESUF): tests/libtcc_test.c libtcc.a - $(CC) $(CFLAGS) -o $@ $< libtcc.a $(LIBS) - -libtest: libtcc_test - ./libtcc_test - -# tiny assembler testing - -asmtest.ref: asmtest.S - $(CC) -c -o asmtest.ref.o asmtest.S - objdump -D asmtest.ref.o > $@ - -# XXX: we compute tcc.c to go faster during development ! -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 - -instr.o: instr.S - $(CC) -O2 -Wall -g -c -o $@ $< - -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 -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 > $@ - -FILE=tcc-$(shell cat VERSION) - -# tar release (use 'make -k tar' on a checkouted tree) -tar: - rm -rf /tmp/$(FILE) - cp -r . /tmp/$(FILE) - ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .hg ) - rm -rf /tmp/$(FILE)
--- a/configure Mon Nov 26 16:54:15 2007 -0600 +++ b/configure Fri Nov 30 01:59:34 2007 -0600 @@ -1,354 +1,44 @@ -#!/bin/sh -# -# tcc configure script (c) 2003 Fabrice Bellard -# -# set temporary file name -if test ! -z "$TMPDIR" ; then - TMPDIR1="${TMPDIR}" -elif test ! -z "$TEMPDIR" ; then - TMPDIR1="${TEMPDIR}" -else - TMPDIR1="/tmp" -fi - -TMPC="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c" -TMPO="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.o" -TMPE="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}" -TMPS="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.S" -TMPH="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h" +#!/bin/bash -# default parameters -build_cross="no" -prefix="" -execprefix="" -bindir="" -libdir="" -tccdir="" -includedir="" -mandir="" -cross_prefix="" -cc="gcc" -host_cc="gcc" -ar="ar" -make="make" -strip="strip" -cpu=`uname -m` -case "$cpu" in - i386|i486|i586|i686|i86pc|BePC) - cpu="x86" - ;; - armv4l) - cpu="armv4l" - ;; - alpha) - cpu="alpha" - ;; - "Power Macintosh"|ppc|ppc64) - cpu="powerpc" - ;; - mips) - cpu="mips" - ;; - s390) - cpu="s390" - ;; - *) - cpu="unknown" - ;; -esac -gprof="no" -bigendian="no" -mingw32="no" -LIBSUF=".a" -EXESUF="" - -# OS specific -targetos=`uname -s` -case $targetos in -MINGW32*) -mingw32="yes" -;; -DragonFly) -noldl="yes" -;; -OpenBSD) -noldl="yes" -;; -*) ;; -esac +# Set lots of environment variables to default values. All of these are +# overridden by existing local variables. -# find source path -# XXX: we assume an absolute path is given when launching configure, -# except in './configure' case. -source_path=${0%configure} -source_path=${source_path%/} -source_path_used="yes" -if test -z "$source_path" -o "$source_path" = "." ; then - source_path=`pwd` - source_path_used="no" -fi +[ -z "$CC" ] && CC=cc +[ -z "$AR" ] && AR=ar +[ -z "$STRIP" ] && STRIP=strip +[ -z "$LIBSUF" ] && LIBSUF=.a +[ -z "$EXESUF" ] && EXESUF= +[ -z "$CFLAGS" ] && CFLAGS="-g -Wall -fsigned-char -Os -fno-strict-aliasing" +[ -z "$LIBS" ] && LIBS="-lm -ldl" +[ -z "$HOST" ] && HOST=$(uname -m | sed 's/i.86/i686/') -for opt do - case "$opt" in - --prefix=*) prefix=`echo $opt | cut -d '=' -f 2` - ;; - --exec-prefix=*) execprefix=`echo $opt | cut -d '=' -f 2` - ;; - --bindir=*) bindir=`echo $opt | cut -d '=' -f 2` - ;; - --libdir=*) libdir=`echo $opt | cut -d '=' -f 2` - ;; - --includedir=*) includedir=`echo $opt | cut -d '=' -f 2` - ;; - --mandir=*) mandir=`echo $opt | cut -d '=' -f 2` - ;; - --source-path=*) source_path=`echo $opt | cut -d '=' -f 2` - ;; - --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` - ;; - --cc=*) cc=`echo $opt | cut -d '=' -f 2` - ;; - --make=*) make=`echo $opt | cut -d '=' -f 2` - ;; - --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" - ;; - --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" - ;; - --extra-libs=*) extralibs=${opt#--extra-libs=} - ;; - --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` - ;; - --enable-gprof) gprof="yes" - ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" - ;; - --enable-cross) build_cross="yes" - ;; - esac -done +# Set the compiler's search/install paths. -# Checking for CFLAGS -if test -z "$CFLAGS"; then - CFLAGS="-O2" -fi - -cc="${cross_prefix}${cc}" -ar="${cross_prefix}${ar}" -strip="${cross_prefix}${strip}" - -if test "$mingw32" = "yes" ; then - LIBSUF=".lib" - EXESUF=".exe" -fi - -if test -z "$cross_prefix" ; then - -# --- -# big/little endian test -cat > $TMPC << EOF -#include <inttypes.h> -int main(int argc, char ** argv){ - volatile uint32_t i=0x01234567; - return (*((uint8_t*)(&i))) == 0x67; -} -EOF - -if $cc -o $TMPE $TMPC 2>/dev/null ; then -$TMPE && bigendian="yes" +if [ "$HOST" == "x86_64" ] && [ TARGET="i386" ] +then + LIB="lib32" else -echo big/little test failed -fi - -else - -# if cross compiling, cannot launch a program, so make a static guess -if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then - bigendian="yes" -fi - + LIB="lib" fi -# check gcc version -cat > $TMPC <<EOF -int main(void) { -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) -return 0; -#else -#error gcc < 3.2 -#endif -} -EOF - -gcc_major="2" -if $cc -o $TMPO $TMPC 2> /dev/null ; then - gcc_major="3" -fi - -if test x"$1" = x"-h" -o x"$1" = x"--help" ; then -cat << EOF - -Usage: configure [options] -Options: [defaults in brackets after descriptions] - -EOF -echo "Standard options:" -echo " --help print this message" -echo " --prefix=PREFIX install in PREFIX [$prefix]" -echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX" -echo " [same as prefix]" -echo " --bindir=DIR user executables in DIR [EPREFIX/bin]" -echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]" -echo " --includedir=DIR C header files in DIR [PREFIX/include]" -echo " --mandir=DIR man documentation in DIR [PREFIX/man]" -echo " --enable-cross build cross compilers" -echo "" -echo "Advanced options (experts only):" -echo " --source-path=PATH path of source code [$source_path]" -echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" -echo " --cc=CC use C compiler CC [$cc]" -echo " --make=MAKE use specified make [$make]" -echo "" -#echo "NOTE: The object files are build at the place where configure is launched" -exit 1 -fi - -if test "$mingw32" = "yes" ; then - if test -z "$prefix" ; then - prefix="/c/Program Files/tcc" - fi - execprefix="$prefix" - bindir="$prefix" - tccdir="$prefix" - docdir="$prefix/doc" -else - if test -z "$prefix" ; then - prefix="/usr" - fi - if test x"$execprefix" = x""; then - execprefix="${prefix}" - fi - if test x"$bindir" = x""; then - bindir="${execprefix}/bin" - fi - if test x"$docdir" = x""; then - docdir="$prefix/share/doc/tcc" - fi -fi # mingw32 - -if test x"$libdir" = x""; then -libdir="${execprefix}/lib" -fi -if test x"$tccdir" = x""; then -tccdir="${execprefix}/lib/tcc" -fi -if test x"$mandir" = x""; then -mandir="${prefix}/man" -fi -if test x"$includedir" = x""; then -includedir="${prefix}/include" -fi +# Directory for tinycc libraries (such as libtinycc.a) +[ -z "$TINYCC_LIBDIR" ] && TINYCC_LIBDIR=/usr/tinycc/lib +# Directory for tinycc headers (varargs.h and such) +[ -z "$TINYCC_HEADERDIR" ] && TINYCC_HEADERDIR=/usr/tinycc/include +# Where should the linker look for C runtime files (crt1.o, crti.o, crtn.o) +[ -z "$CC_CRTDIR" ] && CC_CRTDIR="/usr/$LIB" +# Path to search for system libraries. +[ -z "$CC_LIBPATH" ] && CC_LIBPATH="/usr/local/$LIB:/usr/$LIB:/$LIB" +# Path to search for system #include files. +[ -z "$CC_HEADERPATH" ] && CC_HEADERPATH="$TINYCC_HEADERDIR":/usr/include:/usr/local/include -echo "Binary directory $bindir" -echo "TinyCC directory $tccdir" -echo "Library directory $libdir" -echo "Include directory $includedir" -echo "Manual directory $mandir" -echo "Doc directory $docdir" -echo "Source path $source_path" -echo "C compiler $cc" -echo "make $make" -echo "CPU $cpu" -echo "Big Endian $bigendian" -echo "gprof enabled $gprof" -echo "cross compilers $build_cross" - -echo "Creating config.mak and config.h" - -echo "# Automatically generated by configure - do not modify" > config.mak -echo "/* Automatically generated by configure - do not modify */" > $TMPH +# For ./configure -v display all the variables we just set. -echo "prefix=$prefix" >> config.mak -echo "bindir=$bindir" >> config.mak -echo "tccdir=$tccdir" >> config.mak -echo "libdir=$libdir" >> config.mak -echo "includedir=$includedir" >> config.mak -echo "mandir=$mandir" >> config.mak -echo "docdir=$docdir" >> config.mak -echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH -echo "MAKE=$make" >> config.mak -echo "CC=$cc" >> config.mak -echo "GCC_MAJOR=$gcc_major" >> config.mak -echo "#define GCC_MAJOR $gcc_major" >> $TMPH -echo "HOST_CC=$host_cc" >> config.mak -echo "AR=$ar" >> config.mak -echo "STRIP=$strip -s -R .comment -R .note" >> config.mak -echo "CFLAGS=$CFLAGS" >> config.mak -echo "LDFLAGS=$LDFLAGS" >> config.mak -echo "LIBSUF=$LIBSUF" >> config.mak -echo "EXESUF=$EXESUF" >> config.mak -if test "$cpu" = "x86" ; then - echo "ARCH=i386" >> config.mak - echo "#define HOST_I386 1" >> $TMPH -elif test "$cpu" = "armv4l" ; then - echo "ARCH=arm" >> config.mak - echo "#define HOST_ARM 1" >> $TMPH -elif test "$cpu" = "powerpc" ; then - echo "ARCH=ppc" >> config.mak - echo "#define HOST_PPC 1" >> $TMPH -elif test "$cpu" = "mips" ; then - echo "ARCH=mips" >> config.mak - echo "#define HOST_MIPS 1" >> $TMPH -elif test "$cpu" = "s390" ; then - echo "ARCH=s390" >> config.mak - echo "#define HOST_S390 1" >> $TMPH -elif test "$cpu" = "alpha" ; then - echo "ARCH=alpha" >> config.mak - echo "#define HOST_ALPHA 1" >> $TMPH -else - echo "Unsupported CPU" - exit 1 +if [ "$1" == "-v" ] +then + for i in CC AR STRIP LIBSUF EXESUF CFLAGS LIBS HOST TINYCC_LIBDIR TINYCC_HEADERDIR CC_CRTDIR CC_LIBPATH CC_HEADERPATH + do + echo -n "$i=" + eval 'echo "$'$i'"' + done fi -if test "$noldl" = "yes" ; then - echo "CONFIG_NOLDL=yes" >> config.mak -fi -if test "$mingw32" = "yes" ; then - echo "CONFIG_WIN32=yes" >> config.mak - echo "#define CONFIG_WIN32 1" >> $TMPH -fi -if test "$bigendian" = "yes" ; then - echo "WORDS_BIGENDIAN=yes" >> config.mak - echo "#define WORDS_BIGENDIAN 1" >> $TMPH -fi -if test "$gprof" = "yes" ; then - echo "TARGET_GPROF=yes" >> config.mak - echo "#define HAVE_GPROF 1" >> $TMPH -fi -if test "$build_cross" = "yes" ; then - echo "CONFIG_CROSS=yes" >> config.mak -fi -version=`head $source_path/VERSION` -echo "VERSION=$version" >>config.mak -echo "#define TCC_VERSION \"$version\"" >> $TMPH -echo "@set VERSION $version" > config.texi - -# build tree in object directory if source path is different from current one -if test "$source_path_used" = "yes" ; then - DIRS="tests" - FILES="Makefile tests/Makefile" - for dir in $DIRS ; do - mkdir -p $dir - done - for f in $FILES ; do - ln -sf $source_path/$f $f - done -fi -echo "SRC_PATH=$source_path" >> config.mak - -diff $TMPH config.h >/dev/null 2>&1 -if test $? -ne 0 ; then - mv -f $TMPH config.h -else - echo "config.h is unchanged" -fi - -rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
--- a/libtcc.h Mon Nov 26 16:54:15 2007 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -#ifndef LIBTCC_H -#define LIBTCC_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct TCCState; - -typedef struct TCCState TCCState; - -/* create a new TCC compilation context */ -TCCState *tcc_new(void); - -/* free a TCC compilation context */ -void tcc_delete(TCCState *s); - -/* add debug information in the generated code */ -void tcc_enable_debug(TCCState *s); - -/* set error/warning display callback */ -void tcc_set_error_func(TCCState *s, void *error_opaque, - void (*error_func)(void *opaque, const char *msg)); - -/* set/reset a warning */ -int tcc_set_warning(TCCState *s, const char *warning_name, int value); - -/*****************************/ -/* preprocessor */ - -/* add include path */ -int tcc_add_include_path(TCCState *s, const char *pathname); - -/* add in system include path */ -int tcc_add_sysinclude_path(TCCState *s, const char *pathname); - -/* define preprocessor symbol 'sym'. Can put optional value */ -void tcc_define_symbol(TCCState *s, const char *sym, const char *value); - -/* undefine preprocess symbol 'sym' */ -void tcc_undefine_symbol(TCCState *s, const char *sym); - -/*****************************/ -/* compiling */ - -/* add a file (either a C file, dll, an object, a library or an ld - script). Return -1 if error. */ -int tcc_add_file(TCCState *s, const char *filename); - -/* compile a string containing a C source. Return non zero if - error. */ -int tcc_compile_string(TCCState *s, const char *buf); - -/*****************************/ -/* linking commands */ - -/* set output type. MUST BE CALLED before any compilation */ -#define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no - output file) (default) */ -#define TCC_OUTPUT_EXE 1 /* executable file */ -#define TCC_OUTPUT_DLL 2 /* dynamic library */ -#define TCC_OUTPUT_OBJ 3 /* object file */ -#define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */ -int tcc_set_output_type(TCCState *s, int output_type); - -#define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */ -#define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */ -#define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */ - -/* equivalent to -Lpath option */ -int tcc_add_library_path(TCCState *s, const char *pathname); - -/* the library name is the same as the argument of the '-l' option */ -int tcc_add_library(TCCState *s, const char *libraryname); - -/* add a symbol to the compiled program */ -int tcc_add_symbol(TCCState *s, const char *name, unsigned long val); - -/* output an executable, library or object file. DO NOT call - tcc_relocate() before. */ -int tcc_output_file(TCCState *s, const char *filename); - -/* link and run main() function and return its value. DO NOT call - tcc_relocate() before. */ -int tcc_run(TCCState *s, int argc, char **argv); - -/* do all relocations (needed before using tcc_get_symbol()). Return - non zero if link error. */ -int tcc_relocate(TCCState *s); - -/* return symbol value. return 0 if OK, -1 if symbol not found */ -int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name); - -#ifdef __cplusplus -} -#endif - -#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtinycc.h Fri Nov 30 01:59:34 2007 -0600 @@ -0,0 +1,98 @@ +#ifndef LIBTCC_H +#define LIBTCC_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct TCCState; + +typedef struct TCCState TCCState; + +/* create a new TCC compilation context */ +TCCState *tcc_new(void); + +/* free a TCC compilation context */ +void tcc_delete(TCCState *s); + +/* add debug information in the generated code */ +void tcc_enable_debug(TCCState *s); + +/* set error/warning display callback */ +void tcc_set_error_func(TCCState *s, void *error_opaque, + void (*error_func)(void *opaque, const char *msg)); + +/* set/reset a warning */ +int tcc_set_warning(TCCState *s, const char *warning_name, int value); + +/*****************************/ +/* preprocessor */ + +/* add include path */ +int tcc_add_include_path(TCCState *s, const char *pathname); + +/* add in system include path */ +int tcc_add_sysinclude_path(TCCState *s, const char *pathname); + +/* define preprocessor symbol 'sym'. Can put optional value */ +void tcc_define_symbol(TCCState *s, const char *sym, const char *value); + +/* undefine preprocess symbol 'sym' */ +void tcc_undefine_symbol(TCCState *s, const char *sym); + +/*****************************/ +/* compiling */ + +/* add a file (either a C file, dll, an object, a library or an ld + script). Return -1 if error. */ +int tcc_add_file(TCCState *s, const char *filename); + +/* compile a string containing a C source. Return non zero if + error. */ +int tcc_compile_string(TCCState *s, const char *buf); + +/*****************************/ +/* linking commands */ + +/* set output type. MUST BE CALLED before any compilation */ +#define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no + output file) (default) */ +#define TCC_OUTPUT_EXE 1 /* executable file */ +#define TCC_OUTPUT_DLL 2 /* dynamic library */ +#define TCC_OUTPUT_OBJ 3 /* object file */ +#define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */ +int tcc_set_output_type(TCCState *s, int output_type); + +#define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */ +#define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */ +#define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */ + +/* equivalent to -Lpath option */ +int tcc_add_library_path(TCCState *s, const char *pathname); + +/* the library name is the same as the argument of the '-l' option */ +int tcc_add_library(TCCState *s, const char *libraryname); + +/* add a symbol to the compiled program */ +int tcc_add_symbol(TCCState *s, const char *name, unsigned long val); + +/* output an executable, library or object file. DO NOT call + tcc_relocate() before. */ +int tcc_output_file(TCCState *s, const char *filename); + +/* link and run main() function and return its value. DO NOT call + tcc_relocate() before. */ +int tcc_run(TCCState *s, int argc, char **argv); + +/* do all relocations (needed before using tcc_get_symbol()). Return + non zero if link error. */ +int tcc_relocate(TCCState *s); + +/* return symbol value. return 0 if OK, -1 if symbol not found */ +int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name); + +#ifdef __cplusplus +} +#endif + +#endif
--- a/tcc.c Mon Nov 26 16:54:15 2007 -0600 +++ b/tcc.c Fri Nov 30 01:59:34 2007 -0600 @@ -115,7 +115,7 @@ static struct TCCState *tcc_state; /* give the path of the compiler's libraries */ -static const char *cc_lib_path = CC_LIB_PATH; +static const char *cc_lib_path = CC_LIBPATH; /********************************************************/ @@ -202,8 +202,6 @@ return ptr; } -#define malloc(s) use_tcc_malloc(s) - static void dynarray_add(void ***ptab, int *nb_ptr, void *data) { int nb, nb_alloc; @@ -244,7 +242,7 @@ } // Allocate a symbol structure by popping most recently freed one off a linked -// list, and malloc() a bunch of new ones at once if the list is empty. +// list, and xmalloc() a bunch of new ones at once if the list is empty. static inline Sym *sym_malloc(void) { Sym *sym; @@ -8846,7 +8844,7 @@ add_library_path(s, buf); } #else - add_library_path(s, TINYCC_LIBS); + add_library_path(s, TINYCC_LIBDIR); tcc_define_symbol(s, "__WCHAR_TYPE__", "int"); #endif @@ -9129,12 +9127,8 @@ /* default include paths */ /* XXX: reverse order needed if -isystem support */ -#ifndef TCC_TARGET_PE tcc_add_sysinclude_path(s, "/usr/local/include"); tcc_add_sysinclude_path(s, "/usr/include"); - snprintf(buf, sizeof(buf), "%s/include/winapi", cc_lib_path); - tcc_add_sysinclude_path(s, buf); -#endif snprintf(buf, sizeof(buf), "%s/include", cc_lib_path); tcc_add_sysinclude_path(s, buf); } @@ -9174,8 +9168,8 @@ !s->nostdlib) { if (output_type != TCC_OUTPUT_DLL) - tcc_add_file(s, TINYCC_CRTPATH "/crt1.o"); - tcc_add_file(s, TINYCC_CRTPATH "/crti.o"); + tcc_add_file(s, CC_CRTDIR "/crt1.o"); + tcc_add_file(s, CC_CRTDIR "/crti.o"); } #endif return 0;
--- a/tcc.h Mon Nov 26 16:54:15 2007 -0600 +++ b/tcc.h Fri Nov 30 01:59:34 2007 -0600 @@ -46,7 +46,7 @@ #define O_BINARY 0 #endif -#include "libtcc.h" +#include "libtinycc.h" /* parser debug */ //#define PARSE_DEBUG
--- a/tccelf.c Mon Nov 26 16:54:15 2007 -0600 +++ b/tccelf.c Fri Nov 30 01:59:34 2007 -0600 @@ -1014,7 +1014,7 @@ tcc_add_library(s1, "tinycc"); // add crt end if not memory output if (s1->output_type != TCC_OUTPUT_MEMORY) - tcc_add_file(s1, TINYCC_CRTPATH "/crtn.o"); + tcc_add_file(s1, CC_CRTDIR "/crtn.o"); } }