V
V
Vlad Zaitsev2017-01-07 04:34:11
linux
Vlad Zaitsev, 2017-01-07 04:34:11

How to make different targets in one makefile?

I have a makefile that looks like this:

all:  ud-button ud-rpl_root
PROJECT_SOURCEFILES += ud-dag_node.c 
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI = ../..
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

If it's important, what the makefile.include looks like can be seen here: https://github.com/contiki-os/contiki/blob/master/...
I need to rewrite it in such a way that its execution is similar to two different makefiles :
all: ud-button
PROJECT_SOURCEFILES += ud-dag_node.c 
DEFINES+=PROJECT_CONF_H=\"ud-button.project-conf.h\"
CONTIKI = ../..
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

all: ud-rpl_root
PROJECT_SOURCEFILES += 
DEFINES+=PROJECT_CONF_H=\"ud-rpl_root.project-conf.h\"
CONTIKI = ../..
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

Those. different DEFINES and PROJECT_SOURCEFILES for each project. Tell me how to do it?
UPD: I could only make it so that, depending on the variable, different project-conf.h were connected. Added to Makefile:
ifndef VARIANT
  ${info Not VARIANT defines! Set default: normal}
  VARIANT = normal
endif
PROJECTDIRS += $(VARIANT)

added #include "target-conf.h" to project-conf.h , and placed different target-conf.h in "normal" and "leaf" folders . Now, if you do " make -j5 TARGET=unwired BOARD=udboards/cc26xx VARIANT=leaf ", then the generic part will be taken from project-conf.h and the variable part from leaf/target-conf.h . The problem is that with this approach, both projects are built with the same config ( ud-button and ud-rpl_root ), and I need the defines for ud-button to be taken from project-conf.h + leaf/target-conf.h ,

project-conf.h + standard /target-conf.h

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2017-01-07
@vvzvlad

Well, do this:

ud-button:
PROJECT_SOURCEFILES += ud-dag_node.c 
DEFINES+=PROJECT_CONF_H=\"ud-button.project-conf.h\"
CONTIKI = ../..
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

ud-rpl_root:
PROJECT_SOURCEFILES += 
DEFINES+=PROJECT_CONF_H=\"ud-rpl_root.project-conf.h\"
CONTIKI = ../..
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

make run accordingly:
make ud-rpl_root
or
make ud-button
And for the all target, you can write this:
all: ud-button ud-rpl_root

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question