* 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.
Unified · Split
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | TOP ?= . |
| 6 | 6 | include $(TOP)/config.mak |
| 7 | +VPATH = $(top_srcdir) | |
| 7 | 8 | |
| 8 | 9 | CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC |
| 9 | 10 | CFLAGS_P=$(CFLAGS) -pg -static |
| @@ -356,11 +357,11 @@ tcc-doc.html: tcc-doc.texi · 346 unmodified lines | ||
| 356 | 357 | -texi2html -monolithic -number $< |
| 357 | 358 | |
| 358 | 359 | tcc.1: tcc-doc.texi |
| 359 | − -./texi2pod.pl $< tcc.pod | |
| 360 | + -$(top_srcdir)/texi2pod.pl $< tcc.pod | |
| 360 | 361 | -pod2man --section=1 --center=" " --release=" " tcc.pod > $@ |
| 361 | 362 | |
| 362 | 363 | tcc-doc.info: tcc-doc.texi |
| 363 | − -makeinfo tcc-doc.texi | |
| 364 | + -makeinfo $< | |
| 364 | 365 | |
| 365 | 366 | .PHONY: all clean tar distclean install uninstall FORCE |
| 366 | 367 | |
| @@ -35,6 +35,16 @@ Documentation: · 34 unmodified lines | ||
| 35 | 35 | make test |
| 36 | 36 | make install |
| 37 | 37 | |
| 38 | +Alternatively, VPATH builds are supported: you may use different | |
| 39 | +directories to old build objects, kept separate from your source tree: | |
| 40 | + | |
| 41 | + mkdir _build | |
| 42 | + cd _build | |
| 43 | + ../configure | |
| 44 | + make | |
| 45 | + make test | |
| 46 | + make install | |
| 47 | + | |
| 38 | 48 | By default, tcc is installed in /usr/local/bin. |
| 39 | 49 | ./configure --help shows configuration options. |
| 40 | 50 | |
| @@ -2,6 +2,14 @@ · 1 unmodified line | ||
| 2 | 2 | # |
| 3 | 3 | # tcc configure script (c) 2003 Fabrice Bellard |
| 4 | 4 | |
| 5 | +fn_dirname() | |
| 6 | +{ | |
| 7 | + case $1 in | |
| 8 | + */*) echo "$1" | sed -e 's,/[^/]*,,';; | |
| 9 | + *) echo '.' | |
| 10 | + esac | |
| 11 | +} | |
| 12 | + | |
| 5 | 13 | # set temporary file name |
| 6 | 14 | if test ! -z "$TMPDIR" ; then |
| 7 | 15 | TMPDIR1="${TMPDIR}" |
| @@ -411,10 +419,13 @@ echo "#define GCC_MAJOR $gcc_major" >> $TMPH · 403 unmodified lines | ||
| 411 | 419 | echo "HOST_CC=$host_cc" >> config.mak |
| 412 | 420 | echo "AR=$ar" >> config.mak |
| 413 | 421 | echo "STRIP=$strip -s -R .comment -R .note" >> config.mak |
| 414 | −echo "CFLAGS=$CFLAGS" >> config.mak | |
| 415 | −echo "LDFLAGS=$LDFLAGS" >> config.mak | |
| 416 | −echo "LIBSUF=$LIBSUF" >> config.mak | |
| 417 | −echo "EXESUF=$EXESUF" >> config.mak | |
| 422 | +cat >> config.mak <<EOF | |
| 423 | +CPPFLAGS = -I. -I\$(top_srcdir) | |
| 424 | +CFLAGS=$CFLAGS | |
| 425 | +LDFLAGS=$LDFLAGS | |
| 426 | +LIBSUF=$LIBSUF | |
| 427 | +EXESUF=$EXESUF | |
| 428 | +EOF | |
| 418 | 429 | |
| 419 | 430 | if test "$cpu" = "x86" ; then |
| 420 | 431 | echo "ARCH=i386" >> config.mak |
| @@ -491,16 +502,23 @@ echo "@set VERSION $version" > config.texi · 70 unmodified lines | ||
| 491 | 502 | |
| 492 | 503 | # build tree in object directory if source path is different from current one |
| 493 | 504 | if test "$source_path_used" = "yes" ; then |
| 494 | − DIRS="tests" | |
| 495 | − FILES="Makefile tests/Makefile" | |
| 496 | − for dir in $DIRS ; do | |
| 497 | − mkdir -p $dir | |
| 498 | − done | |
| 505 | + FILES="Makefile lib/Makefile tests/Makefile tests2/Makefile" | |
| 499 | 506 | for f in $FILES ; do |
| 500 | − ln -sf $source_path/$f $f | |
| 507 | + dir=`fn_dirname "$f"` | |
| 508 | + test -d "$dir" || mkdir -p "$dir" | |
| 509 | + back=`echo "$source_path/$dir/" | sed 's,/\./,/,g;s,[^/]*/,../,g'` | |
| 510 | + back=$back$f | |
| 511 | + ln -sf $back $f | |
| 501 | 512 | done |
| 502 | 513 | fi |
| 503 | −echo "SRC_PATH=$source_path" >> config.mak | |
| 514 | +cat >>config.mak <<EOF | |
| 515 | +SRC_PATH = $source_path | |
| 516 | +top_builddir = \$(TOP) | |
| 517 | +EOF | |
| 518 | +case $source_path in | |
| 519 | + /*) echo 'top_srcdir = $(SRC_PATH)';; | |
| 520 | + *) echo 'top_srcdir = $(TOP)/$(SRC_PATH)';; | |
| 521 | +esac >>config.mak | |
| 504 | 522 | |
| 505 | 523 | diff $TMPH config.h >/dev/null 2>&1 |
| 506 | 524 | if test $? -ne 0 ; then |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | TOP = .. |
| 6 | 6 | include $(TOP)/config.mak |
| 7 | +VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib | |
| 7 | 8 | |
| 8 | 9 | ifndef TARGET |
| 9 | 10 | ifdef CONFIG_WIN64 |
| @@ -42,8 +43,6 @@ X86_64_O = libtcc1.o alloca86_64.o · 32 unmodified lines | ||
| 42 | 43 | WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o |
| 43 | 44 | WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o |
| 44 | 45 | |
| 45 | −VPATH = $(TOP)/lib $(TOP)/win32/lib | |
| 46 | − | |
| 47 | 46 | ifeq "$(TARGET)" "i386-win32" |
| 48 | 47 | OBJ = $(addprefix $(DIR)/,$(WIN32_O)) |
| 49 | 48 | TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | TOP = .. |
| 6 | 6 | include $(TOP)/Makefile |
| 7 | +VPATH = $(top_srcdir)/tests | |
| 7 | 8 | |
| 8 | 9 | # what tests to run |
| 9 | 10 | TESTS = libtest \ |
| @@ -56,7 +57,7 @@ endif · 46 unmodified lines | ||
| 56 | 57 | # run local version of tcc with local libraries and includes |
| 57 | 58 | TCC = ../tcc -B.. $(NATIVE_DEFINES) |
| 58 | 59 | ifdef CONFIG_WIN32 |
| 59 | − TCC := $(TCC) -I $(TOP)/win32/include -L$(TOP) | |
| 60 | + TCC := $(TCC) -I $(top_srcdir)/win32/include -L$(top_build) | |
| 60 | 61 | endif |
| 61 | 62 | RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B.. |
| 62 | 63 | DISAS=objdump -d |
| @@ -77,8 +78,8 @@ libtest: libtcc_test$(EXESUF) $(LIBTCC1) · 14 unmodified lines | ||
| 77 | 78 | @echo ------------ $@ ------------ |
| 78 | 79 | ./libtcc_test$(EXESUF) lib_path=.. |
| 79 | 80 | |
| 80 | −libtcc_test$(EXESUF): libtcc_test.c ../$(LIBTCC) | |
| 81 | − $(CC) -o $@ $^ -I.. $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) | |
| 81 | +libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) | |
| 82 | + $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) | |
| 82 | 83 | |
| 83 | 84 | # test.ref - generate using gcc |
| 84 | 85 | # copy only tcclib.h so GCC's stddef and stdarg will be used |
| @@ -169,9 +170,9 @@ btest: boundtest.c ../bcheck.o · 84 unmodified lines | ||
| 169 | 170 | speedtest: ex2 ex3 |
| 170 | 171 | @echo ------------ $@ ------------ |
| 171 | 172 | time ./ex2 1238 2 3 4 10 13 4 |
| 172 | − time $(TCC) -run ../examples/ex2.c 1238 2 3 4 10 13 4 | |
| 173 | + time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4 | |
| 173 | 174 | time ./ex3 35 |
| 174 | − time $(TCC) -run ../examples/ex3.c 35 | |
| 175 | + time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 | |
| 175 | 176 | |
| 176 | 177 | weaktest: test.ref |
| 177 | 178 | $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) |
| @@ -180,7 +181,7 @@ weaktest: test.ref · 2 unmodified lines | ||
| 180 | 181 | objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt |
| 181 | 182 | diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" |
| 182 | 183 | |
| 183 | −ex%: ../examples/ex%.c | |
| 184 | +ex%: $(top_srcdir)/examples/ex%.c | |
| 184 | 185 | $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) |
| 185 | 186 | |
| 186 | 187 | # tiny assembler testing |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | TOP = .. |
| 2 | 2 | include $(TOP)/Makefile |
| 3 | +VPATH = $(top_srcdir)/tests2 | |
| 3 | 4 | |
| 4 | 5 | ifeq ($(TARGETOS),Darwin) |
| 5 | 6 | CFLAGS+=-Wl,-flat_namespace,-undefined,warning |
| @@ -77,15 +78,15 @@ ifdef CONFIG_WIN32 · 71 unmodified lines | ||
| 77 | 78 | TESTS := $(filter-out 28_strings.test,$(TESTS)) |
| 78 | 79 | endif |
| 79 | 80 | |
| 80 | −%.test: %.expect %.c | |
| 81 | +%.test: %.c %.expect | |
| 81 | 82 | @echo Test: $*... |
| 82 | 83 | @if [ "x`echo $* | grep args`" != "x" ]; \ |
| 83 | 84 | then \ |
| 84 | − ../tcc -B.. $(TCCFLAGS) -run $*.c - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ | |
| 85 | + ../tcc -B.. $(TCCFLAGS) -run $< - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ | |
| 85 | 86 | else \ |
| 86 | − ../tcc -B.. $(TCCFLAGS) -run $*.c 2>&1 >$*.output; \ | |
| 87 | + ../tcc -B.. $(TCCFLAGS) -run $< 2>&1 >$*.output; \ | |
| 87 | 88 | fi |
| 88 | − @if diff -bu $*.expect $*.output ; \ | |
| 89 | + @if diff -bu $(<:.c=.expect) $*.output ; \ | |
| 89 | 90 | then \ |
| 90 | 91 | rm -f $*.output \ |
| 91 | 92 | else \ |