# Debugging package Makefile

**URL:** <https://forum.openwrt.org/t/debugging-package-makefile/13764>\
**Category:** For Developers\
**Created:** [April 23, 2018, 12:01am UTC](https://forum.openwrt.org/t/debugging-package-makefile/13764 "2018-04-23T00:01:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://forum.openwrt.org/letter_avatar/jeff/32/5_5575768a8748004e209b776fc1b2916d.png) [@jeff](https://forum.openwrt.org/u/jeff)\
**Post date:** [April 23, 2018, 12:01am UTC](https://forum.openwrt.org/t/debugging-package-makefile/13764/1 "2018-04-23T00:01:40Z")

</div>

I'm trying to get what would ordinarily be a straightforward `make` recipe into a package Makefile. It's "just" some shell scripting that needs access to some `make` variables. No download, extract, patch, configure, compile, just run the `bash` commands with access to the `make` variables.

I am ~~struggling with quoting as well as~~ trying to figure out why `make V=s package/my-package/compile` is apparently executing `Package/my-package/install`

`make -p` isn't showing the rules/recipes for `my-package`

Is there a straightforward way to get a "dump" of the resultant rules/recipes around a package within the OpenWRT build system?

Also, any better references than [Packaging guidelines](https://forum.openwrt.org/t/packaging-guidelines/65/2) and [https://openwrt.org/docs/guide-developer/packages](https://openwrt.org/docs/guide-developer/packages) how the magic works, especially as to how Build/\<step\> and Package/my-package/\<step\> interact with each other and the targets package/my-package/\<step\> ?

---

<div class="post-metadata">

**Author:** ![shm0](https://forum.openwrt.org/letter_avatar/shm0/32/5_5575768a8748004e209b776fc1b2916d.png) [@shm0](https://forum.openwrt.org/u/shm0)\
**Post date:** [April 23, 2018, 2:07am UTC](https://forum.openwrt.org/t/debugging-package-makefile/13764/2 "2018-04-23T02:07:04Z")

</div>

I think you have to override each "step" (download, extract, configure, compile, etc).

For example:

```
....
define Build/my-package/configure
endef

define Build/my-package/compile
endef

define Build/my-package/install
endef
......

```

Maybe there is a better way.  
As you said, the documentation could need some improvements.  
I would also like to see better documentation about procd.

---

<div class="post-metadata">

**Author:** ![jow](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jow/32/13_2.png) [@jow](https://forum.openwrt.org/u/jow)\
**Post date:** [April 23, 2018, 5:48am UTC](https://forum.openwrt.org/t/debugging-package-makefile/13764/3 "2018-04-23T05:48:55Z")

</div>

> [@jeff](#):
>
> Is there a straightforward way to get a “dump” of the resultant rules/recipes around a package within the OpenWRT build system?

I usually replace the `$(eval $(call BuildPackage,...))` with `$(error $(call BuildPackage,...))` - this will dump the entire dynamically generated ruleset to stderr.

> [@jeff](#):
>
> I am struggling with quoting as well as trying to figure out why make V=s package/my-package/compile is apparently executing Package/my-package/install

For all practical purposes, there is no distinction between the `make package/.../compile` and `make package/.../install` targets. The `compile:` goal depends on `$(STAGING_DIR_ROOT)/stamp/.$(1)_installed` which (through another stampfile) depends on `$(STAMP_BUILT)` and executes the `package/.../install` target. See `include/package-ipkg.mk` for reference.

The `install:` target is a mere alias of `compile:`, see `include/package.mk` for reference.

> [@jeff](#):
>
> especially as to how Build/\<step\> and Package/my-package/\<step\> interact with each other and the targets package/my-package/\<step\> ?

- `package/.../clean` =\> `Build/UninstallDev`, `Build/Clean`
- `package/.../prepare` =\> `Hooks/Prepare/Pre`, `Build/Prepare`, `Hooks/Prepare/Post`
- `package/.../configure` =\> `package/.../prepare`, `Hooks/Configure/Pre`, `Build/Configure`, `Hooks/Configure/Post`
- `package/.../compile` =\> `package/.../configure`, `Hooks/Compile/Pre`, `Build/Compile`, `Hooks/Compile/Post`, `Build/Install`, `Hooks/Install/Post`, `Hooks/InstallDev/Pre`, `Build/InstallDev`, `Hooks/InstallDev/Post`, `Package/$(1)/install`, `Package/$(1)/install_lib`
- `package/.../install` =\> `package/.../compile`
