History

Add Makefile to build native tcc 32/64 on Windows using cygwin

Christian Jullien committed 9 years ago

Commit 417a1ed1 parent 983520d1 file · +130 −0Browse files

Unified · Split

win32/Makefile+130−0
@@ -0,0 +1,130 @@
1+#
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 Windows
7+# machines.
8+
9+ARCH = 64
10+VERSION = $(shell cat ../VERSION)
11+BOOTCC = gcc
12+CFLAGS = -s -fno-strict-aliasing -Wno-incompatible-pointer-types -DTCC_TARGET_PE -DONE_SOURCE
13+
14+ifeq ($(ARCH), 64)
15+NATIVE = -m$(ARCH) -DTCC_TARGET_X86_64
16+PREFIX = x86_64
17+else
18+NATIVE = -m$(ARCH) -DTCC_TARGET_I386
19+PREFIX = i386
20+endif
21+
22+all: pre bootstrap libs rebuild
23+ @ls -ls *.exe
24+
25+pre:
26+ @echo "#define TCC_VERSION \"$(VERSION)\"" 1>../config.h
27+ @echo "#ifdef TCC_TARGET_X86_64" 1>>../config.h
28+ @echo "#define CONFIG_TCC_LIBPATHS \"{B}/lib/64;{B}/lib\"" 1>>../config.h
29+ @echo "#else" 1>>../config.h
30+ @echo "#define CONFIG_TCC_LIBPATHS \"{B}/lib/32;{B}/lib\"" 1>>../config.h
31+ @echo "#endif" 1>>../config.h
32+ @echo @set VERSION $(VERSION) 1>../config.texi
33+ @rm -f *tcc.exe tiny_*.exe *tcc.dll
34+ @rm -r -f libtcc
35+ @rm -r -f libtcc doc lib/32 lib/64
36+ @mkdir libtcc
37+ @mkdir doc
38+ @mkdir lib/32
39+ @mkdir lib/64
40+ @cp ../include/*.h include
41+ @cp ../tcclib.h include
42+ @cp ../libtcc.h include
43+ @cp tcc-win32.txt doc
44+ @cp ../tests/libtcc_test.c examples
45+
46+PHONY += pre
47+
48+bootstrap:
49+ @echo Bootstrapping 32bits and 64bits tools with $(BOOTCC) -m$(ARCH)
50+ @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_I386 -o i386-win32-tcc.exe ../tcc.c
51+ @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_I386 -o tiny_libmaker32.exe ./tools/tiny_libmaker.c
52+ @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_X86_64 -o x86_64-win32-tcc.exe ../tcc.c
53+ @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_X86_64 -o tiny_libmaker64.exe ./tools/tiny_libmaker.c
54+ @$(BOOTCC) $(CFLAGS) $(NATIVE) -o tcc.exe ../tcc.c
55+ @$(BOOTCC) $(CFLAGS) $(NATIVE) -DLIBTCC_AS_DLL -o libtcc.dll -shared ../libtcc.c
56+
57+PHONY += bootstrap
58+
59+lib/32/libtcc1.a: tiny_libmaker32.exe
60+ @echo Building $*.a with tcc -m32
61+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/libtcc1.c
62+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/alloca86.S
63+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/alloca86-bt.S
64+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/crt1.c
65+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/wincrt1.c
66+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/dllcrt1.c
67+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/dllmain.c
68+ @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/chkstk.S
69+ @./tiny_libmaker32 lib/32/libtcc1.a libtcc1.o alloca86.o alloca86-bt.o crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
70+ @rm *.o
71+
72+lib/64/libtcc1.a: tcc.exe tiny_libmaker64.exe
73+ @echo Building $*.a with tcc -m64
74+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/libtcc1.c
75+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64.S
76+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64-bt.S
77+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/crt1.c
78+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/wincrt1.c
79+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/dllcrt1.c
80+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/dllmain.c
81+ @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/chkstk.S
82+ @./tiny_libmaker64 lib/64/libtcc1.a libtcc1.o alloca86_64.o alloca86_64-bt.o crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
83+ @rm *.o
84+
85+libs: lib/32/libtcc1.a lib/64/libtcc1.a
86+
87+PHONY += libs
88+
89+rebuild:
90+ @echo Rebuild using tcc itself - default $(ARCH)bits
91+ @./$(PREFIX)-win32-tcc $(NATIVE) -DTCC_TARGET_PE -DONE_SOURCE -o tcc.exe ../tcc.c libtcc.dll
92+ @./$(PREFIX)-win32-tcc $(NATIVE) -DTCC_TARGET_PE -DONE_SOURCE -o tiny_libmaker.exe tools/tiny_libmaker.c
93+ @./tcc -m64 -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -DLIBTCC_AS_DLL -o libtcc.dll -shared ../libtcc.c
94+ @./tcc -m64 -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_I386 -o i386-win32-tcc.exe ../tcc.c
95+ @./tcc -m64 -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_I386 -o tiny_libmaker32.exe tools/tiny_libmaker.c
96+ @./tcc -m64 -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -o x86_64-win32-tcc.exe ../tcc.c
97+ @./tcc -m64 -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -o tiny_libmaker64.exe tools/tiny_libmaker.c
98+
99+PHONY += rebuild
100+
101+TARNAME = tcc-$(VERSION)-$(PREFIX)-win32
102+
103+tarball:
104+ @rm -r -f $(TARNAME)
105+ @mkdir $(TARNAME)
106+ @cp -r doc $(TARNAME)
107+ @cp -r examples $(TARNAME)
108+ @cp -r include $(TARNAME)
109+ @cp -r lib $(TARNAME)
110+ @cp -r libtcc $(TARNAME)
111+ @cp -r tools $(TARNAME)
112+ @cp -r vs2015 $(TARNAME)
113+ @cp -r build-tcc.bat $(TARNAME)
114+ @cp -r i386-win32-tcc.exe $(TARNAME)
115+ @cp -r libtcc.def $(TARNAME)
116+ @cp -r libtcc.dll $(TARNAME)
117+ @cp -r Makefile $(TARNAME)
118+ @cp -r tcc.exe $(TARNAME)
119+ @cp -r tcc-win32.txt $(TARNAME)
120+ @cp -r tiny_libmaker.exe $(TARNAME)
121+ @cp -r tiny_libmaker32.exe $(TARNAME)
122+ @cp -r tiny_libmaker64.exe $(TARNAME)
123+ @cp -r x86_64-win32-tcc.exe $(TARNAME)
124+ @tar czf $(TARNAME).tar.gz $(TARNAME)
125+ @rm -r -f $(TARNAME)
126+
127+PHONY += tarball
128+
129+clean:
130+ rm -f *.o *.exe *.dll lib/*/*.a

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t