-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
107 lines (82 loc) · 2.52 KB
/
Makefile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# A simple gmake Makefile, to be used on Linux and Darwin. It shouldn't
# be used elsewhere because it assumes that the target system doesn't
# support BSD extended file flags.
#
PREFIX?=/usr/local
FLEX?= flex
YACC?= yacc
OWNER?= 0
GROUP?= 0
UNAME= $(shell uname -s)
SRCS= attrstack.c auth.c config.c detailer.c diff.c fattr.c fixups.c \
fnmatch.c globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c \
pathcomp.c parse.c proto.c rcsfile.c rcslex.c rcsparse.c rsyncfile.c \
status.c stream.c threads.c token.c updater.c
OBJS= $(SRCS:.c=.o)
WARNS= -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow \
-Wcast-align -Wunused-parameter -Wchar-subscripts -Winline \
-Wnested-externs -Wredundant-decls -Wno-format-y2k
ifdef DEBUG
CFLAGS+= -g -O0 -DDEBUG
else
CFLAGS+= -DNDEBUG -O
endif
CFLAGS+= -pipe -I$(PREFIX)/include $(WARNS)
ifeq ($(UNAME), Linux)
CFLAGS+= -D_XOPEN_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
endif
ifeq ($(UNAME), Darwin)
CFLAGS+= -DHAVE_FFLAGS
endif
ifeq ($(UNAME), FreeBSD)
CFLAGS+= -DHAVE_FFLAGS
endif
ifeq ($(UNAME), OpenBSD)
CFLAGS+= -DHAVE_FFLAGS
WARNS+= -Wno-system-headers
endif
ifeq ($(UNAME), NetBSD)
CFLAGS+= -DHAVE_FFLAGS
endif
ifeq ($(UNAME), DragonFlyBSD)
CFLAGS+= -DHAVE_FFLAGS
endif
LDFLAGS= -L$(PREFIX)/lib -lz -lpthread
ifeq ($(UNAME), FreeBSD)
LDFLAGS+= -lmd
else
LDFLAGS+= -lcrypto
endif
.PHONY: all clean install
all: csup csup.1.gz cpasswd.1.gz
csup: $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
config.c: parse.h
token.c: token.l
$(FLEX) -t $< > $@
parse.c: parse.y
parse.h: parse.c
# Disable a bunch of warnings to quiet builds for C files generated by flex.
FLEX_NOWARNS= -Wno-redundant-decls -Wno-unused-function -Wno-sign-compare \
-Wno-unused-parameter -Wno-missing-prototypes
token.o: token.c
$(CC) $(CFLAGS) $(FLEX_NOWARNS) -c -o $@ $<
# Recent versions of yacc seem to define yyparse() while older ones don't...
parse.o: parse.c
$(CC) $(CFLAGS) -Wno-redundant-decls -c -o $@ $<
csup.1.gz: csup.1
cpasswd.1.gz: cpasswd.1
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.c: %.y
$(YACC) -d -o $@ $<
%.1.gz: %.1
gzip -cn $< > $@
clean:
rm -f csup $(OBJS) parse.c parse.h token.c csup.1.gz cpasswd.1.gz
install: csup csup.1.gz cpasswd.sh cpasswd.1.gz
install -s -o $(OWNER) -g $(GROUP) csup $(PREFIX)/bin
install -s -o $(OWNER) -g $(GROUP) cpasswd.sh $(PREFIX)/bin/cpasswd
install -s -o $(OWNER) -g $(GROUP) csup.1.gz $(PREFIX)/share/man/man1
install -s -o $(OWNER) -g $(GROUP) cpasswd.1.gz $(PREFIX)/share/man/man1