gmake.defs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
  2. # Copyright (C) 2000-2015 Free Software Foundation, Inc.
  3. # This file is part of GNU Emacs.
  4. # GNU Emacs is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # GNU Emacs is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  14. # Ensure 'all' is the default target
  15. all:
  16. # NOTES
  17. #
  18. # I tried to force gmake to use the native shell for simplicity, by
  19. # setting SHELL as below, but this didn't work reliably because of
  20. # various case sensitivity niggles. Specifically, COMSPEC (which is in
  21. # fact usually spelled ComSpec on NT, to make life difficult) typically
  22. # references "cmd.exe" (on NT) when the file is actually called
  23. # "CMD.EXE" on disk for hysterical raisons. As a result, GNU make
  24. # thinks it doesn't exist (unless compiled with a switch to ignore
  25. # case), and so doesn't change which shell it will invoke to execute
  26. # commands.
  27. #
  28. # It would be possible, though very tedious using just gmake facilities,
  29. # to convert the COMSPEC value to uppercase to solve this problem, but
  30. # it isn't worth it. That is partly because, even when using the native
  31. # shell, gmake tends to not be happy with backslashes in command
  32. # strings. The obvious solution is to use forward slashes as much as
  33. # possible, which can be made to work most of the time (putting
  34. # filenames in quotes often helps), but there are still some internal
  35. # cmd.exe commands like `del' and `copy' that won't work with them.
  36. # Although it is possible to convert slashes to backslashes when
  37. # necessary, gmake requires explicitly calling its subst function, which
  38. # nmake does not understand). For this reason, it is simplest to
  39. # mandate that rm and cp be available, so we can use Unix-format file
  40. # names everywhere. (Fortunately both MS and GNU make, and the
  41. # respective compilers, are happy with Unix-format names.)
  42. #
  43. # Since we cannot easily force the choice of a particular shell, we must
  44. # make the effort to cope with whichever shell is being used.
  45. # Fortunately, the only command we need to use that is shell specific is
  46. # the testing of a file's existence for the purpose of working out when
  47. # we are copying files to their original location. That particular
  48. # requirement is abstracted easily enough.
  49. #
  50. # The only other problem area was the change of directory when running
  51. # temacs to dump emacs.exe (where gmake doesn't support cd foo in any
  52. # useful way), but that has been resolved by modifying the Windows
  53. # unexec function slightly to not require the directory change while
  54. # still allowing objects and binaries to be in subdirectories.
  55. # This doesn't work.
  56. #SHELL:=$(COMSPEC)
  57. # Determine whether make is using sh or cmd/command as shell; cmd.exe
  58. # will output "ECHO is on" when echo is given by itself, while sh will
  59. # not produce any output.
  60. sh_output := $(shell echo)
  61. ifeq "$(findstring ECHO, $(sh_output))" "ECHO"
  62. THE_SHELL = $(COMSPEC)$(ComSpec)
  63. SHELLTYPE=CMD
  64. SWITCHCHAR=/
  65. else
  66. USING_SH = 1
  67. THE_SHELL = $(SHELL)
  68. SHELLTYPE=SH
  69. # MSYS needs to double the slash in cmd-style switches to avoid
  70. # interpreting /x as a Posix style file name reference
  71. ifneq ($(MSYSTEM),)
  72. SWITCHCHAR=//
  73. else
  74. SWITCHCHAR=/
  75. endif
  76. endif
  77. MAKETYPE=gmake
  78. # The following "ifeq" does not appear to DTRT, and therefore breaks
  79. # the build on mingw32. Also the -m option does not exist in many
  80. # (reasonably recent even) versions of Cygwin. These issues need to be
  81. # remedied before putting this cygpath kludge back in.
  82. # Convert CURDIR to native file name, if in Cygwin format
  83. #ifeq "$(shell cygpath $(CURDIR))" "$(CURDIR)"
  84. #CURDIR := $(shell cygpath -m $(CURDIR))
  85. #endif
  86. THISDIR = .
  87. # Cygwin has changed quoting rules somewhat since b20, in a way that
  88. # affects makefiles using sh as the command processor, so we need to
  89. # detect which rules to use.
  90. ifdef USING_SH
  91. sh_output := $(shell echo [Please ignore a syntax error on the next line - it is intentional] 1>&2)
  92. sh_output := $(shell echo foo")
  93. # This single quote " is to fix fontification due to previous line
  94. ifeq "$(sh_output)" ""
  95. NEW_CYGWIN = 1
  96. endif
  97. # By default, newer versions of Cygwin mess with NTFS ACLs in an
  98. # attempt to emulate traditional posix file permissions. This can
  99. # cause bad effects, such as .exe files that are missing the
  100. # FILE_EXECUTE/FILE_GENERIC_EXECUTE permissions when they are created
  101. # with Cygwin commands that don't expect to be creating executable
  102. # files. Then when we later use a non-Cygwin program to create the
  103. # real .exe, the previous Cygwin defined ACL sticks.
  104. CYGWIN=nontsec
  105. export CYGWIN
  106. endif
  107. ALL_DEPS = $^
  108. EMPTY =
  109. SPACE = $(EMPTY) $(EMPTY)
  110. SUBSYSTEM_WINDOWS=-Wl,-subsystem,windows
  111. SUBSYSTEM_CONSOLE=-Wl,-subsystem,console
  112. # INSTALL_DIR is the directory into which emacs will be installed.
  113. #
  114. ifndef INSTALL_DIR
  115. INSTALL_DIR = $(CURDIR)/..
  116. endif
  117. export EMACSLOADPATH
  118. # Determine the architecture we're running on.
  119. # Define ARCH for our purposes;
  120. # Define CPU for use by ntwin32.mak;
  121. # Define CONFIG_H to the appropriate config.h for the system;
  122. #
  123. ifdef PROCESSOR_ARCHITECTURE
  124. # We're on Windows NT
  125. CPU = $(PROCESSOR_ARCHITECTURE)
  126. CONFIG_H = config.nt
  127. OS_TYPE = windowsnt
  128. ifeq "$(PROCESSOR_ARCHITECTURE)" "x86"
  129. ARCH = i386
  130. CPU = i386
  131. EMACS_HEAPSIZE = 27
  132. EMACS_PURESIZE = 5000000
  133. EMACS_MANIFEST = emacs-x86.manifest
  134. else
  135. ifeq "$(PROCESSOR_ARCHITECTURE)" "MIPS"
  136. ARCH = mips
  137. EMACS_HEAPSIZE = 27
  138. EMACS_PURESIZE = 5000000
  139. EMACS_MANIFEST = emacs-mips.manifest
  140. else
  141. ifeq "$(PROCESSOR_ARCHITECTURE)" "ALPHA"
  142. ARCH = alpha
  143. EMACS_HEAPSIZE = 27
  144. EMACS_PURESIZE = 5000000
  145. EMACS_MANIFEST = emacs-alpha.manifest
  146. else
  147. ifeq "$(PROCESSOR_ARCHITECTURE)" "PPC"
  148. ARCH = ppc
  149. EMACS_HEAPSIZE = 27
  150. EMACS_PURESIZE = 5000000
  151. EMACS_MANIFEST = emacs-ppc.manifest
  152. else
  153. $(error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)")
  154. endif
  155. endif
  156. endif
  157. endif
  158. else
  159. # We're on Windows 95
  160. ARCH = i386
  161. CPU = i386
  162. CONFIG_H = config.nt
  163. OS_TYPE = windows95
  164. endif
  165. AR = ar -rsc
  166. AR_OUT =
  167. CC = gcc
  168. CC_OUT = -o$(SPACE)
  169. LINK = gcc
  170. LINK_OUT = -o$(SPACE)
  171. RC = windres -O coff
  172. RC_OUT = -o$(SPACE)
  173. RC_INCLUDE = --include-dir$(SPACE)
  174. libc =
  175. baselibs =
  176. O = o
  177. A = a
  178. BASE_LIBS = $(libc) $(baselibs)
  179. ADVAPI32 = -ladvapi32
  180. COMCTL32 = -lcomctl32
  181. COMDLG32 = -lcomdlg32
  182. GDI32 = -lgdi32
  183. MPR = -lmpr
  184. SHELL32 = -lshell32
  185. USER32 = -luser32
  186. WSOCK32 = -lwsock32
  187. WINMM = -lwinmm
  188. WINSPOOL = -lwinspool
  189. OLE32 = -lole32
  190. UNISCRIBE = -lusp10
  191. UUID = -luuid
  192. # Used by src/makefile.w32-in, since Nmake barfs on $(func SOMETHING)
  193. OBJ0_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ0))
  194. OBJ1_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1))
  195. OBJ2_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2))
  196. ifdef NOOPT
  197. DEBUG_CFLAGS = -DEMACSDEBUG -fno-crossjumping -std=gnu99
  198. else
  199. DEBUG_CFLAGS =
  200. endif
  201. MWINDOWS = -mwindows
  202. CFLAGS = -I. $(ARCH_CFLAGS) $(DEBUG_CFLAGS) $(PROFILE_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
  203. ESC_CFLAGS = -I. $(ARCH_CFLAGS) $(DEBUG_CFLAGS) $(PROFILE_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
  204. EMACS_EXTRA_C_FLAGS = -DUSE_CRT_DLL=1
  205. ifdef PROFILE
  206. PROFILE_CFLAGS = -pg
  207. PROFILE_LDFLAGS = -pg
  208. else
  209. PROFILE_CFLAGS =
  210. PROFILE_LDFLAGS =
  211. endif
  212. # see comments in allocate_heap in w32heap.c before changing any of the
  213. # -stack, -heap, or -image-base settings.
  214. TEMACS_EXTRA_LINK = -Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 $(SUBSYSTEM_CONSOLE) -Wl,-entry,__start -Wl,-Map,$(BLD)/temacs.map
  215. ifdef NOOPT
  216. OBJDIR = oo
  217. else
  218. OBJDIR = oo-spd
  219. endif
  220. $(OBJDIR):; -mkdir "$(OBJDIR)"
  221. BLD = $(OBJDIR)/$(ARCH)
  222. stamp_BLD: $(OBJDIR)
  223. -mkdir "$(BLD)"
  224. echo $(BLD) > $@
  225. COMPILER_TEMP_FILES =
  226. CP = cp -f
  227. CP_DIR = cp -rf
  228. DEL = rm
  229. DEL_TREE = rm -r
  230. DIRNAME = $(notdir $(CURDIR))
  231. ifdef USING_SH
  232. IFNOTSAMEDIR = if [ ! -s ../$(DIRNAME)_same-dir.tst ] ; then
  233. FOREACH = for f in
  234. FORVAR = $${f}
  235. FORDO = ; do
  236. ENDFOR = ; done
  237. ENDIF = ; fi
  238. ARGQUOTE = '
  239. ifdef NEW_CYGWIN
  240. DQUOTE = "
  241. else
  242. DQUOTE = ""
  243. endif
  244. else
  245. IFNOTSAMEDIR = if not exist ../$(DIRNAME)_same-dir.tst
  246. FOREACH = for %%f in (
  247. FORVAR = %%f
  248. FORDO = ) do
  249. ENDFOR =
  250. ENDIF =
  251. ARGQUOTE = "
  252. DQUOTE = \"
  253. endif
  254. ifdef NODEBUG
  255. DEBUG_FLAG =
  256. DEBUG_LINK =
  257. else
  258. DEBUG_FLAG = $(DEBUG_INFO)
  259. DEBUG_LINK = $(DEBUG_INFO)
  260. endif
  261. ifdef NOCYGWIN
  262. NOCYGWIN = -mno-cygwin
  263. endif
  264. ifdef USER_LIBS
  265. USER_LIBS := $(patsubst %,-l%,$(USER_LIBS))
  266. endif
  267. PRAGMA_SYSTEM_HEADER = \#pragma GCC system_header
  268. ifeq "$(ARCH)" "i386"
  269. ifdef NOOPT
  270. ARCH_CFLAGS = -c $(DEBUG_FLAG) $(NOCYGWIN)
  271. else
  272. ARCH_CFLAGS = -c $(DEBUG_FLAG) $(NOCYGWIN) $(MCPU_FLAG) -O2 \
  273. # -fbuiltin \
  274. # -finline-functions \
  275. # -fomit-frame-pointer
  276. endif
  277. ARCH_LDFLAGS = $(SYS_LDFLAGS)
  278. else
  279. ERROR Unknown architecture type "$(ARCH)".
  280. endif
  281. LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(PROFILE_LDFLAGS) $(NOCYGWIN) $(USER_LDFLAGS)
  282. export XMFLAGS
  283. .DEFAULT:
  284. $(BLD)/%.o: %.c
  285. $(CC) $(CFLAGS) $(CC_OUT)$@ $<