[U-Boot] why is the compilation of cmd_pcmcia.c hardcoded?

i'm curious as to why common/Makefile hardcodes the compilation of cmd_pcmcia.c thusly:
COBJS-y += cmd_pcmcia.o
since i'm interested in building for a beagleboard, i have no interest in PCMCIA support, yet that source file will be compiled for me, even though the selection macro CONFIG_CMD_PCMCIA does exist and is defined by a number of other board configurations.
what seems stranger is that, even though that config macro exists, it isn't used in the Makefile but *is* tested in the source file itself to determine whether the "pinit" command will be compiled:
===== #if defined(CONFIG_CMD_PCMCIA)
extern int pcmcia_on (void); extern int pcmcia_off (void);
int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ... }
U_BOOT_CMD( pinit, 2, 0, do_pinit, "PCMCIA sub-system", "on - power on PCMCIA socket\n" "pinit off - power off PCMCIA socket" );
#endif
=====
so the "pinit" command *won't* be compiled into my image, but the remainder of that file will still be compiled. if the rest of that file truly needs to be built for every board, would it not make more sense to break the pinit code into a separate file, and have the Makefile look something like:
ifdef CONFIG_CMD_PCMCIA COBJS-$(CONFIG_CMD_PCMCIA) += cmd_pcmcia.o endif
or is there something else happening there that i'm missing?
rday
p.s. based on the obvious naming convention of those files, i would have imagined a file by the name of cmd_pinit.c.
--
======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Kernel Pedantry.
Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday ========================================================================

Robert,
Robert P. J. Day wrote:
i'm curious as to why common/Makefile hardcodes the compilation of cmd_pcmcia.c thusly:
COBJS-y += cmd_pcmcia.o
since i'm interested in building for a beagleboard, i have no interest in PCMCIA support, yet that source file will be compiled for me, even though the selection macro CONFIG_CMD_PCMCIA does exist and is defined by a number of other board configurations.
what seems stranger is that, even though that config macro exists, it isn't used in the Makefile but *is* tested in the source file itself to determine whether the "pinit" command will be compiled:
===== #if defined(CONFIG_CMD_PCMCIA)
If you look at the source code tree from a couple of years ago you'll see that the pattern you've discovered used to be the norm. Over time, people have been removing the source file wrappers and moving conditionality to the Makefiles. It's a work in progress, and help fixing things up is always appreciated.
regards, Ben

On Wednesday 18 November 2009 03:17:21 Robert P. J. Day wrote:
i'm curious as to why common/Makefile hardcodes the compilation of cmd_pcmcia.c thusly:
COBJS-y += cmd_pcmcia.o
since i'm interested in building for a beagleboard, i have no interest in PCMCIA support, yet that source file will be compiled for me, even though the selection macro CONFIG_CMD_PCMCIA does exist and is defined by a number of other board configurations.
what seems stranger is that, even though that config macro exists, it isn't used in the Makefile but *is* tested in the source file itself to determine whether the "pinit" command will be compiled:
you didnt read enough of the code. specifically, you missed the fact that other config options can compile code in this file even if CONFIG_CMD_PCMCIA is disabled.
if you feel like re-architecting and splitting the code to take this into consideration, that's one thing. but it isnt a simple 'move the config option into the makefile' fix. -mike

Dear "Robert P. J. Day",
In message alpine.LFD.2.00.0911180307560.31136@localhost you wrote:
i'm curious as to why common/Makefile hardcodes the compilation of cmd_pcmcia.c thusly:
Historic / hysteric reasons?
Please feel free to submit cleanup patches!
Best regards,
Wolfgang Denk
participants (4)
-
Ben Warren
-
Mike Frysinger
-
Robert P. J. Day
-
Wolfgang Denk