2 # This Makefile builds native Windows tcc for both 32 and 64 bits generator.
3 # It requires Cygwin 64 and gcc to bootstrap a first tcc version which is used
4 # by a second stage to compile tcc it self.
5 # Generated binaries do not require cygwin to run.
6 # You can launch 'tarball' target to build a tar.gz you can install on any
9 CPU
= $(shell if
`gcc -v 2>&1 | grep Target | grep -q x86_64`; then echo
64; else echo
32; fi
)
10 VERSION
= $(shell cat ..
/VERSION
)
12 CFLAGS
= -s
-static
-fno-strict-aliasing
-Wno-incompatible-pointer-types
-DTCC_TARGET_PE
13 #WINPWD = `cygpath --mixed $(PWD)`
14 #@echo "#define CONFIG_TCCDIR \"$(WINPWD)\""
17 NATIVE
= -m
$(CPU
) -DTCC_TARGET_X86_64
20 NATIVE
= -m
$(CPU
) -DTCC_TARGET_I386
27 TFLAGS
= -m
$(TARGET
) -DTCC_TARGET_X86_64
30 TFLAGS
= -m
$(TARGET
) -DTCC_TARGET_I386
34 all: pre bootstrap libs rebuild
39 @echo ARCH
=$(TARCH
) 1> ..
/config.mak
40 @echo TARGETOS
=Windows
1>> ..
/config.mak
41 @echo CONFIG_WIN32
=yes
1>> ..
/config.mak
42 @echo TOPSRC
=$$\
(TOP\
) 1>> ..
/config.mak
43 @echo
"#define TCC_VERSION \"$(VERSION)\"" 1>..
/config.h
44 @echo
"#ifdef TCC_TARGET_X86_64" 1>>..
/config.h
45 @echo
"#define TCC_LIBTCC1 \"libtcc1-64.a\"" 1>>..
/config.h
46 @echo
"#else" 1>>..
/config.h
47 @echo
"#define TCC_LIBTCC1 \"libtcc1-32.a\"" 1>>..
/config.h
48 @echo
"#endif" 1>>..
/config.h
49 @echo @set VERSION
$(VERSION
) 1>..
/config.texi
50 @
rm -f
*tcc.exe tiny_
*.exe
*tcc.dll lib
/*.a
54 @cp ..
/include/*.h
include
55 @cp ..
/tcclib.h
include
56 @cp ..
/libtcc.h
include
58 @cp ..
/tests
/libtcc_test.c examples
63 @echo Bootstrapping
32bits and
64bits tools with
$(BOOTCC
) -m
$(CPU
)
64 @
$(BOOTCC
) $(CFLAGS
) -DTCC_TARGET_I386
-o i386-win32-tcc.exe ..
/tcc.c
65 @
$(BOOTCC
) $(CFLAGS
) -DTCC_TARGET_X86_64
-o x86_64-win32-tcc.exe ..
/tcc.c
66 @
$(BOOTCC
) $(CFLAGS
) $(NATIVE
) -o tcc.exe ..
/tcc.c
67 @
$(BOOTCC
) $(CFLAGS
) $(NATIVE
) -DLIBTCC_AS_DLL
-o libtcc.dll
-shared ..
/libtcc.c
72 @echo Building
$*.a with tcc
-m32
73 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c ..
/lib
/libtcc1.c
74 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c ..
/lib
/alloca86.S
75 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c ..
/lib
/alloca86-bt.S
76 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/crt1.c
77 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/crt1w.c
78 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/wincrt1.c
79 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/wincrt1w.c
80 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/dllcrt1.c
81 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/dllmain.c
82 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-c lib
/chkstk.S
83 @.
/tcc
-m32
-ar lib
/libtcc1-32.a libtcc1.o alloca86.o alloca86-bt.o crt1.o wincrt1.o crt1w.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
87 @echo Building
$*.a with tcc
-m64
88 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c ..
/lib
/libtcc1.c
89 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c ..
/lib
/alloca86_64.S
90 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c ..
/lib
/alloca86_64-bt.S
91 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/crt1.c
92 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/crt1w.c
93 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/wincrt1.c
94 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/wincrt1w.c
95 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/dllcrt1.c
96 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/dllmain.c
97 @.
/tcc
-O2
-B.
-m64
-DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-c lib
/chkstk.S
98 @.
/tcc
-m64
-ar lib
/libtcc1-64.a libtcc1.o alloca86_64.o alloca86_64-bt.o crt1.o wincrt1.o crt1w.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
101 libs
: lib
/libtcc1-32.a lib
/libtcc1-64.a
106 @echo Rebuild using tcc itself
- default
$(TARGET
)bits
107 @.
/$(TARCH
)-win32-tcc
-O2
-B.
$(TFLAGS
) -DTCC_TARGET_PE
-o tcc.exe ..
/tcc.c
108 @.
/tcc
-O2
-B.
$(TFLAGS
) -DTCC_TARGET_PE
-DLIBTCC_AS_DLL
-o libtcc.dll
-shared ..
/libtcc.c
109 @.
/tcc
-O2
-B.
-m32
-DTCC_TARGET_PE
-DTCC_TARGET_I386
-o tmp-tcc.exe ..
/tcc.c
&& mv tmp-tcc.exe i386-win32-tcc.exe
110 @.
/tcc
-O2
-B.
-m
$(TARGET
) -DTCC_TARGET_PE
-DTCC_TARGET_X86_64
-o tmp-tcc.exe ..
/tcc.c
&& mv tmp-tcc.exe x86_64-win32-tcc.exe
115 @
(cd ..
/tests
; $(MAKE
) -k TCC
=$(PWD
)/tcc hello-exe hello-run
)
116 @
(cd ..
/tests
; $(MAKE
) -k TCC
=$(PWD
)/tcc vla_test-run tests2-dir pp-dir
)
118 @
(cd ..
/tests
; $(MAKE
) -k TCC
=$(PWD
)/i386-win32-tcc hello-exe hello-run
)
119 @
(cd ..
/tests
; $(MAKE
) -k TCC
=$(PWD
)/i386-win32-tcc vla_test-run tests2-dir pp-dir
)
124 TARNAME
= tcc-
$(VERSION
)-$(ARCH
)-win32
129 @cp
-r doc
$(TARNAME
)
130 @cp
-r examples
$(TARNAME
)
131 @cp
-r
include $(TARNAME
)
132 @cp
-r lib
$(TARNAME
)
133 @cp
-r libtcc
$(TARNAME
)
134 @cp
-r tools
$(TARNAME
)
135 @cp
-r build-tcc.bat
$(TARNAME
)
136 @cp
-r i386-win32-tcc.exe
$(TARNAME
)
137 @cp
-r libtcc.def
$(TARNAME
)
138 @cp
-r libtcc.dll
$(TARNAME
)
139 @cp
-r Makefile
$(TARNAME
)
140 @cp
-r tcc.exe
$(TARNAME
)
141 @cp
-r tcc-win32.txt
$(TARNAME
)
142 @cp
-r x86_64-win32-tcc.exe
$(TARNAME
)
143 @
tar czf
$(TARNAME
).
tar.gz
$(TARNAME
)
149 rm -f
*.o
*.exe
*.dll lib
/*.a
*.pdb
*.obj
*.exp
*.def
*.lib