fix systemd unit install path
[external/acpid.git] / Makefile
1 # Makefile for ACPI daemon
2
3 # update these numbers for new releases
4 VERSION = 2.0.14
5
6 OPT = -O2
7
8 DESTDIR =
9 PREFIX = /usr
10
11 BINDIR = $(PREFIX)/bin
12 SBINDIR = $(PREFIX)/sbin
13 MANDIR = $(PREFIX)/share/man
14 DOCDIR = $(PREFIX)/share/doc/acpid
15
16 SBIN_PROGS = acpid
17 BIN_PROGS = acpi_listen
18 PROGS = $(SBIN_PROGS) $(BIN_PROGS)
19
20 acpid_SRCS = acpid.c acpi_ids.c connection_list.c event.c input_layer.c \
21     inotify_handler.c libnetlink.c log.c netlink.c proc.c sock.c ud_socket.c
22 acpid_OBJS = $(acpid_SRCS:.c=.o)
23
24 acpi_listen_SRCS = acpi_listen.c log.c ud_socket.c
25 acpi_listen_OBJS = $(acpi_listen_SRCS:.c=.o)
26
27 all_SRCS = $(acpid_SRCS) $(acpi_listen_SRCS)
28
29 MAN8 = acpid.8 acpi_listen.8
30 MAN8GZ = $(MAN8:.8=.8.gz)
31
32 DOCS = COPYING Changelog README TESTPLAN TODO 
33
34 CFLAGS = -W -Wall -Werror -Wundef -Wshadow -D_GNU_SOURCE $(OPT) \
35         -fno-strict-aliasing -g $(DEFS)
36 DEFS = -DVERSION="\"$(VERSION)\""
37
38 all: $(PROGS)
39
40 acpid: $(acpid_OBJS)
41
42 acpi_listen: $(acpi_listen_OBJS)
43
44 man: $(MAN8)
45         for a in $^; do gzip -f -9 -c $$a > $$a.gz; done
46
47 install_docs:
48         mkdir -p $(DESTDIR)/$(DOCDIR)
49         for a in $(DOCS); do install -m 0644 $$a $(DESTDIR)/$(DOCDIR) ; done
50         cp -a samples $(DESTDIR)/$(DOCDIR)
51
52 install: $(PROGS) man install_docs
53         mkdir -p $(DESTDIR)/$(SBINDIR)
54         mkdir -p $(DESTDIR)/$(BINDIR)
55         install -m 0750 acpid $(DESTDIR)/$(SBINDIR)
56         install -m 0755 acpi_listen $(DESTDIR)/$(BINDIR)
57         mkdir -p $(DESTDIR)/$(MANDIR)/man8
58         install -m 0644 $(MAN8GZ) $(DESTDIR)/$(MANDIR)/man8
59 # You might want to run mandb(8) after install in case your system uses it.
60
61 DISTTMP=/tmp
62 DISTNAME=acpid-$(VERSION)
63 FULLTMP = $(DISTTMP)/$(DISTNAME)
64 dist:
65         rm -rf $(FULLTMP)
66         mkdir -p $(FULLTMP)
67         cp -a * $(FULLTMP)
68         find $(FULLTMP) -type d -name CVS | xargs rm -rf
69         make -C $(FULLTMP) clean
70         make -C $(FULLTMP)/kacpimon clean
71         rm -f $(FULLTMP)/cscope.out
72         rm -f $(FULLTMP)/*anjuta*
73         find $(FULLTMP) -name '*~' | xargs rm -f
74         # Get rid of previous dist
75         rm -f $(FULLTMP)/$(DISTNAME).tar.gz
76         tar -C $(DISTTMP) -zcvf $(DISTNAME).tar.gz $(DISTNAME)
77         rm -rf $(FULLTMP)
78
79 clean:
80         $(RM) $(PROGS) $(MAN8GZ) *.o .depend
81
82 dep depend:
83         @$(RM) .depend
84         @$(MAKE) .depend
85
86 .depend: $(all_SRCS)
87         @for f in $^; do \
88                 OBJ=$$(echo $$f | sed 's/\.cp*$$/.o/'); \
89                 $(CPP) $(PP_INCLUDES) -MM $$f -MT $$OBJ; \
90         done > $@
91
92 # NOTE: 'sinclude' is "silent-include".  This suppresses a warning if
93 # .depend does not exist.  Since Makefile includes this file, and this
94 # file includes .depend, .depend is itself "a makefile" and Makefile is
95 # dependent on it.  Any makefile for which there is a rule (as above for
96 # .depend) will be evaluated before anything else.  If the rule executes
97 # and the makefile is updated, make will reload the original Makefile and
98 # start over.
99 #
100 # This means that the .depend rule will always be checked first.  If
101 # .depend gets rebuilt, then the dependencies we have already sincluded
102 # must have been stale.  Make starts over, the old dependencies are
103 # tossed, and the new dependencies are sincluded.
104 #
105 # So why use 'sinclude' instead of 'include'?  We want to ALWAYS make
106 # Makefile depend on .depend, even if .depend doesn't exist yet.  But we
107 # don't want that pesky warning.
108 sinclude .depend