On Tue, 2015-11-17 at 07:40 +0000, Thomas Christian wrote: > 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
This can't work, the way you've written your makefile. Consider just this statement: > > C_SRCS := \ > > $(wildcard $(DIR)$(SUBDIRS)/*.c) Now that you have multiple subdirectories in SUBDIRS, how will make expand this? It will look like this: $(wildcard D:/test/src/test/usb_cdc_lolevel src/module/cpu/*.c) which will run wildcard on two expressions: first "D:/test/src/test/usb_cdc_lolevel" which presumably exists so it will expand to just that, then "src/module/cpu/*.c" which matches nothing and returns the empty string. If you want to use multiple paths, you will need to use a loop or a function like patsubst to apply the pattern to every word in the SUBDIRS directory, like this: $(wildcard $(patsubst %,$(DIR)%/.c,$(SUBDIRS))) Similarly, the rules cannot be written with multiple paths; this: > > # Each subdirectory must supply rules for building sources it contributes > > ./$(SUBDIRS)/%.o: $(DIR)$(SUBDIRS)/%.c expands to: ./src/test/usb_cdc_lolevel src/module/cpu/%.o: D:/test/src/test/usb_cdc_lolevel src/module/cpu/%.c which is again, clearly not what you want. Unfortunately, there's no way to do a simple loop or patsubst for defining new rules. You'll either have to write them out by hand or else consider a much more advanced feature such as eval. You might read this set of posts (start with the earliest one) but it is a very advanced topic: http://make.mad-scientist.net/category/metaprogramming/ > To avoid running into such insidious errors, it's a good idea to > terminate your make variables with a terminating hash I personally just use a good programmer's text editor to edit my Makefiles: a good text editor will provide modes you can enable that will either remove all trailing whitespace automatically, or at least make it visible (with color etc.) _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make