Generate an error when a function is redefined
[tinycc.git] / lib / Makefile
blob300fa46f85afe3701daff77cf159785238c42c10
2 # Tiny C Compiler Makefile for libtcc1.a
5 TOP = ..
6 include $(TOP)/Makefile
7 VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
9 ifndef TARGET
10 ifdef CONFIG_WIN64
11 TARGET = x86_64-win32
12 else
13 ifdef CONFIG_WIN32
14 TARGET = i386-win32
15 else
16 ifeq ($(ARCH),i386)
17 TARGET = i386
18 ifneq ($(TARGETOS),Darwin)
19 XCC = $(CC)
20 endif
21 else
22 ifeq ($(ARCH),x86-64)
23 TARGET = x86_64
24 ifneq ($(TARGETOS),Darwin)
25 XCC = $(CC)
26 endif
27 endif
28 endif
29 endif
30 endif
31 BCHECK_O = bcheck.o
32 endif
34 DIR = $(TARGET)
36 native : ../libtcc1.a
37 cross : $(DIR)/libtcc1.a
39 native : TCC = $(TOP)/tcc$(EXESUF)
40 cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
42 I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
43 X86_64_O = libtcc1.o alloca86_64.o
44 WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
45 WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
47 ifeq "$(TARGET)" "i386-win32"
48 OBJ = $(addprefix $(DIR)/,$(WIN32_O))
49 TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
50 XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
51 XAR = $(DIR)/tiny_libmaker$(EXESUF)
52 else
53 ifeq "$(TARGET)" "x86_64-win32"
54 OBJ = $(addprefix $(DIR)/,$(WIN64_O))
55 TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
56 XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
57 XAR = $(DIR)/tiny_libmaker$(EXESUF)
58 else
59 ifeq "$(TARGET)" "i386"
60 OBJ = $(addprefix $(DIR)/,$(I386_O))
61 TGT = -DTCC_TARGET_I386
62 XCC ?= $(TCC) -B$(TOP)
63 else
64 ifeq "$(TARGET)" "x86_64"
65 OBJ = $(addprefix $(DIR)/,$(X86_64_O))
66 TGT = -DTCC_TARGET_X86_64
67 XCC ?= $(TCC) -B$(TOP)
68 else
69 $(error libtcc1.a not supported on target '$(TARGET)')
70 endif
71 endif
72 endif
73 endif
75 XFLAGS = $(CPPFLAGS) $(CFLAGS) $(TGT)
77 ifeq ($(TARGETOS),Darwin)
78 XAR = $(DIR)/tiny_libmaker$(EXESUF)
79 XFLAGS += -D_ANSI_SOURCE
80 BCHECK_O =
81 endif
83 ifdef XAR
84 AR = $(XAR)
85 endif
87 $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
88 $(AR) rcs $@ $(OBJ)
89 $(DIR)/%.o : %.c
90 $(XCC) -c $< -o $@ $(XFLAGS)
91 $(DIR)/%.o : %.S
92 $(XCC) -c $< -o $@ $(XFLAGS)
93 $(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
94 $(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
96 $(OBJ) $(XAR) : $(DIR)/exists
97 $(DIR)/exists :
98 mkdir -p $(DIR)
99 @echo $@ > $@
101 clean :
102 rm -rfv i386-win32 x86_64-win32 i386 x86_64
104 Makefile: $(top_srcdir)/lib/Makefile
105 cp $< $@