Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [2.1.1] - 2025-12-10

### Changed
- **bind-hub folder restructure**: Simplified file naming and improved organization
- Renamed user-editable files to remove `mb_` prefix:
- `mb_config.mk` → `config.mk`
- `mb_project.mk` → `project.mk`
- `mb_config.local.mk` → `config.local.mk`
- `mb_project.local.mk` → `project.local.mk`
- Moved auto-generated modules file to `internal/` subfolder:
- `mb_modules.mk` → `internal/modules.mk`
- Updated internal variable names for consistency:
- `mb_project_bindhub_modules_file` → `mb_project_bindhub_internal_modules_file`
- Template files renamed to match new convention (`config.tpl.mk`, `project.tpl.mk`)

### Added
- **Deprecation detection**: Projects using old bind-hub structure (pre-2.1.1) will now fail with migration instructions
- `core/deprecation.mk`: New file containing deprecation checks and error messages
- `templates/README.bind-hub.md`: README template for new bind-hub folders explaining structure

### Fixed
- Improved clarity of bind-hub folder organization (user files vs auto-generated files)

## [2.1.0] - 2025-12-10

### Added
Expand Down
26 changes: 13 additions & 13 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ make mb/help-<keyword>
```

### Debugging
Set debug flags in your environment or mb_config.mk:
Set debug flags in your environment or config.mk:
- `mb_debug=1` - Enable general debugging
- `mb_debug_modules=1` - Debug module loading
- `mb_debug_targets=1` - Debug target listing
Expand Down Expand Up @@ -106,7 +106,7 @@ Set debug flags in your environment or mb_config.mk:

**Module Loading Process**:
1. Build module database from all mod_info.mk files
2. Read `bind-hub/mb_modules.mk` for enabled modules
2. Read `bind-hub/internal/modules.mk` for enabled modules
3. For each enabled module:
- Load module's `mod_config.mk` (if exists)
- Load project override: `bind-hub/configs/<module>_config.mk` (if exists)
Expand All @@ -124,15 +124,15 @@ Set debug flags in your environment or mb_config.mk:
### Project Configuration

**Configuration Hierarchy** (bind-hub folder):
1. `mb_config.mk` - Project configuration (committed)
2. `mb_config.local.mk` - Local overrides (gitignored)
3. `mb_project.mk` - Project-specific targets (committed)
4. `mb_project.local.mk` - Local target overrides (gitignored)
5. `mb_modules.mk` - Auto-generated list of enabled modules (DO NOT EDIT)
6. `configs/` - Module configuration overrides
7. `modules/` - Project-specific custom modules

**Important Variables** (in mb_config.mk):
1. `config.mk` - Project configuration (committed)
2. `config.local.mk` - Local overrides (gitignored)
3. `project.mk` - Project-specific targets (committed)
4. `project.local.mk` - Local target overrides (gitignored)
5. `internal/modules.mk` - Auto-generated list of enabled modules (DO NOT EDIT)
6. `configs/` - Module configuration overrides (created on-demand)
7. `modules/` - Project-specific custom modules (created on-demand)

**Important Variables** (in config.mk):
- `mb_project_path` - Absolute path to project root (REQUIRED)
- `mb_makebind_path` - Path to MakeBind installation
- `mb_default_target` - Default target (default: mb/targets-list)
Expand All @@ -143,11 +143,11 @@ Set debug flags in your environment or mb_config.mk:

Understanding the load order is critical:
1. `Makefile` includes `main.mk`
2. `main.mk` loads `mb_config.mk` and `mb_config.local.mk`
2. `main.mk` loads `config.mk` and `config.local.mk`
3. Core utilities loaded (util.mk, functions.mk)
4. Module database built (`mb_modules_build_db`)
5. Modules loaded (`mb_load_modules`)
6. Project targets loaded (`mb_project.mk`, `mb_project.local.mk`)
6. Project targets loaded (`project.mk`, `project.local.mk`)

This order ensures:
- Module targets can be overridden by project targets
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ powershell -Command "Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/A
- This command downloads the Makefile template and creates a Makefile in your current directory.
- `make` will then automatically execute and check for the existence of the `MakeBind` folder in the path specified by `mb_mb_default_path` (default is `../MakeBind`, meaning it will search in the parent directory).
- If the `MakeBind` folder does not exist, the latest release will be downloaded.
- The folder `bind-hub` will be created in the current directory, which contains important configuration files, which are the `mb_config.mk` and `mb_project.mk` and a few other files and folders.
- The folder `bind-hub` will be created in the current directory, which contains important configuration files, including `config.mk` and `project.mk`, plus an `internal/` subfolder for auto-generated files.
- You will then see a list of available targets, and you can start using MakeBind.

NOTE: if you want better control of where MakeBind is installed, you can either manually clone the repo or download from Github.
Expand All @@ -72,9 +72,9 @@ MakeBind is designed to be simple to use and easy to configure. Here are some co
Run a specific target.

## Configuration
As mentioned, when you run MakeBind for the first time, it will create the `mb_config.mk` and `mb_project.mk` files in the folder `bind-hub`. These files are used to configure MakeBind for your project.
- In `mb_config.mk`, you can set all configuration variables that are used by MakeBind modules or your own modules. You can create a local version named `mb_config.local.mk` to override the default values (do not commit this file to your repository).
- In `mb_project.mk`, you can add all targets that are specific to your project. You can create a local version named `mb_project.local.mk` to override the default values (do not commit this file to your repository).
As mentioned, when you run MakeBind for the first time, it will create the `config.mk` and `project.mk` files in the folder `bind-hub`. These files are used to configure MakeBind for your project.
- In `config.mk`, you can set all configuration variables that are used by MakeBind modules or your own modules. You can create a local version named `config.local.mk` to override the default values (do not commit this file to your repository).
- In `project.mk`, you can add all targets that are specific to your project. You can create a local version named `project.local.mk` to override the default values (do not commit this file to your repository).
- In the `bind-hub` folder, you can add all your custom modules in `bind-hub/modules`.

## Upgrading Make
Expand Down
58 changes: 58 additions & 0 deletions core/deprecation.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#####################################################################################
# Project: MakeBind
# File: core/deprecation.mk
# Description: Deprecation checks for MakeBind
# Author: AntonioCS
# License: MIT License
#####################################################################################
ifndef __MB_CORE_DEPRECATION_MK__
__MB_CORE_DEPRECATION_MK__ := 1

## Check for deprecated bind-hub structure (pre-2.1.1)
## Returns $(mb_true) if old structure detected, $(mb_false) otherwise
define mb_check_deprecated_bindhub
$(strip
$(if $(wildcard $(mb_project_bindhub_path)/mb_config.mk),$(mb_true),
$(if $(wildcard $(mb_project_bindhub_path)/mb_project.mk),$(mb_true),
$(if $(wildcard $(mb_project_bindhub_path)/mb_modules.mk),$(mb_true),
$(mb_false))))
)
endef

## Error message for deprecated bind-hub structure
define mb_deprecated_bindhub_error_msg

================================================================================
ERROR: Deprecated bind-hub structure detected (MakeBind 2.1.1+)
================================================================================

Your project uses the old bind-hub file naming convention.
Please migrate to the new structure:

1. Rename files:
mv bind-hub/mb_config.mk bind-hub/config.mk
mv bind-hub/mb_project.mk bind-hub/project.mk

2. If you have local overrides, rename them too:
mv bind-hub/mb_config.local.mk bind-hub/config.local.mk
mv bind-hub/mb_project.local.mk bind-hub/project.local.mk

3. Move modules file to internal folder:
mkdir -p bind-hub/internal
mv bind-hub/mb_modules.mk bind-hub/internal/modules.mk

After migration, your bind-hub/ folder should look like:
bind-hub/
├── config.mk
├── config.local.mk (optional)
├── project.mk
├── project.local.mk (optional)
└── internal/
└── modules.mk

Note: configs/ and modules/ folders are created automatically when needed.
================================================================================

endef

endif # __MB_CORE_DEPRECATION_MK__
26 changes: 16 additions & 10 deletions core/init_project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,35 @@ mb_debug_init ?= $(mb_debug)
##NOTE: there are still error when calling mb_printf in some situations
### $(call mb_printf_info,Creating missing files)
ifeq ($(OS),Windows_NT)
## TODO: Remove Windows support - tracked in Trello ticket "Remove Windows support from MakeBind"
## NOTE: Windows paths need to be escaped even when SHELL is set to pwsh
mb_init_create_folder_cmd := $(call mb_powershell,mkdir $(subst /,\\,$(mb_project_bindhub_path)))
mb_init_cp_config_mk_cmd := $(call mb_powershell,copy $(subst /,\\,$(mb_makebind_templates_path)\\mb_config.tpl.mk) $(subst /,\\,$(mb_project_mb_config_file)))
mb_init_cp_project_mk_cmd := $(call mb_powershell,copy $(subst /,\\,$(mb_makebind_templates_path)\\mb_project.tpl.mk) $(subst /,\\,$(mb_project_mb_project_mk_file)))
mb_init_cp_config_mk_cmd := $(call mb_powershell,copy $(subst /,\\,$(mb_makebind_templates_path)\\config.tpl.mk) $(subst /,\\,$(mb_project_config_file)))
mb_init_cp_project_mk_cmd := $(call mb_powershell,copy $(subst /,\\,$(mb_makebind_templates_path)\\project.tpl.mk) $(subst /,\\,$(mb_project_file)))

else
mb_init_create_folder_cmd := mkdir -p $(mb_project_bindhub_path)
mb_init_create_configs_folder_cmd := mkdir -p $(mb_project_bindhub_configs);
mb_init_cp_config_mk_cmd := cp $(mb_makebind_templates_path)/mb_config.tpl.mk $(mb_project_mb_config_file);
mb_init_cp_project_mk_cmd := cp $(mb_makebind_templates_path)/mb_project.tpl.mk $(mb_project_mb_project_mk_file);
mb_init_create_internal_folder_cmd := mkdir -p $(mb_project_bindhub_internal_path);
mb_init_cp_config_mk_cmd := cp $(mb_makebind_templates_path)/config.tpl.mk $(mb_project_config_file);
mb_init_cp_project_mk_cmd := cp $(mb_makebind_templates_path)/project.tpl.mk $(mb_project_file);
mb_init_cp_readme_cmd := cp $(mb_makebind_templates_path)/README.bind-hub.md $(mb_project_bindhub_path)/README.md;
endif

$(if $(call mb_not_exists,$(mb_project_bindhub_path)),\
$(call mb_debug_print,Creating bindhub path: $(mb_project_bindhub_path),$(mb_debug_init))\
$(shell $(mb_init_create_folder_cmd) && $(mb_init_create_configs_folder_cmd))\
$(shell $(mb_init_create_folder_cmd) && $(mb_init_create_internal_folder_cmd))\
)
$(if $(call mb_not_exists,$(mb_project_mb_project_mk_file)),\
$(call mb_debug_print, Copying mb_project.tpl.mk to $(mb_project_mb_project_mk_file),$(mb_debug_init))\
$(if $(call mb_not_exists,$(mb_project_file)),\
$(call mb_debug_print, Copying project.tpl.mk to $(mb_project_file),$(mb_debug_init))\
$(shell $(mb_init_cp_project_mk_cmd))\
)
$(if $(call mb_not_exists,$(mb_project_mb_config_file)),\
$(call mb_debug_print, Copying mb_config.tpl.mk to $(mb_project_mb_config_file),$(mb_debug_init))\
$(if $(call mb_not_exists,$(mb_project_config_file)),\
$(call mb_debug_print, Copying config.tpl.mk to $(mb_project_config_file),$(mb_debug_init))\
$(shell $(mb_init_cp_config_mk_cmd))\
)
$(if $(call mb_not_exists,$(mb_project_bindhub_path)/README.md),\
$(call mb_debug_print, Copying README.bind-hub.md to $(mb_project_bindhub_path)/README.md,$(mb_debug_init))\
$(shell $(mb_init_cp_readme_cmd))\
)

endif # __MB_CORE_INIT_PROJECT_MK__
13 changes: 7 additions & 6 deletions core/modules_manager.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ mb_modules_db_all_modules :=# Empty
mb_modules_mod_info_file_name := mod_info.mk
mb_modules_mod_config_file_name := mod_config.mk

### NOTE: Use mb_project_bindhub_modules_file for project modules file
### NOTE: Use mb_project_bindhub_internal_modules_file for project modules file

define mb_modules_header
#####################################################################################
# Project: MakeBind
# File: mb_modules.mk
# File: internal/modules.mk
# Description: Module structure for MakeBind
# Author: AntonioCS
# License: MIT License
Expand Down Expand Up @@ -60,8 +60,9 @@ endef
## NOTE: This must be called after the creation of the bind-hub folder
## This was causing problems on fresh projects that had no bind folder
define mb_modules_build_mod_file
$(file > $(mb_project_bindhub_modules_file),$(mb_modules_header))
$(file >> $(mb_project_bindhub_modules_file),mb_project_modules_loaded :=$(if $(value mb_project_modules_loaded), $(mb_project_modules_loaded),## No modules added))
$(if $(wildcard $(mb_project_bindhub_internal_path)),,$(error Internal folder missing: $(mb_project_bindhub_internal_path). Run project initialization first.))
$(file > $(mb_project_bindhub_internal_modules_file),$(mb_modules_header))
$(file >> $(mb_project_bindhub_internal_modules_file),mb_project_modules_loaded :=$(if $(value mb_project_modules_loaded), $(mb_project_modules_loaded),## No modules added))
endef


Expand All @@ -79,7 +80,7 @@ endef
## Build the database of modules
define mb_modules_build_db
$(strip
$(if $(wildcard $(mb_project_bindhub_modules_file)),,
$(if $(wildcard $(mb_project_bindhub_internal_modules_file)),,
$(call mb_modules_build_mod_file)
)
$(eval $0_all_modules_info_path := $(call mb_modules_find_info,$(mb_modules_path)/))
Expand Down Expand Up @@ -127,7 +128,7 @@ define mb_load_modules
$(strip
$(if $(value mb_project_modules), $(call mb_printf_warn, mb_project_modules is now deprecated$(mb_comma) please remove it and use mb/modules/add to add your modules))
$(call mb_debug_print, Starting modules loading,$(mb_debug_modules))
$(eval -include $(mb_project_bindhub_modules_file))
$(eval -include $(mb_project_bindhub_internal_modules_file))
$(foreach $0_mod,$(mb_project_modules_loaded),
$(call mb_debug_print, Loading module: $($0_mod),$(mb_debug_modules))
$(if $(call mb_module_is_valid_mod,$($0_mod)),
Expand Down
2 changes: 1 addition & 1 deletion core/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif # Windows_NT
## 0_other_files_in_bind_hub_folder is important in case the user wants to include additional files
define mb_targets_list_get_files
$(strip
$(eval $0_files_project := $(filter $(mb_project_mb_project_mk_file) $(mb_project_mb_project_mk_local_file),$(MAKEFILE_LIST)))
$(eval $0_files_project := $(filter $(mb_project_file) $(mb_project_local_file),$(MAKEFILE_LIST)))
$(eval $0_files_mb_modules := $(filter-out %/mod_info.mk %/mod_config.mk,$(filter $(mb_modules_path)/%,$(MAKEFILE_LIST))))
$(eval $0_files_in_bindhub_modules_folder := $(filter $(mb_project_bindhub_modules_path)/%,$(MAKEFILE_LIST)))
$(eval $0_files_project_modules := $(filter-out %/mod_info.mk %/mod_config.mk,$($0_files_in_bindhub_modules_folder)))
Expand Down
22 changes: 13 additions & 9 deletions main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ include $(mb_core_path)/util.mk
include $(mb_core_path)/functions.mk
include $(mb_core_path)/modules_manager.mk
include $(mb_core_path)/targets.mk
include $(mb_core_path)/deprecation.mk

## Check for deprecated bind-hub structure (pre-2.1.1)
$(if $(call mb_check_deprecated_bindhub),$(error $(mb_deprecated_bindhub_error_msg)))


#https://www.gnu.org/software/make/manual/html_node/Options-Summary.html
Expand Down Expand Up @@ -88,14 +92,14 @@ $(call mb_debug_print, mb_modules_path: $(mb_modules_path))
$(call mb_debug_print, mb_project_makefile: $(mb_project_makefile))
$(call mb_debug_print, mb_project_bindhub_path: $(mb_project_bindhub_path))
$(call mb_debug_print, mb_project_bindhub_modules_path: $(mb_project_bindhub_modules_path))
$(call mb_debug_print, mb_project_mb_config_file: $(mb_project_mb_config_file))
$(call mb_debug_print, mb_project_mb_config_local_file: $(mb_project_mb_config_local_file))
$(call mb_debug_print, mb_project_mb_project_mk_file: $(mb_project_mb_project_mk_file))
$(call mb_debug_print, mb_project_mb_project_mk_local_file: $(mb_project_mb_project_mk_local_file))
$(call mb_debug_print, mb_project_config_file: $(mb_project_config_file))
$(call mb_debug_print, mb_project_config_local_file: $(mb_project_config_local_file))
$(call mb_debug_print, mb_project_file: $(mb_project_file))
$(call mb_debug_print, mb_project_local_file: $(mb_project_local_file))
$(call mb_debug_print, mb_default_shell_not_windows: $(mb_default_shell_not_windows))


ifeq ($(and $(mb_check_missing_project_files),$(or $(call mb_not_exists,$(mb_project_mb_config_file)),$(call mb_not_exists,$(mb_project_mb_project_mk_file)))),$(mb_true))
ifeq ($(and $(mb_check_missing_project_files),$(or $(call mb_not_exists,$(mb_project_config_file)),$(call mb_not_exists,$(mb_project_file)))),$(mb_true))
ifeq ($(mb_auto_include_init_project_if_config_missing),$(mb_on))
$(call mb_debug_print, Including init_project since files are missing)
include $(mb_core_path)/init_project.mk
Expand All @@ -106,8 +110,8 @@ endif

## Include the project specific configuration and target files
$(call mb_debug_print, Including project config files)
include $(mb_project_mb_config_file)
-include $(mb_project_mb_config_local_file)
include $(mb_project_config_file)
-include $(mb_project_config_local_file)

$(call mb_modules_build_db)
$(call mb_load_modules)
Expand All @@ -119,6 +123,6 @@ $(call mb_load_modules)
## Then the target that the user has created in either mb_project.mk or the modules

$(call mb_debug_print, Including project target files)
include $(mb_project_mb_project_mk_file)
-include $(mb_project_mb_project_mk_local_file)
include $(mb_project_file)
-include $(mb_project_local_file)

12 changes: 7 additions & 5 deletions mb_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ mb_core_util_bin_path := $(mb_core_util_path)/bin
mb_modules_path := $(abspath $(mb_makebind_path)/modules)
mb_project_makefile := $(mb_project_path)/Makefile
mb_project_bindhub_path := $(mb_project_path)/bind-hub
## Internal folder for auto-generated files
mb_project_bindhub_internal_path := $(mb_project_bindhub_path)/internal
## Specific modules folder for the project
mb_project_bindhub_modules_path := $(mb_project_bindhub_path)/modules
## Configs for modules
mb_project_bindhub_configs := $(mb_project_bindhub_path)/configs
mb_project_mb_config_file := $(mb_project_bindhub_path)/mb_config.mk
mb_project_mb_config_local_file := $(mb_project_bindhub_path)/mb_config.local.mk
mb_project_mb_project_mk_file := $(mb_project_bindhub_path)/mb_project.mk
mb_project_mb_project_mk_local_file := $(mb_project_bindhub_path)/mb_project.local.mk
mb_project_bindhub_modules_file := $(mb_project_bindhub_path)/mb_modules.mk
mb_project_config_file := $(mb_project_bindhub_path)/config.mk
mb_project_config_local_file := $(mb_project_bindhub_path)/config.local.mk
mb_project_file := $(mb_project_bindhub_path)/project.mk
mb_project_local_file := $(mb_project_bindhub_path)/project.local.mk
mb_project_bindhub_internal_modules_file := $(mb_project_bindhub_internal_path)/modules.mk
mb_debug ?= $(mb_off)
# Some functions will not function properly in other shells
mb_default_shell_not_windows ?= /bin/bash
Expand Down
Loading