Changelog: cleanup
[tinycc.git] / lib / Makefile
blob895c4bef456c6cb6493f5ce0112f6305c1048bb3
2 # Tiny C Compiler Makefile for libtcc1.a
5 TOP = ..
6 include $(TOP)/config.mak
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 = gcc -O2 -m32
20 endif
21 else
22 ifeq ($(ARCH),x86-64)
23 TARGET = x86_64
24 ifneq ($(TARGETOS),Darwin)
25 XCC = gcc -O2 -m64
26 endif
27 endif
28 endif
29 endif
30 endif
31 endif
33 DIR = $(TARGET)
35 native : ../libtcc1.a
36 cross : $(DIR)/libtcc1.a
38 native : TCC = $(TOP)/tcc$(EXESUF)
39 cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
41 I386_O = libtcc1.o alloca86.o alloca86-bt.o
42 X86_64_O = libtcc1.o alloca86_64.o
43 WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o bcheck.o
44 WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
46 ifeq "$(TARGET)" "i386-win32"
47 OBJ = $(addprefix $(DIR)/,$(WIN32_O))
48 TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
49 XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
50 XAR = $(DIR)/tiny_libmaker$(EXESUF)
51 else
52 ifeq "$(TARGET)" "x86_64-win32"
53 OBJ = $(addprefix $(DIR)/,$(WIN64_O))
54 TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
55 XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
56 XAR = $(DIR)/tiny_libmaker$(EXESUF)
57 else
58 ifeq "$(TARGET)" "i386"
59 OBJ = $(addprefix $(DIR)/,$(I386_O))
60 TGT = -DTCC_TARGET_I386
61 XCC ?= $(TCC) -B$(TOP) -m32 -D_ANSI_SOURCE
62 ifeq ($(TARGETOS),Darwin)
63 XAR = $(DIR)/tiny_libmaker$(EXESUF)
64 endif
65 else
66 ifeq "$(TARGET)" "x86_64"
67 OBJ = $(addprefix $(DIR)/,$(X86_64_O))
68 TGT = -DTCC_TARGET_X86_64
69 XCC ?= $(TCC) -B$(TOP) -m64 -D_ANSI_SOURCE
70 ifeq ($(TARGETOS),Darwin)
71 XAR = $(DIR)/tiny_libmaker$(EXESUF)
72 endif
73 else
74 $(error libtcc1.a not supported on target '$(TARGET)')
75 endif
76 endif
77 endif
78 endif
80 ifdef XAR
81 AR = $(XAR)
82 endif
84 $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
85 $(AR) rcs $@ $(OBJ)
86 $(DIR)/%.o : %.c
87 $(XCC) -c $< -o $@ $(CPPFLAGS) $(TGT) $(CFLAGS)
88 $(DIR)/%.o : %.S
89 $(XCC) -c $< -o $@ $(CPPFLAGS) $(TGT) $(CFLAGS)
90 $(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
91 $(CC) -Os -s -w -o $@ $< $(CPPFLAGS) $(TGT) $(CFLAGS) $(LDFLAGS)
93 $(OBJ) $(XAR) : $(DIR)/exists
94 $(DIR)/exists :
95 mkdir -p $(DIR)
96 @echo $@ > $@
98 clean :
99 rm -rfv i386-win32 x86_64-win32 i386 x86_64