Makefile 2.18 KB
Newer Older
1
LIBRARIES=libmoberg.so
Anders Blomdell's avatar
Anders Blomdell committed
2
MOBERG_VERSION=$(shell git describe --tags | sed -e 's/^v//;s/-/_/g' )
Anders Blomdell's avatar
Anders Blomdell committed
3
CCFLAGS+=-Wall -Werror -I$(shell pwd) -O3 -g
Anders Blomdell's avatar
Anders Blomdell committed
4
LDFLAGS+=-L$(shell pwd)/build/ -lmoberg
Anders Blomdell's avatar
Anders Blomdell committed
5
PLUGINS:=$(wildcard plugins/*)
Anders Blomdell's avatar
Anders Blomdell committed
6
ADAPTORS:=$(wildcard adaptors/*)
Anders Blomdell's avatar
Anders Blomdell committed
7
export CCFLAGS LDFLAGS
Anders Blomdell's avatar
Anders Blomdell committed
8
9
LDFLAGS_parse_config=-ldl
#-export-dynamic
10

Anders Blomdell's avatar
Anders Blomdell committed
11
all: $(LIBRARIES:%=build/%) build/moberg $(PLUGINS) $(ADAPTORS)
Anders Blomdell's avatar
Anders Blomdell committed
12
	echo $(PLUGINS)
Anders Blomdell's avatar
Anders Blomdell committed
13
	echo $(CCFLAGS)
14

Anders Blomdell's avatar
Anders Blomdell committed
15
16
build/libmoberg.so: Makefile | build
	$(CC) -o $@ $(CCFLAGS) -shared -fPIC -I. \
Anders Blomdell's avatar
Anders Blomdell committed
17
		$(filter %.o,$^) -lxdg-basedir -ldl
18

Anders Blomdell's avatar
Anders Blomdell committed
19
build/moberg: moberg_tool.c Makefile | build
Anders Blomdell's avatar
Anders Blomdell committed
20
	$(CC) -o $@ $(CCFLAGS) $< -Lbuild -lmoberg
Anders Blomdell's avatar
Anders Blomdell committed
21

Anders Blomdell's avatar
Anders Blomdell committed
22
23
build/lib build:
	mkdir -p $@
24

Anders Blomdell's avatar
Anders Blomdell committed
25
26
%:	build/%.o Makefile
	$(CC) $(LDFLAGS) $(LDFLAGS_$(*)) -o $@  $(filter %.o,$^)
27

Anders Blomdell's avatar
Anders Blomdell committed
28
29
build/%.o:	%.c Makefile
	$(CC) $(CCFLAGS) -c -o $@ $<
30

Anders Blomdell's avatar
Anders Blomdell committed
31
32
33
build/lib/%.o:	%.c Makefile | build/lib
	$(CC) $(CCFLAGS) -c -fPIC -o $@ $<

Anders Blomdell's avatar
Anders Blomdell committed
34
35
.PHONY: $(ADAPTORS)
$(ADAPTORS): Makefile
36
37
	$(MAKE) -C $@

Anders Blomdell's avatar
Anders Blomdell committed
38
39
.PHONY: $(PLUGINS)
$(PLUGINS): Makefile
Anders Blomdell's avatar
Anders Blomdell committed
40
	$(MAKE) -C $@
Anders Blomdell's avatar
Anders Blomdell committed
41
42
	cp $@/build/libmoberg_*.so build

Anders Blomdell's avatar
Anders Blomdell committed
43

Anders Blomdell's avatar
Anders Blomdell committed
44
45
46
47
48
49
50
51
52
53
54
55
.PHONY: TAR
TAR:
	git archive \
		--prefix moberg-$(MOBERG_VERSION)/ \
		--output moberg-$(MOBERG_VERSION).tar.gz -- HEAD

.PHONY: moberg-$(MOBERG_VERSION).spec
moberg-$(MOBERG_VERSION).spec: moberg.spec.template Makefile
	sed -e 's/__MOBERG_VERSION__/$(MOBERG_VERSION)/' $< > $@

.PHONY: SRPM
SRPM:	moberg-$(MOBERG_VERSION).spec TAR
Anders Blomdell's avatar
Anders Blomdell committed
56
	rpmbuild --define "_sourcedir $$(pwd)" -bs $<
Anders Blomdell's avatar
Anders Blomdell committed
57
58


59
60
61

.PHONY: test
test: all
Anders Blomdell's avatar
Anders Blomdell committed
62
	$(MAKE) -C test test
63
64

clean:
Anders Blomdell's avatar
Anders Blomdell committed
65
66
	rm -f build/*.so
	rm -f build/*.mex*
Anders Blomdell's avatar
Anders Blomdell committed
67
	rm -f build/lib/*.o
Anders Blomdell's avatar
Anders Blomdell committed
68
	rm -f *~
Anders Blomdell's avatar
Anders Blomdell committed
69
70
	rm -f moberg-*.spec
	rm -f moberg-*.tar.gz
Anders Blomdell's avatar
Anders Blomdell committed
71
	make -C test clean
Anders Blomdell's avatar
Anders Blomdell committed
72
	for d in $(ADAPTORS) ; do make -C $$d clean ; done
Anders Blomdell's avatar
Anders Blomdell committed
73
	for d in $(PLUGINS) ; do make -C $$d clean ; done
74

Anders Blomdell's avatar
Anders Blomdell committed
75
build/libmoberg.so: build/lib/moberg.o
Anders Blomdell's avatar
Anders Blomdell committed
76
77
build/libmoberg.so: build/lib/moberg_config.o
build/libmoberg.so: build/lib/moberg_device.o
Anders Blomdell's avatar
Anders Blomdell committed
78
build/libmoberg.so: build/lib/moberg_parser.o
79
build/lib/%.o: %.h
80
81
82
83
build/lib/%.o: moberg_inline.h
build/lib/moberg.o: moberg_config.h
build/lib/moberg.o: moberg_module.h
build/lib/moberg.o: moberg_parser.h
Anders Blomdell's avatar
Anders Blomdell committed
84
85
86
87
88
89
build/lib/moberg_device.o: moberg.h
build/lib/moberg_device.o: moberg_channel.h
build/lib/moberg_device.o: moberg_config.h
build/lib/moberg_device.o: moberg_device.h
build/lib/moberg_device.o: moberg_inline.h