1 # GNU -*-Makefile-*- to build GNU make on Windows
3 # Windows overrides for use with Basic.mk.
5 # Copyright (C) 2017-2020 Free Software Foundation, Inc.
6 # This file is part of GNU Make.
8 # GNU Make is free software; you can redistribute it and/or modify it under
9 # the terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 3 of the License, or (at your option) any later
13 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 # You should have received a copy of the GNU General Public License along with
19 # this program. If not, see <http://www.gnu.org/licenses/>.
21 # TARGET_TYPE can be either "release" or "debug"
24 # TOOLCHAIN can be either "msvc" or "gcc"
27 # Translate a POSIX path into a Windows path. Don't bother with drives.
28 # Used only inside recipes, with DOS/CMD tools that require it.
31 prog_SOURCES += $(loadavg_SOURCES) $(glob_SOURCES) $(w32_SOURCES)
33 BUILT_SOURCES += $(lib)alloca.h $(lib)fnmatch.h $(lib)glob.h
35 w32_LIBS = kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 \
36 oleaut32 uuid odbc32 odbccp32
46 msvc_CPPFLAGS = /DHAVE_CONFIG_H /DWINDOWS32 /DWIN32 /D_CONSOLE
47 msvc_CPPFLAGS += /I$(OUTDIR)src /I$(SRCDIR)/src /I$(SRCDIR)/src/w32/include /I$(OUTDIR)lib /I$(SRCDIR)/lib
49 msvc_CFLAGS = /nologo /MT /W4 /EHsc
50 msvc_CFLAGS += /FR$(OUTDIR) /Fp$(BASE_PROG).pch /Fd$(BASE_PROG).pdb
52 msvc_LDFLAGS = /nologo /SUBSYSTEM:console /PDB:$(BASE_PROG).pdb
54 msvc_LDLIBS = $(addsuffix .lib,$(w32_LIBS))
57 msvc_OUTPUT_OPTION = /Fo$@
58 msvc_LINK_OUTPUT = /OUT:$@
60 release_msvc_OUTDIR = ./WinRel/
61 release_msvc_CPPFLAGS = /D NDEBUG
62 release_msvc_CFLAGS = /O2
64 debug_msvc_OUTDIR = ./WinDebug/
65 debug_msvc_CPPFLAGS = /D _DEBUG
66 debug_msvc_CFLAGS = /Zi /Od
67 debug_msvc_LDFLAGS = /DEBUG
73 release_gcc_OUTDIR = ./GccRel/
74 debug_gcc_OUTDIR = ./GccDebug/
76 gcc_CPPFLAGS = -DHAVE_CONFIG_H -I$(OUTDIR)src -I$(SRCDIR)/src -I$(SRCDIR)/src/w32/include -I$(OUTDIR)lib -I$(SRCDIR)/lib
77 gcc_CFLAGS = -mthreads -Wall -std=gnu99 -gdwarf-2 -g3
78 gcc_LDFLAGS = -mthreads -gdwarf-2 -g3
79 gcc_LDLIBS = $(addprefix -l,$(w32_libs))
82 gcc_OUTPUT_OPTION = -o $@
83 gcc_LINK_OUTPUT = -o $@
85 debug_gcc_CFLAGS = -O0
86 release_gcc_CFLAGS = -O2
90 LINK.cmd = $(LD) $(extra_LDFLAGS) $(LDFLAGS) $(TARGET_ARCH) $1 $(LDLIBS) $(LINK_OUTPUT)
92 CHECK.cmd = cmd /c cd tests \& .\run_make_tests.bat -make ../$(PROG)
94 MKDIR.cmd = cmd /c mkdir $(call P2W,$1)
95 RM.cmd = cmd /c del /F /Q $(call P2W,$1)
96 CP.cmd = cmd /c copy /Y $(call P2W,$1 $2)
98 CC = $($(TOOLCHAIN)_CC)
99 LD = $($(TOOLCHAIN)_LD)
101 C_SOURCE = $($(TOOLCHAIN)_C_SOURCE)
102 OUTPUT_OPTION = $($(TOOLCHAIN)_OUTPUT_OPTION)
103 LINK_OUTPUT = $($(TOOLCHAIN)_LINK_OUTPUT)
105 OUTDIR = $($(TARGET_TYPE)_$(TOOLCHAIN)_OUTDIR)
110 _CUSTOM = $($(TOOLCHAIN)_$1) $($(TARGET_TYPE)_$1) $($(TARGET_TYPE)_$(TOOLCHAIN)_$1)
112 # I'm not sure why this builds gnumake rather than make...?
113 PROG = $(OUTDIR)gnumake$(EXEEXT)
114 BASE_PROG = $(basename $(PROG))
116 extra_CPPFLAGS = $(call _CUSTOM,CPPFLAGS)
117 extra_CFLAGS = $(call _CUSTOM,CFLAGS)
118 extra_LDFLAGS = $(call _CUSTOM,LDFLAGS)
119 LDLIBS = $(call _CUSTOM,LDLIBS)
121 $(OUTDIR)src/config.h: $(SRCDIR)/src/config.h.W32