mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-07 16:01:34 +00:00
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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@52 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
2e4f147647
commit
000b95cce0
3 files changed
+28
-20
No files matched your search
@@ -7,7 +7,7 @@
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
@@ -137,7 +137,7 @@ clean::
|
||||
%.d: %.c
|
||||
$(CC) -M -MG $(CFLAGS) $< | \
|
||||
sed -e 's@^\(.*\)\.o:@$*.d $*.o Makefile '`dirname $*.d`/Module.mk':@' > $@
|
||||
|
||||
|
||||
|
||||
# This is tricky, but it works like a charm. It needs lots of utilities
|
||||
# though: cut, find, gzip, ln, tail and tar.
|
||||
@@ -159,3 +159,15 @@ version:
|
||||
echo '#define LM_DATE "'`date +'%Y%m%d'`\" > version.h
|
||||
echo -n 'Version: '; \
|
||||
echo '#define LM_VERSION "'`read VER; echo $$VER`\" >> version.h
|
||||
|
||||
# .ro files are used for programs (as opposed to modules)
|
||||
%.ro: %.c
|
||||
$(CC) $(EXCFLAGS) -c $< -o $@
|
||||
|
||||
%: %.ro
|
||||
$(CC) $(EXLDFLAGS) -o $@ $^
|
||||
|
||||
%.rd: %.c
|
||||
$(CC) -M -MG $(CFLAGS) $< | \
|
||||
sed -e 's@^\(.*\)\.o:@$*.rd $*.ro Makefile '`dirname $*.rd`/Module.mk':@' > $@
|
||||
|
||||
@@ -50,5 +50,16 @@ ones for developers:
|
||||
Set to 1 to enable any debugging code. Note that debugging code should
|
||||
only output more information, and never make the code mis-behave.
|
||||
|
||||
Several files are generated by Makefiles:
|
||||
* .d
|
||||
Dependency files for modules. Automatically generated.
|
||||
* .rd
|
||||
Dependency files for executables. Automatically generated.
|
||||
* .ro
|
||||
Object files for executables. They will be linked together to create
|
||||
the executable. This extension is used to distinguish them from
|
||||
modules (which end on .o). Also, using a different extensions makes
|
||||
the Makefile fragments much simpler.
|
||||
|
||||
There are lots of comments within the main Makefile. Please read them if
|
||||
you want to know more.
|
||||
+3
-18
@@ -25,8 +25,9 @@ MODULE_DIR := i2c/eeprom
|
||||
I2CEEPROMTARGETS := $(MODULE_DIR)/eeprom
|
||||
I2CEEPROMSOURCES := $(MODULE_DIR)/eeprom.c
|
||||
|
||||
# Include all dependency files
|
||||
INCLUDEFILES += $(I2CEEPROMSOURCES:.c=.d)
|
||||
# Include all dependency files. We use '.rd' to indicate this will create
|
||||
# executables.
|
||||
INCLUDEFILES += $(I2CEEPROMSOURCES:.c=.rd)
|
||||
|
||||
all-i2c-eeprom: $(I2CEEPROMTARGETS)
|
||||
all :: all-i2c-eeprom
|
||||
@@ -37,19 +38,3 @@ clean-i2c-eeprom:
|
||||
$(RM) $(I2CEEPROMSOURCES:.c=.d) $(I2CEEPROMSOURCES:.c=.o) \
|
||||
$(I2CEEPROMTARGETS)
|
||||
clean :: clean-i2c-eeprom
|
||||
|
||||
# The targets
|
||||
$(MODULE_DIR)/eeprom: $(MODULE_DIR)/eeprom.o
|
||||
|
||||
|
||||
# Oops, we need to use EXCFLAGS instead of CFLAGS... And we have to deal with
|
||||
# an executable. Ugly code approaching... :-)
|
||||
|
||||
$(I2CEEPROMSOURCES:.c=.o):
|
||||
$(CC) $(EXCFLAGS) -c $(@:.o=.c) -o $@
|
||||
|
||||
$(I2CEEPROMSOURCES:.c=.d):
|
||||
$(CC) -M -MG $(EXCFLAGS) $(@:.d=.c) | \
|
||||
sed -e \
|
||||
's@^\(.*\)\.o:@$@ $(@:.d=.o) Makefile '`dirname $@`/Module.mk':@' > $@
|
||||
|
||||
Reference in new issue
Block a user