abcminiuser / lufa

LUFA - the Lightweight USB Framework for AVRs.
http://www.lufa-lib.org
1.03k stars 321 forks source link

Configuration variables cannot be set/overridden by target specific variable values #175

Open Virtual-Java opened 3 years ago

Virtual-Java commented 3 years ago

It is not possible to set/override LUFA configuration variables by target specific variable values. e.g. the following target specific expression in makefile will be ignored. Instead of the target specific value the globally declared value will be taken when calling "make atmega8u2".

makefile_select_mcu _#global (default value): MCU = atmega16u2

target specific:

atmega8u2: MCU = atmega8u2_ https://github.com/Virtual-Java/HoodLoader2/blob/automake/avr/bootloaders/HoodLoader2/makefile_select_mcu

Besides the LUFA configuration variable "TARGET" is a rather unfortunate choice for the target file, because it is in conflict with the Target to compile for. Is it possible to change the name of this variable in my makefile, so that the name can be used for different purposes? Maybe the term "FILENAME" is a better description. https://github.com/davr/lufa-lib/commit/04ad8bab464f85fb2b815f128b98fd904a6f47f0

abcminiuser commented 3 years ago

The TARGET variable likely is an unfortunate naming choice. It's used throughout the DMBS makefile build system so changing it both there and here is possible, but may cause issues for existing DMBS users (if there actually are any!).

The DMBS project uses TARGET to specify what the output artifacts will be named (the generated HEX, EEP and other files) and I usually also assume in the LUFA project makefiles that TARGET is also the name of the main source file. You're free to rename the main sources if needed however and just use the TARGET variable to name the output binaries; just change the $(TARGET).c in SRC to the actual name of your main source file.

Make supports default variable values, so you can use VARIABLE ?= default_value to set a default variable value if it is not already set.