Makefile 606 B

12345678910111213141516171819202122232425262728293031323334
  1. OUT = sergate
  2. #CC = clang
  3. CC = gcc
  4. CFLAGS = -Wall -O2
  5. #CXX = clang++
  6. CXX = g++
  7. CXXFLAGS = -Wall -O2
  8. ODIR = obj
  9. SDIR = src
  10. LIBS = -pthread -lm
  11. INC = -Iinclude
  12. C_SRCS := $(wildcard $(SDIR)/*.c)
  13. CXX_SRCS := $(wildcard $(SDIR)/*.cpp)
  14. C_OBJS := $(patsubst $(SDIR)/%.c,$(ODIR)/%.o,$(C_SRCS))
  15. CXX_OBJS := $(patsubst $(SDIR)/%.cpp,$(ODIR)/%.o,$(CXX_SRCS))
  16. OBJS := $(C_OBJS) $(CXX_OBJS)
  17. $(ODIR)/%.o: $(SDIR)/%.c
  18. $(CC) -c $(INC) $(CFLAGS) $< -o $@
  19. $(ODIR)/%.o: $(SDIR)/%.cpp
  20. $(CXX) -c $(INC) $(CXXFLAGS) $< -o $@
  21. $(OUT): $(OBJS)
  22. $(CXX) $(LIBS) $^ -o $(OUT)
  23. .PHONY: clean
  24. clean:
  25. rm -f $(ODIR)/*.o $(OUT)