2013-07-19 00:14:54 +10:00
|
|
|
# MinGW/MinGW-w64 makefile for ANSICON.
|
|
|
|
# Jason Hood, 11 March, 2006. Updated 20 June, 2009.
|
|
|
|
#
|
|
|
|
# 19 November, 2010:
|
|
|
|
# explicitly use 64-bit flags, in case the compiler isn't.
|
|
|
|
#
|
|
|
|
# 13 December, 2011:
|
|
|
|
# use CMD for file operations, not programs from fileutils.
|
|
|
|
#
|
|
|
|
# 23 November, 2012:
|
|
|
|
# set the base address of the DLLs to AC0000[00] (AnsiCon).
|
|
|
|
#
|
|
|
|
# 17 & 18 July, 2013:
|
|
|
|
# work with 32-bit only, 64-bit only or multilib compilers;
|
|
|
|
# hide the commands (use V=1 to show them).
|
|
|
|
#
|
|
|
|
# Tested with:
|
|
|
|
# * MinGW/gcc 4.7.2;
|
2014-02-05 00:21:42 +10:00
|
|
|
# * tdm-gcc-4.8.1-3;
|
|
|
|
# * tdm64-gcc-4.8.1-3;
|
2013-07-19 00:14:54 +10:00
|
|
|
# * MinGW-builds x64-4.8.1-release-posix-seh-rev1.
|
|
|
|
|
|
|
|
CC = gcc
|
2014-02-10 16:33:42 +10:00
|
|
|
CFLAGS = -O2 -Wall -Wno-multichar
|
2013-07-19 00:14:54 +10:00
|
|
|
|
2014-02-05 00:21:42 +10:00
|
|
|
# Identify ansicon.exe using "ANSI" as a version number.
|
|
|
|
IVER = -Wl,--major-image-version,20033,--minor-image-version,18771
|
|
|
|
|
2013-07-19 00:14:54 +10:00
|
|
|
#ARCH = 32
|
|
|
|
#ARCH = 64
|
|
|
|
#ARCH = multi
|
|
|
|
|
|
|
|
ifndef ARCH
|
|
|
|
# Use the machine to distinguish between MinGW and MinGW-w64.
|
|
|
|
ifeq (,$(findstring 64,$(shell gcc -dumpmachine)))
|
|
|
|
ARCH = 32
|
|
|
|
else
|
|
|
|
# It's 64-bit, if it's multi the lib name will be different.
|
|
|
|
ifeq ($(shell gcc -m32 -print-libgcc-file-name),$(shell gcc -m64 -print-libgcc-file-name))
|
|
|
|
ARCH = 64
|
|
|
|
else
|
|
|
|
ARCH = multi
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-02-08 01:10:51 +10:00
|
|
|
X86OBJS = x86/injdll.o x86/proctype.o x86/util.o
|
|
|
|
X64OBJS = x64/injdll.o x64/proctype.o x64/util.o x64/procrva.o
|
2013-07-19 00:14:54 +10:00
|
|
|
|
2013-11-13 20:30:09 +10:00
|
|
|
# Determine the appropriate separator to run multiple commands - ";" for sh.exe
|
|
|
|
# and "&" for CMD.EXE. $(SHELL) is initially defined to "sh.exe" - if it
|
|
|
|
# actually exists, it becomes the full path.
|
|
|
|
ifneq ($(wildcard $(SHELL)),)
|
|
|
|
SEP = ;
|
|
|
|
else
|
|
|
|
SEP = &
|
|
|
|
endif
|
|
|
|
|
2013-07-19 00:14:54 +10:00
|
|
|
V ?= 0
|
|
|
|
ifeq ($(V),0)
|
2013-11-13 20:30:09 +10:00
|
|
|
CCmsg = @echo $<$(SEP)
|
2013-07-19 00:14:54 +10:00
|
|
|
RCmsg = $(CCmsg)
|
2013-11-13 20:30:09 +10:00
|
|
|
LDmsg = @echo $@$(SEP)
|
2013-07-19 00:14:54 +10:00
|
|
|
endif
|
|
|
|
|
|
|
|
x86/%.o: %.c ansicon.h
|
|
|
|
$(CCmsg)$(CC) -m32 -c $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
x86/%v.o: %.rc version.h
|
|
|
|
$(RCmsg)windres -U _WIN64 -F pe-i386 $< $@
|
|
|
|
|
|
|
|
x64/%.o: %.c ansicon.h
|
2014-02-05 00:21:42 +10:00
|
|
|
$(CCmsg)$(CC) -m64 -g -c $(CFLAGS) $< -o $@
|
2013-07-19 00:14:54 +10:00
|
|
|
|
|
|
|
x64/%v.o: %.rc version.h
|
|
|
|
$(RCmsg)windres -F pe-x86-64 $< $@
|
|
|
|
|
|
|
|
x64/%32.o: %.c
|
|
|
|
$(CCmsg)$(CC) -m32 -DW32ON64 $(CFLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(ARCH),multi)
|
|
|
|
all: ansicon32 ansicon64
|
|
|
|
else
|
|
|
|
all: ansicon$(ARCH)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ansicon32: x86 x86/ansicon.exe x86/ANSI32.dll x64 x64/ANSI32.dll
|
|
|
|
|
|
|
|
ansicon64: x64 x64/ansicon.exe x64/ANSI64.dll
|
|
|
|
|
|
|
|
x86:
|
|
|
|
cmd /c "mkdir x86"
|
|
|
|
|
2014-02-08 01:10:51 +10:00
|
|
|
x86/ansicon.exe: x86/ansicon.o $(X86OBJS) x86/procrva.o x86/ansiconv.o
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) -m32 $+ -s -o $@ $(IVER)
|
2013-07-19 00:14:54 +10:00
|
|
|
|
|
|
|
x86/ANSI32.dll: x86/ANSI.o $(X86OBJS) x86/ansiv.o
|
|
|
|
$(LDmsg)$(CC) -m32 $+ -s -o $@ -mdll -Wl,-shared,--image-base,0xAC0000
|
|
|
|
|
|
|
|
x64:
|
|
|
|
cmd /c "mkdir x64"
|
|
|
|
|
2014-02-08 01:10:51 +10:00
|
|
|
x64/ansicon.exe: x64/ansicon.o $(X64OBJS) x64/ansiconv.o
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) -m64 $+ -s -o $@ $(IVER)
|
2013-07-19 00:14:54 +10:00
|
|
|
|
|
|
|
x64/ANSI64.dll: x64/ANSI.o $(X64OBJS) x64/ansiv.o
|
|
|
|
$(LDmsg)$(CC) -m64 $+ -s -o $@ -mdll -Wl,-shared,--image-base,0xAC000000
|
|
|
|
|
2014-02-05 00:21:42 +10:00
|
|
|
x64/ANSI32.dll: x64/ANSI32.o x64/proctype32.o x86/injdll.o x86/util.o x86/ansiv.o
|
|
|
|
$(LDmsg)$(CC) -m32 $+ -s -o $@ -mdll \
|
|
|
|
-Wl,-shared,--image-base,0xAC0000,--large-address-aware
|
2013-07-19 00:14:54 +10:00
|
|
|
|
|
|
|
x86/ansicon.o: version.h
|
|
|
|
x86/ANSI.o: version.h
|
|
|
|
x86/util.o: version.h
|
|
|
|
x64/ansicon.o: version.h
|
|
|
|
x64/ANSI.o: version.h
|
|
|
|
x64/util.o: version.h
|
|
|
|
|
|
|
|
# Need two commands, because if the directory doesn't exist, it won't delete
|
|
|
|
# anything at all.
|
|
|
|
clean:
|
|
|
|
-cmd /c "del x86\*.o 2>nul"
|
|
|
|
-cmd /c "del x64\*.o 2>nul"
|