gmake.defs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. # -*- Makefile -*- definition file for building GNU Emacs on Windows NT.
  2. # Copyright (C) 2000-2012 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. else
  65. USING_SH = 1
  66. THE_SHELL = $(SHELL)
  67. SHELLTYPE=SH
  68. endif
  69. MAKETYPE=gmake
  70. # The following "ifeq" does not appear to DTRT, and therefore breaks
  71. # the build on mingw32. Also the -m option does not exist in many
  72. # (reasonably recent even) versions of Cygwin. These issues need to be
  73. # remedied before putting this cygpath kludge back in.
  74. # Convert CURDIR to native file name, if in Cygwin format
  75. #ifeq "$(shell cygpath $(CURDIR))" "$(CURDIR)"
  76. #CURDIR := $(shell cygpath -m $(CURDIR))
  77. #endif
  78. THISDIR = .
  79. # Cygwin has changed quoting rules somewhat since b20, in a way that
  80. # affects makefiles using sh as the command processor, so we need to
  81. # detect which rules to use.
  82. ifdef USING_SH
  83. sh_output := $(shell echo [Please ignore a syntax error on the next line - it is intentional] 1>&2)
  84. sh_output := $(shell echo foo")
  85. # This single quote " is to fix fontification due to previous line
  86. ifeq "$(sh_output)" ""
  87. NEW_CYGWIN = 1
  88. endif
  89. # By default, newer versions of Cygwin mess with NTFS ACLs in an
  90. # attempt to emulate traditional posix file permissions. This can
  91. # cause bad effects, such as .exe files that are missing the
  92. # FILE_EXECUTE/FILE_GENERIC_EXECUTE permissions when they are created
  93. # with Cygwin commands that don't expect to be creating executable
  94. # files. Then when we later use a non-Cygwin program to create the
  95. # real .exe, the previous Cygwin defined ACL sticks.
  96. CYGWIN=nontsec
  97. export CYGWIN
  98. endif
  99. ALL_DEPS = $^
  100. EMPTY =
  101. SPACE = $(EMPTY) $(EMPTY)
  102. SUBSYSTEM_WINDOWS=-Wl,-subsystem,windows
  103. SUBSYSTEM_CONSOLE=-Wl,-subsystem,console
  104. # INSTALL_DIR is the directory into which emacs will be installed.
  105. #
  106. ifndef INSTALL_DIR
  107. INSTALL_DIR = $(CURDIR)/..
  108. endif
  109. export EMACSLOADPATH
  110. # Determine the architecture we're running on.
  111. # Define ARCH for our purposes;
  112. # Define CPU for use by ntwin32.mak;
  113. # Define CONFIG_H to the appropriate config.h for the system;
  114. #
  115. ifdef PROCESSOR_ARCHITECTURE
  116. # We're on Windows NT
  117. CPU = $(PROCESSOR_ARCHITECTURE)
  118. CONFIG_H = config.nt
  119. OS_TYPE = windowsnt
  120. ifeq "$(PROCESSOR_ARCHITECTURE)" "x86"
  121. ARCH = i386
  122. CPU = i386
  123. else
  124. ifeq "$(PROCESSOR_ARCHITECTURE)" "MIPS"
  125. ARCH = mips
  126. else
  127. ifeq "$(PROCESSOR_ARCHITECTURE)" "ALPHA"
  128. ARCH = alpha
  129. else
  130. ifeq "$(PROCESSOR_ARCHITECTURE)" "PPC"
  131. ARCH = ppc
  132. else
  133. $(error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)")
  134. endif
  135. endif
  136. endif
  137. endif
  138. else
  139. # We're on Windows 95
  140. ARCH = i386
  141. CPU = i386
  142. CONFIG_H = config.nt
  143. OS_TYPE = windows95
  144. endif
  145. AR = ar -rsc
  146. AR_OUT =
  147. CC = gcc
  148. CC_OUT = -o$(SPACE)
  149. LINK = gcc
  150. LINK_OUT = -o$(SPACE)
  151. RC = windres -O coff
  152. RC_OUT = -o$(SPACE)
  153. RC_INCLUDE = --include-dir$(SPACE)
  154. libc =
  155. baselibs =
  156. O = o
  157. A = a
  158. BASE_LIBS = $(libc) $(baselibs)
  159. ADVAPI32 = -ladvapi32
  160. COMCTL32 = -lcomctl32
  161. COMDLG32 = -lcomdlg32
  162. GDI32 = -lgdi32
  163. MPR = -lmpr
  164. SHELL32 = -lshell32
  165. USER32 = -luser32
  166. WSOCK32 = -lwsock32
  167. WINMM = -lwinmm
  168. WINSPOOL = -lwinspool
  169. OLE32 = -lole32
  170. UNISCRIBE = -lusp10
  171. UUID = -luuid
  172. # Used by src/makefile.w32-in, since Nmake barfs on $(func SOMETHING)
  173. OBJ0_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ0))
  174. OBJ1_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1))
  175. OBJ2_c = $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2))
  176. ifdef NOOPT
  177. DEBUG_CFLAGS = -DEMACSDEBUG
  178. else
  179. DEBUG_CFLAGS =
  180. endif
  181. ifdef ENABLECHECKS
  182. CHECKING_CFLAGS = -DENABLE_CHECKING -DXASSERTS -fno-crossjumping
  183. else
  184. CHECKING_CFLAGS =
  185. endif
  186. MWINDOWS = -mwindows
  187. CFLAGS = -I. $(ARCH_CFLAGS) $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(PROFILE_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
  188. ESC_CFLAGS = -I. $(ARCH_CFLAGS) $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(PROFILE_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
  189. EMACS_EXTRA_C_FLAGS = -DUSE_CRT_DLL=1
  190. ifdef PROFILE
  191. PROFILE_CFLAGS = -pg
  192. PROFILE_LDFLAGS = -pg
  193. else
  194. PROFILE_CFLAGS =
  195. PROFILE_LDFLAGS =
  196. endif
  197. # see comments in allocate_heap in w32heap.c before changing any of the
  198. # -stack, -heap, or -image-base settings.
  199. TEMACS_EXTRA_LINK = -Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 $(SUBSYSTEM_CONSOLE) -Wl,-entry,__start -Wl,-Map,$(BLD)/temacs.map
  200. ifdef NOOPT
  201. OBJDIR = oo
  202. else
  203. OBJDIR = oo-spd
  204. endif
  205. $(OBJDIR):; -mkdir "$(OBJDIR)"
  206. BLD = $(OBJDIR)/$(ARCH)
  207. stamp_BLD: $(OBJDIR)
  208. -mkdir "$(BLD)"
  209. echo $(BLD) > $@
  210. COMPILER_TEMP_FILES =
  211. CP = cp -f
  212. CP_DIR = cp -rf
  213. DEL = rm
  214. DEL_TREE = rm -r
  215. DIRNAME = $(notdir $(CURDIR))
  216. ifdef USING_SH
  217. IFNOTSAMEDIR = if [ ! -s ../$(DIRNAME)_same-dir.tst ] ; then
  218. FOREACH = for f in
  219. FORVAR = $${f}
  220. FORDO = ; do
  221. ENDFOR = ; done
  222. ENDIF = ; fi
  223. ARGQUOTE = '
  224. ifdef NEW_CYGWIN
  225. DQUOTE = "
  226. else
  227. DQUOTE = ""
  228. endif
  229. else
  230. IFNOTSAMEDIR = if not exist ../$(DIRNAME)_same-dir.tst
  231. FOREACH = for %%f in (
  232. FORVAR = %%f
  233. FORDO = ) do
  234. ENDFOR =
  235. ENDIF =
  236. ARGQUOTE = "
  237. DQUOTE = \"
  238. endif
  239. ifdef NODEBUG
  240. DEBUG_FLAG =
  241. DEBUG_LINK =
  242. else
  243. DEBUG_FLAG = $(DEBUG_INFO)
  244. DEBUG_LINK = $(DEBUG_INFO)
  245. endif
  246. ifdef NOCYGWIN
  247. NOCYGWIN = -mno-cygwin
  248. endif
  249. ifdef USER_LIBS
  250. USER_LIBS := $(patsubst %,-l%,$(USER_LIBS))
  251. endif
  252. PRAGMA_SYSTEM_HEADER = \#pragma GCC system_header
  253. ifeq "$(ARCH)" "i386"
  254. ifdef NOOPT
  255. ARCH_CFLAGS = -c $(DEBUG_FLAG) $(NOCYGWIN)
  256. else
  257. ARCH_CFLAGS = -c $(DEBUG_FLAG) $(NOCYGWIN) $(MCPU_FLAG) -O2 \
  258. # -fbuiltin \
  259. # -finline-functions \
  260. # -fomit-frame-pointer
  261. endif
  262. ARCH_LDFLAGS = $(SYS_LDFLAGS)
  263. else
  264. ERROR Unknown architecture type "$(ARCH)".
  265. endif
  266. LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(PROFILE_LDFLAGS) $(NOCYGWIN) $(USER_LDFLAGS)
  267. export XMFLAGS
  268. .DEFAULT:
  269. $(BLD)/%.o: %.c
  270. $(CC) $(CFLAGS) $(CC_OUT)$@ $<