2010-12-04 23:47:08 +08:00
|
|
|
#
|
|
|
|
# Tiny C Compiler Makefile for libtcc1.a
|
|
|
|
#
|
|
|
|
|
2015-07-30 04:53:57 +08:00
|
|
|
TOP = ..
|
2013-02-15 00:43:24 +08:00
|
|
|
include $(TOP)/Makefile
|
2016-10-02 03:06:33 +08:00
|
|
|
VPATH = $(TOP)/lib $(TOP)/win32/lib
|
2010-12-04 23:47:08 +08:00
|
|
|
|
2016-10-02 03:06:33 +08:00
|
|
|
ifndef TARGET
|
|
|
|
# we're building the native libtcc1.a
|
2010-12-04 23:47:08 +08:00
|
|
|
ifdef CONFIG_WIN64
|
2016-10-02 03:06:33 +08:00
|
|
|
TARGET = x86_64-win32
|
|
|
|
# using tcc
|
|
|
|
else ifdef CONFIG_WIN32
|
|
|
|
TARGET = i386-win32
|
|
|
|
# using tcc
|
|
|
|
else ifeq ($(ARCH),i386)
|
2010-12-04 23:47:08 +08:00
|
|
|
TARGET = i386
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC = $(CC) # using gcc
|
|
|
|
else ifeq ($(ARCH),x86-64)
|
2010-12-04 23:47:08 +08:00
|
|
|
TARGET = x86_64
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC = $(CC) # using gcc
|
|
|
|
else ifeq ($(ARCH),arm)
|
2013-02-28 23:55:10 +08:00
|
|
|
TARGET = arm
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC = $(CC) # using gcc
|
|
|
|
else ifeq ($(ARCH),arm64)
|
2015-02-14 02:58:31 +08:00
|
|
|
TARGET = arm64
|
2010-12-04 23:47:08 +08:00
|
|
|
endif
|
2016-10-02 03:06:33 +08:00
|
|
|
BCHECK_O = bcheck.o
|
2010-12-04 23:47:08 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
DIR = $(TARGET)
|
|
|
|
|
2015-07-30 04:53:57 +08:00
|
|
|
native : ../libtcc1.a
|
2010-12-04 23:47:08 +08:00
|
|
|
cross : $(DIR)/libtcc1.a
|
|
|
|
|
|
|
|
native : TCC = $(TOP)/tcc$(EXESUF)
|
|
|
|
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
|
|
|
|
2013-02-07 02:01:07 +08:00
|
|
|
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
2015-04-10 20:17:22 +08:00
|
|
|
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
|
2014-04-06 04:54:11 +08:00
|
|
|
ARM_O = libtcc1.o armeabi.o alloca-arm.o
|
2013-02-07 02:01:07 +08:00
|
|
|
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
2010-12-04 23:47:08 +08:00
|
|
|
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
2015-02-14 02:58:31 +08:00
|
|
|
ARM64_O = lib-arm64.o
|
2010-12-04 23:47:08 +08:00
|
|
|
|
2014-04-03 03:27:22 +08:00
|
|
|
# build TCC runtime library to contain PIC code, so it can be linked
|
|
|
|
# into shared libraries
|
|
|
|
PICFLAGS = -fPIC
|
|
|
|
|
2016-10-02 03:06:33 +08:00
|
|
|
ifeq "$(TARGET)" "i386-win32"
|
2010-12-04 23:47:08 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
|
|
|
|
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
XFLAGS = $(TGT)
|
|
|
|
else ifeq "$(TARGET)" "x86_64-win32"
|
2010-12-04 23:47:08 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
XFLAGS = $(TGT)
|
|
|
|
else ifeq "$(TARGET)" "i386"
|
2010-12-04 23:47:08 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(I386_O))
|
|
|
|
TGT = -DTCC_TARGET_I386
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
|
|
else ifeq "$(TARGET)" "x86_64"
|
2010-12-04 23:47:08 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
|
|
else ifeq "$(TARGET)" "arm"
|
2013-02-28 23:55:10 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(ARM_O))
|
|
|
|
TGT = -DTCC_TARGET_ARM
|
2016-10-02 03:06:33 +08:00
|
|
|
XCC ?= $(TCC) -B$(TOP)
|
|
|
|
else ifeq "$(TARGET)" "arm64"
|
2015-02-14 02:58:31 +08:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
|
|
|
|
TGT = -DTCC_TARGET_ARM64
|
2016-05-20 20:55:36 +08:00
|
|
|
XCC ?= $(TCC) -B$(top_srcdir)
|
2010-12-04 23:47:08 +08:00
|
|
|
else
|
|
|
|
$(error libtcc1.a not supported on target '$(TARGET)')
|
|
|
|
endif
|
|
|
|
|
2016-10-02 03:06:33 +08:00
|
|
|
XFLAGS ?= $(CFLAGS) $(PICFLAGS) $(TGT)
|
2013-02-07 02:01:07 +08:00
|
|
|
|
|
|
|
ifeq ($(TARGETOS),Darwin)
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
XFLAGS += -D_ANSI_SOURCE
|
|
|
|
BCHECK_O =
|
|
|
|
endif
|
|
|
|
|
2016-10-02 03:06:33 +08:00
|
|
|
ifdef XAR
|
|
|
|
AR = $(XAR)
|
|
|
|
endif
|
2010-12-04 23:47:08 +08:00
|
|
|
|
2015-07-30 04:53:57 +08:00
|
|
|
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
|
2016-10-02 03:06:33 +08:00
|
|
|
$(AR) rcs $@ $(OBJ)
|
2010-12-04 23:47:08 +08:00
|
|
|
$(DIR)/%.o : %.c
|
2013-02-07 02:01:07 +08:00
|
|
|
$(XCC) -c $< -o $@ $(XFLAGS)
|
2010-12-04 23:47:08 +08:00
|
|
|
$(DIR)/%.o : %.S
|
2014-04-07 17:13:19 +08:00
|
|
|
$(XCC) -c $< -o $@ $(XFLAGS)
|
2016-10-02 03:06:33 +08:00
|
|
|
# windows : utilities
|
|
|
|
$(DIR)/tiny_%$(EXESUF) : $(TOP)/win32/tools/tiny_%.c
|
|
|
|
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(TGT)
|
2010-12-04 23:47:08 +08:00
|
|
|
|
|
|
|
$(OBJ) $(XAR) : $(DIR)/exists
|
2016-10-02 03:06:33 +08:00
|
|
|
|
|
|
|
%/exists :
|
2010-12-04 23:47:08 +08:00
|
|
|
mkdir -p $(DIR)
|
|
|
|
@echo $@ > $@
|
|
|
|
|
|
|
|
clean :
|
2016-10-02 03:06:33 +08:00
|
|
|
rm -rfv i386-win32 x86_64-win32 i386 x86_64 arm arm64
|