help-make
[Top][All Lists]
Advanced

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

AW: make help


From: Thomas Christian
Subject: AW: make help
Date: Wed, 18 Nov 2015 08:47:27 +0000

C_SRCS := \
        $(foreach d,$(SUBDIRS),$(wildcard $(DIR)$d/*.c))

Did it:

C_SRCS='D:/foxbms2/foxbms/src/test/stm32_ub_usb_cdc.c 
D:/foxbms2/foxbms/src/test/vcp_test.c

however, the path for the object files is wrong now, it points to 

D:/foxbms2/foxbms/src/test/stm32_ub_usb_cdc.o

Instead of

D:\foxbms2\foxbms\EclipseWorkspace\Project\Debug\src\test /stm32_ub_usb_cdc.o 

-----Ursprüngliche Nachricht-----
Von: Rakesh Sharma [mailto:address@hidden 
Gesendet: Mittwoch, 18. November 2015 09:28
An: Thomas Christian
Cc: address@hidden
Betreff: Re: make help

Guten morgen,

In that case then change the following :

C_SRCS := \
        $(patsubst %,$(DIR)%.c,$(SUBDIRS)) $(info C_SRCS='$(C_SRCS)')

to

C_SRCS := \
        $(foreach d,$(SUBDIRS),$(wildcard $d/*.c)) $(info C_SRCS='$(C_SRCS)')


Please do a reply to the messages so that they reach the address@hidden also.

-Rakesh
________________________________________
From: Thomas Christian <address@hidden>
Sent: Tuesday, November 17, 2015 11:15 PM
To: Rakesh Sharma
Subject: AW: make help

Good morning!

I tried your fixed version and it went until

C_SRCS := \
        $(patsubst %,$(DIR)%.c,$(SUBDIRS)) $(info C_SRCS='$(C_SRCS)')

which produces output like

C_SRCS='D:/foxbms2/foxbms/src/test.c 
D:/foxbms2/foxbms/src/test/usb_cdc_lolevel.c D:/foxbms2/foxbms/src/os.c ...

And finally leads to this error:

make: *** No rule to make target 'D:/foxbms2/foxbms/src/test.o', needed by 
'foxbms.elf'.  Stop.

The problem is all directories defined as subdirs should be searched for all 
*.c files, not the name of the subdir followed by .c used as filename.

 e.g.
D:/foxbms2/foxbms/src/os.c
should be
D:/foxbms2/foxbms/src/os/example1.c, D:/foxbms2/foxbms/src/os/example2.c and so 
on

I am not a native speaker so some things are hard to explain...

Thank you

Christian


-----Ursprüngliche Nachricht-----
Von: Rakesh Sharma [mailto:address@hidden
Gesendet: Dienstag, 17. November 2015 17:23
An: Thomas Christian
Cc: address@hidden
Betreff: Re: make help

I have made some fixes in the makefile , try running with this version (name: 
zxc.mk) YMMV

During debug stages , you must look at all the variables values by sprinkling 
the $(info ...) statements so that you satisfy yourself that makefile build 
programs are getting correct inputs.


________________________________________
From: Thomas Christian <address@hidden>
Sent: Tuesday, November 17, 2015 5:07 AM
To: Rakesh Sharma
Subject: AW: make help

Yes that makes sense, thought it was part of the comment..

And again next problem...it gives me following errors on invoking the build:

Building target: foxbms.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mlittle-endian 
arm-none-eabi-g++ -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -O0
arm-none-eabi-g++ -fmessage-length=0 -fsigned-char -ffunction-sections 
arm-none-eabi-g++ -fdata-sections -ffreestanding 
arm-none-eabi-g++ -fno-move-loop-invariants -Wall  -g3 -T 
arm-none-eabi-g++ "D:\foxbms2\foxbms\EclipseWorkspace/../src/STM32F429ZI
arm-none-eabi-g++ T6_FLASH.ld" -Xlinker --gc-sections 
arm-none-eabi-g++ -Wl,-Map,"foxbms.map" --specs=nano.specs -o 
arm-none-eabi-g++ "foxbms.elf" D:/foxbms2/foxbms/src/test 
arm-none-eabi-g++ src/test/usb_cdc_lolevel src/os src/os/FreeRTOS/Source 
arm-none-eabi-g++ src/os/FreeRTOS/Source/portable/MemMang
arm-none-eabi-g++ src/os/FreeRTOS/Source/portable/GCC/ARM_CM4F
arm-none-eabi-g++ src/os/FreeRTOS/Source/CMSIS_RTOS src/module/uart 
arm-none-eabi-g++ src/module/spi src/module/rcc src/module/ltc 
arm-none-eabi-g++ src/module/irq src/module/io src/module/eeprom 
arm-none-eabi-g++ src/module/dma src/module/cpu src/module/contactor 
arm-none-eabi-g++ src/module/config src/module/com src/module/can 
arm-none-eabi-g++ src/module/adc src/hal/STM32F4xx_HAL_Driver/Src 
arm-none-eabi-g++ src/general src/general/config src/engine/task 
arm-none-eabi-g++ src/engine/sysctrl src/engine/sof src/engine/soc 
arm-none-eabi-g++ src/engine/isoguard src/engine/diag 
arm-none-eabi-g++ src/engine/database src/engine/config 
arm-none-eabi-g++ src/application/task src/application/config
c:/program files (x86)/gnu tools arm embedded/4.9 
2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: 
cannot find D:/foxbms2/foxbms/src/test: Permission denied c:/program files 
(x86)/gnu tools arm embedded/4.9 
2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: 
cannot find src/test/usb_cdc_lolevel: Permission denied c:/program files 
(x86)/gnu tools arm embedded/4.9 
2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: 
cannot find src/os: Permission denied

obviously the files it's looking for aren't there..

I have posted you the current makefile content to pastebin, I think that will 
make things easier. Do I have to adjust filenames or paths for the linker as 
well?


http://pastebin.com/4QbxR932


Thanks!

Christian





The below line is the bug causing you misery!

*****
# this generates the rules for every subdirectory path $(foreach 
d,$(SUBDIRS),$(eval $(call mkRule,$(d))))
*****

It should have rather been:

# this generates the rules for every subdirectory path

$(foreach d,$(SUBDIRS),$(eval $(call mkRule,$(d))))

So that answers your very valid query about the use of mkRule.

N.B.:
   Please post my responses to the GNU site also, as then maybe Paul Smith,etc. 
might be alerted to my issue.

IOW, I'll be speaking through you !

________________________________________
From: Thomas Christian <address@hidden>
Sent: Tuesday, November 17, 2015 4:45 AM
To: Rakesh Sharma
Subject: AW: make help

Hello!

Again, thank you very much for your efforts :)

TBH I never used make before so I am a bit confused about it...

Let's say you define a function label called "mkRecipe" in this case which gets 
"called" by mkRule which is a label itself... so where does mkRule get called?

I feel kinda stupid because you already provided me with a spoonfeed solution 
and I am still unable to get it working, currently it doesn't create object 
files and therefore doesn't work :(

It's perfectly fine when you reply to this account :)

Thank you!
Christian

-----Ursprüngliche Nachricht-----
Von: Rakesh Sharma [mailto:address@hidden
Gesendet: Dienstag, 17. November 2015 12:57
An: Thomas Christian
Betreff: Re: make help

Hello ,

Of course you would get errors when you introduce the spaces once again in the 
$(SUBDIRS) variable ;-)

Now the spaces are there on purpose, i.e., to act as directory separators and 
so can no longer be ignored.
For this we have to generate a pattern rule per directory path. Towards that 
end, we can use the GNU make's macro facility to simplify our tasks, like as,


DIR :=   \
        D:/test/#

SUBDIRS :=   \
        src/test/usb_cdc_lolevel   \
        src/module/cpu#

$(info subdirs='$(SUBDIRS)')

# this is a macro holding the recipe portion of the pattern rule(Note the $ are 
all doubled up) define mkRecipe
        echo 'Building file: $$<'
        echo 'Invoking: Cross ARM C Compiler'   \
                        arm-none-eabi-gcc $$(CFLAGS) $$(INCDIRS)   \
                        -MMD -MP -MF"$$(@:%.o=%.d)" -MT"$$@" -c -o "$$@" "$$<"
        echo 'Finished building: $$<'
        echo ' '
endef

# this macro computes the rule alongwith its recipe.
define mkRule
./$1/%.o: $(DIR)$1/%.c
        @$(mkRecipe)
endef

# this generates the rules for every subdirectory path $(foreach 
d,$(SUBDIRS),$(eval $(call mkRule,$(d))))

# now you are all set to invoke those pattern rules for your object files... %.o


HTH
-Rakesh

Note:
      I don't know why all my mails to the address@hidden are bouncing, hence I 
am forced to reply to your personal mail account.
     I wrote a mail to the gnu.org helpdesk as well as Paul Smith himself, but 
even those mails bounced.
So AFAICT  iam pretty much cutoff from them. Pretty scary situation when one 
can't even be heard calling for help :-\

________________________________________
From: address@hidden <address@hidden> on behalf of Thomas Christian 
<address@hidden>
Sent: Monday, November 16, 2015 11:40 PM
To: address@hidden
Subject: AW: make help

Hello!

I followed your advice and you were right, there was a space after the first 
SUBDIRS entry. However when I add a second path to SUBDIRS variable I get the 
same error, again.

SUBDIRS := \
src/test/usb_cdc_lolevel \
src/module/cpu

$(info SUBDIRS='$(SUBDIRS)') shows:

SUBDIRS='src/test/usb_cdc_lolevel src/module/cpu'

When you use multiple paths within a variable, how do you separate them in this 
case?

Thank you for your help :)

Christian

Von: Rakesh Sharma [mailto:address@hidden
Gesendet: Dienstag, 17. November 2015 05:20
An: Thomas Christian
Betreff: Re: make help


> Hello!
>
> I am currently setting up a make file (at least I try) for building a 
> firmware image for a cortex M4 MCU.
>
> However I am struggeling at this point:
>
> DIR := \
> D:/test/
>
> SUBDIRS := \
> src/test/usb_cdc_lolevel
>
> C_SRCS := \
> $(wildcard $(DIR)src/test/usb_cdc_lolevel/*.c)
>
> OBJS := \
> $(patsubst $(DIR)src/test/usb_cdc_lolevel/%.c,
> ./src/test/usb_cdc_lolevel/%.o,
> $(C_SRCS))
>
> C_DEPS := \
> $(wildcard ./src/test/usb_cdc_lolevel/*.d)
>
> ./src/test/usb_cdc_lolevel/%.o: $(DIR)src/test/usb_cdc_lolevel/%.c
>                 @echo 'Building file: $<'
>                 @echo 'Invoking: Cross ARM C Compiler'
>                 arm-none-eabi-gcc $(CFLAGS) $(INCDIRS) -MMD -MP 
> -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<"
>                 @echo 'Finished building: $<'
>                 @echo ' '
>
> All I want to do is replacing the hardcoded string using a variable I 
> have defined before, so it looks like:
>
> C_SRCS := \
> $(wildcard $(DIR)$(SUBDIRS)/*.c)
>
> OBJS := \
> $(patsubst $(DIR)$(SUBDIRS)/%.c, ./$(SUBDIRS)/%.o, $(C_SRCS))
>
> C_DEPS := \
> $(wildcard ./$(SUBDIRS)/*.d)
>
> # Each subdirectory must supply rules for building sources it 
> contributes
> ./$(SUBDIRS)/%.o: $(DIR)$(SUBDIRS)/%.c
>                 @echo 'Building file: $<'
>                 @echo 'Invoking: Cross ARM C Compiler'
>                 arm-none-eabi-gcc $(CFLAGS) $(INCDIRS) -MMD -MP 
> -MF"$(@:%.o=%.d)" -MT"$@" -c -o "$@" "$<"
>                 @echo 'Finished building: $<'
>                 @echo ' '
>
> These changes throw me an error "*** mixed implicit and normal rules:
> deprecated syntax" on line "./$(SUBDIRS)/%.o: $(DIR)$(SUBDIRS)/%.c", 
> already googled this issue and it seems to happen to quiet some 
> people. As far as I understand the issue is the "/%" occurance. It's 
> driving me nuts because it seems I am not able to fix it on my own (I 
> have little to no experience in writing make files so far)
>
> Any help or hint would be appreciated!
>
> Thank you!
>
> Regards
> Christian
>

This error indicates that there must be spaces somewhere within the $(SUBDIRS) 
variable.

Place this code in your Makefile, to verify:
$(info SUBDIRS='$(SUBDIRS)')

You need to ensure that there are NO trailing blanks in the SUBDIRS variable 
definition line
> SUBDIRS := \
> src/test/usb_cdc_lolevel

especially after the _lolevel

To avoid running into such insidious errors, it's a good idea to terminate your 
make variables with a terminating hash, like as,

SUBDIRS := \
src/test/usb_cdc_lolevel#

HTH

-Rakesh

_______________________________________________
Help-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-make



reply via email to

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