2010-12-04 18:47:08 +03:00
|
|
|
#
|
|
|
|
# Tiny C Compiler Makefile for libtcc1.a
|
|
|
|
#
|
|
|
|
|
|
|
|
TOP = ..
|
|
|
|
include $(TOP)/config.mak
|
2012-12-14 20:18:03 +04:00
|
|
|
VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
|
2010-12-04 18:47:08 +03:00
|
|
|
|
|
|
|
ifndef TARGET
|
|
|
|
ifdef CONFIG_WIN64
|
|
|
|
TARGET = x86_64-win32
|
|
|
|
else
|
|
|
|
ifdef CONFIG_WIN32
|
|
|
|
TARGET = i386-win32
|
|
|
|
else
|
|
|
|
ifeq ($(ARCH),i386)
|
|
|
|
TARGET = i386
|
2012-03-06 22:26:36 +04:00
|
|
|
ifneq ($(TARGETOS),Darwin)
|
|
|
|
XCC = gcc -O2 -m32
|
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifeq ($(ARCH),x86-64)
|
|
|
|
TARGET = x86_64
|
2012-03-06 22:26:36 +04:00
|
|
|
ifneq ($(TARGETOS),Darwin)
|
|
|
|
XCC = gcc -O2 -m64
|
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
DIR = $(TARGET)
|
|
|
|
|
|
|
|
native : ../libtcc1.a
|
|
|
|
cross : $(DIR)/libtcc1.a
|
|
|
|
|
|
|
|
native : TCC = $(TOP)/tcc$(EXESUF)
|
|
|
|
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
|
|
|
|
|
|
|
I386_O = libtcc1.o alloca86.o alloca86-bt.o
|
|
|
|
X86_64_O = libtcc1.o alloca86_64.o
|
|
|
|
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o
|
|
|
|
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
|
|
|
|
|
|
|
ifeq "$(TARGET)" "i386-win32"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
|
|
|
|
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
|
|
|
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "x86_64-win32"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(WIN64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
|
|
|
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "i386"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(I386_O))
|
|
|
|
TGT = -DTCC_TARGET_I386
|
2012-03-06 22:26:36 +04:00
|
|
|
XCC ?= $(TCC) -B$(TOP) -m32 -D_ANSI_SOURCE
|
|
|
|
ifeq ($(TARGETOS),Darwin)
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
ifeq "$(TARGET)" "x86_64"
|
|
|
|
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
|
|
|
TGT = -DTCC_TARGET_X86_64
|
2012-03-06 22:26:36 +04:00
|
|
|
XCC ?= $(TCC) -B$(TOP) -m64 -D_ANSI_SOURCE
|
|
|
|
ifeq ($(TARGETOS),Darwin)
|
|
|
|
XAR = $(DIR)/tiny_libmaker$(EXESUF)
|
|
|
|
endif
|
2010-12-04 18:47:08 +03:00
|
|
|
else
|
|
|
|
$(error libtcc1.a not supported on target '$(TARGET)')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef XAR
|
|
|
|
AR = $(XAR)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
|
|
|
|
$(AR) rcs $@ $(OBJ)
|
|
|
|
$(DIR)/%.o : %.c
|
2012-10-22 13:11:42 +04:00
|
|
|
$(XCC) -c $< -o $@ $(CPPFLAGS) $(TGT) $(CFLAGS)
|
2010-12-04 18:47:08 +03:00
|
|
|
$(DIR)/%.o : %.S
|
2012-10-22 13:11:42 +04:00
|
|
|
$(XCC) -c $< -o $@ $(CPPFLAGS) $(TGT) $(CFLAGS)
|
2010-12-04 18:47:08 +03:00
|
|
|
$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
|
2012-10-22 13:11:42 +04:00
|
|
|
$(CC) -Os -s -w -o $@ $< $(CPPFLAGS) $(TGT) $(CFLAGS) $(LDFLAGS)
|
2010-12-04 18:47:08 +03:00
|
|
|
|
|
|
|
$(OBJ) $(XAR) : $(DIR)/exists
|
|
|
|
$(DIR)/exists :
|
|
|
|
mkdir -p $(DIR)
|
|
|
|
@echo $@ > $@
|
|
|
|
|
|
|
|
clean :
|
|
|
|
rm -rfv i386-win32 x86_64-win32 i386 x86_64
|