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