Reorganize the source tree.

* Documentation is now in "docs".
 * Source code is now in "src".
 * Misc. fixes here and there so that everything still works.

I think I got everything in this commit, but I only tested this
on Linux (Make) and Windows (CMake), so I might've messed
something up on other platforms...
This commit is contained in:
gus knight 2015-07-27 16:03:25 -04:00 committed by Augustin Cavalier
parent 694d0fdade
commit 47e06c6d4e
45 changed files with 90 additions and 91 deletions

4
.gitignore vendored
View File

@ -5,7 +5,7 @@ a.out
*.log
tcc_g
tcc
/*-tcc
/src/*-tcc
tc2.c
doc
tc3s.c
@ -63,7 +63,7 @@ lib/i386-win32
lib/arm
lib/arm64
tcc-doc.info
conftest*
conftest*!conftest.c
tiny_libmaker
*.dSYM
*~

View File

@ -85,14 +85,14 @@ endif()
file(STRINGS "VERSION" TCC_VERSION)
list(GET TCC_VERSION 0 TCC_VERSION)
include_directories(${CMAKE_BINARY_DIR})
configure_file(config.h.in config.h)
configure_file(config.texi.in config.texi)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h)
configure_file(docs/config.texi.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/config.texi)
# Utility variables
set(I386_SOURCES i386-gen.c i386-asm.c i386-asm.h i386-tok.h)
set(X86_64_SOURCES x86_64-gen.c i386-asm.c x86_64-asm.h)
set(ARM_SOURCES arm_gen.c)
set(I386_SOURCES src/x86/i386-gen.c src/x86/i386-asm.c src/x86/i386-asm.h src/x86/i386-tok.h)
set(X86_64_SOURCES src/x86/x86_64-gen.c src/x86/i386-asm.c src/x86/x86_64-asm.h)
set(ARM_SOURCES src/arm/arm_gen.c)
set(LIBTCC1_I386_SOURCES lib/alloca86.S lib/alloca86-bt.S)
set(LIBTCC1_WIN_SOURCES win32/lib/crt1.c win32/lib/wincrt1.c win32/lib/dllcrt1.c win32/lib/dllmain.c win32/lib/chkstk.S)
@ -157,22 +157,22 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt
if (TCC_BUILD_NATIVE)
add_library(libtcc
libtcc.c
tccpp.c
tccgen.c
tccelf.c
tccasm.c
tccrun.c
tcc.h
libtcc.h
tcctok.h
src/libtcc.c
src/tccpp.c
src/tccgen.c
src/tccelf.c
src/tccasm.c
src/tccrun.c
src/tcc.h
src/libtcc.h
src/tcctok.h
${tcc_sources}
)
set_target_properties(libtcc PROPERTIES OUTPUT_NAME tcc PREFIX lib)
if(WIN32)
set_target_properties(libtcc PROPERTIES LINK_FLAGS "-Wl,--output-def,libtcc.def")
endif()
add_executable(tcc tcc.c)
add_executable(tcc src/tcc.c)
target_link_libraries(tcc libtcc)
if(NOT WIN32)
target_link_libraries(tcc dl)
@ -185,7 +185,7 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt
endif()
endif()
elseif(${cross_enabled})
add_executable(${cross_name}-tcc tcc.c)
add_executable(${cross_name}-tcc src/tcc.c)
set_target_properties(${cross_name}-tcc PROPERTIES COMPILE_DEFINITIONS "ONE_SOURCE;${definitions}")
install(TARGETS ${cross_name}-tcc RUNTIME DESTINATION ${EXE_PATH})
@ -197,17 +197,17 @@ endmacro()
make_tcc("Win32" i386-w64-mingw32 TCC_BUILD_WIN32
"TCC_TARGET_I386;TCC_TARGET_PE"
"${I386_SOURCES};tccpe.c"
"${I386_SOURCES};src/tccpe.c"
tiny_libmaker_32 "${LIBTCC1_I386_SOURCES};${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi"
)
make_tcc("Win64" x86_64-w64-mingw32 TCC_BUILD_WIN64
"TCC_TARGET_X86_64;TCC_TARGET_PE"
"${X86_64_SOURCES};tccpe.c"
"${X86_64_SOURCES};src/tccpe.c"
tiny_libmaker_64 "lib/alloca86_64.S;${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi"
)
make_tcc("WinCE" arm-wince-mingw32ce TCC_BUILD_WINCE
"TCC_TARGET_ARM;TCC_ARM_VERSION=${TCC_ARM_VERSION};TCC_TARGET_PE"
"${ARM_SOURCES};tccpe.c"
"${ARM_SOURCES};src/tccpe.c"
"" "" ""
)
make_tcc("i386" i386-linux-gnu TCC_BUILD_I386
@ -248,7 +248,7 @@ make_tcc("" arm-linux-gnu TCC_BUILD_ARM_VFP
)
make_tcc("" c67 TCC_BUILD_C67
TCC_TARGET_C67
"c67-gen.c;tcccoff.c"
"c67-gen.c;src/tcccoff.c"
"" "" ""
)
@ -257,14 +257,14 @@ add_subdirectory(tests)
find_program(MAKEINFO NAMES makeinfo PATHS C:/MinGW/MSYS/1.0/bin)
if(MAKEINFO)
add_custom_command(OUTPUT tcc-doc.html
COMMAND ${MAKEINFO} --no-split --html -o tcc-doc.html ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
COMMAND ${MAKEINFO} --no-split --html -o tcc-doc.html ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
)
set(TCC_DOC_FILES tcc-doc.html)
if(NOT WIN32)
add_custom_command(OUTPUT tcc-doc.info
COMMAND ${MAKEINFO} -o tcc-doc.info ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tcc-doc.texi
COMMAND ${MAKEINFO} -o tcc-doc.info ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docs/tcc-doc.texi
)
set(TCC_DOC_FILES ${TCC_DOC_FILES} tcc-doc.info)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tcc-doc.info DESTINATION share/info)
@ -290,4 +290,3 @@ else()
install(DIRECTORY win32/include/ DESTINATION lib/tcc/win32/include)
install(DIRECTORY include/ DESTINATION lib/tcc/win32/include)
endif()

8
configure vendored
View File

@ -337,7 +337,7 @@ strip="${cross_prefix}${strip}"
CONFTEST=./conftest$EXESUF
if test -z "$cross_prefix" ; then
if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then
if ! $cc -o $CONFTEST $source_path/src/conftest.c 2>/dev/null ; then
echo "configure: error: '$cc' failed to compile conftest.c."
else
bigendian="$($CONFTEST bigendian)"
@ -560,7 +560,7 @@ fi
version=`head $source_path/VERSION`
echo "VERSION=$version" >>config.mak
echo "#define TCC_VERSION \"$version\"" >> $TMPH
echo "@set VERSION $version" > config.texi
echo "@set VERSION $version" >docs/config.texi
echo "SRC_PATH=$source_path" >>config.mak
if test "$source_path_used" = "yes" ; then
@ -573,9 +573,9 @@ else
fi
echo 'top_builddir=$(TOP)' >>config.mak
diff $TMPH config.h >/dev/null 2>&1
diff $TMPH src/config.h >/dev/null 2>&1
if test $? -ne 0 ; then
mv -f $TMPH config.h
mv -f $TMPH src/config.h
else
echo "config.h is unchanged"
fi

View File

0
texi2pod.pl → docs/texi2pod.pl Executable file → Normal file
View File

View File

@ -2,9 +2,9 @@
# Tiny C Compiler Makefile for libtcc1.a
#
TOP = ..
TOP = ../src
include $(TOP)/Makefile
VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
VPATH = $(top_srcdir)/../lib $(top_srcdir)/../win32/lib
ifndef TARGET # native library
ifdef CONFIG_WIN64
@ -37,7 +37,7 @@ endif
BCHECK_O = bcheck.o
DIR = $(TARGET)
native : ../libtcc1.a
native : $(DIR)/libtcc1.a
cross : $(DIR)/libtcc1.a
native : TCC = $(TOP)/tcc$(EXESUF)
@ -61,26 +61,26 @@ CFLAGS := $(filter-out -fstack-protector-strong,$(CFLAGS))
ifeq "$(TARGET)" "i386-win"
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
PICFLAGS =
else
ifeq "$(TARGET)" "x86_64-win"
OBJ = $(addprefix $(DIR)/,$(WIN64_O))
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
PICFLAGS =
else
ifeq "$(TARGET)" "i386"
OBJ = $(addprefix $(DIR)/,$(I386_O))
TGT = -DTCC_TARGET_I386
XCC ?= $(TCC) -B$(TOP)
XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
else
ifeq "$(TARGET)" "x86_64"
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
TGT = -DTCC_TARGET_X86_64
XCC ?= $(TCC) -B$(TOP)
XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
else
ifeq "$(TARGET)" "arm"
OBJ = $(addprefix $(DIR)/,$(ARM_O))
@ -110,7 +110,7 @@ endif
XAR ?= $(AR)
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
$(DIR)/libtcc1.a : $(OBJ) $(XAR)
$(XAR) rcs $@ $(OBJ)
$(DIR)/%.o : %.c
$(XCC) -c $< -o $@ $(XFLAGS)

View File

@ -3,7 +3,7 @@
#
TOP ?= .
include $(TOP)/config.mak
include $(TOP)/../config.mak
VPATH = $(top_srcdir)
CPPFLAGS += -I$(TOP) # for config.h
@ -113,14 +113,14 @@ endif
CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
CORE_FILES += tcc.h config.h libtcc.h tcctok.h
I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
WIN64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
X86_64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h
ARM_FILES = $(CORE_FILES) arm-gen.c
ARM64_FILES = $(CORE_FILES) arm64-gen.c
C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
I386_FILES = $(CORE_FILES) x86/i386-gen.c x86/i386-asm.c x86/i386-asm.h x86/i386-tok.h
WIN32_FILES = $(CORE_FILES) x86/i386-gen.c x86/i386-asm.c x86/i386-asm.h x86/i386-tok.h tccpe.c
WIN64_FILES = $(CORE_FILES) x86/x86_64-gen.c x86/i386-asm.c x86/x86_64-asm.h tccpe.c
WINCE_FILES = $(CORE_FILES) arm/arm-gen.c tccpe.c
X86_64_FILES = $(CORE_FILES) x86/x86_64-gen.c x86/i386-asm.c x86/x86_64-asm.h
ARM_FILES = $(CORE_FILES) arm/arm-gen.c
ARM64_FILES = $(CORE_FILES) arm/arm64-gen.c
C67_FILES = $(CORE_FILES) tms320c67/c67-gen.c tcccoff.c
ifdef CONFIG_WIN64
PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
@ -249,18 +249,18 @@ libtcc.dll libtcc.def libtcc.a: $(LIBTCC_OBJ)
endif
# windows utilities
tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
tiny_impdef$(EXESUF): ../win32/tools/tiny_impdef.c
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
tiny_libmaker$(EXESUF): ../win32/tools/tiny_libmaker.c
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
# TinyCC runtime libraries
libtcc1.a : FORCE
$(MAKE) -C lib native
$(MAKE) -C ../lib native
if test ! -d $(ARCH); then mkdir $(ARCH); fi
if test ! -L $(ARCH)/$@; then ln -sf ../$@ $(ARCH)/$@; fi
lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
$(MAKE) -C lib cross TARGET=$*
$(MAKE) -C ../lib cross TARGET=$*
FORCE:
@ -360,21 +360,21 @@ uninstall:
endif
# documentation and man page
tcc-doc.html: tcc-doc.texi
tcc-doc.html: ../docs/tcc-doc.texi
-makeinfo --no-split --html --number-sections -o $@ $<
tcc.1: tcc-doc.texi
tcc.1: ../docs/tcc-doc.texi
-$(top_srcdir)/texi2pod.pl $< tcc.pod
-pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/VERSION` tcc.pod > $@
-pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/../VERSION` tcc.pod > $@
tcc-doc.info: tcc-doc.texi
tcc-doc.info: ../docs/tcc-doc.texi
-makeinfo $<
# in tests subdir
export LIBTCC1
%est:
$(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)'
$(MAKE) -C ../tests $@ 'PROGS_CROSS=$(PROGS_CROSS)'
clean:
rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.log \
@ -384,9 +384,9 @@ ifeq ($(HOST_OS),Linux)
-rm -r ./C:
endif
-rm *-tcc$(EXESUF)
$(MAKE) -C tests $@
$(MAKE) -C ../tests $@
ifneq ($(LIBTCC1),)
$(MAKE) -C lib $@
$(MAKE) -C ../lib $@
endif
distclean: clean
@ -404,7 +404,7 @@ TAGS:
# create release tarball from *current* git branch (including tcc-doc.html
# and converting two files to CRLF)
TCC-VERSION := tcc-$(shell cat $(top_srcdir)/VERSION)
TCC-VERSION := tcc-$(shell cat $(top_srcdir)/../VERSION)
tar: tcc-doc.html
mkdir $(TCC-VERSION)
( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )

View File

@ -151,7 +151,7 @@ enum float_abi {
/******************************************************/
#else /* ! TARGET_DEFS_ONLY */
/******************************************************/
#include "tcc.h"
#include "../tcc.h"
enum float_abi float_abi;

