Changeset 52

Show
Ignore:
Timestamp:
12/09/98 00:51:29 (14 years ago)
Author:
frodo
Message:

Another Makefile simplification

Object files for executables (as opposed to modules) will now use the .ro
extension; their dependency file is a .rd file. Currently, this affects only
the i2c/eeprom/eeprom program. but in the future, there will be more
executables generated.

Location:
lm-sensors/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/Makefile

    r23 r52  
    88# 
    99#  This program is distributed in the hope that it will be useful, 
    10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10        #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1111#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212#  GNU General Public License for more details. 
     
    138138        $(CC) -M -MG $(CFLAGS) $< | \ 
    139139        sed -e 's@^\(.*\)\.o:@$*.d $*.o Makefile '`dirname $*.d`/Module.mk':@' > $@ 
    140          
     140 
    141141 
    142142# This is tricky, but it works like a charm. It needs lots of utilities 
     
    160160        echo -n 'Version: '; \ 
    161161        echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h 
     162 
     163# .ro files are used for programs (as opposed to modules) 
     164%.ro: %.c 
     165        $(CC) $(EXCFLAGS) -c $< -o $@ 
     166 
     167%: %.ro 
     168        $(CC) $(EXLDFLAGS) -o $@ $^ 
     169 
     170%.rd: %.c 
     171        $(CC) -M -MG $(CFLAGS) $< | \ 
     172        sed -e 's@^\(.*\)\.o:@$*.rd $*.ro Makefile '`dirname $*.rd`/Module.mk':@' > $@ 
     173 
  • lm-sensors/trunk/doc/makefiles

    r19 r52  
    5151    only output more information, and never make the code mis-behave. 
    5252 
     53Several files are generated by Makefiles: 
     54  * .d 
     55    Dependency files for modules. Automatically generated. 
     56  * .rd 
     57    Dependency files for executables. Automatically generated. 
     58  * .ro 
     59    Object files for executables. They will be linked together to create 
     60    the executable. This extension is used to distinguish them from  
     61    modules (which end on .o). Also, using a different extensions makes 
     62    the Makefile fragments much simpler. 
     63 
    5364There are lots of comments within the main Makefile. Please read them if 
    5465you want to know more. 
  • lm-sensors/trunk/i2c/eeprom/Module.mk

    r19 r52  
    2626I2CEEPROMSOURCES := $(MODULE_DIR)/eeprom.c 
    2727 
    28 # Include all dependency files 
    29 INCLUDEFILES += $(I2CEEPROMSOURCES:.c=.d) 
     28# Include all dependency files. We use '.rd' to indicate this will create 
     29# executables. 
     30INCLUDEFILES += $(I2CEEPROMSOURCES:.c=.rd) 
    3031 
    3132all-i2c-eeprom: $(I2CEEPROMTARGETS) 
     
    3839              $(I2CEEPROMTARGETS) 
    3940clean :: clean-i2c-eeprom 
    40  
    41 # The targets 
    42 $(MODULE_DIR)/eeprom: $(MODULE_DIR)/eeprom.o 
    43  
    44  
    45 # Oops, we need to use EXCFLAGS instead of CFLAGS... And we have to deal with 
    46 # an executable. Ugly code approaching... :-) 
    47  
    48 $(I2CEEPROMSOURCES:.c=.o): 
    49         $(CC) $(EXCFLAGS) -c $(@:.o=.c) -o $@ 
    50  
    51 $(I2CEEPROMSOURCES:.c=.d): 
    52         $(CC) -M -MG $(EXCFLAGS) $(@:.d=.c) | \ 
    53         sed -e \ 
    54         's@^\(.*\)\.o:@$@ $(@:.d=.o) Makefile '`dirname $@`/Module.mk':@' > $@ 
    55