different source dirs and one build dir

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

different source dirs and one build dir

zamek42
Hi All,

I have a project which has more different source dirs but I want to use
only one build directory. VPATH is not usable, because there are more
files with the same name in different directories. Is there an example
how can I setup it with make?


--
thx
Zoltan (Zamek) Zidarics
programmer
email:[hidden email]
Self Playing Pipe Organ Systems
http://replayorgan.eu


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: different source dirs and one build dir

Paul Smith-20
On Mon, 2016-07-11 at 20:25 +0200, zamek42 wrote:
> I have a project which has more different source dirs but I want to
> use only one build directory. VPATH is not usable, because there are
> more files with the same name in different directories.

If you have different source files with the same name in different
source directories but you want to put all the object files into the
same build directory, how can that work?

Anyway, in general you'll have to create one pattern rule per source
directory, like this:

  build/%.o : src1/%.c
          $(COMPILE.c) -o $@ -c $<

  build/%.o : src2/%.c
          $(COMPILE.c) -o $@ -c $<

  build/%.o : src3/%.c
          $(COMPILE.c) -o $@ -c $<

However, this won't solve your "same filename" problem... you'll have to decide how you want it to work before you can make it work that way.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: different source dirs and one build dir

zamek42
Hi Paul,

Thx for your response.

On 07/11/2016 08:40 PM, Paul Smith wrote:
> On Mon, 2016-07-11 at 20:25 +0200, zamek42 wrote:
>> I have a project which has more different source dirs but I want to
>> use only one build directory. VPATH is not usable, because there are
>> more files with the same name in different directories.
> If you have different source files with the same name in different
> source directories but you want to put all the object files into the
> same build directory, how can that work?
This is an arm example from st.com which is a demo for bluetooth.
Unfortunately ST give out this without Makefile:(
There are two files with the same name: _reset_hardware.c and
_initialize_hardwer.c. I need these files from only one directory. That
is the reason why I cannot use vpath.

I have a list of sources like this:

SRC+=$(SYSTEM_DIR)/src/stm32f4-hal/stm32f4xx_hal_rcc_ex.c     \
      $(SYSTEM_DIR)/src/stm32f4-hal/stm32f4xx_hal_spi.c     \
      $(SYSTEM_DIR)/src/newlib/_cxx.cpp         \
      $(SYSTEM_DIR)/src/newlib/_exit.c        \
      $(SYSTEM_DIR)/src/newlib/_sbrk.c        \
      $(SYSTEM_DIR)/src/newlib/_startup.c     \
      $(SYSTEM_DIR)/src/newlib/_syscalls.c    \
      $(SYSTEM_DIR)/src/newlib/assert.c    \
      $(SYSTEM_DIR)/src/diag/Trace.c    \
      $(SYSTEM_DIR)/src/diag/trace_impl.c    \
      $(SYSTEM_DIR)/src/cortexm/_initialize_hardware.c    \
      $(SYSTEM_DIR)/src/cortexm/_reset_hardware.c    \
      $(SYSTEM_DIR)/src/cortexm/exception_handlers.c    \
      $(SYSTEM_DIR)/src/cmsis/system_stm32f4xx.c        \
      $(SYSTEM_DIR)/src/cmsis/vectors_stm32f4xx.c    \
      src/_initialize_hardware.c    \
      src/_write.c    \
      src/bluenrg_interface.c    \
      src/clock.c \
      src/cube_hal_f4.c    \
      src/main.c        \
      src/sensor_service.c    \
      src/stm32xx_it.c    \
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/utils/gp_timer.c
     \
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/utils/list.c
     \
$(BLUENRG_STACK_DIR)/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/utils/osal.c \
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_IFR.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_gap_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_gap_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_gatt_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_hal_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_l2cap_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_updater_aci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/controller/bluenrg_utils.c
     \
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/SimpleBlueNRG_HCI/hci/hci.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/STM32_BlueNRG/Interface/bluenrg_itf_template.c
\
$(BLUENRG_STACK_DIR)/Middlewares/ST/LowPowerManager/Src/stm32xx_lpm.c \
$(BLUENRG_STACK_DIR)/BSP/X-NUCLEO-IDB04A1/stm32_bluenrg_ble.c    \
      $(BLUENRG_STACK_DIR)/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c

> Anyway, in general you'll have to create one pattern rule per source
> directory, like this:
>
>    build/%.o : src1/%.c
>            $(COMPILE.c) -o $@ -c $<
>
>    build/%.o : src2/%.c
>            $(COMPILE.c) -o $@ -c $<
>
>    build/%.o : src3/%.c
>            $(COMPILE.c) -o $@ -c $<
>
> However, this won't solve your "same filename" problem... you'll have to decide how you want it to work before you can make it work that way.
There is another method like linux kernel does:

Every directory has a sub makefile wich can compile its files and the
main Makefile includes these sub makefiles. It seems to be good, but the
object files will be in the module subdirectory. Despite I would like to
use a different single build directory.


--
thx
Zoltan (Zamek) Zidarics
programmer
email:[hidden email]
Self Playing Pipe Organ Systems
http://replayorgan.eu


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: different source dirs and one build dir

Paul Smith-20
On Mon, 2016-07-11 at 21:24 +0200, zamek42 wrote:
> There are two files with the same name: _reset_hardware.c and 
> _initialize_hardwer.c. I need these files from only one directory.
> That is the reason why I cannot use vpath.

Well, vpath searches directories in order so if you only want one
instance of those files and they are both in the same directory, you
can just ensure that the directory you want comes first in the vpath
list, before the one you don't want.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: different source dirs and one build dir [SOLVED]

zamek42
Hi All,

On 07/11/2016 09:38 PM, Paul Smith wrote:
> On Mon, 2016-07-11 at 21:24 +0200, zamek42 wrote:
>> There are two files with the same name: _reset_hardware.c and
>> _initialize_hardwer.c. I need these files from only one directory.
>> That is the reason why I cannot use vpath.
> Well, vpath searches directories in order so if you only want one
> instance of those files and they are both in the same directory, you
> can just ensure that the directory you want comes first in the vpath
> list, before the one you don't want.
I could solve the problem.  There need all of the duplicated files,
because its functions are tagged with (weak) tag:

void
__attribute__((weak))
__initialize_hardware_early(void)

and the other is:

void
__initialize_hardware(void)

I made a list with all source files including its directory, named SRC
and I changed .c to .o in this list named OBJ.
At the compiling the object files stored into
build/<full_path>/<filename.o> file. Linker can links these object and
clean is easy because I need to remove build directory.


Thank you for the help...


--
thx
Zoltan (Zamek) Zidarics
programmer
email:[hidden email]
Self Playing Pipe Organ Systems
http://replayorgan.eu


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make