Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -1,50 +1,114 @@ +prefix = UNSPECIFIED +exec_prefix = @exec_prefix@ +libdir = @libdir@ + +TARGET = @TARGET@ + CC = @CC@ +CPP = @CPP@ AR = @AR@ RANLIB = @RANLIB@ CFLAGS = @CFLAGS@ @SHOBJFLAGS@ -CPPFLAGS = @CPPFLAGS@ -I@srcdir@ @DEFS@ +CPPFLAGS = @CPPFLAGS@ -I@srcdir@ -I@srcdir@/tcc -Itcc @DEFS@ LDFLAGS = SHOBJLDFLAGS = @SHOBJLDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ + PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ + +TCLCONFIGPATH = @TCLCONFIGPATH@ TCL_PACKAGE_PATH = @TCL_PACKAGE_PATH@ -PACKAGE_INSTALL_DIR = $(TCL_PACKAGE_PATH)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) -TARGETS = @TARGETS@ +tcllibdir = $(shell if echo "$(libdir)" | grep '^UNSPECIFIED' >/dev/null; then echo $(TCL_PACKAGE_PATH); else echo "$(libdir)"; fi) +PACKAGE_INSTALL_DIR = $(tcllibdir)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) +TCC_CONFIGURE_OPTS = --extra-cflags='$(CPPFLAGS) $(CFLAGS)' --with-tcl=$(TCLCONFIGPATH) --sysincludepaths='{B}/include' --libpaths='{B}/lib' @TCC_CONFIGURE_OPTS@ +INSTALL_HEADERS = tcl.h assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h time.h wctype.h srcdir = @srcdir@ - -all: $(TARGETS) - -tcltcc.o: $(srcdir)/tcltcc.c - $(CC) $(CPPFLAGS) $(CFLAGS) -o tcltcc.o -c $(srcdir)/tcltcc.c - -tcltcc-shared.@SHOBJEXT@: tcltcc.o - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SHOBJLDFLAGS) -o tcltcc-shared.@SHOBJEXT@ tcltcc.o $(LIBS) - -tcltcc-static.a: tcltcc.o - $(AR) rcu tcltcc-static.a tcltcc.o - -$(RANLIB) tcltcc-static.a - -install: $(TARGETS) pkgIndex.tcl +host_os = @host_os@ +@SET_MAKE@ + +all: $(TARGET) + +tcc/config.h: + if [ "$(srcdir)" = "." ]; then \ + cd tcc && ./configure $(TCC_CONFIGURE_OPTS); \ + else \ + mkdir tcc >/dev/null 2>/dev/null; \ + cd tcc && $(shell cd $(srcdir) && pwd)/tcc/configure $(TCC_CONFIGURE_OPTS); \ + fi + +tcc/libtcc.a: tcc/config.h + $(MAKE) -C tcc libtcc.a + +tcc/libtcc1.a: tcc/config.h + $(MAKE) -C tcc libtcc1.a + +tcc4tcl.o: $(srcdir)/tcc4tcl.c $(srcdir)/tcc/tcc.h $(srcdir)/tcc/libtcc.h tcc/config.h + $(CC) $(CPPFLAGS) $(CFLAGS) -o tcc4tcl.o -c $(srcdir)/tcc4tcl.c + +tcc4tcl.@SHOBJEXT@: tcc4tcl.o tcc/libtcc.a + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SHOBJLDFLAGS) -o tcc4tcl.@SHOBJEXT@ tcc4tcl.o tcc/libtcc.a $(LIBS) + -@WEAKENSYMS@ tcc4tcl.@SHOBJEXT@ + -@REMOVESYMS@ tcc4tcl.@SHOBJEXT@ + +tcc4tcl-static.a: tcc4tcl.o tcc/libtcc.a + cp tcc/libtcc.a tcc4tcl-static.new.a + $(AR) rcu tcc4tcl-static.new.a tcc4tcl.o + -$(RANLIB) tcc4tcl-static.new.a + mv tcc4tcl-static.new.a tcc4tcl-static.a + +install: $(TARGET) pkgIndex.tcl $(srcdir)/tcc4tcl.tcl tcc/libtcc1.a $(shell echo $(srcdir)/tcc/include/*) $(srcdir)/headers.awk $(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)" + $(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib" + $(INSTALL) -d "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include" + $(INSTALL) -m 0755 $(TARGET) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)" $(INSTALL) -m 0644 pkgIndex.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)" - $(INSTALL) -m 0755 $(TARGETS) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)" + $(INSTALL) -m 0644 $(srcdir)/tcc4tcl.tcl "$(DESTDIR)$(PACKAGE_INSTALL_DIR)" + $(INSTALL) -m 0644 tcc/libtcc1.a "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib" + $(INSTALL) -m 0644 $(shell echo $(srcdir)/tcc/include/*) "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include" + @if ! echo "_WIN32" | $(CPP) $(CPPFLAGS) - | grep '^_WIN32$$' >/dev/null; then \ + echo cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \ + cp -r $(srcdir)/tcc/win32/include/* "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/"; \ + echo cp -r $(srcdir)/tcc/win32/lib/*.def "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib/"; \ + cp -r $(srcdir)/tcc/win32/lib/*.def "$(DESTDIR)$(PACKAGE_INSTALL_DIR)/lib/"; \ + fi + ( for file in $(INSTALL_HEADERS); do echo "#include <$${file}>"; done ) | \ + $(CPP) $(CPPFLAGS) $(CFLAGS) -I$(srcdir)/tcc/include -I$(srcdir)/tcc/include - | awk -f $(srcdir)/headers.awk | while read src dst; do \ + dst="$(DESTDIR)$(PACKAGE_INSTALL_DIR)/include/$$dst"; \ + if [ -e "$${dst}" ]; then continue; fi; \ + dstdir="$$(dirname "$$dst")"; \ + echo mkdir -p "$$dstdir"; \ + mkdir -p "$$dstdir"; \ + echo cp "$$src" "$$dst"; \ + cp "$$src" "$$dst"; \ + done + +test: + rm -rf __TMP__ + $(MAKE) install tcllibdir=$(shell pwd)/__TMP__ + cd __TMP__/* && ../../test + echo Tests Completed OK > TEST-STATUS + rm -rf __TMP__ clean: - rm -f tcltcc.o - rm -f tcltcc-shared.@SHOBJEXT@ tcltcc-static.a - rm -f tcltcc-shared.@SHOBJEXT@.a tcltcc-shared.@SHOBJEXT@.def + rm -f tcc4tcl.o + rm -f tcc4tcl.@SHOBJEXT@ tcc4tcl-static.a + rm -f tcc4tcl.@SHOBJEXT@.a tcc4tcl.@SHOBJEXT@.def + rm -rf __TMP__ + rm -f TEST-STATUS + -$(MAKE) -C tcc clean distclean: clean rm -rf autom4te.cache rm -f config.log config.status - rm -f pkgIndex.tcl + rm -f pkgIndex.tcl tcc4tcl.syms tcc4tcl.vers rm -f Makefile + -$(MAKE) -C tcc distclean mrproper: distclean - rm -rf __TMP__ tcc + rm -rf tcc rm -f configure aclocal.m4 rm -f config.guess config.sub install-sh -.PHONY: all install clean distclean mrproper +.PHONY: all install test clean distclean mrproper Index: build/pre.sh ================================================================== --- build/pre.sh +++ build/pre.sh @@ -4,27 +4,39 @@ # Generate configure script ./build/autogen.sh # Download TCC +tcc_version='0.9.26' +tcc_url="http://download.savannah.gnu.org/releases/tinycc/tcc-${tcc_version}.tar.bz2" +tcc_sha256='521e701ae436c302545c3f973a9c9b7e2694769c71d9be10f70a2460705b6d71' ( - TCC_VERSION="0.9.26" - TCC_URL="http://download.savannah.gnu.org/releases/tinycc/tcc-${TCC_VERSION}.tar.bz2" - TCC_SHA256='521e701ae436c302545c3f973a9c9b7e2694769c71d9be10f70a2460705b6d71' - rm -rf __TMP__ mkdir __TMP__ || exit 1 cd __TMP__ || exit 1 - wget -O tcc.tar.bz2.new "${TCC_URL}" || rm -f tcc.tar.bz2.new - TCC_NEW_SHA256="$(openssl sha256 < tcc.tar.bz2.new | sed 's@.*= *@@')" + + wget -O 'new' "${tcc_url}" || rm -f new + new_sha256="$(openssl sha256 new | sed 's@.*= *@@')" + + if [ "${new_sha256}" != "${tcc_sha256}" ]; then + echo "Checksum Mismatch: Downloaded: ${new_sha256}; Expected: ${tcc_sha256}" >&2 + + rm -f new - if [ "${TCC_NEW_SHA256}" = "${TCC_SHA256}" ]; then - mv tcc.tar.bz2.new tcc.tar.bz2 + exit 1 fi - tar -xf tcc.tar.bz2 - rm -f tcc.tar.bz2 + mv new "tcc-${tcc_version}.tar.bz2" + + bzip2 -dc "tcc-${tcc_version}.tar.bz2" | tar -xf - + + rm -f "tcc-${tcc_version}.tar.bz2" + + ## Apply patches + for patchfile in ../build/tcc-patches/${tcc_version}/*.diff; do + ( cd * && patch -p1 ) < "${patchfile}" + done rm -rf ../tcc mkdir ../tcc || exit 1 mv */* ../tcc/ ) Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -4,34 +4,72 @@ dnl Checks for programs. AC_PROG_CC AC_PROG_MAKE_SET AC_PROG_INSTALL AC_GNU_SOURCE +AC_LANG(C) dnl Determine system information DC_CHK_OS_INFO dnl Determine if a shared or static build is requested AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], [build static library instead of shared library]), [ if test "$enableval" = "no"; then - target=shared + TCC4TCL_TARGET=static else - target=static + TCC4TCL_TARGET=shared fi ], [ - target=shared + TCC4TCL_TARGET=shared ]) -if test "${target}" = "shared"; then +dnl Configure TCC build options +AC_SUBST(TCC_CONFIGURE_OPTS) +TCC_CONFIGURE_OPTS="" + +dnl -- If cross-compiling, specify a "--cross-prefix" and define the CPU +if test "${host}" != "${build}"; then + TCC_CONFIGURE_OPTS="${TCC_CONFIGURE_OPTS} --cross-prefix=${host_alias}- --cpu=${host_cpu} --os=${host_os}" +fi + +if test "${TCC4TCL_TARGET}" = "shared"; then dnl Determine how to make shared objects DC_GET_SHOBJFLAGS - TARGETS="tcltcc-shared.${SHOBJEXT}" + dnl Only export symbols we wish to expose + TARGET="tcc4tcl.${SHOBJEXT}" + + AC_CHECK_HEADERS(windows.h) + AC_CHECK_HEADERS(psapi.h,,, [ +#ifdef HAVE_WINDOWS_H +# include +#endif +]) + + AC_MSG_CHECKING([for EnumProcessModules in -lpsapi]) + SAVE_LIBS="$LIBS" + LIBS="-lpsapi $LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#ifdef HAVE_WINDOWS_H +# include +#endif +#ifdef HAVE_PSAPI_H +# include +#endif +], [ + EnumProcessModules(NULL, NULL, 0, NULL); +])], [ + AC_MSG_RESULT([found]) +], [ + AC_MSG_RESULT([not found]) + LIBS="$SAVE_LIBS" +]) else - TARGETS="tcltcc-static.a" + TARGET="tcc4tcl-static.a" fi -AC_SUBST(TARGETS) +AC_SUBST(TARGET) +AC_SUBST(TCC4TCL_TARGET) dnl Find out if we have the functions needed to open shared objects AC_SEARCH_LIBS(dlopen, dl,, [ AC_SEARCH_LIBS(shl_load, dld dl) ]) @@ -40,8 +78,14 @@ dnl Look for appropriate headers AC_CHECK_HEADERS(unistd.h stdlib.h string.h strings.h dlfcn.h dl.h) dnl Perform Tcl Extension required stuff TCLEXT_INIT + +dnl This must be done last since it breaks the compilation +if test "${TCC4TCL_TARGET}" = "shared"; then + DC_SETVERSIONSCRIPT([tcc4tcl.syms], [tcc4tcl.vers]) + DC_FIND_STRIP_AND_REMOVESYMS([tcc4tcl.syms]) +fi dnl Produce output -AC_OUTPUT(Makefile pkgIndex.tcl) +AC_OUTPUT(Makefile pkgIndex.tcl tcc4tcl.syms)