File: defs.mk

package info (click to toggle)
ibsim 0.5-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 376 kB
  • sloc: ansic: 5,286; makefile: 66; sh: 55
file content (67 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download | duplicates (2)
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

old_ofed:=/usr/local/ofed

prefix:= $(strip $(if $(prefix),$(prefix),\
	$(if $(wildcard $(old_ofed)/lib/libibumad.so \
		$(old_ofed)/lib/libibumad.so),$(old_ofed),\
	$(if $(wildcard /usr/local/lib/libibumad.so \
		/usr/local/lib/libibumad.so),/usr/local,\
	$(if $(wildcard /usr/lib /usr/lib),/usr,/tmp/unknown)))))

libpath:= $(strip $(if $(libpath),$(libpath),\
	$(if $(wildcard $(prefix)/lib/libibumad.so),\
		$(prefix)/lib,$(prefix)/lib)))
binpath:= $(if $(binpath),$(binpath),$(prefix)/bin)

#IB_DEV_DIR:=$(HOME)/src/p
ifdef IB_DEV_DIR
 INCS:= $(foreach l, mad umad common, -I$(IB_DEV_DIR)/libib$(l)/include) \
  -I/usr/local/include
 LIBS:= \
  $(foreach l, mad umad common, $(IB_DEV_DIR)/libib$(l)/.libs/libib$(l).so)
else
 INCS:= -I$(dir $(libpath))/include
 LIBS:= -L$(libpath) -libmad -libumad -libcommon
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) $(CFLAGS) -c -o $@ $<

%.so:
	$(CC) -shared $(LDFLAGS) -o $@ $^ $(LIBS)

$(progs):
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

dep:
	$(CC) -M $(CFLAGS) $(srcs) > .depend
-include .depend

clean:
	$(RM) $(objs) $(libs) $(progs)
	$(RM) .build_profile
	$(RM) *.o *.a *.so *~

install: all
	install -d $(DESTDIR)$(binpath)
	install -d $(DESTDIR)$(libpath)/umad2sim
	$(foreach p, $(progs), install $(p) $(DESTDIR)$(binpath))
	$(foreach l, $(libs), install $(l) $(DESTDIR)$(libpath)/umad2sim)

$(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