forked from bwalex/tc-play
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.classic
142 lines (107 loc) · 3.59 KB
/
Makefile.classic
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# either linux or dragonfly
SYSTEM?=linux
DESTDIR?=
PREFIX?=/usr/local
LIBSUFFIX?=
LIBDIR?=$(PREFIX)/lib$(LIBSUFFIX)
MANDIR?=$(PREFIX)/share/man
SBINDIR?=$(PREFIX)/sbin
INCLUDEDIR?=$(PREFIX)/include
# either openssl or gcrypt
PBKDF_BACKEND?=openssl
# system compiler, normally gcc
CC?=gcc
INSTALL?=install
RM?=rm -f
LN?=ln
# whether to enable debugging or not
DEBUG?=no
MAJ_VER=2
MIN_VER=0
# I've given up on -Werror for now; many Linux distros have warnings even in
# their standard header files.
WARNFLAGS= -Wsystem-headers -Wall -W -Wno-unused-parameter \
-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
-Wold-style-definition -Wreturn-type -Wwrite-strings \
-Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts \
-Winline -Wnested-externs
VER_FLAGS= -DMAJ_VER=$(MAJ_VER) -DMIN_VER=$(MIN_VER) -D_FILE_OFFSET_BITS=64
SRCS= tcplay.c crc32.c safe_mem.c io.c hdr.c humanize.c
SRCS+= crypto.c generic_xts.c
OBJS= tcplay.o crc32.o safe_mem.o io.o hdr.o humanize.o
OBJS+= crypto.o generic_xts.o
COMMON_CFLAGS= $(WARNFLAGS) -fPIC $(VER_FLAGS)
ifeq ($(DEBUG), yes)
COMMON_CFLAGS+= -O0 -g -DDEBUG
else
COMMON_CFLAGS+= -O3
endif
ifeq (${SYSTEM}, linux)
COMMON_CFLAGS+= -D_GNU_SOURCE
LIBS+= -lgcrypt -lgpg-error -ldevmapper -luuid
SRCS+= crypto-gcrypt.c
OBJS+= crypto-gcrypt.o
ifeq (${PBKDF_BACKEND}, gcrypt)
SRCS+= pbkdf2-gcrypt.c
OBJS+= pbkdf2-gcrypt.o
endif
ifeq (${PBKDF_BACKEND}, openssl)
SRCS+= pbkdf2-openssl.c
OBJS+= pbkdf2-openssl.o
LIBS+= -lcrypto
endif
endif
ifeq (${SYSTEM}, dragonfly)
LIBS+= -lcrypto -ldm -lprop
SRCS+= crypto-dev.c
OBJS+= crypto-dev.o
SRCS+= pbkdf2-openssl.c
OBJS+= pbkdf2-openssl.o
endif
OBJS_PROG= $(OBJS) main.o
OBJS_LIB= $(OBJS) tcplay_api.o
all: tcplay libtcplay.so libtcplay.a
%.o: %.c
$(CC) $(COMMON_CFLAGS) $(CFLAGS) -c -o $@ $<
tcplay: $(OBJS_PROG)
$(CC) $(COMMON_CFLAGS) $(CFLAGS) -o tcplay $(OBJS_PROG) $(LIBS)
libtcplay.so.$(MAJ_VER).$(MIN_VER): $(OBJS_LIB)
$(CC) -shared -Wl,-version-script=tcplay.map -Wl,-soname=libtcplay.so.$(MAJ_VER).$(MIN_VER) $(LDFLAGS) \
-o libtcplay.so.$(MAJ_VER).$(MIN_VER) $(OBJS_LIB) $(LIBS)
libtcplay.so: libtcplay.so.$(MAJ_VER).$(MIN_VER)
$(LN) -sf libtcplay.so.$(MAJ_VER).$(MIN_VER) libtcplay.so
libtcplay.a: $(OBJS_LIB)
$(AR) -rs libtcplay.a $(OBJS_LIB)
install: install_program install_lib install_lib_static
install_program: tcplay install_man8
$(INSTALL) -d "$(DESTDIR)$(SBINDIR)"
$(INSTALL) tcplay "$(DESTDIR)$(SBINDIR)"
install_lib: libtcplay.so.$(MAJ_VER).$(MIN_VER) libtcplay.so install_h install_man3
$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
$(INSTALL) libtcplay.so.$(MAJ_VER).$(MIN_VER) "$(DESTDIR)$(LIBDIR)"
$(LN) -sf libtcplay.so.$(MAJ_VER).$(MIN_VER) "$(DESTDIR)$(LIBDIR)/libtcplay.so"
install_lib_static: libtcplay.a install_h install_man3
$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
$(INSTALL) libtcplay.a "$(DESTDIR)$(LIBDIR)"
install_h: tcplay_api.h
$(INSTALL) -d "$(DESTDIR)$(INCLUDEDIR)"
$(INSTALL) tcplay_api.h "$(DESTDIR)$(INCLUDEDIR)"
install_man3: tcplay.3
$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man3"
$(INSTALL) tcplay.3 "$(DESTDIR)$(MANDIR)/man3"
install_man8: tcplay.8
$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man8"
$(INSTALL) tcplay.8 "$(DESTDIR)$(MANDIR)/man8"
clean_cmake_mess:
$(RM) CMakeCache.txt
$(RM) -r CMakeFiles
$(RM) CPackConfig.cmake
$(RM) CPackSourceConfig.cmake
$(RM) Makefile
$(RM) cmake_install.cmake
$(RM) tcplay.pc
clean: clean_cmake_mess
$(RM) $(OBJS_PROG)
$(RM) $(OBJS_LIB)
$(RM) tcplay libtcplay.so* libtcplay.a tcplay.core ktrace.out
.PHONY: install install_program install_lib install_lib_static install_man3 install_man8 install_h