mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-28 04:00:06 +08:00
7e7e6148fd
* define targetos=Windows when --enable-tcc32-mingw, --enable-cygwin, ... * use TARGETOS insteed HOST_OS when selecting PROGS * use "$(tccdir)" insteed $(tccdir) on install (spaces in path) * install tcc.exe too * produce bcheck.o when cross-compiling too (lib/Makefile) * force bcheck.o linking by compiling inside tcc_set_output_type() a dummy program with local array. Otherwise bcheck.o may be not linked. * replace %xz format specifier with %p in bcheck (don't supported on Windows) * call a __bound_init when __bound_ptr_add, __bound_ptr_indir, __bound_new_region, __bound_delete_region called. This is because a __bound_init inside ".init" section is not called on Windows for unknown reason. * print on stderr a message when an illegal pointer is returned: there is no segmentation violation on Windows for a program compiled with "tcc -b" * remove "C:" subdir on clean if $HOST_OS = "Linux" * default CFLAGS="-Wall -g -O0" insteed CFLAGS="-Wall -g -O2" to speed up compilation and more precise debugging.
129 lines
2.7 KiB
Makefile
129 lines
2.7 KiB
Makefile
#
|
|
# Tiny C Compiler Makefile for libtcc1.a
|
|
#
|
|
|
|
TOP = ..
|
|
include $(TOP)/Makefile
|
|
VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
|
|
|
|
ifndef TARGET # native library
|
|
ifdef CONFIG_WIN64
|
|
TARGET = x86_64-win
|
|
else
|
|
ifdef CONFIG_WIN32
|
|
TARGET = i386-win
|
|
else
|
|
ifeq ($(ARCH),i386)
|
|
TARGET = i386
|
|
else
|
|
ifeq ($(ARCH),x86-64)
|
|
TARGET = x86_64
|
|
else
|
|
ifeq ($(ARCH),arm)
|
|
TARGET = arm
|
|
XCC = $(CC)
|
|
else
|
|
ifeq ($(ARCH),arm64)
|
|
TARGET = arm64
|
|
else
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
BCHECK_O = bcheck.o
|
|
DIR = $(TARGET)
|
|
|
|
native : ../libtcc1.a
|
|
cross : $(DIR)/libtcc1.a
|
|
|
|
native : TCC = $(TOP)/tcc$(EXESUF)
|
|
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
|
|
|
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
|
X86_64_O = libtcc1.o alloca86_64.o
|
|
ARM_O = libtcc1.o armeabi.o alloca-arm.o
|
|
WIN32_O = $(I386_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
|
|
ARM64_O = lib-arm64.o
|
|
|
|
# build TCC runtime library to contain PIC code, so it can be linked
|
|
# into shared libraries
|
|
PICFLAGS = -fPIC
|
|
|
|
# don't compile with -fstack-protector-strong, TCC doesn't handle it
|
|
# correctly
|
|
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
|
|
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
|
|
XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
|
|
PICFLAGS =
|
|
else
|
|
ifeq "$(TARGET)" "i386"
|
|
OBJ = $(addprefix $(DIR)/,$(I386_O))
|
|
TGT = -DTCC_TARGET_I386
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
else
|
|
ifeq "$(TARGET)" "x86_64"
|
|
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
|
TGT = -DTCC_TARGET_X86_64
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
else
|
|
ifeq "$(TARGET)" "arm"
|
|
OBJ = $(addprefix $(DIR)/,$(ARM_O))
|
|
TGT = -DTCC_TARGET_ARM
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
else
|
|
ifeq "$(TARGET)" "arm64"
|
|
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
|
|
TGT = -DTCC_TARGET_ARM64
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
else
|
|
$(error libtcc1.a not supported on target '$(TARGET)')
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
XFLAGS = $(CPPFLAGS) $(CFLAGS) $(PICFLAGS) $(TGT)
|
|
|
|
ifeq ($(TARGETOS),Darwin)
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
XFLAGS += -D_ANSI_SOURCE
|
|
BCHECK_O =
|
|
endif
|
|
|
|
XAR ?= $(AR)
|
|
|
|
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
|
|
$(XAR) rcs $@ $(OBJ)
|
|
$(DIR)/%.o : %.c
|
|
$(XCC) -c $< -o $@ $(XFLAGS)
|
|
$(DIR)/%.o : %.S
|
|
$(XCC) -c $< -o $@ $(XFLAGS)
|
|
$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
|
|
$(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
|
|
|
|
$(OBJ) $(XAR) : $(DIR)/exists
|
|
$(DIR)/exists :
|
|
mkdir -p $(DIR)
|
|
@echo $@ > $@
|
|
|
|
clean :
|
|
rm -rfv i386-win x86_64-win i386 x86_64 arm64
|