2 ms·
I have a makemake function in my zsh config for simple C programs that relies on implicit rules (which I turn off for more complex programs) : function makemak
by cassepipe 3y ago
I have a makemake function in my zsh config for simple C programs that relies on implicit rules (which I turn off for more complex programs) :
function makemake() {
>makefile echo '
.RECIPEPREFIX = >
ASAN = -fsanitize=address
CFLAGS += -Wall -Wextra -g3
CFLAGS += $(ASAN)
LDFLAGS += $(ASAN) -Wall -Wextra -g3
SRCS = $(wildcard .c)
OBJS = $(patsubst .c, .o, $(SRCS))
#CC = clang
# main function must be in the $NAME.c file
'"NAME=${1:-main}" '
all: $(NAME)
$(NAME): $(OBJS)
print_name:
> @echo $(NAME)
clean:
> rm -rf .o
fclean: clean
> rm -rf ${NAME}
re: fclean all
.PHONY: print_name clean fclean re
'
}