[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about a Makefile example

From: ali hagigat
Subject: Question about a Makefile example
Date: Mon, 28 Feb 2011 15:45:11 +0330

If I have the following variable:
objs:= build/mainboard/asus/mew-am/static.o
build/mainboard/asus/mew-am/irq_tables.o build/lib/clog2.o
build/lib/uart8250.o build/lib/memset.o build/lib/memcpy.o
build/lib/memcmp.o build/lib/memmove.o build/lib/malloc.o
build/lib/delay.o build/lib/fallback_boot.o
build/lib/compute_ip_checksum.o build/lib/version.o build/lib/cbfs.o

and a Makefile as follows:

export obj ?= build
define create_cc_template
de$(EMPTY)fine $(1)_$(2)_template
$(obj)/$$(1)%$(3).o: src/$$(1)%.$(2) $(obj)/config.h
        @printf "    CC         $$$$(subst $$$$(obj)/,,$$$$(@))\n"
        $(CC) $(4) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$<

$(eval $(call create_cc_template,objs,c))
$(eval $(call create_cc_template,objs,S,,-DASSEMBLY))

usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call
$(1)_$(2)_template,$(subst $(obj)/,,$(d)))))

$(eval $(call usetemplate,objs,c))
$(eval $(call usetemplate,objs,S))
What rules are made by this Makefile? For example I think two rules
are made for "build/lib/malloc.o". One is:
build/lib/malloc.o :  src/lib/malloc.c  build/config.h
And another one is:
build/lib/malloc.o :  src/lib/malloc.S build/config.h
But logically there should be only one rule, please correct me if I am
wrong. When make sees a .o file, it does not know this .o must be
built from .c or a .S. It must look for any possible .c or .S (like
src/lib/malloc.c or src/lib/malloc.S) and then write its rule.

My another question is the following call:
usetemplate=$(foreach d,$(sort $(dir $($(1)))),$(eval $(call
$(1)_$(2)_template,$(subst $(obj)/,,$(d)))))

Where $(subst $(obj)/,,$(d)) is used? For example if it is the
argument of objs_c_template, where it will used inside it?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]