From 2a0355f51019af84c1bf34c75920e89148149aa9 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sat, 18 Feb 2017 08:13:16 +0200 Subject: [PATCH 2/2] win: makefiles: add upport for wmain and wWinMain Prior to this commit, wmain and wWinMain were only supported at build-tcc.bat Since crt1.c and wincrt1.c need to be compiled twice with different defines and to different .o files, it's easier to add wrapper .c file for each which sets the defines and includes the original file. This makes the makefiles, and especially the main makefile, much simpler to handle. We also change win32/build-tcc.bat to use the same wrappers and method instead of manually specifying the defines and output files. --- lib/Makefile | 2 +- win32/Makefile | 8 ++++++-- win32/build-tcc.bat | 8 ++++---- win32/lib/crt1_w.c | 3 +++ win32/lib/wincrt1_w.c | 3 +++ 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 win32/lib/crt1_w.c create mode 100644 win32/lib/wincrt1_w.c diff --git a/lib/Makefile b/lib/Makefile index 9596cbb..b8ce1d5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -41,7 +41,7 @@ I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O) X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O) ARM_O = libtcc1.o armeabi.o alloca-arm.o ARM64_O = lib-arm64.o -WIN32_O = crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o +WIN32_O = crt1.o crt1_w.o wincrt1.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o ifeq "$(TARGET)" "i386-win32" OBJ = $(addprefix $(DIR)/,$(I386_O) $(WIN32_O)) diff --git a/win32/Makefile b/win32/Makefile index 854aa93..62ca222 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -77,11 +77,13 @@ lib/32/libtcc1.a: tiny_libmaker32.exe @./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 -c lib/crt1_w.c @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/wincrt1.c + @./tcc -m32 -DTCC_TARGET_PE -DTCC_TARGET_I386 -c lib/wincrt1_w.c @./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 + @./tiny_libmaker32 lib/32/libtcc1.a libtcc1.o alloca86.o alloca86-bt.o crt1.o crt1_w.o wincrt1.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o @rm *.o lib/64/libtcc1.a: tiny_libmaker64.exe @@ -90,11 +92,13 @@ lib/64/libtcc1.a: tiny_libmaker64.exe @./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 -c lib/crt1_w.c @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/wincrt1.c + @./tcc -m64 -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c lib/wincrt1_w.c @./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_libmaker64 lib/64/libtcc1.a libtcc1.o alloca86_64.o alloca86_64-bt.o crt1.o crt1_w.o wincrt1.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o @rm *.o libs: lib/32/libtcc1.a lib/64/libtcc1.a diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat index 8da1404..231171e 100644 --- a/win32/build-tcc.bat +++ b/win32/build-tcc.bat @@ -140,9 +140,9 @@ copy>nul tiny_libmaker.exe tiny_libmaker-m%T%.exe @set O1=libtcc1.o crt1.o wincrt1.o crt1_w.o wincrt1_w.o dllcrt1.o dllmain.o chkstk.o bcheck.o .\tcc -m32 %D32% -c ../lib/libtcc1.c .\tcc -m32 %D32% -c lib/crt1.c -.\tcc -m32 %D32% -c lib/crt1.c -D_UNICODE -DUNICODE -o crt1_w.o +.\tcc -m32 %D32% -c lib/crt1_w.c .\tcc -m32 %D32% -c lib/wincrt1.c -.\tcc -m32 %D32% -c lib/wincrt1.c -D_UNICODE -DUNICODE -o wincrt1_w.o +.\tcc -m32 %D32% -c lib/wincrt1_w.c .\tcc -m32 %D32% -c lib/dllcrt1.c .\tcc -m32 %D32% -c lib/dllmain.c .\tcc -m32 %D32% -c lib/chkstk.S @@ -153,9 +153,9 @@ tiny_libmaker-m32 lib/32/libtcc1.a %O1% alloca86.o alloca86-bt.o @if errorlevel 1 goto :the_end .\tcc -m64 %D64% -c ../lib/libtcc1.c .\tcc -m64 %D64% -c lib/crt1.c -.\tcc -m64 %D64% -c lib/crt1.c -D_UNICODE -DUNICODE -o crt1_w.o +.\tcc -m64 %D64% -c lib/crt1_w.c .\tcc -m64 %D64% -c lib/wincrt1.c -.\tcc -m64 %D64% -c lib/wincrt1.c -D_UNICODE -DUNICODE -o wincrt1_w.o +.\tcc -m64 %D64% -c lib/wincrt1_w.c .\tcc -m64 %D64% -c lib/dllcrt1.c .\tcc -m64 %D64% -c lib/dllmain.c .\tcc -m64 %D64% -c lib/chkstk.S diff --git a/win32/lib/crt1_w.c b/win32/lib/crt1_w.c new file mode 100644 index 0000000..771294a --- /dev/null +++ b/win32/lib/crt1_w.c @@ -0,0 +1,3 @@ +#define _UNICODE +#define UNICODE +#include "crt1.c" diff --git a/win32/lib/wincrt1_w.c b/win32/lib/wincrt1_w.c new file mode 100644 index 0000000..b537abb --- /dev/null +++ b/win32/lib/wincrt1_w.c @@ -0,0 +1,3 @@ +#define _UNICODE +#define UNICODE +#include "wincrt1.c" -- 2.11.0