Mostly revert "tccpp.c: minor fix I'd accidentally not committed"
[tinycc.git] / Makefile
Commit [+]AuthorDateLineData
eb0e3e70 bellard2001-11-11 18:01:29 +00001#
2# Tiny C Compiler Makefile
3#
5829791f grischka2009-04-18 14:31:35 +02004
5TOP ?= .
6include $(TOP)/config.mak
3f09b90d Akim Demaille2012-12-14 17:18:03 +01007VPATH = $(top_srcdir)
86ffc481 grischka2010-12-04 16:47:08 +01008
87d879aa Matteo Cypriani2014-09-07 11:57:09 -04009CPPFLAGS += -I$(TOP) # for config.h
17cf0dcf grischka2013-01-30 18:39:09 +010010
48d12e42 seyko2015-03-04 11:47:52 +030011ifneq (-$(findstring gcc,$(CC))-,-gcc-)
c4397b2b grischka2013-02-14 21:15:56 +010012ifeq (-$(findstring clang,$(CC))-,-clang-)
062efe6a Urs Janssen2013-02-14 08:24:51 +010013# make clang accept gnuisms in libtcc1.c
062efe6a
UJ
Urs Janssen2013-02-14 08:24:51 +010014CFLAGS+=-fheinous-gnu-extensions
15endif
c4397b2b grischka2013-02-14 21:15:56 +010016endif
17
18CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
19CFLAGS_P=$(CFLAGS) -pg -static
20LIBS_P=
21LDFLAGS_P=$(LDFLAGS)
062efe6a Urs Janssen2013-02-14 08:24:51 +010022
86ffc481 grischka2010-12-04 16:47:08 +010023ifdef CONFIG_WIN64
24CONFIG_WIN32=yes
2eaa1104 grischka2008-03-08 19:55:47 +000025endif
15626621 grischka2009-04-19 21:24:32 +020026
27ifndef CONFIG_WIN32
86ffc481 grischka2010-12-04 16:47:08 +010028LIBS=-lm
29ifndef CONFIG_NOLDL
30LIBS+=-ldl
31endif
15626621 grischka2009-04-19 21:24:32 +020032endif
33
86ffc481 grischka2010-12-04 16:47:08 +010034# make libtcc as static or dynamic library?
35ifdef DISABLE_STATIC
2bbfaf43 James Lyon2013-04-18 17:27:34 +010036ifndef CONFIG_WIN32
86ffc481 grischka2010-12-04 16:47:08 +010037LIBTCC=libtcc.so.1.0
2bbfaf43
JL
James Lyon2013-04-18 17:27:34 +010038else
39LIBTCC=libtcc.dll
40LIBTCC_DLL=yes
41LIBTCC_EXTRA=libtcc.def libtcc.a
42endif
86ffc481 grischka2010-12-04 16:47:08 +010043LINK_LIBTCC=-Wl,-rpath,"$(libdir)"
90355c78 Henry Kroll III2010-12-20 05:55:54 -080044ifdef DISABLE_RPATH
44f7055a Henry Kroll III2010-12-21 08:44:48 -080045LINK_LIBTCC=
90355c78 Henry Kroll III2010-12-20 05:55:54 -080046endif
86ffc481 grischka2010-12-04 16:47:08 +010047else
48LIBTCC=libtcc.a
49LINK_LIBTCC=
15626621 grischka2009-04-19 21:24:32 +020050endif
51
c4397b2b grischka2013-02-14 21:15:56 +010052CONFIG_$(ARCH) = yes
53NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
54NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
55NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
56NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
fbb48416 Thomas Preud'homme2013-02-28 16:55:10 +010057NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
c4397b2b grischka2013-02-14 21:15:56 +010058NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
59NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
60NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +000061NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64
c4397b2b grischka2013-02-14 21:15:56 +010062NATIVE_DEFINES += $(NATIVE_DEFINES_yes)
63
5829791f grischka2009-04-18 14:31:35 +020064ifeq ($(TOP),.)
7baf9681 bellard2005-04-14 23:52:04 +000065
7baf9681 bellard2005-04-14 23:52:04 +000066PROGS=tcc$(EXESUF)
bf2854d2 Thomas Preud'homme2014-01-04 21:57:52 +080067I386_CROSS = i386-linux-gnu-tcc$(EXESUF)
54fc439e seyko2015-03-04 11:19:39 +030068WIN32_CROSS = i386-win-mingw32-tcc$(EXESUF)
69WIN64_CROSS = x86_64-win-mingw32-tcc$(EXESUF)
70WINCE_CROSS = arm-win-mingw32ce-tcc$(EXESUF)
bf2854d2
TP
Thomas Preud'homme2014-01-04 21:57:52 +080071X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF)
72ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF)
73ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF)
74ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF)
75ARM_EABI_CROSS = arm-linux-gnueabi-tcc$(EXESUF)
76ARM_EABIHF_CROSS = arm-linux-gnueabihf-tcc$(EXESUF)
903b6001 grischka2009-12-20 20:34:35 +010077ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS)
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +000078ARM64_CROSS = arm64-tcc$(EXESUF)
15626621 grischka2009-04-19 21:24:32 +020079C67_CROSS = c67-tcc$(EXESUF)
80
bf2854d2
TP
Thomas Preud'homme2014-01-04 21:57:52 +080081# Legacy symlinks for cross compilers
82$(I386_CROSS)_LINK = i386-tcc$(EXESUF)
54fc439e seyko2015-03-04 11:19:39 +030083$(WIN32_CROSS)_LINK = i386-win-tcc$(EXESUF)
84$(WIN64_CROSS)_LINK = x86_64-win-tcc$(EXESUF)
85$(WINCE_CROSS)_LINK = arm-win-tcc$(EXESUF)
bf2854d2
TP
Thomas Preud'homme2014-01-04 21:57:52 +080086$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF)
87$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF)
88$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF)
89$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF)
90$(ARM_EABI_CROSS)_LINK = arm-eabi-tcc$(EXESUF)
91
7e7e6148 seyko2015-04-10 07:37:31 +030092ifeq ($(TARGETOS),Windows)
87ec08ec seyko2015-03-10 13:39:26 +030093ifeq ($(ARCH),i386)
94PROGS:=$($(WIN32_CROSS)_LINK)
95$($(WIN32_CROSS)_LINK)_TCC = yes
96endif
97ifeq ($(ARCH),x86-64)
98PROGS:=$($(WIN64_CROSS)_LINK)
99$($(WIN64_CROSS)_LINK)_TCC = yes
100endif
101endif
102
7e7e6148 seyko2015-04-10 07:37:31 +0300103ifeq ($(TARGETOS),Linux)
76af9486 seyko2015-03-04 11:40:33 +0300104ifeq ($(ARCH),i386)
105PROGS:=$($(I386_CROSS)_LINK)
106$($(I386_CROSS)_LINK)_TCC = yes
107endif
108ifeq ($(ARCH),x86-64)
109PROGS:=$($(X64_CROSS)_LINK)
110$($(X64_CROSS)_LINK)_TCC = yes
111endif
87ec08ec seyko2015-03-10 13:39:26 +0300112endif
76af9486 seyko2015-03-04 11:40:33 +0300113
903b6001 grischka2009-12-20 20:34:35 +0100114CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
115CORE_FILES += tcc.h config.h libtcc.h tcctok.h
526c4645
FF
Frederic Feret2009-08-27 09:53:50 +0200116I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
117WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
1308e8eb grischka2009-12-19 22:08:37 +0100118WIN64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
b7d7af4f Frederic Feret2009-08-27 10:25:28 +0200119WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
1308e8eb grischka2009-12-19 22:08:37 +0100120X86_64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h
15626621 grischka2009-04-19 21:24:32 +0200121ARM_FILES = $(CORE_FILES) arm-gen.c
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +0000122ARM64_FILES = $(CORE_FILES) arm64-gen.c
15626621 grischka2009-04-19 21:24:32 +0200123C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
5829791f grischka2009-04-18 14:31:35 +0200124
86ffc481 grischka2010-12-04 16:47:08 +0100125ifdef CONFIG_WIN64
126PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
127NATIVE_FILES=$(WIN64_FILES)
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +0000128PROGS_CROSS=$(WIN32_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
54fc439e seyko2015-03-04 11:19:39 +0300129LIBTCC1_CROSS=lib/i386-win/libtcc1.a
86ffc481 grischka2010-12-04 16:47:08 +0100130LIBTCC1=libtcc1.a
8adfb4a4 Akim Demaille2012-12-21 14:17:16 +0100131else ifdef CONFIG_WIN32
86ffc481 grischka2010-12-04 16:47:08 +0100132PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
133NATIVE_FILES=$(WIN32_FILES)
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +0000134PROGS_CROSS=$(WIN64_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
54fc439e seyko2015-03-04 11:19:39 +0300135LIBTCC1_CROSS=lib/x86_64-win/libtcc1.a
86ffc481 grischka2010-12-04 16:47:08 +0100136LIBTCC1=libtcc1.a
8adfb4a4 Akim Demaille2012-12-21 14:17:16 +0100137else ifeq ($(ARCH),i386)
86ffc481 grischka2010-12-04 16:47:08 +0100138NATIVE_FILES=$(I386_FILES)
76af9486 seyko2015-03-04 11:40:33 +0300139PROGS_CROSS=$($(X64_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
cfaa165e seyko2015-03-20 08:52:01 +0300140LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
141 lib/arm64/libtcc1.a
86ffc481 grischka2010-12-04 16:47:08 +0100142LIBTCC1=libtcc1.a
8adfb4a4 Akim Demaille2012-12-21 14:17:16 +0100143else ifeq ($(ARCH),x86-64)
2ba7542e
RC
Raphael Cohn2015-04-07 15:28:31 +0100144ifeq ($(TARGETOS),Darwin)
145NATIVE_FILES=$(X86_64_FILES)
50fc86a4 Raphael Cohn2015-04-07 15:55:41 +0100146PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
2ba7542e
RC
Raphael Cohn2015-04-07 15:28:31 +0100147LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a
148LIBTCC1=libtcc1.a
149else
86ffc481 grischka2010-12-04 16:47:08 +0100150NATIVE_FILES=$(X86_64_FILES)
50fc86a4 Raphael Cohn2015-04-07 15:55:41 +0100151PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
cfaa165e seyko2015-03-20 08:52:01 +0300152LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \
153 lib/arm64/libtcc1.a
86ffc481 grischka2010-12-04 16:47:08 +0100154LIBTCC1=libtcc1.a
2ba7542e Raphael Cohn2015-04-07 15:28:31 +0100155endif
8adfb4a4 Akim Demaille2012-12-21 14:17:16 +0100156else ifeq ($(ARCH),arm)
86ffc481 grischka2010-12-04 16:47:08 +0100157NATIVE_FILES=$(ARM_FILES)
b14ef0e2
EGE
Edmund Grimley Evans2015-02-13 18:58:31 +0000158PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
159LIBTCC1=libtcc1.a
54fc439e seyko2015-03-04 11:19:39 +0300160LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
b14ef0e2
EGE
Edmund Grimley Evans2015-02-13 18:58:31 +0000161else ifeq ($(ARCH),arm64)
162NATIVE_FILES=$(ARM64_FILES)
163PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS)
fbb48416 Thomas Preud'homme2013-02-28 16:55:10 +0100164LIBTCC1=libtcc1.a
54fc439e seyko2015-03-04 11:19:39 +0300165LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a
86ffc481 grischka2010-12-04 16:47:08 +0100166endif
bf2854d2 Thomas Preud'homme2014-01-04 21:57:52 +0800167PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK))
5829791f grischka2009-04-18 14:31:35 +0200168
6e13c353 Milutin Jovanovic2012-02-16 11:24:14 -0500169ifeq ($(TARGETOS),Darwin)
de54586d Milutin Jovanovic2012-03-06 13:26:36 -0500170PROGS+=tiny_libmaker$(EXESUF)
6e13c353 Milutin Jovanovic2012-02-16 11:24:14 -0500171endif
ac0b7d82 Henry Kroll III2010-04-26 01:27:15 -0700172
2bbfaf43 James Lyon2013-04-18 17:27:34 +0100173TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCC_EXTRA)
571465d3 Thomas Preud'homme2011-07-07 12:14:08 +0200174TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
86ffc481 grischka2010-12-04 16:47:08 +0100175
7baf9681 bellard2005-04-14 23:52:04 +0000176ifdef CONFIG_CROSS
86ffc481 grischka2010-12-04 16:47:08 +0100177PROGS+=$(PROGS_CROSS)
178TCCLIBS+=$(LIBTCC1_CROSS)
0a9873aa Shinichiro Hamaji2008-12-02 03:19:25 +0900179endif
7baf9681 bellard2005-04-14 23:52:04 +0000180
8c56b0cf Thomas Preud'homme2013-01-14 17:34:07 +0100181all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
5829791f grischka2009-04-18 14:31:35 +0200182
7baf9681 bellard2005-04-14 23:52:04 +0000183# Host Tiny C Compiler
86ffc481 grischka2010-12-04 16:47:08 +0100184tcc$(EXESUF): tcc.o $(LIBTCC)
8c56b0cf Thomas Preud'homme2013-01-14 17:34:07 +0100185 $(CC) -o $@ $^ $(LIBS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC)
eb0e3e70 bellard2001-11-11 18:01:29 +0000186
7baf9681 bellard2005-04-14 23:52:04 +0000187# Cross Tiny C Compilers
1b1e7ee1 Thomas Preud'homme2013-01-30 19:39:29 +0100188%-tcc$(EXESUF): tcc.c
aba2d648 seyko2015-03-22 18:05:29 +0300189 $(CC) -o $@ $< -DONE_SOURCE $(if $($@_TCC),$(NATIVE_DEFINES),$(DEFINES)) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS)
bf2854d2 Thomas Preud'homme2014-01-04 21:57:52 +0800190 $(if $($@_LINK),ln -sf $@ $($@_LINK))
883aafc6 Roy2015-03-06 10:25:47 +0800191 $(if $($@_TCC),ln -sf $@ tcc$(EXESUF))
903b6001 grischka2009-12-20 20:34:35 +0100192
7a477d70 grischka2013-02-06 19:01:07 +0100193# profiling version
194tcc_p$(EXESUF): $(NATIVE_FILES)
195 $(CC) -o $@ $< -DONE_SOURCE $(NATIVE_DEFINES) $(CPPFLAGS_P) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
196
76af9486 seyko2015-03-04 11:40:33 +0300197$(I386_CROSS) $($(I386_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386
198$(X64_CROSS) $($(X64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64
199$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \
df9cce24 grischka2011-08-01 01:10:36 +0200200 -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
74a24d77 grischka2011-08-11 16:55:30 +0200201 -DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\""
76af9486 seyko2015-03-04 11:40:33 +0300202$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \
df9cce24 grischka2011-08-01 01:10:36 +0200203 -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
74a24d77 grischka2011-08-11 16:55:30 +0200204 -DCONFIG_TCC_LIBPATHS="\"{B}/lib/64;{B}/lib\""
903b6001 grischka2009-12-20 20:34:35 +0100205$(WINCE_CROSS): DEFINES = -DTCC_TARGET_PE
206$(C67_CROSS): DEFINES = -DTCC_TARGET_C67
207$(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM
208$(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
7ec39e22 seyko2015-03-04 10:50:33 +0300209$(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP
210$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +0000211$(ARM64_CROSS): DEFINES = -DTCC_TARGET_ARM64
903b6001 grischka2009-12-20 20:34:35 +0100212
65a4fbd1 seyko2015-03-06 16:19:10 +0300213$(I386_CROSS) $($(I386_CROSS)_LINK): $(I386_FILES)
214$(X64_CROSS) $($(X64_CROSS)_LINK): $(X86_64_FILES)
215$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): $(WIN32_FILES)
216$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): $(WIN64_FILES)
217$(WINCE_CROSS) $($(WINCE_CROSS)_LINK): $(WINCE_FILES)
218$(C67_CROSS) $($(C67_CROSS)_LINK): $(C67_FILES)
903b6001 grischka2009-12-20 20:34:35 +0100219$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
65a4fbd1 seyko2015-03-06 16:19:10 +0300220$($(ARM_FPA_CROSS)_LINK) $($(ARM_FPA_LD_CROSS)_LINK) $($(ARM_VFP_CROSS)_LINK) $($(ARM_EABI_CROSS)_LINK): $(ARM_FILES)
b14ef0e2 Edmund Grimley Evans2015-02-13 18:58:31 +0000221$(ARM64_CROSS): $(ARM64_FILES)
5829791f grischka2009-04-18 14:31:35 +0200222
223# libtcc generation and test
5280293d grischka2011-07-14 18:45:37 +0200224ifndef ONE_SOURCE
88a3ccab grischka2009-12-20 01:53:49 +0100225LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
226LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
88a3ccab grischka2009-12-20 01:53:49 +0100227else
228LIBTCC_OBJ = libtcc.o
229LIBTCC_INC = $(NATIVE_FILES)
ab936aeb grischka2012-04-18 18:43:09 +0200230libtcc.o : NATIVE_DEFINES += -DONE_SOURCE
88a3ccab grischka2009-12-20 01:53:49 +0100231endif
232
88a3ccab grischka2009-12-20 01:53:49 +0100233$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
a7f010ee Thomas Preud'homme2012-10-22 11:11:42 +0200234 $(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CPPFLAGS) $(CFLAGS)
88a3ccab grischka2009-12-20 01:53:49 +0100235
2bbfaf43 James Lyon2013-04-18 17:27:34 +0100236ifndef LIBTCC_DLL
88a3ccab grischka2009-12-20 01:53:49 +0100237libtcc.a: $(LIBTCC_OBJ)
5829791f grischka2009-04-18 14:31:35 +0200238 $(AR) rcs $@ $^
2bbfaf43 James Lyon2013-04-18 17:27:34 +0100239endif
e8039673 Daniel Glöckner2008-09-05 21:07:56 +0200240
76599239 Henry Kroll III2010-04-25 13:34:02 -0700241libtcc.so.1.0: $(LIBTCC_OBJ)
a7f010ee Thomas Preud'homme2012-10-22 11:11:42 +0200242 $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
80b4c698 Henry Kroll III2010-04-24 13:27:56 -0700243
86ffc481 grischka2010-12-04 16:47:08 +0100244libtcc.so.1.0: CFLAGS+=-fPIC
6e5b1cc4 bellard2004-10-04 22:19:21 +0000245
2bbfaf43
JL
James Lyon2013-04-18 17:27:34 +0100246ifdef LIBTCC_DLL
247libtcc.dll libtcc.def libtcc.a: $(LIBTCC_OBJ)
248 $(CC) -shared $^ -o $@ $(LDFLAGS) -Wl,--output-def,libtcc.def,--out-implib,libtcc.a
249endif
250
7baf9681 bellard2005-04-14 23:52:04 +0000251# windows utilities
2eaa1104 grischka2008-03-08 19:55:47 +0000252tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
a7f010ee Thomas Preud'homme2012-10-22 11:11:42 +0200253 $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
2eaa1104 grischka2008-03-08 19:55:47 +0000254tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
a7f010ee Thomas Preud'homme2012-10-22 11:11:42 +0200255 $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
7baf9681 bellard2005-04-14 23:52:04 +0000256
840d197e bellard2002-07-24 22:13:02 +0000257# TinyCC runtime libraries
86ffc481 grischka2010-12-04 16:47:08 +0100258libtcc1.a : FORCE
d6d7686b grischka2013-02-08 19:07:11 +0100259 $(MAKE) -C lib native
76af9486 seyko2015-03-04 11:40:33 +0300260 if test ! -d $(ARCH); then mkdir $(ARCH); fi
883aafc6 Roy2015-03-06 10:25:47 +0800261 if test ! -L $(ARCH)/$@; then ln -sf ../$@ $(ARCH)/$@; fi
33f86ada Henry Kroll III2010-12-05 12:39:55 -0800262lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
d6d7686b grischka2013-02-08 19:07:11 +0100263 $(MAKE) -C lib cross TARGET=$*
7a477d70 grischka2013-02-06 19:01:07 +0100264
86ffc481 grischka2010-12-04 16:47:08 +0100265FORCE:
fe3b68b0 bellard2003-05-24 15:45:33 +0000266
5829791f grischka2009-04-18 14:31:35 +0200267# install
1caee8ab James Lyon2013-04-25 22:30:53 +0100268TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h
5829791f grischka2009-04-18 14:31:35 +0200269INSTALL=install
3511e6e2
TP
Thomas Preud'homme2011-06-17 22:22:04 +0200270ifdef STRIP_BINARIES
271INSTALLBIN=$(INSTALL) -s
272else
273INSTALLBIN=$(INSTALL)
274endif
cb96022a bellard2003-04-13 19:48:19 +0000275
0382131c
TP
Thomas Preud'homme2014-01-04 09:48:15 +0800276install-strip: install
277 strip $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG))
278
13affef3 bellard2004-10-07 21:11:43 +0000279ifndef CONFIG_WIN32
86ffc481 grischka2010-12-04 16:47:08 +0100280install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
5829791f grischka2009-04-18 14:31:35 +0200281 mkdir -p "$(bindir)"
3511e6e2 Thomas Preud'homme2011-06-17 22:22:04 +0200282 $(INSTALLBIN) -m755 $(PROGS) "$(bindir)"
8764993c seyko2015-03-06 17:13:45 +0300283 cp -P tcc$(EXESUF) "$(bindir)"
5829791f grischka2009-04-18 14:31:35 +0200284 mkdir -p "$(mandir)/man1"
99851b0d Vincent Lefevre2014-01-07 16:05:31 +0100285 -$(INSTALL) -m644 tcc.1 "$(mandir)/man1"
86ffc481 grischka2010-12-04 16:47:08 +0100286 mkdir -p "$(infodir)"
99851b0d Vincent Lefevre2014-01-07 16:05:31 +0100287 -$(INSTALL) -m644 tcc-doc.info "$(infodir)"
5829791f grischka2009-04-18 14:31:35 +0200288 mkdir -p "$(tccdir)"
289 mkdir -p "$(tccdir)/include"
86ffc481 grischka2010-12-04 16:47:08 +0100290ifneq ($(LIBTCC1),)
76af9486 seyko2015-03-04 11:40:33 +0300291 mkdir -p "$(tccdir)/$(ARCH)"
292 $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)/$(ARCH)"
86ffc481 grischka2010-12-04 16:47:08 +0100293endif
1caee8ab James Lyon2013-04-25 22:30:53 +0100294 $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
5829791f grischka2009-04-18 14:31:35 +0200295 mkdir -p "$(libdir)"
99851b0d Vincent Lefevre2014-01-07 16:05:31 +0100296 $(INSTALL) -m644 $(LIBTCC) "$(libdir)"
76599239
HKI
Henry Kroll III2010-04-25 13:34:02 -0700297ifdef DISABLE_STATIC
298 ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
299 ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
239fdf0b Henry Kroll III2010-04-24 21:58:12 -0700300endif
a4e630c7
TP
Thomas Preud'homme2013-01-14 18:16:17 +0100301 mkdir -p "$(includedir)"
302 $(INSTALL) -m644 $(top_srcdir)/libtcc.h "$(includedir)"
e81569bc grischka2009-12-19 22:08:15 +0100303 mkdir -p "$(docdir)"
86ffc481 grischka2010-12-04 16:47:08 +0100304 -$(INSTALL) -m644 tcc-doc.html "$(docdir)"
239fdf0b Henry Kroll III2010-04-24 21:58:12 -0700305ifdef CONFIG_CROSS
a2779556 Henry Kroll III2010-12-02 03:08:57 -0800306 mkdir -p "$(tccdir)/win32/lib/32"
a2779556 Henry Kroll III2010-12-02 03:08:57 -0800307 mkdir -p "$(tccdir)/win32/lib/64"
1c821373 Henry Kroll III2010-12-05 01:04:28 -0800308 mkdir -p "$(tccdir)/i386"
e3851d23 seyko2015-03-20 09:27:59 +0300309 mkdir -p "$(tccdir)/x86-64"
aa6946b9 Raphael Cohn2015-04-07 16:06:43 +0100310ifneq ($(HOST_OS),Darwin)
cfaa165e seyko2015-03-20 08:52:01 +0300311 mkdir -p "$(tccdir)/arm64"
312 $(INSTALL) -m644 lib/arm64/libtcc1.a "$(tccdir)/arm64"
2ba7542e Raphael Cohn2015-04-07 15:28:31 +0100313endif
1c821373 Henry Kroll III2010-12-05 01:04:28 -0800314 $(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
e3851d23 seyko2015-03-20 09:27:59 +0300315 $(INSTALL) -m644 lib/x86_64/libtcc1.a "$(tccdir)/x86-64"
1caee8ab James Lyon2013-04-25 22:30:53 +0100316 $(INSTALL) -m644 $(top_srcdir)/win32/lib/*.def "$(tccdir)/win32/lib"
54fc439e seyko2015-03-04 11:19:39 +0300317 $(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/win32/lib/32"
318 $(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/win32/lib/64"
1caee8ab James Lyon2013-04-25 22:30:53 +0100319 cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include"
767410b8 Thomas Preud'homme2014-01-09 17:15:08 +0800320 cp -r "$(tccdir)/include" "$(tccdir)/win32"
239fdf0b Henry Kroll III2010-04-24 21:58:12 -0700321endif
5829791f grischka2009-04-18 14:31:35 +0200322
323uninstall:
324 rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
8764993c seyko2015-03-06 17:13:45 +0300325 rm -fv "$(bindir)/tcc$(EXESUF)"
7a477d70 grischka2013-02-06 19:01:07 +0100326 rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
5829791f grischka2009-04-18 14:31:35 +0200327 rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
76af9486 seyko2015-03-04 11:40:33 +0300328 rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
86ffc481 grischka2010-12-04 16:47:08 +0100329 rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
330 rm -fv "$(libdir)/libtcc.so*"
76af9486 seyko2015-03-04 11:40:33 +0300331 rm -rv "$(tccdir)"
332 rm -rv "$(docdir)"
a2779556 Henry Kroll III2010-12-02 03:08:57 -0800333else
86ffc481 grischka2010-12-04 16:47:08 +0100334# on windows
335install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
5829791f grischka2009-04-18 14:31:35 +0200336 mkdir -p "$(tccdir)"
337 mkdir -p "$(tccdir)/lib"
338 mkdir -p "$(tccdir)/include"
339 mkdir -p "$(tccdir)/examples"
340 mkdir -p "$(tccdir)/doc"
341 mkdir -p "$(tccdir)/libtcc"
3511e6e2 Thomas Preud'homme2011-06-17 22:22:04 +0200342 $(INSTALLBIN) -m755 $(PROGS) "$(tccdir)"
7e7e6148 seyko2015-04-10 07:37:31 +0300343 $(INSTALLBIN) -m755 tcc.exe "$(tccdir)"
1d673cbf
JL
James Lyon2013-04-17 17:31:18 +0100344 $(INSTALL) -m644 $(LIBTCC1) $(top_srcdir)/win32/lib/*.def "$(tccdir)/lib"
345 cp -r $(top_srcdir)/win32/include/. "$(tccdir)/include"
346 cp -r $(top_srcdir)/win32/examples/. "$(tccdir)/examples"
1caee8ab James Lyon2013-04-25 22:30:53 +0100347 $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
1d673cbf James Lyon2013-04-17 17:31:18 +0100348 $(INSTALL) -m644 tcc-doc.html $(top_srcdir)/win32/tcc-win32.txt "$(tccdir)/doc"
2bbfaf43 James Lyon2013-04-18 17:27:34 +0100349 $(INSTALL) -m644 $(top_srcdir)/libtcc.h $(LIBTCC_EXTRA) "$(tccdir)/libtcc"
7e7e6148 seyko2015-04-10 07:37:31 +0300350 $(INSTALL) -m644 $(LIBTCC) "$(tccdir)"
a2779556 Henry Kroll III2010-12-02 03:08:57 -0800351ifdef CONFIG_CROSS
86ffc481 grischka2010-12-04 16:47:08 +0100352 mkdir -p "$(tccdir)/lib/32"
353 mkdir -p "$(tccdir)/lib/64"
54fc439e seyko2015-03-04 11:19:39 +0300354 -$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/lib/32"
355 -$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/lib/64"
a2779556
HKI
Henry Kroll III2010-12-02 03:08:57 -0800356endif
357
86ffc481 grischka2010-12-04 16:47:08 +0100358uninstall:
359 rm -rfv "$(tccdir)/*"
0a9873aa Shinichiro Hamaji2008-12-02 03:19:25 +0900360endif
1e14c90c bellard2002-05-13 22:58:22 +0000361
f0d5a74b bellard2003-05-18 18:11:06 +0000362# documentation and man page
840d197e bellard2002-07-24 22:13:02 +0000363tcc-doc.html: tcc-doc.texi
d0c4138a Thomas Preud'homme2013-05-29 13:14:59 +0200364 -makeinfo --no-split --html --number-sections -o $@ $<
840d197e bellard2002-07-24 22:13:02 +0000365
f0d5a74b bellard2003-05-18 18:11:06 +0000366tcc.1: tcc-doc.texi
3f09b90d Akim Demaille2012-12-14 17:18:03 +0100367 -$(top_srcdir)/texi2pod.pl $< tcc.pod
0bdbd49e Urs Janssen2013-02-17 00:48:51 +0100368 -pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/VERSION` tcc.pod > $@
f0d5a74b bellard2003-05-18 18:11:06 +0000369
3f829d11 Thomas Preud'homme2010-09-10 21:19:01 +0200370tcc-doc.info: tcc-doc.texi
3f09b90d Akim Demaille2012-12-14 17:18:03 +0100371 -makeinfo $<
3f829d11 Thomas Preud'homme2010-09-10 21:19:01 +0200372
5829791f grischka2009-04-18 14:31:35 +0200373# in tests subdir
eb152022
TP
Thomas Preud'homme2011-05-14 16:21:45 +0200374export LIBTCC1
375
fad8e13c Iavael2014-01-23 21:19:56 +0400376%est:
32a49625 grischka2014-01-21 13:25:14 +0100377 $(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)'
86ffc481 grischka2010-12-04 16:47:08 +0100378
88a3ccab grischka2009-12-20 01:53:49 +0100379clean:
73e8f6b6 Lee Duhem2014-11-26 11:48:07 +0800380 rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.log \
44c6e992 Roy2015-03-05 09:12:42 +0800381 *.exe a.out tags TAGS libtcc_test$(EXESUF) tcc$(EXESUF)
cfaa165e seyko2015-03-20 08:52:01 +0300382 -rm -r $(ARCH) arm64
7e7e6148 seyko2015-04-10 07:37:31 +0300383ifeq ($(HOST_OS),Linux)
384 -rm -r ./C:
385endif
44c6e992 Roy2015-03-05 09:12:42 +0800386 -rm *-tcc$(EXESUF)
88a3ccab grischka2009-12-20 01:53:49 +0100387 $(MAKE) -C tests $@
921f002a Thomas Preud'homme2011-05-14 16:21:45 +0200388ifneq ($(LIBTCC1),)
86ffc481 grischka2010-12-04 16:47:08 +0100389 $(MAKE) -C lib $@
921f002a Thomas Preud'homme2011-05-14 16:21:45 +0200390endif
5829791f grischka2009-04-18 14:31:35 +0200391
392distclean: clean
3f829d11 Thomas Preud'homme2010-09-10 21:19:01 +0200393 rm -vf config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
5829791f grischka2009-04-18 14:31:35 +0200394
88a3ccab grischka2009-12-20 01:53:49 +0100395config.mak:
86ffc481 grischka2010-12-04 16:47:08 +0100396 @echo "Please run ./configure."
397 @exit 1
88a3ccab grischka2009-12-20 01:53:49 +0100398
73e8f6b6
LD
Lee Duhem2014-11-26 11:48:07 +0800399tags:
400 ctags $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
401
402TAGS:
403 ctags -e $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS]
404
5ebc6a96 grischka2012-12-20 21:29:57 +0100405# create release tarball from *current* git branch (including tcc-doc.html
406# and converting two files to CRLF)
7667a888 Akim Demaille2012-12-21 14:17:23 +0100407TCC-VERSION := tcc-$(shell cat $(top_srcdir)/VERSION)
5ebc6a96 grischka2012-12-20 21:29:57 +0100408tar: tcc-doc.html
409 mkdir $(TCC-VERSION)
410 ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
411 cp tcc-doc.html $(TCC-VERSION)
412 for f in tcc-win32.txt build-tcc.bat ; do \
413 cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(TCC-VERSION)/win32/$$f ; \
414 done
415 tar cjf $(TCC-VERSION).tar.bz2 $(TCC-VERSION)
416 rm -rf $(TCC-VERSION)
417 git reset
418
73e8f6b6 Lee Duhem2014-11-26 11:48:07 +0800419.PHONY: all clean tar tags TAGS distclean install uninstall FORCE
5ebc6a96 grischka2012-12-20 21:29:57 +0100420
15626621 grischka2009-04-19 21:24:32 +0200421endif # ifeq ($(TOP),.)