File: Makefile

package info (click to toggle)
libfiu 1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 2,633; python: 973; makefile: 599; sh: 309
file content (92 lines) | stat: -rw-r--r-- 1,979 bytes parent folder | download | duplicates (5)
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

CFLAGS += -std=c99 -Wall -O3
ALL_CFLAGS = -D_XOPEN_SOURCE=600 -fPIC -DFIU_ENABLE=1 \
		-I. -I../../libfiu/ \
		$(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

ifdef DEBUG
ALL_CFLAGS += -g
endif

ifdef PROFILE
ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
endif

# prefix for installing the binaries
PREFIX=/usr/local

# location of preload libraries
PLIBPATH=$(PREFIX)/lib

# install utility, we assume it's GNU/BSD compatible
INSTALL=install


OBJS = run.o


ifneq ($(V), 1)
	NICE_CC = @echo "  CC  $@"; $(CC)
else
	NICE_CC = $(CC)
endif


default: all
	
all: fiu_run_preload.so fiu-run

BF = $(ALL_CFLAGS) ~ $(PREFIX)
build-flags: .force-build-flags
	@if [ x"$(BF)" != x"`cat build-flags 2>/dev/null`" ]; then \
		if [ -f build-flags ]; then \
			echo "build flags changed, rebuilding"; \
		fi; \
		echo "$(BF)" > build-flags; \
	fi

$(OBJS): build-flags

.c.o:
	$(NICE_CC) $(ALL_CFLAGS) -c $< -o $@


# some platforms do not have libdl, we only use it if available
build-needlibdl:
	@$(LD) -ldl -o dlcheck.so 2>/dev/null \
		&& echo -ldl > $@ || echo > $@
	@rm -f dlcheck.so


fiu_run_preload.so: build-flags build-needlibdl $(OBJS)
	$(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) \
		-L../../libfiu/ \
		-lfiu `cat build-needlibdl` \
		-o fiu_run_preload.so


fiu-run: build-flags fiu-run.in
	cat fiu-run.in | sed "s+@@PLIBPATH@@+$(PLIBPATH)+g" > fiu-run
	chmod +x fiu-run

install: fiu_run_preload.so fiu-run
	$(INSTALL) -d $(PREFIX)/lib
	$(INSTALL) -m 0755 fiu_run_preload.so $(PREFIX)/lib
	$(INSTALL) -d $(PREFIX)/bin
	$(INSTALL) -m 0755 fiu-run $(PREFIX)/bin
	$(INSTALL) -d $(PREFIX)/share/man/man1
	$(INSTALL) -m 0644 fiu-run.1 $(PREFIX)/share/man/man1/

uninstall:
	$(RM) $(PREFIX)/lib/fiu_run_preload.so
	$(RM) $(PREFIX)/bin/fiu-run
	$(RM) $(PREFIX)/share/man/man1/fiu-run.1

clean:
	rm -f $(OBJS) fiu_run_preload.so fiu-run build-flags
	rm -f *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out
	rm -f build-needlibdl

.PHONY: default install uninstall clean .force-build-flags