Advertisement
synthnassizer

gnuMake

Dec 10th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.90 KB | None | 0 0
  1. program_NAME := CO2sensor
  2.  
  3. program_C_SRCS := $(wildcard *.c)
  4. program_CXX_SRCS := $(wildcard *.cpp)
  5. #add extra directories with c / cpp files here
  6. program_C_SRCS += $(wildcard ../common/*.c)
  7. program_C_SRCS += $(wildcard ../common/*.cpp)
  8.  
  9. #get .o from .c & .cpp files
  10. program_C_OBJS := ${program_C_SRCS:.c=.o}
  11. program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
  12. program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
  13.  
  14. program_INCLUDE_DIRS :=
  15. program_LIBRARY_DIRS :=
  16. program_LIBRARIES := pthread
  17.  
  18. #CFLAGS += -Wall -Wextra -g
  19. CFLAGS += -Wall -Wextra -O2
  20. CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
  21. LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
  22. LDFLAGS += $(foreach library,$(program_LIBRARIES),-$(library))\
  23.  
  24. ifneq (-g,$(findstring -g,$(CFLAGS)))
  25.         EXEC_TYPE := release
  26. else
  27.         EXEC_TYPE := debug
  28. endif
  29. #LINK.cc := $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
  30.  
  31. .PHONY: all clean distclean
  32.  
  33. all: $(program_NAME)
  34.  
  35. $(program_NAME): $(program_OBJS)
  36.         $(CC) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(program_OBJS) -o "$(program_NAME)"
  37. #       $(LINK.cc) $(program_OBJS) -o $(program_NAME)
  38.         mv $(program_NAME) $(program_NAME)_$(EXEC_TYPE)
  39.  
  40. clean:
  41.         @- $(RM) $(program_NAME) $(program_NAME)_debug $(program_NAME)_release
  42.         @- $(RM) $(program_OBJS)
  43.  
  44. distclean: clean
  45.  
  46. #general rule : all object (.o) files have their same-name source file (.c , .cpp) dependencies
  47. %.o : %.c
  48.         $(CC) $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o "$@" "$<"
  49.  
  50. #Add explicit object and source file dependencies here
  51. main.o : main.c commands_sensorCO2.h ../common/std_defines.h ../common/stringhelper.h
  52. commands_sensorCO2.o : commands_sensorCO2.c ../common/serialcomm.h ../common/stringhelper.h ../common/std_defines.h
  53. stringhelper.o : stringhelper.c stringhelper.h
  54. serialcomm.o : serialcomm.c serialcomm.h
  55. serialcomm.h :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement