mirror of
https://github.com/frida/tinycc
synced 2024-12-25 14:36:49 +03:00
build: fix VPATH builds
* configure (fn_dirname): New. Use it to ensure the creation of proper symlinks to Makefiles. (config.mak): Define top_builddir and top_srcdir. (CPPFLAGS): Be sure to find the headers. * Makefile, lib/Makefile, tests/Makefile, tests2/Makefile: Adjust to set VPATH properly. Fix confusion between top_builddir and top_srcdir.
This commit is contained in:
parent
d815896d4c
commit
3f09b90d21
5
Makefile
5
Makefile
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
TOP ?= .
|
TOP ?= .
|
||||||
include $(TOP)/config.mak
|
include $(TOP)/config.mak
|
||||||
|
VPATH = $(top_srcdir)
|
||||||
|
|
||||||
CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
|
CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
|
||||||
CFLAGS_P=$(CFLAGS) -pg -static
|
CFLAGS_P=$(CFLAGS) -pg -static
|
||||||
@ -356,11 +357,11 @@ tcc-doc.html: tcc-doc.texi
|
|||||||
-texi2html -monolithic -number $<
|
-texi2html -monolithic -number $<
|
||||||
|
|
||||||
tcc.1: tcc-doc.texi
|
tcc.1: tcc-doc.texi
|
||||||
-./texi2pod.pl $< tcc.pod
|
-$(top_srcdir)/texi2pod.pl $< tcc.pod
|
||||||
-pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
-pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
||||||
|
|
||||||
tcc-doc.info: tcc-doc.texi
|
tcc-doc.info: tcc-doc.texi
|
||||||
-makeinfo tcc-doc.texi
|
-makeinfo $<
|
||||||
|
|
||||||
.PHONY: all clean tar distclean install uninstall FORCE
|
.PHONY: all clean tar distclean install uninstall FORCE
|
||||||
|
|
||||||
|
10
README
10
README
@ -35,6 +35,16 @@ Documentation:
|
|||||||
make test
|
make test
|
||||||
make install
|
make install
|
||||||
|
|
||||||
|
Alternatively, VPATH builds are supported: you may use different
|
||||||
|
directories to old build objects, kept separate from your source tree:
|
||||||
|
|
||||||
|
mkdir _build
|
||||||
|
cd _build
|
||||||
|
../configure
|
||||||
|
make
|
||||||
|
make test
|
||||||
|
make install
|
||||||
|
|
||||||
By default, tcc is installed in /usr/local/bin.
|
By default, tcc is installed in /usr/local/bin.
|
||||||
./configure --help shows configuration options.
|
./configure --help shows configuration options.
|
||||||
|
|
||||||
|
40
configure
vendored
40
configure
vendored
@ -2,6 +2,14 @@
|
|||||||
#
|
#
|
||||||
# tcc configure script (c) 2003 Fabrice Bellard
|
# tcc configure script (c) 2003 Fabrice Bellard
|
||||||
|
|
||||||
|
fn_dirname()
|
||||||
|
{
|
||||||
|
case $1 in
|
||||||
|
*/*) echo "$1" | sed -e 's,/[^/]*,,';;
|
||||||
|
*) echo '.'
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# set temporary file name
|
# set temporary file name
|
||||||
if test ! -z "$TMPDIR" ; then
|
if test ! -z "$TMPDIR" ; then
|
||||||
TMPDIR1="${TMPDIR}"
|
TMPDIR1="${TMPDIR}"
|
||||||
@ -411,10 +419,13 @@ echo "#define GCC_MAJOR $gcc_major" >> $TMPH
|
|||||||
echo "HOST_CC=$host_cc" >> config.mak
|
echo "HOST_CC=$host_cc" >> config.mak
|
||||||
echo "AR=$ar" >> config.mak
|
echo "AR=$ar" >> config.mak
|
||||||
echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
|
echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
|
||||||
echo "CFLAGS=$CFLAGS" >> config.mak
|
cat >> config.mak <<EOF
|
||||||
echo "LDFLAGS=$LDFLAGS" >> config.mak
|
CPPFLAGS = -I. -I\$(top_srcdir)
|
||||||
echo "LIBSUF=$LIBSUF" >> config.mak
|
CFLAGS=$CFLAGS
|
||||||
echo "EXESUF=$EXESUF" >> config.mak
|
LDFLAGS=$LDFLAGS
|
||||||
|
LIBSUF=$LIBSUF
|
||||||
|
EXESUF=$EXESUF
|
||||||
|
EOF
|
||||||
|
|
||||||
if test "$cpu" = "x86" ; then
|
if test "$cpu" = "x86" ; then
|
||||||
echo "ARCH=i386" >> config.mak
|
echo "ARCH=i386" >> config.mak
|
||||||
@ -491,16 +502,23 @@ echo "@set VERSION $version" > config.texi
|
|||||||
|
|
||||||
# build tree in object directory if source path is different from current one
|
# build tree in object directory if source path is different from current one
|
||||||
if test "$source_path_used" = "yes" ; then
|
if test "$source_path_used" = "yes" ; then
|
||||||
DIRS="tests"
|
FILES="Makefile lib/Makefile tests/Makefile tests2/Makefile"
|
||||||
FILES="Makefile tests/Makefile"
|
|
||||||
for dir in $DIRS ; do
|
|
||||||
mkdir -p $dir
|
|
||||||
done
|
|
||||||
for f in $FILES ; do
|
for f in $FILES ; do
|
||||||
ln -sf $source_path/$f $f
|
dir=`fn_dirname "$f"`
|
||||||
|
test -d "$dir" || mkdir -p "$dir"
|
||||||
|
back=`echo "$source_path/$dir/" | sed 's,/\./,/,g;s,[^/]*/,../,g'`
|
||||||
|
back=$back$f
|
||||||
|
ln -sf $back $f
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo "SRC_PATH=$source_path" >> config.mak
|
cat >>config.mak <<EOF
|
||||||
|
SRC_PATH = $source_path
|
||||||
|
top_builddir = \$(TOP)
|
||||||
|
EOF
|
||||||
|
case $source_path in
|
||||||
|
/*) echo 'top_srcdir = $(SRC_PATH)';;
|
||||||
|
*) echo 'top_srcdir = $(TOP)/$(SRC_PATH)';;
|
||||||
|
esac >>config.mak
|
||||||
|
|
||||||
diff $TMPH config.h >/dev/null 2>&1
|
diff $TMPH config.h >/dev/null 2>&1
|
||||||
if test $? -ne 0 ; then
|
if test $? -ne 0 ; then
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
TOP = ..
|
TOP = ..
|
||||||
include $(TOP)/config.mak
|
include $(TOP)/config.mak
|
||||||
|
VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
|
||||||
|
|
||||||
ifndef TARGET
|
ifndef TARGET
|
||||||
ifdef CONFIG_WIN64
|
ifdef CONFIG_WIN64
|
||||||
@ -42,8 +43,6 @@ X86_64_O = libtcc1.o alloca86_64.o
|
|||||||
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o
|
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o
|
||||||
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
||||||
|
|
||||||
VPATH = $(TOP)/lib $(TOP)/win32/lib
|
|
||||||
|
|
||||||
ifeq "$(TARGET)" "i386-win32"
|
ifeq "$(TARGET)" "i386-win32"
|
||||||
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
|
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
|
||||||
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
TOP = ..
|
TOP = ..
|
||||||
include $(TOP)/Makefile
|
include $(TOP)/Makefile
|
||||||
|
VPATH = $(top_srcdir)/tests
|
||||||
|
|
||||||
# what tests to run
|
# what tests to run
|
||||||
TESTS = libtest \
|
TESTS = libtest \
|
||||||
@ -56,7 +57,7 @@ endif
|
|||||||
# run local version of tcc with local libraries and includes
|
# run local version of tcc with local libraries and includes
|
||||||
TCC = ../tcc -B.. $(NATIVE_DEFINES)
|
TCC = ../tcc -B.. $(NATIVE_DEFINES)
|
||||||
ifdef CONFIG_WIN32
|
ifdef CONFIG_WIN32
|
||||||
TCC := $(TCC) -I $(TOP)/win32/include -L$(TOP)
|
TCC := $(TCC) -I $(top_srcdir)/win32/include -L$(top_build)
|
||||||
endif
|
endif
|
||||||
RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B..
|
RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B..
|
||||||
DISAS=objdump -d
|
DISAS=objdump -d
|
||||||
@ -77,8 +78,8 @@ libtest: libtcc_test$(EXESUF) $(LIBTCC1)
|
|||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
./libtcc_test$(EXESUF) lib_path=..
|
./libtcc_test$(EXESUF) lib_path=..
|
||||||
|
|
||||||
libtcc_test$(EXESUF): libtcc_test.c ../$(LIBTCC)
|
libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC)
|
||||||
$(CC) -o $@ $^ -I.. $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS)
|
$(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS)
|
||||||
|
|
||||||
# test.ref - generate using gcc
|
# test.ref - generate using gcc
|
||||||
# copy only tcclib.h so GCC's stddef and stdarg will be used
|
# copy only tcclib.h so GCC's stddef and stdarg will be used
|
||||||
@ -169,9 +170,9 @@ btest: boundtest.c ../bcheck.o
|
|||||||
speedtest: ex2 ex3
|
speedtest: ex2 ex3
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
time ./ex2 1238 2 3 4 10 13 4
|
time ./ex2 1238 2 3 4 10 13 4
|
||||||
time $(TCC) -run ../examples/ex2.c 1238 2 3 4 10 13 4
|
time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4
|
||||||
time ./ex3 35
|
time ./ex3 35
|
||||||
time $(TCC) -run ../examples/ex3.c 35
|
time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
|
||||||
|
|
||||||
weaktest: test.ref
|
weaktest: test.ref
|
||||||
$(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
|
$(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
|
||||||
@ -180,7 +181,7 @@ weaktest: test.ref
|
|||||||
objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
|
objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
|
||||||
diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
|
diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
|
||||||
|
|
||||||
ex%: ../examples/ex%.c
|
ex%: $(top_srcdir)/examples/ex%.c
|
||||||
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
# tiny assembler testing
|
# tiny assembler testing
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
TOP = ..
|
TOP = ..
|
||||||
include $(TOP)/Makefile
|
include $(TOP)/Makefile
|
||||||
|
VPATH = $(top_srcdir)/tests2
|
||||||
|
|
||||||
ifeq ($(TARGETOS),Darwin)
|
ifeq ($(TARGETOS),Darwin)
|
||||||
CFLAGS+=-Wl,-flat_namespace,-undefined,warning
|
CFLAGS+=-Wl,-flat_namespace,-undefined,warning
|
||||||
@ -77,15 +78,15 @@ ifdef CONFIG_WIN32
|
|||||||
TESTS := $(filter-out 28_strings.test,$(TESTS))
|
TESTS := $(filter-out 28_strings.test,$(TESTS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.test: %.expect %.c
|
%.test: %.c %.expect
|
||||||
@echo Test: $*...
|
@echo Test: $*...
|
||||||
@if [ "x`echo $* | grep args`" != "x" ]; \
|
@if [ "x`echo $* | grep args`" != "x" ]; \
|
||||||
then \
|
then \
|
||||||
../tcc -B.. $(TCCFLAGS) -run $*.c - arg1 arg2 arg3 arg4 2>&1 >$*.output; \
|
../tcc -B.. $(TCCFLAGS) -run $< - arg1 arg2 arg3 arg4 2>&1 >$*.output; \
|
||||||
else \
|
else \
|
||||||
../tcc -B.. $(TCCFLAGS) -run $*.c 2>&1 >$*.output; \
|
../tcc -B.. $(TCCFLAGS) -run $< 2>&1 >$*.output; \
|
||||||
fi
|
fi
|
||||||
@if diff -bu $*.expect $*.output ; \
|
@if diff -bu $(<:.c=.expect) $*.output ; \
|
||||||
then \
|
then \
|
||||||
rm -f $*.output \
|
rm -f $*.output \
|
||||||
else \
|
else \
|
||||||
|
Loading…
Reference in New Issue
Block a user