1
0
mirror of https://github.com/frida/tinycc synced 2024-12-24 14:06:48 +03:00
tinycc/lib/Makefile
grischka 5f33d313c8 tcc: re-enable correct option -r support
Forgot about it.  It allows to compile several
sources (and other .o's) to one single .o file;

    tcc -r -o all.o f1.c f2.c f3.S o4.o ...

Also:
- option -fold-struct-init-code removed, no effect anymore
- (tcc_)set_environment() moved to tcc.c
- win32/lib/(win)crt1 minor fix & add dependency
- debug line output for asm (tcc -c -g xxx.S) enabled
- configure/Makefiles: x86-64 -> x86_64 changes
- README: cleanup
2017-02-20 18:58:08 +01:00

97 lines
2.2 KiB
Makefile

#
# Tiny C Compiler Makefile for libtcc1.a
#
TOP = ..
include $(TOP)/Makefile
VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
ifndef TARGET
# we're building the native libtcc1.a
ifdef CONFIG_WIN32
ifeq ($(ARCH),x86_64)
TARGET = x86_64-win32
else
TARGET = i386-win32
endif
else ifeq ($(ARCH),i386)
TARGET = i386
else ifeq ($(ARCH),x86_64)
TARGET = x86_64
else ifeq ($(ARCH),arm)
TARGET = arm
else ifeq ($(ARCH),arm64)
TARGET = arm64
endif
BCHECK_O = bcheck.o
endif
DIR = $(TARGET)
native : ../libtcc1.a
cross : $(DIR)/libtcc1.a
native : TCC = $(TOP)/tcc$(EXESUF)
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
XCC = $(TCC) -B$(TOPSRC)
XAR = $(TCC) -ar
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
ARM_O = libtcc1.o armeabi.o alloca-arm.o
ARM64_O = lib-arm64.o
WIN32_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
ifeq "$(TARGET)" "i386-win32"
OBJ = $(addprefix $(DIR)/,$(I386_O) $(WIN32_O))
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
else ifeq "$(TARGET)" "x86_64-win32"
OBJ = $(addprefix $(DIR)/,$(X86_64_O) $(WIN32_O))
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
else ifeq "$(TARGET)" "i386"
OBJ = $(addprefix $(DIR)/,$(I386_O))
TGT = -DTCC_TARGET_I386
else ifeq "$(TARGET)" "x86_64"
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
TGT = -DTCC_TARGET_X86_64
else ifeq "$(TARGET)" "arm"
OBJ = $(addprefix $(DIR)/,$(ARM_O))
TGT = -DTCC_TARGET_ARM
# using gcc, need asm
XCC = $(CC)
XFLAGS = $(CFLAGS) -fPIC
XAR = $(AR)
else ifeq "$(TARGET)" "arm64"
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
TGT = -DTCC_TARGET_ARM64
else
$(error libtcc1.a not supported on target '$(TARGET)')
endif
ifeq ($(TARGETOS),Darwin)
XFLAGS += -D_ANSI_SOURCE
BCHECK_O =
endif
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ)
$(XAR) rcs $@ $(OBJ)
$(DIR)/%.o : %.c
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
$(DIR)/%.o : %.S
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
$(DIR)/crt1w.o : crt1.c
$(DIR)/wincrt1w.o : wincrt1.c
$(OBJ) : $(DIR)/exists
%/exists :
mkdir -p $(DIR)
@echo $@ > $@
clean :
rm -rf i386-win32 x86_64-win32 i386 x86_64 arm arm64