2001-11-11 21:01:29 +03:00
|
|
|
#
|
|
|
|
# Tiny C Compiler Makefile
|
|
|
|
#
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
TOP ?= .
|
|
|
|
include $(TOP)/config.mak
|
2001-10-28 02:48:39 +03:00
|
|
|
|
2009-04-16 20:22:34 +04:00
|
|
|
TARGET=
|
2005-09-03 22:34:22 +04:00
|
|
|
CFLAGS+=-g -Wall
|
2009-03-15 20:47:52 +03:00
|
|
|
ifeq ($(ARCH),x86-64)
|
2009-04-16 20:22:34 +04:00
|
|
|
TARGET=-DTCC_TARGET_X86_64
|
2009-03-15 20:47:52 +03:00
|
|
|
CFLAGS+=-Wno-pointer-sign
|
|
|
|
endif
|
|
|
|
|
2004-10-08 01:11:43 +04:00
|
|
|
ifndef CONFIG_WIN32
|
2007-12-16 21:24:44 +03:00
|
|
|
LIBS=-lm
|
|
|
|
ifndef CONFIG_NOLDL
|
|
|
|
LIBS+=-ldl
|
|
|
|
endif
|
2008-12-01 21:19:25 +03:00
|
|
|
ifneq ($(ARCH),x86-64)
|
2004-10-08 01:11:43 +04:00
|
|
|
BCHECK_O=bcheck.o
|
|
|
|
endif
|
2008-12-01 21:19:25 +03:00
|
|
|
endif
|
2001-12-18 00:57:01 +03:00
|
|
|
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
|
|
|
|
LIBS_P=
|
2001-10-28 02:48:39 +03:00
|
|
|
|
2008-12-01 21:19:25 +03:00
|
|
|
ifneq ($(GCC_MAJOR),2)
|
|
|
|
CFLAGS+=-fno-strict-aliasing
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(ARCH),i386)
|
2003-04-13 23:48:19 +04:00
|
|
|
CFLAGS+=-mpreferred-stack-boundary=2
|
|
|
|
ifeq ($(GCC_MAJOR),2)
|
|
|
|
CFLAGS+=-m386 -malign-functions=0
|
|
|
|
else
|
2008-12-01 21:19:25 +03:00
|
|
|
CFLAGS+=-march=i386 -falign-functions=0
|
2008-03-08 22:55:47 +03:00
|
|
|
ifneq ($(GCC_MAJOR),3)
|
2009-04-18 16:31:35 +04:00
|
|
|
CFLAGS+=-Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0
|
2003-04-13 23:48:19 +04:00
|
|
|
endif
|
2008-03-08 22:55:47 +03:00
|
|
|
endif
|
2008-12-01 21:19:25 +03:00
|
|
|
endif
|
2003-04-13 23:48:19 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
ifeq ($(TOP),.)
|
2005-04-15 03:52:04 +04:00
|
|
|
|
|
|
|
PROGS=tcc$(EXESUF)
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) arm-tcc-vfp$(EXESUF) arm-tcc-vfp-eabi$(EXESUF)
|
|
|
|
I386_CROSS = i386-tcc$(EXESUF)
|
|
|
|
WIN32_CROSS = i386-win32-tcc$(EXESUF)
|
|
|
|
C67_CROSS = c67-tcc$(EXESUF)
|
|
|
|
X64_CROSS = x86_64-tcc$(EXESUF)
|
|
|
|
|
|
|
|
ifdef CONFIG_WIN32
|
2008-03-08 22:55:47 +03:00
|
|
|
PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
|
2009-04-18 16:31:35 +04:00
|
|
|
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),i386)
|
|
|
|
PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),arm)
|
|
|
|
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(C67_CROSS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),x86-64)
|
|
|
|
PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
2005-04-15 03:52:04 +04:00
|
|
|
endif
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2005-04-15 03:52:04 +04:00
|
|
|
ifdef CONFIG_CROSS
|
2009-04-18 16:31:35 +04:00
|
|
|
PROGS+=$(PROGS_CROSS)
|
2008-12-01 21:19:25 +03:00
|
|
|
endif
|
2005-04-15 03:52:04 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
ifndef CONFIG_USE_LIBGCC
|
2008-09-05 23:08:37 +04:00
|
|
|
LIBTCC1=libtcc1.a
|
|
|
|
endif
|
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
all: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc-doc.html tcc.1 libtcc_test$(EXESUF)
|
|
|
|
|
|
|
|
TCC_CORE_FILES = tcc.c tccelf.c tccasm.c tcctok.h libtcc.h config.h
|
2001-10-28 18:20:24 +03:00
|
|
|
|
2005-04-15 03:52:04 +04:00
|
|
|
# Host Tiny C Compiler
|
|
|
|
ifdef CONFIG_WIN32
|
2009-04-18 16:31:35 +04:00
|
|
|
tcc$(EXESUF): $(TCC_CORE_FILES) i386-gen.c i386-asm.c i386-asm.h tccpe.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_PE $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),i386)
|
|
|
|
tcc$(EXESUF): $(TCC_CORE_FILES) i386-gen.c i386-asm.c i386-asm.h
|
|
|
|
$(CC) -o $@ $< $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),x86-64)
|
|
|
|
tcc$(EXESUF): $(TCC_CORE_FILES) x86_64-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_X86_64 $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
else ifeq ($(ARCH),arm)
|
2008-09-05 23:07:56 +04:00
|
|
|
ARMFLAGS = $(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI)
|
|
|
|
ARMFLAGS += $(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP)
|
2009-04-18 16:31:35 +04:00
|
|
|
tcc$(EXESUF): $(TCC_CORE_FILES) arm-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_ARM $(ARMFLAGS) $(CFLAGS) $(LIBS)
|
2005-04-15 03:52:04 +04:00
|
|
|
endif
|
2001-11-11 21:01:29 +03:00
|
|
|
|
2005-04-15 03:52:04 +04:00
|
|
|
# Cross Tiny C Compilers
|
2009-04-18 16:31:35 +04:00
|
|
|
i386-tcc$(EXESUF): $(TCC_CORE_FILES) i386-gen.c i386-asm.c i386-asm.h
|
|
|
|
$(CC) -o $@ $< $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
i386-win32-tcc$(EXESUF): $(TCC_CORE_FILES) i386-gen.c i386-asm.c i386-asm.h tccpe.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_PE $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
x86_64-tcc$(EXESUF): $(TCC_CORE_FILES) x86_64-gen.c i386-asm.c i386-asm.h
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_X86_64 $(CFLAGS) $(LIBS)
|
2001-10-28 02:48:39 +03:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
c67-tcc$(EXESUF): $(TCC_CORE_FILES) c67-gen.c tcccoff.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS)
|
2004-10-05 01:57:35 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
arm-tcc-fpa$(EXESUF): $(TCC_CORE_FILES) arm-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
arm-tcc-fpa-ld$(EXESUF): $(TCC_CORE_FILES) arm-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
arm-tcc-vfp$(EXESUF): $(TCC_CORE_FILES) arm-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_VFP $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
arm-tcc-vfp-eabi$(EXESUF): $(TCC_CORE_FILES) arm-gen.c
|
|
|
|
$(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_EABI $(CFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
# libtcc generation and test
|
|
|
|
libtcc.o: tcc.c i386-gen.c
|
|
|
|
ifdef CONFIG_WIN32
|
|
|
|
$(CC) -o $@ -c $< -DTCC_TARGET_PE -DLIBTCC $(CFLAGS)
|
|
|
|
else
|
|
|
|
$(CC) -o $@ -c $< $(TARGET) -DLIBTCC $(CFLAGS)
|
|
|
|
endif
|
2008-09-05 23:07:56 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
libtcc.a: libtcc.o
|
|
|
|
$(AR) rcs $@ $^
|
2008-09-05 23:07:56 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
libtcc_test$(EXESUF): tests/libtcc_test.c libtcc.a
|
|
|
|
$(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS)
|
2008-09-05 23:07:56 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
libtest: libtcc_test$(EXESUF) $(LIBTCC1)
|
|
|
|
./libtcc_test$(EXESUF) lib_path=.
|
2004-10-05 02:19:21 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
# profiling version
|
|
|
|
tcc_p: tcc.c
|
|
|
|
$(CC) -o $@ $< $(CFLAGS_P) $(LIBS_P)
|
2005-04-11 01:46:58 +04:00
|
|
|
|
2005-04-15 03:52:04 +04:00
|
|
|
# windows utilities
|
2008-03-08 22:55:47 +03:00
|
|
|
tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
|
2009-04-18 16:31:35 +04:00
|
|
|
$(CC) -o $@ $< $(CFLAGS)
|
2008-03-08 22:55:47 +03:00
|
|
|
tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
|
2009-04-18 16:31:35 +04:00
|
|
|
$(CC) -o $@ $< $(CFLAGS)
|
2005-04-15 03:52:04 +04:00
|
|
|
|
2002-07-25 02:13:02 +04:00
|
|
|
# TinyCC runtime libraries
|
2009-04-18 16:31:35 +04:00
|
|
|
LIBTCC1_OBJS=libtcc1.o
|
|
|
|
LIBTCC1_CC=$(CC)
|
|
|
|
VPATH+=lib
|
2005-04-15 03:52:04 +04:00
|
|
|
ifdef CONFIG_WIN32
|
2005-06-18 02:03:50 +04:00
|
|
|
# for windows, we must use TCC because we generate ELF objects
|
2009-04-18 16:31:35 +04:00
|
|
|
LIBTCC1_OBJS+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
2008-01-17 01:33:56 +03:00
|
|
|
LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE
|
2009-04-18 16:31:35 +04:00
|
|
|
VPATH+=win32/lib
|
2005-04-15 03:52:04 +04:00
|
|
|
endif
|
2007-11-21 20:16:31 +03:00
|
|
|
ifeq ($(ARCH),i386)
|
|
|
|
LIBTCC1_OBJS+=alloca86.o alloca86-bt.o
|
|
|
|
endif
|
2005-04-15 03:52:04 +04:00
|
|
|
|
|
|
|
%.o: %.c
|
2009-04-18 16:31:35 +04:00
|
|
|
$(LIBTCC1_CC) -o $@ -c $< -O2 -Wall
|
2002-07-25 02:13:02 +04:00
|
|
|
|
2005-04-15 03:52:04 +04:00
|
|
|
%.o: %.S
|
2009-04-18 16:31:35 +04:00
|
|
|
$(LIBTCC1_CC) -o $@ -c $<
|
2005-04-15 03:52:04 +04:00
|
|
|
|
2005-06-18 02:03:50 +04:00
|
|
|
libtcc1.a: $(LIBTCC1_OBJS)
|
2003-05-24 19:45:33 +04:00
|
|
|
$(AR) rcs $@ $^
|
|
|
|
|
2002-07-25 02:13:02 +04:00
|
|
|
bcheck.o: bcheck.c
|
2009-04-18 16:31:35 +04:00
|
|
|
$(CC) -o $@ -c $< -O2 -Wall
|
2003-04-13 23:48:19 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
# install
|
|
|
|
TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
|
|
|
|
INSTALL=install
|
2003-04-13 23:48:19 +04:00
|
|
|
|
2004-10-08 01:11:43 +04:00
|
|
|
ifndef CONFIG_WIN32
|
2009-04-18 16:31:35 +04:00
|
|
|
install: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc.1 tcc-doc.html
|
|
|
|
mkdir -p "$(bindir)"
|
|
|
|
$(INSTALL) -s -m755 $(PROGS) "$(bindir)"
|
|
|
|
mkdir -p "$(mandir)/man1"
|
|
|
|
$(INSTALL) tcc.1 "$(mandir)/man1"
|
|
|
|
mkdir -p "$(tccdir)"
|
|
|
|
mkdir -p "$(tccdir)/include"
|
|
|
|
ifneq ($(LIBTCC1),)
|
|
|
|
$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
|
2004-10-08 01:11:43 +04:00
|
|
|
endif
|
2009-04-18 16:31:35 +04:00
|
|
|
ifneq ($(BCHECK_O),)
|
|
|
|
$(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
|
2005-04-15 03:52:04 +04:00
|
|
|
endif
|
2009-04-18 16:31:35 +04:00
|
|
|
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
|
|
|
mkdir -p "$(docdir)"
|
|
|
|
$(INSTALL) -m644 tcc-doc.html "$(docdir)"
|
|
|
|
mkdir -p "$(libdir)"
|
|
|
|
$(INSTALL) -m644 libtcc.a "$(libdir)"
|
|
|
|
mkdir -p "$(includedir)"
|
|
|
|
$(INSTALL) -m644 libtcc.h "$(includedir)"
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
|
|
|
|
rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(tccdir)/$P")
|
|
|
|
rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
|
|
|
|
rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
|
|
|
|
rm -fv "$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
|
2001-10-28 02:48:39 +03:00
|
|
|
|
2008-12-01 21:19:25 +03:00
|
|
|
else
|
2009-04-18 16:31:35 +04:00
|
|
|
install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html
|
|
|
|
mkdir -p "$(tccdir)"
|
|
|
|
mkdir -p "$(tccdir)/lib"
|
|
|
|
mkdir -p "$(tccdir)/include"
|
|
|
|
mkdir -p "$(tccdir)/examples"
|
|
|
|
mkdir -p "$(tccdir)/doc"
|
|
|
|
mkdir -p "$(tccdir)/libtcc"
|
|
|
|
$(INSTALL) -s -m755 $(PROGS) "$(tccdir)"
|
|
|
|
$(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib"
|
|
|
|
cp -r win32/include/. "$(tccdir)/include"
|
|
|
|
cp -r win32/examples/. "$(tccdir)/examples"
|
|
|
|
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
|
|
|
$(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt"$(tccdir)/doc"
|
|
|
|
$(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc"
|
2008-12-01 21:19:25 +03:00
|
|
|
endif
|
2002-05-14 02:58:22 +04:00
|
|
|
|
2003-05-18 22:11:06 +04:00
|
|
|
# documentation and man page
|
2002-07-25 02:13:02 +04:00
|
|
|
tcc-doc.html: tcc-doc.texi
|
2007-11-21 20:16:31 +03:00
|
|
|
-texi2html -monolithic -number $<
|
2002-07-25 02:13:02 +04:00
|
|
|
|
2003-05-18 22:11:06 +04:00
|
|
|
tcc.1: tcc-doc.texi
|
2007-11-21 20:16:31 +03:00
|
|
|
-./texi2pod.pl $< tcc.pod
|
|
|
|
-pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
2003-05-18 22:11:06 +04:00
|
|
|
|
2005-04-15 04:11:02 +04:00
|
|
|
# tar release (use 'make -k tar' on a checkouted tree)
|
2009-04-18 16:31:35 +04:00
|
|
|
TCC-VERSION=tcc-$(shell cat VERSION)
|
2001-11-11 21:01:29 +03:00
|
|
|
tar:
|
2009-04-18 16:31:35 +04:00
|
|
|
rm -rf /tmp/$(TCC-VERSION)
|
|
|
|
cp -r . /tmp/$(TCC-VERSION)
|
|
|
|
( cd /tmp ; tar zcvf ~/$(TCC-VERSION).tar.gz $(TCC-VERSION) --exclude CVS )
|
|
|
|
rm -rf /tmp/$(TCC-VERSION)
|
|
|
|
|
|
|
|
# in tests subdir
|
|
|
|
test clean :
|
|
|
|
$(MAKE) -C tests $@
|
|
|
|
|
|
|
|
# clean
|
|
|
|
clean: local_clean
|
|
|
|
local_clean:
|
|
|
|
rm -vf $(PROGS) tcc_p tcc.pod *~ *.o *.a *.out libtcc_test$(EXESUF)
|
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
rm -vf config.h config.mak config.texi tcc.1 tcc-doc.html
|
|
|
|
|
|
|
|
endif
|
|
|
|
# ifeq ($(TOP),.)
|