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:53 +03:00
|
|
|
VPATH = $(TOPSRC)/lib $(TOPSRC)/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
|
2016-10-02 02:39:07 +03:00
|
|
|
ifdef CONFIG_WIN32
|
|
|
|
ifeq ($(ARCH),x86-64)
|
|
|
|
TARGET = x86_64-win32
|
|
|
|
else
|
|
|
|
TARGET = i386-win32
|
|
|
|
endif
|
2016-10-01 22:06:33 +03:00
|
|
|
else ifeq ($(ARCH),i386)
|
2010-12-04 18:47:08 +03:00
|
|
|
TARGET = i386
|
2016-10-01 22:06:33 +03:00
|
|
|
else ifeq ($(ARCH),x86-64)
|
2010-12-04 18:47:08 +03:00
|
|
|
TARGET = x86_64
|
2016-10-01 22:06:33 +03:00
|
|
|
else ifeq ($(ARCH),arm)
|
2013-02-28 19:55:10 +04:00
|
|
|
TARGET = arm
|
2016-12-20 20:05:33 +03:00
|
|
|
# using gcc, need asm
|
|
|
|
XCC = $(CC)
|
2017-02-11 11:30:20 +03:00
|
|
|
XFLAGS = $(CFLAGS) -fPIC
|
2016-10-01 22:06:33 +03:00
|
|
|
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
|
2015-02-13 21:58:31 +03:00
|
|
|
ARM64_O = lib-arm64.o
|
2017-02-18 11:51:23 +03:00
|
|
|
WIN32_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
|
2010-12-04 18:47:08 +03:00
|
|
|
|
2016-10-01 22:06:33 +03:00
|
|
|
ifeq "$(TARGET)" "i386-win32"
|
2016-10-18 00:22:21 +03:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(I386_O) $(WIN32_O))
|
2010-12-04 18:47:08 +03:00
|
|
|
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
2016-10-01 22:06:53 +03:00
|
|
|
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
2016-10-01 22:06:33 +03:00
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
else ifeq "$(TARGET)" "x86_64-win32"
|
2016-10-18 00:22:21 +03:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(X86_64_O) $(WIN32_O))
|
2010-12-04 18:47:08 +03:00
|
|
|
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
2016-10-01 22:06:53 +03:00
|
|
|
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
2016-10-01 22:06:33 +03:00
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
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:53 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOPSRC)
|
2016-10-01 22:06:33 +03:00
|
|
|
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:53 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOPSRC)
|
2016-10-01 22:06:33 +03:00
|
|
|
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:53 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOPSRC)
|
2016-10-01 22:06:33 +03:00
|
|
|
else ifeq "$(TARGET)" "arm64"
|
2015-02-13 21:58:31 +03:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
|
|
|
|
TGT = -DTCC_TARGET_ARM64
|
2016-10-01 22:06:53 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOPSRC)
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
$(error libtcc1.a not supported on target '$(TARGET)')
|
|
|
|
endif
|
|
|
|
|
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
|
2017-02-11 11:30:20 +03:00
|
|
|
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
|
2010-12-04 18:47:08 +03:00
|
|
|
$(DIR)/%.o : %.S
|
2017-02-11 11:30:20 +03:00
|
|
|
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
|
2016-10-01 22:06:33 +03:00
|
|
|
# windows : utilities
|
2016-10-01 22:06:53 +03:00
|
|
|
$(DIR)/tiny_%$(EXESUF) : $(TOPSRC)/win32/tools/tiny_%.c
|
2016-10-01 22:06:33 +03:00
|
|
|
$(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-18 00:22:21 +03:00
|
|
|
rm -rf i386-win32 x86_64-win32 i386 x86_64 arm arm64
|