View File

@ -58,7 +58,7 @@ typedef int RegArgs;
/******************************************************/
#else /* ! TARGET_DEFS_ONLY */
/******************************************************/
#include "tcc.h"
#include "../tcc.h"
#include <assert.h>
ST_DATA const int reg_classes[NB_REGS] = {

View File

View File

View File

@ -40,24 +40,24 @@ ST_DATA struct TCCState *tcc_state;
#include "tccelf.c"
#include "tccrun.c"
#ifdef TCC_TARGET_I386
#include "i386-gen.c"
#include "x86/i386-gen.c"
#endif
#ifdef TCC_TARGET_ARM
#include "arm-gen.c"
#include "arm/arm-gen.c"
#endif
#ifdef TCC_TARGET_ARM64
#include "arm64-gen.c"
#include "arm/arm64-gen.c"
#endif
#ifdef TCC_TARGET_C67
#include "c67-gen.c"
#include "tms320c67/c67-gen.c"
#endif
#ifdef TCC_TARGET_X86_64
#include "x86_64-gen.c"
#include "x86/x86_64-gen.c"
#endif
#ifdef CONFIG_TCC_ASM
#include "tccasm.c"
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
#include "i386-asm.c"
#include "x86/i386-asm.c"
#endif
#endif
#ifdef TCC_TARGET_COFF

View File

View File

View File

@ -293,20 +293,20 @@
#define TARGET_DEFS_ONLY
#ifdef TCC_TARGET_I386
# include "i386-gen.c"
# include "x86/i386-gen.c"
#endif
#ifdef TCC_TARGET_X86_64
# include "x86_64-gen.c"
# include "x86/x86_64-gen.c"
#endif
#ifdef TCC_TARGET_ARM
# include "arm-gen.c"
# include "arm/arm-gen.c"
#endif
#ifdef TCC_TARGET_ARM64
# include "arm64-gen.c"
# include "arm/arm64-gen.c"
#endif
#ifdef TCC_TARGET_C67
# include "coff.h"
# include "c67-gen.c"
# include "tms320c67c67-gen.c"
#endif
#undef TARGET_DEFS_ONLY

View File

@ -1549,7 +1549,7 @@ static int tcc_add_support(TCCState *s1, const char *filename)
"i386"
#endif
#ifdef TCC_TARGET_X86_64
"x86-64"
"x86_64"
#endif
#ifdef TCC_TARGET_ARM
"arm"

View File

@ -1636,7 +1636,7 @@ quit:
/* ------------------------------------------------------------- */
#define TINY_IMPDEF_GET_EXPORT_NAMES_ONLY
#include "win32/tools/tiny_impdef.c"
#include "../win32/tools/tiny_impdef.c"
static int pe_load_dll(TCCState *s1, const char *dllname, int fd)
{

View File

@ -331,5 +331,5 @@
#endif
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
#include "i386-tok.h"
#include "x86/i386-tok.h"
#endif

View File

@ -127,7 +127,7 @@ enum {
/******************************************************/
#else /* ! TARGET_DEFS_ONLY */
/******************************************************/
#include "tcc.h"
#include "../tcc.h"
ST_DATA const int reg_classes[NB_REGS] = {
/* eax */ RC_INT | RC_FLOAT | RC_EAX,

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "tcc.h"
#include "../tcc.h"
/* #define NB_ASM_REGS 8 */
#define MAX_OPERANDS 3

View File

@ -89,7 +89,7 @@ enum {
/******************************************************/
#else /* ! TARGET_DEFS_ONLY */
/******************************************************/
#include "tcc.h"
#include "../tcc.h"
ST_DATA const int reg_classes[NB_REGS] = {
/* eax */ RC_INT | RC_EAX,

View File

@ -136,7 +136,7 @@ enum {
/******************************************************/
#else /* ! TARGET_DEFS_ONLY */
/******************************************************/
#include "tcc.h"
#include "../tcc.h"
#include <assert.h>
ST_DATA const int reg_classes[NB_REGS] = {

View File

@ -2,7 +2,7 @@
# Tiny C Compiler Makefile - tests
#
TOP = ..
TOP = ../src
include $(TOP)/Makefile
SRCDIR = $(top_srcdir)/tests
VPATH = $(SRCDIR) $(top_srcdir)
@ -60,11 +60,11 @@ ifeq ($(TARGETOS),Darwin)
endif
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP)
TCCFLAGS = -B$(TOP)/../lib -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/../include -L$(TOP)
ifdef CONFIG_WIN32
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP)
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/../include -L$(TOP)
endif
XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
XTCCFLAGS = -B$(TOP)/../lib -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/../include
TCC = $(TOP)/tcc $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(top_srcdir)/tcc.c $(TCCFLAGS)
@ -73,7 +73,7 @@ DISAS = objdump -d
# libtcc test
ifdef LIBTCC1
LIBTCC1:=$(TOP)/$(LIBTCC1)
LIBTCC1:=$(TOP)/lib/$(LIBTCC1)
endif
all test : $(TESTS)

View File

@ -2,7 +2,7 @@
# credits: 01..13.c from the pcc cpp-tests suite
#
TCC = ../../tcc
TCC = ../../src/tcc
TESTS = $(patsubst %.c,%.test,$(wildcard *.c))
all test : $(TESTS)

View File

@ -1,4 +1,4 @@
TOP = ../..
TOP = ../../src
include $(TOP)/Makefile
# clear CFLAGS and LDFLAGS
@ -6,9 +6,9 @@ CFLAGS :=
LDFLAGS :=
ifdef CONFIG_WIN32
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/../include -L$(TOP)
else
TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include -lm
TCCFLAGS = -B$(TOP)/../lib -I$(top_srcdir)/../include -lm
endif
ifeq ($(TARGETOS),Darwin)

View File

@ -21,7 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../elf.h"
#include "../../src/elf.h"
#ifdef TCC_TARGET_X86_64
# define ELFCLASSW ELFCLASS64