use of TOK_alloca breaks cross compiler build
[tinycc.git] / lib / Makefile
blob071c49ff571a399e475987cb2c6920e43f385911
2 # Tiny C Compiler Makefile for libtcc1.a
5 TOP = ..
6 include $(TOP)/config.mak
8 ifndef TARGET
9 ifdef CONFIG_WIN64
10 TARGET = x86_64-win32
11 else
12 ifdef CONFIG_WIN32
13 TARGET = i386-win32
14 else
15 ifeq ($(ARCH),i386)
16 TARGET = i386
17 XCC = gcc -O2
18 else
19 ifeq ($(ARCH),x86-64)
20 TARGET = x86_64
21 XCC = gcc -O2
22 endif
23 endif
24 endif
25 endif
26 endif
28 DIR = $(TARGET)
30 native : ../libtcc1.a
31 cross : $(DIR)/libtcc1.a
33 native : TCC = $(TOP)/tcc$(EXESUF)
34 cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
36 I386_O = libtcc1.o alloca86.o alloca86-bt.o
37 X86_64_O = libtcc1.o alloca86_64.o
38 WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o
39 WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
41 VPATH = $(TOP)/lib $(TOP)/win32/lib
43 ifeq "$(TARGET)" "i386-win32"
44 OBJ = $(addprefix $(DIR)/,$(WIN32_O))
45 TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
46 XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
47 XAR = $(DIR)/tiny_libmaker$(EXESUF)
48 else
49 ifeq "$(TARGET)" "x86_64-win32"
50 OBJ = $(addprefix $(DIR)/,$(WIN64_O))
51 TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
52 XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
53 XAR = $(DIR)/tiny_libmaker$(EXESUF)
54 else
55 ifeq "$(TARGET)" "i386"
56 OBJ = $(addprefix $(DIR)/,$(I386_O))
57 TGT = -DTCC_TARGET_I386
58 XCC ?= $(TCC) -B$(TOP)
59 else
60 ifeq "$(TARGET)" "x86_64"
61 OBJ = $(addprefix $(DIR)/,$(X86_64_O))
62 TGT = -DTCC_TARGET_X86_64
63 XCC ?= $(TCC) -B$(TOP)
64 else
65 $(error libtcc1.a not supported on target '$(TARGET)')
66 endif
67 endif
68 endif
69 endif
71 ifdef XAR
72 AR = $(XAR)
73 endif
75 $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
76 $(AR) rcs $@ $(OBJ)
77 $(DIR)/%.o : %.c
78 $(XCC) -c $< -o $@ $(TGT)
79 $(DIR)/%.o : %.S
80 $(XCC) -c $< -o $@ $(TGT)
81 $(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
82 $(CC) -Os -s -w -o $@ $< $(TGT)
84 $(OBJ) $(XAR) : $(DIR)/exists
85 $(DIR)/exists :
86 mkdir -p $(DIR)
87 @echo $@ > $@
89 clean :
90 rm -rfv i386-win32 x86_64-win32 i386 x86_64