| 1 | ############################################################################### | 
|---|
| 2 | # makefrwd.mif :: Make Include -- Forwards GNU Make to other Make Utilities.  # | 
|---|
| 3 | ############################################################################### | 
|---|
| 4 |  | 
|---|
| 5 | # | 
|---|
| 6 | # A Linux build-environment where "make" would not work is like having | 
|---|
| 7 | # a motorbike with an empty tank, flat tires and no wrench in site. | 
|---|
| 8 | # Penguins like to "just make" using GNU Make, so let's forward it. | 
|---|
| 9 | # | 
|---|
| 10 | # This is done by defining 2 targets: 'all:' for when no targets are specified, | 
|---|
| 11 | # and '%:' to forward one or more targets. | 
|---|
| 12 | # | 
|---|
| 13 | # Because GNU Make first looks for 'GNUmakefile', which only includes this | 
|---|
| 14 | # forwarder, it will process this file before 'Makefile'. | 
|---|
| 15 | # The Make Utility that we forward to will process 'Makefile'. | 
|---|
| 16 | # | 
|---|
| 17 | # Note that GNU Make processes the '%:' target-list sequentially. | 
|---|
| 18 | # So for multiple targets specified on the cli, there is a difference | 
|---|
| 19 | # whether make (and thus this front-end) or wmake directly (using Makefile) | 
|---|
| 20 | # was used. | 
|---|
| 21 | # | 
|---|
| 22 | # With wmake the targets are all specified in the Makefile so dependencies | 
|---|
| 23 | # are resolved. With GNU Make, each target is seperately forwarded to Makefile | 
|---|
| 24 | # wmake, so no dependencies are resolved. | 
|---|
| 25 | # This means that a 'make rebuild clean' behaves exactly like that, | 
|---|
| 26 | # removing all just built targets, because the 'clean' is performed last. | 
|---|
| 27 | # A 'wmake rebuild clean' will not run the last 'clean' because 'rebuild' | 
|---|
| 28 | # runs it before doing the build, so 'clean' is considered up-to-date. | 
|---|
| 29 | # | 
|---|
| 30 |  | 
|---|
| 31 | # | 
|---|
| 32 | # The Make Utility we want to forward to. | 
|---|
| 33 | # | 
|---|
| 34 | OTHER_MAKE=wmake | 
|---|
| 35 |  | 
|---|
| 36 | # | 
|---|
| 37 | # Braces need to be escaped on Linux. | 
|---|
| 38 | # | 
|---|
| 39 | ifeq "$(SHELL)"  "/bin/sh" | 
|---|
| 40 | LB  = \( | 
|---|
| 41 | RB  = \) | 
|---|
| 42 | LQ  = \' | 
|---|
| 43 | RQ  = \' | 
|---|
| 44 | LDQ = \" | 
|---|
| 45 | RDQ = \" | 
|---|
| 46 | else | 
|---|
| 47 | LB  = ( | 
|---|
| 48 | RB  = ) | 
|---|
| 49 | LQ  = ' | 
|---|
| 50 | RQ  = ' | 
|---|
| 51 | LDQ = " | 
|---|
| 52 | RDQ = " | 
|---|
| 53 | endif | 
|---|
| 54 |  | 
|---|
| 55 | # | 
|---|
| 56 | # Show this message to indicate this front-end is active. | 
|---|
| 57 | # | 
|---|
| 58 | HEADER=GNU Make front-end invoked for $(LQ)$(OTHER_MAKE)$(RQ) | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | # | 
|---|
| 63 | # Forward to the other Make Utility. | 
|---|
| 64 | # Note that the local target 'default:' is not passed so the | 
|---|
| 65 | # first target in Makefile is used. | 
|---|
| 66 | # | 
|---|
| 67 | default: | 
|---|
| 68 | @echo $(HEADER) | 
|---|
| 69 | @$(OTHER_MAKE) | 
|---|
| 70 |  | 
|---|
| 71 | # | 
|---|
| 72 | # Forward any target to the other Make Utility. | 
|---|
| 73 | # Note that this rule gets processed in sequence for every target | 
|---|
| 74 | # specified on the cli. | 
|---|
| 75 | # | 
|---|
| 76 | %: | 
|---|
| 77 | @echo $(HEADER) with target: $(LQ)$@$(RQ) | 
|---|
| 78 | @$(OTHER_MAKE) -h $@ | 
|---|