Makefile.misc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ## Small Functions ##
  2. get_csrcs = $(foreach subdir, $(1), $(wildcard $(subdir)/*.c $(subdir)/*.C))
  3. get_asmsrcs = $(foreach subdir, $(1), $(wildcard $(subdir)/*.s $(subdir)/*.S))
  4. get_cxxsrcs = $(foreach subdir, $(1), $(wildcard $(subdir)/*.cpp $(subdir)/*.CPP $(subdir)/*.cc $(subdir)/*.CC))
  5. check_item_exist = $(strip $(if $(filter 1, $(words $(1))),$(filter $(1), $(sort $(2))),))
  6. ###
  7. # For Windows, in Win9x, COMSPEC is defined, WinNT, ComSpec is defined
  8. ###
  9. ifdef ComSpec
  10. WINCMD:=$(ComSpec)
  11. endif
  12. ifdef COMSPEC
  13. WINCMD:=$(COMSPEC)
  14. endif
  15. ifneq "$(WINCMD)" ""
  16. ifneq "$(findstring /cygdrive/,$(PATH))" ""
  17. HOST_OS:=Cygwin
  18. else
  19. HOST_OS:=Windows
  20. endif
  21. else
  22. HOST_OS:=$(shell uname)
  23. endif
  24. ##
  25. # Define one space
  26. ##
  27. nullstring=
  28. space=$(nullstring) # one space
  29. RM=rm -rf
  30. RMD=rm -rf
  31. ECHO=echo
  32. # TODO cp currently only avail in linux
  33. # windows build tool not provide it
  34. CP=cp -rf
  35. # https://github.com/bmatzelle/gow/issues/171#issuecomment-91709839
  36. # add extra "" around mkdir to overwrite cmd default mkdir in windows
  37. MKD="mkdir" -p
  38. PS=/$(nullstring)
  39. NULL=/dev/null
  40. ## Check OS ##
  41. ## Check OS == Windows ##
  42. ifeq "$(HOST_OS)" "Windows"
  43. PS=\$(nullstring)
  44. NULL=NUL
  45. DOS_CMD=$(WINCMD) /C
  46. # when OS is windows, force SHELL to be cmd
  47. # or if in your evironment path there is
  48. # a mingw shell, the make process will go wrong
  49. SHELL:=$(WINCMD)
  50. endif
  51. ## Check OS == Linux ##
  52. ifeq "$(HOST_OS)" "Linux"
  53. PS=/$(nullstring)
  54. NULL=/dev/null
  55. endif
  56. ## Check OS == Darwin ##
  57. ifeq "$(HOST_OS)" "Darwin"
  58. PS=/$(nullstring)
  59. NULL=/dev/null
  60. endif
  61. ## MAKEFILE COMPILE MESSAGE CONTROL ##
  62. ifeq ($(V),1)
  63. Q=
  64. else
  65. Q=@
  66. endif
  67. ## Suppress All Message ##
  68. ifeq ($(SILENT), 1)
  69. TRACE_CREATE_DIR =
  70. TRACE_COMPILE =
  71. TRACE_ASSEMBLE =
  72. TRACE_LINK =
  73. TRACE_ARCHIVE =
  74. ## Overwrite Q Value set by V option ##
  75. override Q=@
  76. else
  77. TRACE_CREATE_DIR = @$(ECHO) "Creating Directory : " $(@D)
  78. TRACE_COMPILE = @$(ECHO) "Compiling : " $<
  79. TRACE_ASSEMBLE = @$(ECHO) "Assembling : " $<
  80. TRACE_LINK = @$(ECHO) "Linking : " $@
  81. TRACE_ARCHIVE = @$(ECHO) "Archiving : " $@
  82. endif