From 9bd04fa000d8ab2919d714c05d748cea29735698 Mon Sep 17 00:00:00 2001 From: Christian Jullien Date: Sat, 18 Feb 2017 08:00:58 +0100 Subject: [PATCH] Makefile for Windows native tcc handles recent UNICODE support --- win32/Makefile | 58 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/win32/Makefile b/win32/Makefile index 854aa93..abb8b11 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -6,27 +6,29 @@ # You can launch 'tarball' target to build a tar.gz you can install on any # Windows machines. -ARCH = $(shell if `gcc -v 2>&1 | grep Target | grep -q x86_64`; then echo 64; else echo 32; fi) +CPU = $(shell if `gcc -v 2>&1 | grep Target | grep -q x86_64`; then echo 64; else echo 32; fi) VERSION = $(shell cat ../VERSION) BOOTCC = gcc CFLAGS = -s -fno-strict-aliasing -Wno-incompatible-pointer-types -DTCC_TARGET_PE -DONE_SOURCE -ifeq ($(ARCH), 64) -NATIVE = -m$(ARCH) -DTCC_TARGET_X86_64 -PREFIX = x86_64 +ifeq ($(CPU), 64) +NATIVE = -m$(CPU) -DTCC_TARGET_X86_64 +ARCH = x86_64 else -NATIVE = -m$(ARCH) -DTCC_TARGET_I386 -PREFIX = i386 +NATIVE = -m$(CPU) -DTCC_TARGET_I386 +ARCH = i386 endif -TARGET = $(ARCH) +TARGET = $(CPU) ifeq ($(TARGET), 64) TFLAGS = -m$(TARGET) -DTCC_TARGET_X86_64 -TPREFIX = x86_64 +TARCH = x86_64 +CARCH = x86-64 else TFLAGS = -m$(TARGET) -DTCC_TARGET_I386 -TPREFIX = i386 +TARCH = i386 +CARCH = i386 endif all: pre bootstrap libs rebuild @@ -34,7 +36,7 @@ all: pre bootstrap libs rebuild @ls -ls *.exe pre: - @echo ARCH=x86-64 1> ../config.mak + @echo ARCH=$(CARCH) 1> ../config.mak @echo TARGETOS=Windows 1>> ../config.mak @echo CONFIG_WIN32=yes 1>> ../config.mak @echo TOPSRC=$$\(TOP\) 1>> ../config.mak @@ -61,40 +63,44 @@ pre: PHONY += pre bootstrap: - @echo Bootstrapping 32bits and 64bits tools with $(BOOTCC) -m$(ARCH) + @echo Bootstrapping 32bits and 64bits tools with $(BOOTCC) -m$(CPU) @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_I386 -o i386-win32-tcc.exe ../tcc.c - @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_I386 -o tiny_libmaker32.exe ./tools/tiny_libmaker.c + @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_I386 -o tiny_libmaker-m32.exe ./tools/tiny_libmaker.c @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_X86_64 -o x86_64-win32-tcc.exe ../tcc.c - @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_X86_64 -o tiny_libmaker64.exe ./tools/tiny_libmaker.c + @$(BOOTCC) $(CFLAGS) -DTCC_TARGET_X86_64 -o tiny_libmaker-m64.exe ./tools/tiny_libmaker.c @$(BOOTCC) $(CFLAGS) $(NATIVE) -o tcc.exe ../tcc.c @$(BOOTCC) $(CFLAGS) $(NATIVE) -DLIBTCC_AS_DLL -o libtcc.dll -shared ../libtcc.c PHONY += bootstrap -lib/32/libtcc1.a: tiny_libmaker32.exe +lib/32/libtcc1.a: tiny_libmaker-m32.exe @echo Building $*.a with tcc -m32 @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/libtcc1.c @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/alloca86.S @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c ../lib/alloca86-bt.S @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/crt1.c + @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -D_UNICODE -DUNICODE -c lib/crt1.c -o crt1_w.o @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/wincrt1.c + @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -D_UNICODE -DUNICODE -c lib/wincrt1.c -o wincrt1_w.o @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/dllcrt1.c @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/dllmain.c - @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/chkstk.S - @./tiny_libmaker32 lib/32/libtcc1.a libtcc1.o alloca86.o alloca86-bt.o crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o + @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/chkstk.S + @./tiny_libmaker-m32 lib/32/libtcc1.a libtcc1.o alloca86.o alloca86-bt.o crt1.o wincrt1.o crt1_w.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o @rm *.o -lib/64/libtcc1.a: tiny_libmaker64.exe +lib/64/libtcc1.a: tiny_libmaker-m64.exe @echo Building $*.a with tcc -m64 @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/libtcc1.c @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64.S @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64-bt.S @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/crt1.c + @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -D_UNICODE -DUNICODE -c lib/crt1.c -o crt1_w.o @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/wincrt1.c + @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -D_UNICODE -DUNICODE -c lib/wincrt1.c -o wincrt1_w.o @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/dllcrt1.c @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/dllmain.c @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/chkstk.S - @./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 + @./tiny_libmaker-m64 lib/64/libtcc1.a libtcc1.o alloca86_64.o alloca86_64-bt.o crt1.o wincrt1.o crt1_w.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o @rm *.o libs: lib/32/libtcc1.a lib/64/libtcc1.a @@ -103,14 +109,14 @@ PHONY += libs rebuild: @echo Rebuild using tcc itself - default $(TARGET)bits - @./$(TPREFIX)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tcc.exe ../tcc.c - @./$(TPREFIX)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tiny_libmaker.exe tools/tiny_libmaker.c - @./$(TPREFIX)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tiny_impdef.exe tools/tiny_impdef.c + @./$(TARCH)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tcc.exe ../tcc.c + @./$(TARCH)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tiny_libmaker.exe tools/tiny_libmaker.c + @./$(TARCH)-win32-tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -o tiny_impdef.exe tools/tiny_impdef.c @./tcc $(TFLAGS) -DTCC_TARGET_PE -DONE_SOURCE -DLIBTCC_AS_DLL -o libtcc.dll -shared ../libtcc.c @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_I386 -o tmp-tcc.exe ../tcc.c && mv tmp-tcc.exe i386-win32-tcc.exe @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -o tmp-tcc.exe ../tcc.c && mv tmp-tcc.exe x86_64-win32-tcc.exe - @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_I386 -o tiny_libmaker32.exe tools/tiny_libmaker.c - @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -o tiny_libmaker64.exe tools/tiny_libmaker.c + @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_I386 -o tiny_libmaker-m32.exe tools/tiny_libmaker.c + @./tcc -m$(TARGET) -DTCC_TARGET_PE -DONE_SOURCE -DTCC_TARGET_X86_64 -o tiny_libmaker-m64.exe tools/tiny_libmaker.c PHONY += rebuild @@ -119,7 +125,7 @@ test: PHONY += test -TARNAME = tcc-$(VERSION)-$(PREFIX)-win32 +TARNAME = tcc-$(VERSION)-$(ARCH)-win32 tarball: @rm -r -f $(TARNAME) @@ -139,8 +145,8 @@ tarball: @cp -r tcc-win32.txt $(TARNAME) @cp -r tiny_impdef.exe $(TARNAME) @cp -r tiny_libmaker.exe $(TARNAME) - @cp -r tiny_libmaker32.exe $(TARNAME) - @cp -r tiny_libmaker64.exe $(TARNAME) + @cp -r tiny_libmaker-m32.exe $(TARNAME) + @cp -r tiny_libmaker-m64.exe $(TARNAME) @cp -r x86_64-win32-tcc.exe $(TARNAME) @tar czf $(TARNAME).tar.gz $(TARNAME) @rm -r -f $(TARNAME)