2010-12-04 18:47:08 +03:00
|
|
|
#
|
|
|
|
# Tiny C Compiler Makefile for libtcc1.a
|
|
|
|
#
|
|
|
|
|
2015-07-27 23:03:25 +03:00
|
|
|
TOP = ../src
|
2013-02-14 20:43:24 +04:00
|
|
|
include $(TOP)/Makefile
|
2015-07-27 23:03:25 +03:00
|
|
|
VPATH = $(top_srcdir)/../lib $(top_srcdir)/../win32/lib
|
2010-12-04 18:47:08 +03:00
|
|
|
|
2014-04-07 13:13:19 +04:00
|
|
|
ifndef TARGET # native library
|
2010-12-04 18:47:08 +03:00
|
|
|
ifdef CONFIG_WIN64
|
2015-03-04 11:19:39 +03:00
|
|
|
TARGET = x86_64-win
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifdef CONFIG_WIN32
|
2015-03-04 11:19:39 +03:00
|
|
|
TARGET = i386-win
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifeq ($(ARCH),i386)
|
|
|
|
TARGET = i386
|
|
|
|
else
|
|
|
|
ifeq ($(ARCH),x86-64)
|
|
|
|
TARGET = x86_64
|
2013-02-28 19:55:10 +04:00
|
|
|
else
|
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
TARGET = arm
|
2015-03-10 13:54:12 +03:00
|
|
|
XCC = $(CC)
|
2015-02-13 21:58:31 +03:00
|
|
|
else
|
|
|
|
ifeq ($(ARCH),arm64)
|
|
|
|
TARGET = arm64
|
|
|
|
else
|
|
|
|
endif
|
2013-02-28 19:55:10 +04:00
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-04-10 07:37:31 +03:00
|
|
|
BCHECK_O = bcheck.o
|
2010-12-04 18:47:08 +03:00
|
|
|
DIR = $(TARGET)
|
|
|
|
|
2015-07-27 23:03:25 +03:00
|
|
|
native : $(DIR)/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
|
|
|
|
|
2014-09-07 18:47:02 +04:00
|
|
|
# don't compile with -fstack-protector-strong, TCC doesn't handle it
|
|
|
|
# correctly
|
|
|
|
CFLAGS := $(filter-out -fstack-protector-strong,$(CFLAGS))
|
|
|
|
|
2015-03-04 11:19:39 +03:00
|
|
|
ifeq "$(TARGET)" "i386-win"
|
2010-12-04 18:47:08 +03:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
|
|
|
|
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
2015-07-27 23:03:25 +03:00
|
|
|
XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
|
2015-03-04 11:47:52 +03:00
|
|
|
XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
|
2014-04-07 13:13:19 +04:00
|
|
|
PICFLAGS =
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
2015-03-04 11:19:39 +03:00
|
|
|
ifeq "$(TARGET)" "x86_64-win"
|
2010-12-04 18:47:08 +03:00
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
2015-07-27 23:03:25 +03:00
|
|
|
XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/../include
|
2015-03-04 11:47:52 +03:00
|
|
|
XAR ?= $(DIR)/tiny_libmaker$(EXESUF)
|
2014-04-07 13:13:19 +04:00
|
|
|
PICFLAGS =
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "i386"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(I386_O))
|
|
|
|
TGT = -DTCC_TARGET_I386
|
2015-07-27 23:03:25 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "x86_64"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64
|
2015-07-27 23:03:25 +03:00
|
|
|
XCC ?= $(TCC) -B$(TOP) -I$(top_srcdir)/../include
|
2013-02-28 19:55:10 +04:00
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "arm"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(ARM_O))
|
|
|
|
TGT = -DTCC_TARGET_ARM
|
|
|
|
XCC ?= $(TCC) -B$(TOP)
|
2015-02-13 21:58:31 +03:00
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "arm64"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
|
|
|
|
TGT = -DTCC_TARGET_ARM64
|
|
|
|
XCC ?= $(TCC) -B$(TOP)
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
$(error libtcc1.a not supported on target '$(TARGET)')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2013-02-28 19:55:10 +04:00
|
|
|
endif
|
2015-02-13 21:58:31 +03:00
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
|
2014-04-02 23:27:22 +04:00
|
|
|
XFLAGS = $(CPPFLAGS) $(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
|
|
|
|
|
2015-03-19 13:07:02 +03:00
|
|
|
XAR ?= $(AR)
|
2010-12-04 18:47:08 +03:00
|
|
|
|
2015-07-27 23:03:25 +03:00
|
|
|
$(DIR)/libtcc1.a : $(OBJ) $(XAR)
|
2015-03-19 13:07:02 +03:00
|
|
|
$(XAR) 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)
|
2010-12-04 18:47:08 +03:00
|
|
|
$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
|
2013-02-14 20:43:24 +04:00
|
|
|
$(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
|
2010-12-04 18:47:08 +03:00
|
|
|
|
|
|
|
$(OBJ) $(XAR) : $(DIR)/exists
|
|
|
|
$(DIR)/exists :
|
|
|
|
mkdir -p $(DIR)
|
|
|
|
@echo $@ > $@
|
|
|
|
|
|
|
|
clean :
|
2015-03-20 08:52:01 +03:00
|
|
|
rm -rfv i386-win x86_64-win i386 x86_64 arm64
|