GNUmakefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ##############################################################################
  2. # GNU Make 3.82+ Makefile
  3. #
  4. # Usage:
  5. # $ gmake [compiler={gcc|clang[-cl]|msvc}] [std={98|11|14|17|20|23}]
  6. include ../src/defs.mk
  7. std = 17
  8. compiler = gcc
  9. ##############################################################################
  10. ifeq ($(compiler),gcc)
  11. CC := g++ -std=c++$(std) -mthreads
  12. CFLAGS := -pedantic-errors -DNDEBUG -O3 -ffunction-sections -fdata-sections
  13. WARNS := $(if $(filter 98,$(std)),-Wno-long-long)
  14. binutils = 1
  15. ##############################################################################
  16. else ifeq ($(compiler),clang)
  17. CC := clang++
  18. TARGET := -target $(patsubst %-msvc,%-gnu,$(lastword $(shell $(CC) --version|find "Target:")))
  19. CC += -std=c++$(std) $(TARGET) -pthread
  20. CFLAGS := -pedantic-errors -DNDEBUG -O3
  21. WARNS := $(if $(filter 98,$(std)),-Wno-long-long )-Wno-non-literal-null-conversion
  22. binutils = 1
  23. ##############################################################################
  24. else ifeq ($(compiler),clang-cl)
  25. CC := clang-cl /std:c++$(std)
  26. CFLAGS := -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE -O2 -Ob1 -GF
  27. WARNS :=
  28. ##############################################################################
  29. else ifeq ($(compiler),msvc)
  30. CC := cl /nologo /std:c++$(std) /Zc:__cplusplus /permissive- /EHsc
  31. CFLAGS := -DNDEBUG -D_CRT_SECURE_NO_DEPRECATE -O2 -Ob1 -GF
  32. WARNS :=
  33. endif
  34. ##############################################################################
  35. LIBSUFFIX = $(std)
  36. ifdef binutils
  37. OBJSUFF = o
  38. ARSUFF = a
  39. LIBFILE := lib$(LIBNAME)$(LIBSUFFIX).$(ARSUFF)
  40. AR = ar
  41. ARFLAGS = s
  42. ARFLAGS_ALL = r$(ARFLAGS) $@
  43. else
  44. OBJSUFF = obj
  45. ARSUFF = lib
  46. LIBFILE := $(LIBNAME)$(LIBSUFFIX).$(ARSUFF)
  47. AR = lib
  48. ARFLAGS =
  49. ARFLAGS_ALL = -nologo $(ARFLAGS) /OUT:$@
  50. endif
  51. CFLAGS_ALL = -I../include -DUNICODE=1 $(CFLAGS) $(WARNS)
  52. ifndef SOURCES
  53. SOURCES := $(wildcard *.cpp)
  54. endif
  55. OBJS := $(patsubst %.cpp,%.$(OBJSUFF),$(SOURCES))
  56. .PHONY: clean
  57. include ../src/rules.mk