-
Notifications
You must be signed in to change notification settings - Fork 13
/
defs.mk
69 lines (53 loc) · 1.72 KB
/
defs.mk
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
old_ofed:=/usr/local/ofed
prefix:= $(strip $(if $(prefix),$(prefix),\
$(if $(wildcard $(old_ofed)/lib64/libibumad.so \
$(old_ofed)/lib/libibumad.so),$(old_ofed),\
$(if $(wildcard /usr/local/lib/libibumad.so \
/usr/local/lib64/libibumad.so),/usr/local,\
$(if $(wildcard /usr/lib /usr/lib64),/usr,/tmp/unknown)))))
libpath:= $(strip $(if $(libpath),$(libpath),\
$(if $(wildcard $(prefix)/lib64/libibumad.so),\
$(prefix)/lib64,$(prefix)/lib)))
binpath:= $(if $(binpath),$(binpath),$(prefix)/bin)
libdir:=$(libpath)/umad2sim
#IB_DEV_DIR:=$(HOME)/src/m
ifdef IB_DEV_DIR
INCS:= $(foreach l, mad umad, -I$(IB_DEV_DIR)/libib$(l)/include) \
-I/usr/local/include
LIBS:= \
$(foreach l, mad umad, $(IB_DEV_DIR)/libib$(l)/.libs/libib$(l).so)
else
INCS:= -I$(dir $(libpath))include
LIBS:= -L$(libpath) -libmad -libumad -lpthread
endif
CFLAGS += -Wall -g -fpic -I. -I../include $(INCS)
LDFLAGS+= -fpic
srcs?=$(wildcard *.c)
objs?=$(srcs:.c=.o)
.PHONY: all clean dep install
all:
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
%.so:
$(CC) -shared $(LDFLAGS) -o $@ $^ $(LIBS)
$(bins): %:
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
dep:
$(CC) -M $(CFLAGS) $(srcs) > .depend
-include .depend
clean:
$(RM) $(objs) $(libs) $(bins) $(extra_clean)
$(RM) .build_profile
$(RM) *.o *.a *.so *~
install: all
install -d $(DESTDIR)$(binpath)
install -d $(DESTDIR)$(libdir)
$(foreach p, $(progs), install $(p) $(DESTDIR)$(binpath);)
$(foreach l, $(libs), install $(l) $(DESTDIR)$(libdir);)
$(objs): .build_profile
.build_profile::
@echo CFLAGS=$(CFLAGS) > .build_profile.new
@if ( test -f .build_profile \
&& diff .build_profile .build_profile.new > /dev/null ) ; then \
rm .build_profile.new ; \
else mv .build_profile.new .build_profile ; fi