root/lm-sensors/branches/lm-sensors-3.0.0/lib/Module.mk @ 4545

Revision 4545, 7.5 KB (checked in by khali, 7 years ago)

Add some more warning flags, and fix these warnings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#  Module.mk - Makefile for a Linux module for reading sensor data.
2#  Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
3#
4#  This program is free software; you can redistribute it and/or modify
5#  it under the terms of the GNU General Public License as published by
6#  the Free Software Foundation; either version 2 of the License, or
7#  (at your option) any later version.
8#
9#  This program is distributed in the hope that it will be useful,
10#  but WITHOUT ANY WARRANTY; without even the implied warranty of
11#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12#  GNU General Public License for more details.
13#
14#  You should have received a copy of the GNU General Public License
15#  along with this program; if not, write to the Free Software
16#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18# Note that MODULE_DIR (the directory in which this file resides) is a
19# 'simply expanded variable'. That means that its value is substituted
20# verbatim in the rules, until it is redefined.
21MODULE_DIR := lib
22LIB_DIR := $(MODULE_DIR)
23
24# The manual dirs and files
25LIBMAN3DIR := $(MANDIR)/man3
26LIBMAN3FILES := $(MODULE_DIR)/libsensors.3
27LIBMAN5DIR := $(MANDIR)/man5
28LIBMAN5FILES := $(MODULE_DIR)/sensors.conf.5
29
30# The main and minor version of the library
31# The library soname (major number) must be changed if and only if the interface is
32# changed in a backward incompatible way.  The interface is defined by
33# the public header files - in this case they are error.h and sensors.h.
34LIBMAINVER := 4
35LIBMINORVER := 0.0
36LIBVER := $(LIBMAINVER).$(LIBMINORVER)
37
38# The static lib name, the shared lib name, and the internal ('so') name of
39# the shared lib.
40LIBSHBASENAME := libsensors.so
41LIBSHLIBNAME := libsensors.so.$(LIBVER)
42LIBSTLIBNAME := libsensors.a
43LIBSHSONAME := libsensors.so.$(LIBMAINVER)
44
45LIBTARGETS := $(MODULE_DIR)/$(LIBSTLIBNAME) $(MODULE_DIR)/$(LIBSHLIBNAME) \
46              $(MODULE_DIR)/$(LIBSHSONAME) $(MODULE_DIR)/$(LIBSHBASENAME)
47
48LIBCSOURCES := $(MODULE_DIR)/data.c $(MODULE_DIR)/general.c \
49               $(MODULE_DIR)/error.c \
50               $(MODULE_DIR)/proc.c $(MODULE_DIR)/access.c \
51               $(MODULE_DIR)/init.c $(MODULE_DIR)/sysfs.c
52
53LIBOTHEROBJECTS := $(MODULE_DIR)/conf-parse.o $(MODULE_DIR)/conf-lex.o
54LIBSHOBJECTS := $(LIBCSOURCES:.c=.lo) $(LIBOTHEROBJECTS:.o=.lo)
55LIBSTOBJECTS := $(LIBCSOURCES:.c=.ao) $(LIBOTHEROBJECTS:.o=.ao)
56LIBEXTRACLEAN := $(MODULE_DIR)/conf-parse.h $(MODULE_DIR)/conf-parse.c \
57                 $(MODULE_DIR)/conf-lex.c
58
59LIBHEADERFILES := $(MODULE_DIR)/error.h $(MODULE_DIR)/sensors.h
60
61# How to create the shared library
62$(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS)
63        $(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc -lm -lsysfs
64
65$(MODULE_DIR)/$(LIBSHSONAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
66        $(RM) $@
67        $(LN) $(LIBSHLIBNAME) $@
68
69$(MODULE_DIR)/$(LIBSHBASENAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
70        $(RM) $@ 
71        $(LN) $(LIBSHLIBNAME) $@
72
73# And the static library
74$(MODULE_DIR)/$(LIBSTLIBNAME): $(LIBSTOBJECTS)
75        $(RM) $@
76        $(AR) rcvs $@ $^
77
78# Depencies for non-C sources
79$(MODULE_DIR)/conf-lex.c: $(MODULE_DIR)/conf-lex.l $(MODULE_DIR)/general.h \
80                          $(MODULE_DIR)/data.h $(MODULE_DIR)/conf-parse.h
81$(MODULE_DIR)/conf-parse.c: $(MODULE_DIR)/conf-parse.y $(MODULE_DIR)/general.h \
82                            $(MODULE_DIR)/data.h
83$(MODULE_DIR)/conf-parse.h: $(MODULE_DIR)/conf-parse.c
84
85# Include all dependency files
86INCLUDEFILES += $(LIBCSOURCES:.c=.ld) $(LIBCSOURCES:.c=.ad)
87
88# Special warning prevention for flex-generated files
89$(MODULE_DIR)/conf-lex.ao: $(MODULE_DIR)/conf-lex.c
90        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -Wno-unused -Wno-missing-prototypes -c $< -o $@
91$(MODULE_DIR)/conf-lex.lo: $(MODULE_DIR)/conf-lex.c
92        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -Wno-unused -Wno-missing-prototypes -c $< -o $@
93
94REMOVELIBST := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSTLIBNAME))
95REMOVELIBSH := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSHLIBNAME))
96REMOVELNSO  := $(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)
97REMOVELNBS  := $(DESTDIR)$(LIBDIR)/$(LIBSHBASENAME)
98REMOVELIBHF := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBINCLUDEDIR)/%,$(LIBHEADERFILES))
99REMOVEMAN3  := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBMAN3DIR)/%,$(LIBMAN3FILES))
100REMOVEMAN5  := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBMAN5DIR)/%,$(LIBMAN5FILES))
101
102all-lib: $(LIBTARGETS)
103user :: all-lib
104
105# Generate warnings if the install directory isn't in /etc/ld.so.conf
106# or if the library wasn't there before (which means ldconfig must be run).
107# Note that some ld.so's put /usr/lib and /lib first, others put them last,
108# so we can't make any assumptions.
109install-lib: all-lib
110        $(MKDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(LIBINCLUDEDIR) $(DESTDIR)$(LIBMAN3DIR) $(DESTDIR)$(LIBMAN5DIR)
111        @if [ ! -e "$(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)" ] ; then \
112             echo '******************************************************************************' ; \
113             echo 'Warning: This is the first installation of the $(LIBSHSONAME)*' ; \
114             echo '         library files in $(DESTDIR)$(LIBDIR)!' ; \
115             echo '         You must update the library cache or the userspace tools may fail' ; \
116             echo '         or have unpredictable results!' ; \
117                 echo '         Run the following command: /sbin/ldconfig' ; \
118             echo '******************************************************************************' ; \
119        fi
120        $(INSTALL) -m 644 $(LIB_DIR)/$(LIBSTLIBNAME) $(DESTDIR)$(LIBDIR)
121        $(INSTALL) -m 755 $(LIB_DIR)/$(LIBSHLIBNAME) $(DESTDIR)$(LIBDIR)
122        $(LN) $(LIBSHLIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)
123        $(LN) $(LIBSHSONAME) $(DESTDIR)$(LIBDIR)/$(LIBSHBASENAME)
124        @if [ "$(DESTDIR)$(LIBDIR)" != "/usr/lib" -a "$(DESTDIR)$(LIBDIR)" != "/lib" ] ; then \
125           if [ -e "/usr/lib/$(LIBSHSONAME)" -o -e "/usr/lib/$(LIBSHBASENAME)" ] ; then \
126             echo '******************************************************************************' ; \
127             echo 'Warning: You have at least one $(LIBSHBASENAME) library file in /usr/lib' ; \
128             echo '         and the new library files are in $(DESTDIR)$(LIBDIR)!' ; \
129             echo '         These old files must be removed or the userspace tools may fail' ; \
130             echo '         or have unpredictable results!' ; \
131             echo '         Run the following command: rm /usr/lib/$(LIBSHBASENAME)*' ; \
132             echo '******************************************************************************' ; \
133           fi ; \
134           grep -q '^$(DESTDIR)$(LIBDIR)$$' /etc/ld.so.conf || \
135           grep -q '^$(DESTDIR)$(LIBDIR)[[:space:]:,=]' /etc/ld.so.conf || \
136           grep -q '[[:space:]:,]$(DESTDIR)$(LIBDIR)$$' /etc/ld.so.conf || \
137           grep -q '[[:space:]:,]$(DESTDIR)$(LIBDIR)[[:space:]:,=]' /etc/ld.so.conf || \
138                ( echo '******************************************************************************' ; \
139                  echo 'Warning: Library directory $(DESTDIR)$(LIBDIR) is not in /etc/ld.so.conf!' ; \
140                  echo '         Add it and run /sbin/ldconfig for the userspace tools to work.' ; \
141                  echo '******************************************************************************' ) ; \
142        fi
143        $(INSTALL) -m 644 $(LIBHEADERFILES) $(DESTDIR)$(LIBINCLUDEDIR)
144        $(INSTALL) -m 644 $(LIBMAN3FILES) $(DESTDIR)$(LIBMAN3DIR)
145        $(INSTALL) -m 644 $(LIBMAN5FILES) $(DESTDIR)$(LIBMAN5DIR)
146
147
148user_install :: install-lib
149
150user_uninstall::
151        $(RM) $(REMOVELIBST) $(REMOVELIBSH) $(REMOVELNSO) $(REMOVELNBS) 
152        $(RM) $(REMOVELIBHF) $(REMOVEMAN3) $(REMOVEMAN5)
153# Remove directory if empty, ignore failure
154        $(RMDIR) $(DESTDIR)$(LIBINCLUDEDIR) 2> /dev/null || true
155
156clean-lib:
157        $(RM) $(LIB_DIR)/*.ld $(LIB_DIR)/*.ad
158        $(RM) $(LIB_DIR)/*.lo $(LIB_DIR)/*.ao
159        $(RM) $(LIBTARGETS) $(LIBEXTRACLEAN)
160# old versions
161        $(RM) $(LIB_DIR)/$(LIBSHBASENAME).*
162clean :: clean-lib
Note: See TracBrowser for help on using the browser.