1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# Makefile for marsond. Should be fine with any make (GNU, BSD, etc).
# Remember, all these assignments, you can override on the make
# command line rather than editing this file. Examples:
# make CC=clang CFLAGS=-O3
# make install PREFIX=/usr/local
### Project information.
PROJ=marsond
VERSION=0.1.4
### Compiler and options.
CC=gcc
# CC=clang works, too
COPT=-O2
CWARN=-Wall
CFLAGS=-std=c99 $(COPT) $(CWARN) -DVERSION='"$(VERSION)"'
### Install paths. Not compiled into the binary.
# These are appropriate for Slackware. Most other distros will need
# MANDIR=$(PREFIX)/share/man, and DOCDIR=$(PREFIX)/share/doc/marsond.
PREFIX=/usr
SBINDIR=$(PREFIX)/sbin
MANDIR=$(PREFIX)/man
MAN8DIR=$(MANDIR)/man8
DOCDIR=/usr/doc/$(PROJ)-$(VERSION)
UDEVDIR=/etc/udev/rules.d
INSTALL=install
INSTALL_FILE=$(INSTALL) -m0644
INSTALL_MAN=$(INSTALL_FILE)
INSTALL_UDEV=$(INSTALL_FILE)
INSTALL_DOC=$(INSTALL_FILE)
INSTALL_BIN=$(INSTALL) -s -m0755
# Build with GZIP=false to avoid gzipping the man page.
GZIP=gzip -9
# When building a Slackware package, use RULESUFFIX=.new
RULESUFFIX=
### No user-serviceable parts below (I hope).
all: $(PROJ) $(PROJ).8 99-$(PROJ).rules
$(PROJ): $(PROJ).c usage.c
usage.c: mkusage.pl $(PROJ).8
perl mkusage.pl $(PROJ).rst > usage.c
$(PROJ).8: $(PROJ).rst
rst2man $(PROJ).rst > $(PROJ).8
99-$(PROJ).rules:
sed 's,@SBINDIR@,$(SBINDIR),' < 99-$(PROJ).rules.in > 99-$(PROJ).rules
clean:
rm -f $(PROJ) core *.o
realclean: clean
rm -f $(PROJ).8 usage.c
# this is a "private" target, not expected to work on random systems.
# It specifically works on Slackware 15.0, if the system/musl package
# from SlackBuilds.org is installed.
static: clean
$(MAKE) CC=musl-gcc COPT="-static -nostdinc -isystem /usr/include/musl -isystem /usr/include -Wl,-s"
mv $(PROJ) $(PROJ).static
install: all
mkdir -p $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(MAN8DIR) $(DESTDIR)/$(UDEVDIR) $(DESTDIR)/$(DOCDIR)
$(INSTALL_BIN) $(PROJ) $(DESTDIR)/$(SBINDIR)
$(INSTALL_MAN) $(PROJ).8 $(DESTDIR)/$(MAN8DIR)
$(GZIP) $(DESTDIR)/$(MAN8DIR)/$(PROJ).8 || true
$(INSTALL_UDEV) 99-$(PROJ).rules $(DESTDIR)/$(UDEVDIR)/99-$(PROJ).rules$(RULESUFFIX)
$(INSTALL_DOC) README TODO LICENSE $(DESTDIR)/$(DOCDIR)
|