Makefile.misc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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))
  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. CP=cp -rf
  33. MKD = mkdir -p
  34. PS=/$(nullstring)
  35. NULL=/dev/null
  36. ## Check OS ##
  37. ## Check OS == Windows ##
  38. ifeq "$(HOST_OS)" "Windows"
  39. PS=\$(nullstring)
  40. NULL=NUL
  41. DOS_CMD=$(WINCMD) /C
  42. # when OS is windows, force SHELL to be cmd
  43. # or if in your evironment path there is
  44. # a mingw shell, the make process will go wrong
  45. SHELL:=$(WINCMD)
  46. endif
  47. ## Check OS == Linux ##
  48. ifeq "$(HOST_OS)" "Linux"
  49. PS=/$(nullstring)
  50. NULL=/dev/null
  51. endif
  52. ## Check OS == Darwin ##
  53. ifeq "$(HOST_OS)" "Darwin"
  54. PS=/$(nullstring)
  55. NULL=/dev/null
  56. endif
  57. ## MAKEFILE COMPILE MESSAGE CONTROL ##
  58. ifeq ($(V),1)
  59. Q=
  60. else
  61. Q=@
  62. endif
  63. ## Suppress All Message ##
  64. ifeq ($(SILENT), 1)
  65. TRACE_CREATE_DIR =
  66. TRACE_COMPILE =
  67. TRACE_ASSEMBLE =
  68. TRACE_LINK =
  69. TRACE_ARCHIVE =
  70. ## Overwrite Q Value set by V option ##
  71. override Q=@
  72. else
  73. TRACE_CREATE_DIR = @$(ECHO) "Creating Directory : " $(@D)
  74. TRACE_COMPILE = @$(ECHO) "Compiling : " $<
  75. TRACE_ASSEMBLE = @$(ECHO) "Assembling : " $<
  76. TRACE_LINK = @$(ECHO) "Linking : " $@
  77. TRACE_ARCHIVE = @$(ECHO) "Archiving : " $@
  78. endif