visualc.mak 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # makefile to compile MCPP version 2.7.1 and later for Visual C / nmake
  2. # 2008/11 kmatsui
  3. # You must first edit BINDIR, LIBDIR and INCDIR according to your system.
  4. # To make compiler-independent-build of MCPP do:
  5. # nmake
  6. # To make Visual-C-specific-build of MCPP do:
  7. # nmake COMPILER=MSC
  8. # To re-compile MCPP using Visual-C-specific-build of MCPP do:
  9. # nmake COMPILER=MSC PREPROCESSED=1
  10. # To link kmmalloc V.2.5.3 (malloc() package of kmatsui) or later do:
  11. # (Note: Visual C 2005 and 2008 cannot coexist with kmmalloc)
  12. # nmake [PREPROCESSED=1] KMMALLOC=1
  13. # To make mcpp.lib (subroutine-build of mcpp) do:
  14. # nmake MCPP_LIB=1 mcpplib
  15. # nmake MCPP_LIB=1 mcpplib_install
  16. # To make testmain.c (sample to use mcpp.lib) against mcpp.lib do
  17. # (add 'DLL_IMPORT=1' to link against the DLL):
  18. # nmake [OUT2MEM=1] testmain
  19. # nmake [OUT2MEM=1] testmain_install
  20. # To use this Makefile in IDE of Visual C, include $(targ)_install target
  21. # in $(targ) target, since the IDE can't handle install target.
  22. # This is a modified copy of //lyengine/3rdPartySource/mcpp/mcpp-2.7.2/noconfig/visualc.mak
  23. # Modifications Copyright (c) Contributors to the Open 3D Engine Project, SPDX-License-Identifier: Apache-2.0 OR MIT
  24. NAME = mcpp
  25. CC = cl
  26. CFLAGS = $(CFLAGS) -Za -c /favor:AMD64 #-Zi
  27. # Add -Zi for debugging on Visual C / IDE
  28. LINKFLAGS = -Fe$(NAME) /MACHINE:X64 #-Zi
  29. CPPFLAGS = $(CPPFLAGS) -D_CRT_SECURE_NO_DEPRECATE # -Za
  30. # -D_CRT_SECURE_NO_DEPRECATE for Visual C 2005, 2008
  31. # -Za should not be specified for compiler-independent-built MCPP
  32. !if "$(COMPILER)"=="MSC"
  33. CPPFLAGS = $(CPPFLAGS) -DCOMPILER=MSC
  34. # BINDIR : Adjust to your system.
  35. # for Visual C 2003
  36. #BINDIR = "$(MSVCDIR)"\bin
  37. # for Visual C 2005, 2008
  38. BINDIR = "$(VCINSTALLDIR)"\bin
  39. !else
  40. # compiler-independent-build: use compiler-independent directory
  41. BINDIR = \PUB\bin
  42. !endif
  43. !ifdef KMMALLOC
  44. MEM_MACRO = -DKMMALLOC -D_MEM_DEBUG -DXMALLOC
  45. MEMLIB = kmmalloc_debug.lib
  46. !else
  47. MEM_MACRO =
  48. MEMLIB =
  49. !endif
  50. OBJS = main.obj directive.obj eval.obj expand.obj support.obj system.obj \
  51. mbchar.obj
  52. $(NAME).exe : $(OBJS)
  53. $(CC) $(LINKFLAGS) $(OBJS) $(MEMLIB)
  54. #install :
  55. # Visual C++ / IDE "makefile project" does not have "make install" command
  56. # copy /b $(NAME).exe $(BINDIR)\$(NAME).exe
  57. !ifdef PREPROCESSED
  58. # make a "pre-preprocessed" header file to recompile MCPP with MCPP.
  59. mcpp.H : system.H internal.H
  60. $(BINDIR)\$(NAME) $(CPPFLAGS) $(LANG) $(MEM_MACRO) preproc.c mcpp.H
  61. $(OBJS) : mcpp.H
  62. system.H: noconfig.H
  63. !else
  64. $(OBJS) : noconfig.H
  65. main.obj directive.obj eval.obj expand.obj support.obj system.obj mbchar.obj: \
  66. system.H internal.H
  67. !endif
  68. !ifdef PREPROCESSED
  69. .c.obj :
  70. $(BINDIR)\$(NAME) -DPREPROCESSED $(CPPFLAGS) $< $(<B).i
  71. $(CC) $(CFLAGS) -TC $(<B).i
  72. !else
  73. .c.obj :
  74. $(CC) $(CFLAGS) $(CPPFLAGS) $(MEM_MACRO) $<
  75. !endif
  76. clean :
  77. -del *.obj *.i mcpp.H *.exe *.lib *.dll *.exp *.so
  78. !ifdef MCPP_LIB
  79. #LIBDIR = "$(MSVCDIR)"\lib
  80. LIBDIR = "$(VCINSTALLDIR)"\lib
  81. INCDIR = "$(VCINSTALLDIR)"\include
  82. CFLAGS = $(CFLAGS) -DMCPP_LIB
  83. mcpplib: mcpplib_lib mcpplib_dll
  84. # To use in Visual C IDE
  85. #mcpplib: mcpplib_lib mcpplib_dll mcpplib_install
  86. # Debug mode: Do 'nmake DEBUG=1 ...'
  87. !ifdef DEBUG
  88. CFLAGS = $(CFLAGS) -MDd -D_DEBUG
  89. #LIBSUFFIX = d
  90. !else
  91. CFLAGS = $(CFLAGS) -O2 -MD -DNDEBUG
  92. !endif
  93. mcpplib_lib: $(OBJS)
  94. lib -out:mcpp$(LIBSUFFIX).lib $(OBJS)
  95. # DLL
  96. DLL_VER = 0
  97. SOBJS = main.so directive.so eval.so expand.so support.so system.so mbchar.so
  98. .SUFFIXES: .so
  99. .c.so :
  100. $(CC) $(CFLAGS) $(CPPFLAGS) $(MEM_MACRO) -DDLL_EXPORT -TC -Fo$*.so $<
  101. mcpplib_dll: $(SOBJS)
  102. $(CC) -LD -Femcpp$(DLL_VER)$(LIBSUFFIX) $(SOBJS) $(MEMLIB) /MACHINE:X64
  103. mcpplib_install:
  104. copy mcpp$(LIBSUFFIX).lib $(LIBDIR)
  105. copy mcpp$(DLL_VER)$(LIBSUFFIX).lib $(LIBDIR)
  106. copy mcpp$(DLL_VER)$(LIBSUFFIX).dll $(BINDIR)
  107. copy mcpp_lib.h $(INCDIR)
  108. copy mcpp_out.h $(INCDIR)
  109. $(CC) main_libmcpp.c -Fe$(NAME).exe \
  110. $(LIBDIR)\mcpp$(DLL_VER)$(LIBSUFFIX).lib \
  111. -link -force:multiple /MACHINE:X64
  112. copy $(NAME).exe $(BINDIR)
  113. mcpplib_uninstall:
  114. del $(LIBDIR)\mcpp$(LIBSUFFIX).lib \
  115. $(LIBDIR)\mcpp$(DLL_VER)$(LIBSUFFIX).lib \
  116. $(BINDIR)\mcpp$(DLL_VER)$(LIBSUFFIX).dll
  117. del $(BINDIR)\$(NAME).exe
  118. del $(INCDIR)\mcpp*
  119. !endif
  120. # use mcpp as a subroutine from testmain.c
  121. !ifdef DLL_IMPORT
  122. CFLAGS = $(CFLAGS) -DDLL_IMPORT
  123. LINKLIB = mcpp$(DLL_VER)$(LIBSUFFIX).lib
  124. !else
  125. LINKLIB = mcpp$(LIBSUFFIX).lib
  126. !endif
  127. TMAIN_LINKFLAGS = testmain.obj -Fetestmain.exe $(LIBDIR)\$(LINKLIB) \
  128. -link -force:multiple /MACHINE:X64
  129. !ifdef OUT2MEM
  130. # output to memory buffer
  131. CFLAGS = $(CFLAGS) -DOUT2MEM
  132. !endif
  133. testmain : testmain.obj
  134. $(CC) $(TMAIN_LINKFLAGS)
  135. testmain_install :
  136. copy testmain.exe $(BINDIR)
  137. testmain_uninstall :
  138. del $(BINDIR)\testmain.exe