let st = g:snip_start_tag let et = g:snip_end_tag let cd = g:snip_elem_delim exec "Snippet makecc # Specify the main target\rTARGET = ".st."bin".et.st.et."\r# Default build type\rTYPE = debug\r# Which directories contain source files\rDIRS = .\r# Which libraries are linked\rLIBS =\r# Dynamic libraries\rDLIBS =\r\r# The next blocks change some variables depending on the build type\rifeq ($(TYPE),debug)\rLDPARAM =\rCCPARAM = -Wall -g3\rMACROS =\rendif\r\rifeq ($(TYPE),profile)\rLDPARAM = -pg /lib/libc.so.5\rCCPARAM = -Wall -pg\rMACROS = NDEBUG\rendif\r\rifeq ($(TYPE), release)\rLDPARAM = -s\rCCPARAM = -Wall -O2\rMACROS = NDEBUG\rendif\r\r# Add directories to the include and library paths\rINCPATH = . $(HOME)/Development/include\rLIBPATH =\r\r# Which files to add to backups, apart from the source code\rEXTRA_FILES = Makefile\r# The compiler\rCXX = g++\r\r# Where to store object and dependancy files.\rSTORE = .make-$(TYPE)\r# Makes a list of the source (.cc) files.\rSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cc))\r# List of header files.\rHEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.hh))\r# Makes a list of the object files that will have to be created.\rOBJECTS := $(addprefix $(STORE)/, $(SOURCE:.cc=.o))\r# Same for the .d (dependancy) files.\rDFILES := $(addprefix $(STORE)/,$(SOURCE:.cc=.d))\r\r# Specify phony rules. These are rules that are not real files.\r.PHONY: clean backup dirs\r\r# Main target. The @ in front of a command prevents make from displaying\r# it to the standard output.\r$(TARGET): dirs $(OBJECTS)\r@echo \" LD\t$(TARGET)\"\r@$(CXX) -o $(TARGET) $(OBJECTS) $(LDPARAM) $(foreach LIBRARY, \\\r$(LIBS),-l$(LIBRARY)) $(foreach LIB,$(LIBPATH),-L$(LIB))\r\r# Rule for creating object file and .d file, the sed magic is to add\r# the object path at the start of the file because the files gcc\r# outputs assume it will be in the same dir as the source file.\r$(STORE)/%.o: %.cc\r@echo \" CXX\t$?\"\r@$(CXX) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC,$(INCPATH),-I$(INC)) \\\r$(foreach MACRO,$(MACROS),-D$(MACRO)) -c $< -o $@\r@sed -e '1s/^\\(.*\\)$$/$(subst /,\\/,$(dir $@))\\1/' $(STORE)/$*.dd > $(STORE)/$*.d\r@rm -f $(STORE)/$*.dd\r\r# Empty rule to prevent problems when a header is deleted.\r%.hh: ;\r\r# Cleans up the objects, .d files and executables.\rclean:\r@echo Cleaning up\r@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)\r@-rm -f $(TARGET)\r\r# Backup the source files.\rbackup:\r@-if [ ! -e .backup ]; then mkdir .backup; fi;\r@zip .backup/backup_`date +%d-%m-%y_%H.%M`.zip $(SOURCE) $(HEADERS) $(EXTRA_FILES)\r\r# Create necessary directories\rdirs:\r@-if [ ! -e $(STORE) ]; then mkdir $(STORE); fi;\r@-$(foreach DIR,$(DIRS), if [ ! -e $(STORE)/$(DIR) ]; \\\rthen mkdir $(STORE)/$(DIR); fi; )\r\r# Includes the .d files so it knows the exact dependencies for every\r# source.\r-include $(DFILES)" exec "Snippet makec # Specify the main target\rTARGET = ".st."bin".et.st.et."\r# Default build type\rTYPE = debug\r# Which directories contain source files\rDIRS = .\r# Which libraries are linked\rLIBS =\r# Dynamic libraries\rDLIBS =\r\r# The next blocks change some variables depending on the build type\rifeq ($(TYPE),debug)\rLDPARAM =\rCCPARAM = -Wall -pedantic -ansi -g3\rMACROS =\rendif\r\rifeq ($(TYPE),profile)\rLDPARAM = -pg /lib/libc.so.5\rCCPARAM = -Wall -pedantic -ansi -pg\rMACROS = NDEBUG\rendif\r\rifeq ($(TYPE), release)\rLDPARAM = -s\rCCPARAM = -Wall -pedantic -ansi -O2\rMACROS = NDEBUG\rendif\r\r# Add directories to the include and library paths\rINCPATH = . $(HOME)/Development/include\rLIBPATH =\r\r# Which files to add to backups, apart from the source code\rEXTRA_FILES = Makefile\r# The compiler\rCC = gcc\r\r# Where to store object and dependancy files.\rSTORE = .make-$(TYPE)\r# Makes a list of the source (.c) files.\rSOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c))\r# List of header files.\rHEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))\r# Makes a list of the object files that will have to be created.\rOBJECTS := $(addprefix $(STORE)/, $(SOURCE:.c=.o))\r# Same for the .d (dependancy) files.\rDFILES := $(addprefix $(STORE)/,$(SOURCE:.c=.d))\r\r# Specify phony rules. These are rules that are not real files.\r.PHONY: clean backup dirs\r\r# Main target. The @ in front of a command prevents make from displaying\r# it to the standard output.\r$(TARGET): dirs $(OBJECTS)\r@echo \" LD\t$(TARGET)\"\r@$(CC) -o $(TARGET) $(OBJECTS) $(LDPARAM) $(foreach LIBRARY, \\\r$(LIBS),-l$(LIBRARY)) $(foreach LIB,$(LIBPATH),-L$(LIB))\r\r# Rule for creating object file and .d file, the sed magic is to add\r# the object path at the start of the file because the files gcc\r# outputs assume it will be in the same dir as the source file.\r$(STORE)/%.o: %.c\r@echo \" CC\t$?\"\r@$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC,$(INCPATH),-I$(INC)) \\\r$(foreach MACRO,$(MACROS),-D$(MACRO)) -c $< -o $@\r@sed -e '1s/^\\(.*\\)$$/$(subst /,\\/,$(dir $@))\\1/' $(STORE)/$*.dd > $(STORE)/$*.d\r@rm -f $(STORE)/$*.dd\r\r# Empty rule to prevent problems when a header is deleted.\r%.h: ;\r\r# Cleans up the objects, .d files and executables.\rclean:\r@echo Cleaning up\r@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)\r@-rm -f $(TARGET)\r\r# Backup the source files.\rbackup:\r@-if [ ! -e .backup ]; then mkdir .backup; fi;\r@zip .backup/backup_`date +%d-%m-%y_%H.%M`.zip $(SOURCE) $(HEADERS) $(EXTRA_FILES)\r\r# Create necessary directories\rdirs:\r@-if [ ! -e $(STORE) ]; then mkdir $(STORE); fi;\r@-$(foreach DIR,$(DIRS), if [ ! -e $(STORE)/$(DIR) ]; \\\rthen mkdir $(STORE)/$(DIR); fi; )\r\r# Includes the .d files so it knows the exact dependencies for every\r# source.\r-include $(DFILES)"