help-make
[Top][All Lists]
Advanced

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

Re: different source dirs and one build dir


From: zamek42
Subject: Re: different source dirs and one build dir
Date: Mon, 11 Jul 2016 21:24:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0

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:address@hidden
Self Playing Pipe Organ Systems
http://replayorgan.eu




reply via email to

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