Skip to content

Instantly share code, notes, and snippets.

@kube
Created January 15, 2015 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kube/9909140369c2edae755d to your computer and use it in GitHub Desktop.
Save kube/9909140369c2edae755d to your computer and use it in GitHub Desktop.
Makefile : Sublime Snippet
<snippet>
<content><![CDATA[
NAME = ${1:program}
CXX = g++
CXXFLAGS = ${2:-Wall -Werror -Wextra}
SRC = \
${3:main.cpp}
OBJ = \$(SRC:.cpp=.o)
# Colors
NO_COLOR = \x1b[0m
OK_COLOR = \x1b[32;01m
ERROR_COLOR = \x1b[31;01m
WARN_COLOR = \x1b[33;01m
SILENT_COLOR = \x1b[30;01m
ALIGN_TAB = \e[25G
.PHONY: all re space clean fclean
all: \$(NAME)
%.o: %.cpp
@printf "\$(SILENT_COLOR)\$<\$(NO_COLOR)"
@\$(CXX) \$(CXXFLAGS) -c \$< -o \$@
@printf "\$(ALIGN_TAB)\$(OK_COLOR)✓\$(NO_COLOR)\n"
\$(NAME): \$(OBJ)
@printf "\$(OK_COLOR)\$(NAME)\$(NO_COLOR)"
@\$(CXX) \$(CXXFLAGS) \$(OBJ) \$(LDFLAGS) -o \$(NAME)
@printf "\$(ALIGN_TAB)\$(OK_COLOR)Done ✓\$(NO_COLOR)\n"
clean:
@rm -f \$(OBJ)
@printf "\$(SILENT_COLOR)Removed objects\$(NO_COLOR)\n"
fclean: clean
@rm -f \$(NAME)
@printf "\$(SILENT_COLOR)Removed \$(NAME)\$(NO_COLOR)\n"
space:
@echo
re: fclean space all
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>makefile</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.makefile, text.plain</scope>
</snippet>
@ryukinix
Copy link

I try use this snippet on my sublime with gcc. But i have this error:

delicious-error

My makefile script is here:
makefile-script

What are you doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment