root/lm-sensors/trunk/lib/Module.mk @ 3253

Revision 3253, 7.6 KB (checked in by khali, 9 years ago)

Bump lib version to 3.1.0 for the upcoming lm_sensors 2.10.0
release.

  • 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, sensors.h,
34# chips.h.
35LIBMAINVER := 3
36LIBMINORVER := 1.0
37LIBVER := $(LIBMAINVER).$(LIBMINORVER)
38
39# The static lib name, the shared lib name, and the internal ('so') name of
40# the shared lib.
41LIBSHBASENAME := libsensors.so
42LIBSHLIBNAME := libsensors.so.$(LIBVER)
43LIBSTLIBNAME := libsensors.a
44LIBSHSONAME := libsensors.so.$(LIBMAINVER)
45
46LIBTARGETS := $(MODULE_DIR)/$(LIBSTLIBNAME) $(MODULE_DIR)/$(LIBSHLIBNAME) \
47              $(MODULE_DIR)/$(LIBSHSONAME) $(MODULE_DIR)/$(LIBSHBASENAME)
48
49LIBCSOURCES := $(MODULE_DIR)/data.c $(MODULE_DIR)/general.c \
50               $(MODULE_DIR)/error.c $(MODULE_DIR)/chips.c \
51               $(MODULE_DIR)/proc.c $(MODULE_DIR)/access.c \
52               $(MODULE_DIR)/init.c
53ifdef SYSFS_SUPPORT
54        LIBCSOURCES := $(LIBCSOURCES) $(MODULE_DIR)/sysfs.c
55endif
56
57LIBOTHEROBJECTS := $(MODULE_DIR)/conf-parse.o $(MODULE_DIR)/conf-lex.o
58LIBSHOBJECTS := $(LIBCSOURCES:.c=.lo) $(LIBOTHEROBJECTS:.o=.lo)
59LIBSTOBJECTS := $(LIBCSOURCES:.c=.ao) $(LIBOTHEROBJECTS:.o=.ao)
60LIBEXTRACLEAN := $(MODULE_DIR)/conf-parse.h $(MODULE_DIR)/conf-parse.c \
61                 $(MODULE_DIR)/conf-lex.c
62
63LIBHEADERFILES := $(MODULE_DIR)/error.h $(MODULE_DIR)/sensors.h \
64                  $(MODULE_DIR)/chips.h
65
66# How to create the shared library
67ifdef SYSFS_SUPPORT
68$(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS)
69        $(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc -lm -lsysfs
70else
71$(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS)
72        $(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc -lm
73endif
74
75$(MODULE_DIR)/$(LIBSHSONAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
76        $(RM) $@
77        $(LN) $(LIBSHLIBNAME) $@
78
79$(MODULE_DIR)/$(LIBSHBASENAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
80        $(RM) $@ 
81        $(LN) $(LIBSHLIBNAME) $@
82
83# And the static library
84$(MODULE_DIR)/$(LIBSTLIBNAME): $(LIBSTOBJECTS)
85        $(RM) $@
86        $(AR) rcvs $@ $^
87
88# Depencies for non-C sources
89$(MODULE_DIR)/conf-lex.c: $(MODULE_DIR)/conf-lex.l $(MODULE_DIR)/general.h \
90                          $(MODULE_DIR)/data.h $(MODULE_DIR)/conf-parse.h
91$(MODULE_DIR)/conf-parse.c: $(MODULE_DIR)/conf-parse.y $(MODULE_DIR)/general.h \
92                            $(MODULE_DIR)/data.h
93$(MODULE_DIR)/conf-parse.h: $(MODULE_DIR)/conf-parse.c
94
95# Include all dependency files
96INCLUDEFILES += $(LIBCSOURCES:.c=.ld) $(LIBCSOURCES:.c=.ad)
97
98# Special warning prevention for flex-generated files
99$(MODULE_DIR)/conf-lex.ao: $(MODULE_DIR)/conf-lex.c
100        $(CC) $(ARCPPFLAGS) $(ARCFLAGS) -Wno-unused -c $< -o $@
101$(MODULE_DIR)/conf-lex.lo: $(MODULE_DIR)/conf-lex.c
102        $(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -Wno-unused -c $< -o $@
103
104REMOVELIBST := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSTLIBNAME))
105REMOVELIBSH := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSHLIBNAME))
106REMOVELNSO  := $(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)
107REMOVELNBS  := $(DESTDIR)$(LIBDIR)/$(LIBSHBASENAME)
108REMOVELIBHF := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBINCLUDEDIR)/%,$(LIBHEADERFILES))
109REMOVEMAN3  := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBMAN3DIR)/%,$(LIBMAN3FILES))
110REMOVEMAN5  := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBMAN5DIR)/%,$(LIBMAN5FILES))
111
112all-lib: $(LIBTARGETS)
113user :: all-lib
114
115# Generate warnings if the install directory isn't in /etc/ld.so.conf
116# or if the library wasn't there before (which means ldconfig must be run).
117# Note that some ld.so's put /usr/lib and /lib first, others put them last,
118# so we can't make any assumptions.
119install-lib: all-lib
120        $(MKDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(LIBINCLUDEDIR) $(DESTDIR)$(LIBMAN3DIR) $(DESTDIR)$(LIBMAN5DIR)
121        @if [ ! -e "$(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)" ] ; then \
122             echo '******************************************************************************' ; \
123             echo 'Warning: This is the first installation of the $(LIBSHSONAME)*' ; \
124             echo '         library files in $(DESTDIR)$(LIBDIR)!' ; \
125             echo '         You must update the library cache or the userspace tools may fail' ; \
126             echo '         or have unpredictable results!' ; \
127                 echo '         Run the following command: /sbin/ldconfig' ; \
128             echo '******************************************************************************' ; \
129        fi
130        $(INSTALL) -m 644 $(LIB_DIR)/$(LIBSTLIBNAME) $(DESTDIR)$(LIBDIR)
131        $(INSTALL) -m 755 $(LIB_DIR)/$(LIBSHLIBNAME) $(DESTDIR)$(LIBDIR)
132        $(LN) $(LIBSHLIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBSHSONAME)
133        $(LN) $(LIBSHSONAME) $(DESTDIR)$(LIBDIR)/$(LIBSHBASENAME)
134        @if [ "$(DESTDIR)$(LIBDIR)" != "/usr/lib" -a "$(DESTDIR)$(LIBDIR)" != "/lib" ] ; then \
135           if [ -e "/usr/lib/$(LIBSHSONAME)" -o -e "/usr/lib/$(LIBSHBASENAME)" ] ; then \
136             echo '******************************************************************************' ; \
137             echo 'Warning: You have at least one $(LIBSHBASENAME) library file in /usr/lib' ; \
138             echo '         and the new library files are in $(DESTDIR)$(LIBDIR)!' ; \
139             echo '         These old files must be removed or the userspace tools may fail' ; \
140             echo '         or have unpredictable results!' ; \
141             echo '         Run the following command: rm /usr/lib/$(LIBSHBASENAME)*' ; \
142             echo '******************************************************************************' ; \
143           fi ; \
144           grep -q '^$(DESTDIR)$(LIBDIR)$$' /etc/ld.so.conf || \
145           grep -q '^$(DESTDIR)$(LIBDIR)[[:space:]:,=]' /etc/ld.so.conf || \
146           grep -q '[[:space:]:,]$(DESTDIR)$(LIBDIR)$$' /etc/ld.so.conf || \
147           grep -q '[[:space:]:,]$(DESTDIR)$(LIBDIR)[[:space:]:,=]' /etc/ld.so.conf || \
148                ( echo '******************************************************************************' ; \
149                  echo 'Warning: Library directory $(DESTDIR)$(LIBDIR) is not in /etc/ld.so.conf!' ; \
150                  echo '         Add it and run /sbin/ldconfig for the userspace tools to work.' ; \
151                  echo '******************************************************************************' ) ; \
152        fi
153        $(INSTALL) -m 644 $(LIBHEADERFILES) $(DESTDIR)$(LIBINCLUDEDIR)
154        $(INSTALL) -m 644 $(LIBMAN3FILES) $(DESTDIR)$(LIBMAN3DIR)
155        $(INSTALL) -m 644 $(LIBMAN5FILES) $(DESTDIR)$(LIBMAN5DIR)
156
157
158user_install :: install-lib
159
160user_uninstall::
161        $(RM) $(REMOVELIBST) $(REMOVELIBSH) $(REMOVELNSO) $(REMOVELNBS) 
162        $(RM) $(REMOVELIBHF) $(REMOVEMAN3) $(REMOVEMAN5)
163
164clean-lib:
165        $(RM) $(LIB_DIR)/*.ld $(LIB_DIR)/*.ad
166        $(RM) $(LIB_DIR)/*.lo $(LIB_DIR)/*.ao
167        $(RM) $(LIBTARGETS) $(LIBEXTRACLEAN)
168# old versions
169        $(RM) $(LIB_DIR)/$(LIBSHBASENAME).*
170clean :: clean-lib
Note: See TracBrowser for help on using the browser.