summaryrefslogtreecommitdiff
path: root/src/Makefile
blob: f8f58005ab885f605172e745f17ff5b06ccecabe (plain)
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
#
# Notes:
#
#   * Compilation Defines:
#
#     FAKE_STAT
#         - Enables time faking also for files' timestamps. 
#
#     NO_ATFILE
#         - Disables support for the fstatat() group of functions
#     
#     PTHREAD
#         - Define this to enable multithreading support.
#
#     PTHREAD_SINGLETHREADED_TIME
#         - Define this if you want to single-thread time() ... there ARE
#           possibile caching side-effects in a multithreaded environment
#           without this, but the performance impact may require you to
#           try it unsynchronized.
#
#     FAKE_INTERNAL_CALLS
#         - Also intercept libc internal __functions, e.g. not just time(), 
#           but also __time(). Enhances compatibility with applications
#           that make use of low-level system calls, such as Java Virtual
#           Machines.       
#
#     NO_CACHING
#         - Disables the caching of the fake time offset. Only disable caching
#           if you change the fake time offset during program runtime very 
#           frequently. Disabling the cache may negatively influence the
#           performance. 
#
#
#   * Compilation addition: second libMT target added for building the pthread-
#     enabled library as a separate library
#
#   * Compilation switch change: previous versions compiled using '-nostartfiles'
#     This is no longer the case since there is a 'startup' constructor for the library
#     which is used to activate the start-at times when specified. This also initializes
#     the dynamic disabling of the FAKE_STAT calls.
#

CC = gcc

PREFIX = /usr/local

CFLAGS = -std=gnu99 -Wall -DFAKE_STAT -DFAKE_INTERNAL_CALLS -fPIC
LDFLAGS = -shared -ldl -lm -lpthread

SRC = faketime.c
OBJ = faketime.o faketimeMT.o

SONAME = 1
LIBS = libfaketime.so.${SONAME} libfaketimeMT.so.${SONAME}

all: ${LIBS}

faketimeMT.o: EXTRA_FLAGS := -DPTHREAD -DPTHREAD_SINGLETHREADED_TIME

${OBJ}: faketime.c
	${CC} -o $@ -c ${CFLAGS} ${EXTRA_FLAGS} $<

lib%.so.${SONAME}: %.o
	${CC} -o $@ -Wl,-soname,$@ ${LDFLAGS} $<

clean: 
	@rm -f ${OBJ} ${LIBS}

distclean: clean
	@echo 

install: ${LIBS}
	@echo 
	@echo "Copying the libraries to /usr/lib/faketime and the wrapper script to /usr/bin ..."
	-mkdir -p "${DESTDIR}${PREFIX}/lib/faketime"
	cp ${LIBS} "${DESTDIR}${PREFIX}/lib/faketime"
	cp faketime "${DESTDIR}${PREFIX}/bin"
	-mkdir -p "${DESTDIR}${PREFIX}/share/doc/faketime"
	cp README "${DESTDIR}${PREFIX}/share/doc/faketime/README"
	cp Changelog "${DESTDIR}${PREFIX}/share/doc/faketime/Changelog"

uninstall:
	for f in ${LIBS}; do rm -f "${DESTDIR}${PREFIX}/lib/faketime/$$f"; done
	rmdir "${DESTDIR}${PREFIX}/lib/faketime"
	rm -f "${DESTDIR}${PREFIX}/bin/faketime"
	rm -f "${DESTDIR}${PREFIX}/share/doc/faketime/README"
	rm -f "${DESTDIR}${PREFIX}/share/doc/faketime/Changelog"
	rmdir "${DESTDIR}${PREFIX}/share/doc/faketime"

.PHONY: all clean distclean install uninstall