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

Revision 5114, 7.8 KB (checked in by khali, 7 years ago)

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