make-makefile

Crates.iomake-makefile
lib.rsmake-makefile
version0.1.2
sourcesrc
created_at2023-02-21 04:51:10.880022
updated_at2023-02-21 06:25:34.759858
descriptionThe simple Makefile generator.
homepage
repositoryhttps://github.com/seongs1024/make-makefile
max_upload_size
id790377
size17,695
Seongsu Park (seongs1024)

documentation

README

make-makefile

The simple Makefile generator

Usage: mm [OPTIONS]

Options:
  -n, --name <NAME>  Name of the project
  -k, --kind <KIND>  Binary or library [default: bin] [possible values: bin, lib]
  -h, --help         Print help
  -V, --version      Print version

Install

If you've got the cargo package manager of Rust then you can run the command.

cargo install make-makefile

Or you can download it on the release page.


Generate a template

The mm generates Makefile template in your project directory.

You can change {PROGRAM} to your project name.

mm 
#The Target
#For Binary: <name>, For Library: lib<name>.a
NAME		:=	{PROGRAM}

#Source Files
SOURCES		:=	main.c \

#The Directories, Source, Includes, Dependencies
TESTDIR		:=	test
BONUSDIR	:=	bonus
SRCDIR		:=	src
INCDIR		:=	inc
DEPDIR		:=	dep
BLDDIR		:=	obj

#Dependencies
DEPLIBS		:=	
DEPDIRS		:=	

#Compiler, Linker, Flags
CC			:=	cc
# DEBUG		:=	-g
# SANITIZE	:=	-fsanitize=address
CFLAGS		:=	-Wall -Wextra -Werror

#-------------------------------------------------------------------------------
#DO NOT EDIT BELOW THIS LINE
#-------------------------------------------------------------------------------
TARGET		:=	$(suffix $(NAME))
CEXT		:=	c
OEXT		:=	o
INC			:=	-I$(INCDIR) $(addprefix -I$(DEPDIR)/, $(DEPDIRS))
LIB			:=	$(addprefix -l, $(DEPLIBS))
LID			:=	$(addprefix -L$(DEPDIR)/, $(DEPDIRS))
SRCS		:=	$(addprefix $(SRCDIR)/,$(SOURCES))
OBJS		:=	$(patsubst $(SRCDIR)/%,$(BLDDIR)/%,$(SRCS:.$(CEXT)=.$(OEXT)))

#Defauilt Make
all: $(NAME)

bonus: 
	@make -C $(BONUSDIR)
	@cp $(BONUSDIR)/$(NAME) ./

#Remake
re: fclean all

#Make the Directories
directories:
	@mkdir -p $(BLDDIR)

#Dependencies
depend:
	@for ddir in $(addprefix $(DEPDIR)/, $(DEPDIRS)); do \
		make -s -C $$ddir; \
	done

#Clean only Objects
clean:
	@for ddir in $(addprefix $(DEPDIR)/, $(DEPDIRS)); do \
		make -s -C $$ddir clean; \
	done
	@$(RM) -rf $(BLDDIR)

#Full Clean, Objects and Binaries
fclean: clean
	@for ddir in $(addprefix $(DEPDIR)/, $(DEPDIRS)); do \
		make -s -C $$ddir fclean; \
	done
	@$(RM) -rf $(NAME)

#Link
$(NAME): $(OBJS)
	@for ddir in $(addprefix $(DEPDIR)/, $(DEPDIRS)); do \
		make -s -C $$ddir; \
	done
ifeq ($(TARGET), .a)
	$(AR) -rc $@ $^
else
	$(CC) $(SANITIZE) $(DEBUG) $(INC) -o $(NAME) $^ $(LID) $(LIB)
endif

#Compile
$(BLDDIR)/%.$(OEXT): $(SRCDIR)/%.$(CEXT) 
	@mkdir -p $(dir $@)
	$(CC) $(CFLAGS) $(SANITIZE) $(DEBUG) $(INC) -c -o $@ $<

#Non-File Targets
.PHONY: all re clean fclean bonus directories depend

Name specifier

mm --name hello
#The Target
#For Binary: <name>, For Library: lib<name>.a
NAME		:=	hello

Kind option

Binary template
mm --name hello --kind=bin
#The Target
#For Binary: <name>, For Library: lib<name>.a
NAME		:=	hello
Library template
mm --name hello --kind=lib
#The Target
#For Binary: <name>, For Library: lib<name>.a
NAME		:=	libhello.a
Commit count: 4

cargo fmt