aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2011-07-14 18:45:37 +0200
committergrischka <grischka>2011-07-14 18:45:37 +0200
commit5280293d6b16bbe24dfda76e37f32322fa2874ca (patch)
tree29d05bd4034a3841e6920817d39b0334926f442f
parent4ccb5662cbfbf3e8c58a1b642fd3446fcce55e16 (diff)
downloadtinycc-5280293d6b16bbe24dfda76e37f32322fa2874ca.tar.gz
tinycc-5280293d6b16bbe24dfda76e37f32322fa2874ca.tar.bz2
make: create native tcc from separate objects
This was already possible using make NOTALLINONE=1 and is now the default. To build as previously from one big source, use make ONE_SOURCE=1 Cross compilers are still build from one source because using separate objects requires separate build directories one per platform which currently is not (yet) supported by the makefile. We could probably use gnu-makeish target variables like $(I386_CROSS): OUTDIR=build/i386 $(X64_CROSS): OUTDIR=build/x86-64 and so on ... Also NEED_FLOAT_TYPES for arm-gen is removed. It was about variables that are referenced from outside (libtcc, tccgen). We could declare them in tcc.h (as with reg_classes) or have them twice in arm-gen.c. I chose option 2.
-rw-r--r--Makefile7
-rw-r--r--arm-gen.c9
-rw-r--r--libtcc.c3
-rw-r--r--tcc.c6
-rw-r--r--tcc.h4
-rw-r--r--tccpe.c2
-rw-r--r--win32/build-tcc.bat4
7 files changed, 18 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index d1dfbda..f60f465 100644
--- a/Makefile
+++ b/Makefile
@@ -157,7 +157,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC)
# Cross Tiny C Compilers
%-tcc$(EXESUF):
- $(CC) -o $@ tcc.c $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS)
+ $(CC) -o $@ tcc.c -DONE_SOURCE $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS)
$(I386_CROSS): DEFINES = -DTCC_TARGET_I386 -DCONFIG_TCCDIR="\"$(tccdir)/i386\""
$(X64_CROSS): DEFINES = -DTCC_TARGET_X86_64
@@ -179,14 +179,13 @@ $(C67_CROSS): $(C67_FILES)
$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
# libtcc generation and test
-ifdef NOTALLINONE
+ifndef ONE_SOURCE
LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
-$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DNOTALLINONE
else
LIBTCC_OBJ = libtcc.o
LIBTCC_INC = $(NATIVE_FILES)
-tcc.o : NATIVE_DEFINES += -DNOTALLINONE
+$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DONE_SOURCE
endif
$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
diff --git a/arm-gen.c b/arm-gen.c
index 9feae1b..5cb5c2e 100644
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -102,10 +102,8 @@ enum {
//#define FUNC_STRUCT_PARAM_AS_PTR
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
-#ifdef NEED_FLOAT_TYPES
-static CType float_type, double_type, func_float_type, func_double_type;
+ST_DATA CType float_type, double_type, func_float_type, func_double_type;
#define func_ldouble_type func_double_type
-#endif
#else
#define func_float_type func_old_type
#define func_double_type func_old_type
@@ -172,6 +170,11 @@ ST_DATA const int reg_classes[NB_REGS] = {
#endif
};
+/* keep in sync with line 104 above */
+#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
+ST_DATA CType float_type, double_type, func_float_type, func_double_type;
+#endif
+
static int func_sub_sp_offset, last_itod_magic;
static int leaffunc;
diff --git a/libtcc.c b/libtcc.c
index 46a13fc..9fa0dd8 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -18,7 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define NEED_FLOAT_TYPES
#include "tcc.h"
/********************************************************/
@@ -41,7 +40,7 @@ ST_DATA void *rt_prog_main;
/********************************************************/
-#ifndef NOTALLINONE
+#ifdef ONE_SOURCE
#include "tccpp.c"
#include "tccgen.c"
#include "tccelf.c"
diff --git a/tcc.c b/tcc.c
index 570a61c..cab257d 100644
--- a/tcc.c
+++ b/tcc.c
@@ -18,10 +18,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#if defined NOTALLINONE || defined TCC_USE_LIBTCC
-#include "tcc.h"
-#else
+#ifdef ONE_SOURCE
#include "libtcc.c"
+#else
+#include "tcc.h"
#endif
static char **files;
diff --git a/tcc.h b/tcc.h
index ce7ee22..eaf0e65 100644
--- a/tcc.h
+++ b/tcc.h
@@ -877,7 +877,7 @@ static inline int toup(int c)
#define PUB_FUNC
-#ifndef NOTALLINONE
+#ifdef ONE_SOURCE
#define ST_INLN static inline
#define ST_FUNC static
#define ST_DATA static
@@ -1278,7 +1278,7 @@ ST_DATA const int reg_classes[NB_REGS];
/********************************************************/
#undef ST_DATA
-#ifndef NOTALLINONE
+#ifdef ONE_SOURCE
#define ST_DATA static
#else
#define ST_DATA
diff --git a/tccpe.c b/tccpe.c
index ed57c63..22b61a6 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -376,7 +376,7 @@ static int pe_find_import(TCCState * s1, ElfW(Sym) *sym)
{
char buffer[200];
const char *s, *p;
- int sym_index, n = 0;
+ int sym_index = 0, n = 0;
do {
s = pe_export_name(s1, sym);
diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat
index 42dc8f6..3b2bb1e 100644
--- a/win32/build-tcc.bat
+++ b/win32/build-tcc.bat
@@ -29,11 +29,11 @@ echo>>..\config.h #define CONFIG_SYSROOT ""
:libtcc
if not exist libtcc\nul mkdir libtcc
copy ..\libtcc.h libtcc\libtcc.h
-%CC% %target% -fno-strict-aliasing ../libtcc.c -c -o libtcc.o
+%CC% %target% -fno-strict-aliasing -DONE_SOURCE ../libtcc.c -c -o libtcc.o
%AR% rcs libtcc/libtcc.a libtcc.o
:tcc
-%CC% %target% -fno-strict-aliasing ../tcc.c -o tcc.exe -DTCC_USE_LIBTCC -ltcc -Llibtcc
+%CC% %target% -fno-strict-aliasing ../tcc.c -o tcc.exe -ltcc -Llibtcc
:copy_std_includes
copy ..\include\*.h include