auto_makefile is a C++ program that automates the generation of Makefiles Rules for your projects. It analyzes your project directory structure and completes your Makefile rules to compile all relevant source files.
⭐ Don't forget to put a star if you like the project !
- Clone this repository to your local machine:
git clone git@github.com:thibaudcathala/auto_makefile.git
- Navigate to the project directory:
cd auto_makefile
- Build the program using make:
make
- Move the program to /usr/local/bin to execute it from anywhere:
sudo mv auto_makefile /usr/local/bin/
- (optional) You can delete the repository:
cd .. ;
rm -R auto_makefile/
auto_makefile [Makefile] ...
auto_makefile take as argument Makefile where you want the rule to be auto-completed.
In the Makefile, you must define specific variables and utilize tags that will serve as markers for the auto_makefile program to generate the rule content:
# root: [ROOT_RULE_NAME], ...;
# path: [PATH_TO_FOLDER], ...;
# file_ext: [FILE_EXT, ...], ...;
# subfold_rule_name: [SUBFOLDER_RULE_NAME], ...;
# nb_tab: [NB_TAB], ...;
#//
ROOT_RULE_NAME =
#//
- To delineate the section where auto_makefile needs to auto-complete the rules, use tags formatted as:
#//
. These tags serve as markers to indicate the boundaries of the area that require automatic rule generation.
root: [ROOT_RULE_NAME], ...;
- This variable specifies the root rule names to complete. You can list multiple root rule names, separated by commas.
path: [PATH_TO_FOLDER], ...;
- Here, you provide the paths to the folders where your project's source files are located. Each path corresponds to one of the root rules defined earlier. You can specify multiple paths separated by commas.
file_ext: [FILE_EXT, ...], ...;
- This variable specifies the file extensions of the source files you want to include in each root rule. Each entry in this list corresponds to a root rule defined earlier. You can specify multiple file extensions separated by commas for each root rule.
subfold_rule_name: [SUBFOLDER_RULE_NAME], ...;
-
For each root rule, you can specify a subfolder rule name. This name will be used to generate rules for subdirectories within each root rule's directory. Like the other variables, you can specify multiple subfolder rule names separated by commas, corresponding to the root rules.
-
{FOLD} and {SUBFOLD} are variable that you can use in
[SUBFOLDER_RULE_NAME]
to generate different subrule name.
nb_tab: [NB_TAB], ...;
- This variable specifies the number of tabs to use for each rule's indentation. Each entry corresponds to a root rule.
Here is a simple Makefile where the rule SRC will be auto-completed by auto_makefile:
.
├── Makefile
└── src
└── main.cpp
# root: SRC;
# path: src/;
# file_ext: .cpp;
# subfold_rule_name: {FOLD} + "_" + {SUBFOLD};
# nb_tab: 4;
#//
SRC = main.cpp
#//
CPPFLAGS =
NAME =
OBJ = $(SRC:.cpp=.o)
$(NAME): $(OBJ)
g++ -o $(NAME) $(OBJ)
generate_rule:
auto_makefile Makefile
all: generate_rule $(NAME)
clean:
rm -f $(OBJ)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re
Here is a Makefile whith multiple rule that will be auto-completed by auto_makefile:
.
├── Makefile
├── src
│ └── main.cpp
└── tests
├── suite_1
│ └── test_1.cpp
└── suite_2
└── test_2.cpp
# root: SRC, SRC_TESTS;
# path: src/, tests/;
# file_ext: .cpp .c++, cpp;
# subfold_rule_name:
# {FOLD} + "_" + {SUBFOLD},
# {FOLD} + "_" + {SUBFOLD};
# nb_tab: 4, 4;
#//
SRC = main.cpp
#//
CPPFLAGS =
NAME =
#//
TESTS_SUITE_1 = tests/suite_1/test_1.cpp
TESTS_SUITE_2 = tests/suite_2/test_2.cpp
SRC_TESTS = $(TESTS_SUITE_1) \
$(TESTS_SUITE_2)
#//
OBJ = $(SRC:.cpp=.o)
$(NAME): $(OBJ)
g++ -o $(NAME) $(OBJ)
generate_rule:
auto_makefile Makefile
all: generate_rule $(NAME)
clean:
rm -f $(OBJ)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
. - Make your changes and commit them:
git commit -m 'Add your feature'
. - Push to the branch:
git push origin feature/your-feature-name
. - Create a pull request on GitHub.