improve Makefiles, introduce rpath
Stefan Schuermans

Stefan Schuermans commited on 2014-05-10 10:28:08
Showing 5 changed files, with 41 additions and 40 deletions.

... ...
@@ -3,29 +3,30 @@
3 3
 # Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4 4
 # a blinkenarea.org project
5 5
 
6
-CC=gcc
7
-CFLAGS=-Wall -Wextra -Werror -fPIC -O2 -I..
8
-LFLAGS=-L.
9
-AR=ar
10
-RANLIB=ranlib
6
+CC:=gcc
7
+CFLAGS:=-Wall -Wextra -Werror -fPIC -O2 -I..
8
+LIB_LFLAGS:=
9
+BIN_LFLAGS:=-L. -Wl,-rpath,'$$ORIGIN'
10
+AR:=ar
11
+RANLIB:=ranlib
11 12
 
12 13
 include ../version.mk
13 14
 include ../config/config.mk
14 15
 
15 16
 ifeq ($(BLINKENLIB_CFG_OSX),1)
16
-SHLIBEXT=dylib
17
+SHLIBEXT:=dylib
17 18
 CFLAGS+=-I/sw/include
18 19
 LFLAGS+=-L/sw/lib
19 20
 SONAMEOPT=
20 21
 else
21
-SHLIBEXT=so
22
-SONAMEOPT=-Wl,-soname,libBlinkenLib.$(SHLIBEXT).$(VERSION_MAJOR)
22
+SHLIBEXT:=so
23
+SONAMEOPT:=-Wl,-soname,libBlinkenLib.$(SHLIBEXT).$(VERSION_MAJOR)
23 24
 endif
24 25
 
25 26
 ifeq ($(BLINKENLIB_CFG_MNG),1)
26
-BLINKEN_MNG_H=BlinkenMng.h
27
-BLINKEN_MNG_O=BlinkenMng.o
28
-LMNG=-lmng -lz
27
+BLINKEN_MNG_H:=BlinkenMng.h
28
+BLINKEN_MNG_O:=BlinkenMng.o
29
+LMNG:=-lmng -lz
29 30
 endif
30 31
 
31 32
 LIB_OBJS=BlinkenColorizer.o BlinkenFrame.o BlinkenMovie.o $(BLINKEN_MNG_O) \
... ...
@@ -61,7 +62,7 @@ libBlinkenLib.a: $(LIB_OBJS)
61 62
 	$(RANLIB) $@
62 63
 
63 64
 libBlinkenLib.$(SHLIBEXT).$(VERSION): $(LIB_OBJS)
64
-	$(CC) -shared $(SONAMEOPT) $(LFLAGS) -o $@ $+ $(LMNG)
65
+	$(CC) -shared $(SONAMEOPT) $(LIB_LFLAGS) -o $@ $+ $(LMNG)
65 66
 
66 67
 libBlinkenLib.$(SHLIBEXT).$(VERSION_MAJOR): libBlinkenLib.$(SHLIBEXT).$(VERSION)
67 68
 	rm -f $@
... ...
@@ -78,25 +79,25 @@ BlinkenConv.o: BlinkenConv.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenPro
78 79
 	$(CC) $(CFLAGS) -c -o $@ $<
79 80
 
80 81
 BlinkenConv: BlinkenConv.o libBlinkenLib.$(SHLIBEXT)
81
-	$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib
82
+	$(CC) $(BIN_LFLAGS) -o $@ $< -lBlinkenLib
82 83
 
83 84
 BlinkenSend.o: BlinkenSend.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenProto.h BlinkenFrame.h BlinkenMovie.h Tools2.h
84 85
 	$(CC) $(CFLAGS) -c -o $@ $<
85 86
 
86 87
 BlinkenSend: BlinkenSend.o Tools2.o libBlinkenLib.$(SHLIBEXT)
87
-	$(CC) $(LFLAGS) -o $@ $(filter %.o,$^) -lBlinkenLib
88
+	$(CC) $(BIN_LFLAGS) -o $@ $(filter %.o,$^) -lBlinkenLib
88 89
 
89 90
 BlinkenRecv.o: BlinkenRecv.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenProto.h BlinkenFrame.h BlinkenMovie.h Tools2.h
90 91
 	$(CC) $(CFLAGS) -c -o $@ $<
91 92
 
92 93
 BlinkenRecv: BlinkenRecv.o Tools2.o libBlinkenLib.$(SHLIBEXT)
93
-	$(CC) $(LFLAGS) -o $@ $(filter %.o,$^) -lBlinkenLib
94
+	$(CC) $(BIN_LFLAGS) -o $@ $(filter %.o,$^) -lBlinkenLib
94 95
 
95 96
 BlinkenOutput.o: BlinkenOutput.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenProto.h BlinkenFrame.h BlinkenMovie.h
96 97
 	$(CC) $(CFLAGS) -c -o $@ $<
97 98
 
98 99
 BlinkenOutput: BlinkenOutput.o libBlinkenLib.$(SHLIBEXT)
99
-	$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib
100
+	$(CC) $(BIN_LFLAGS) -o $@ $< -lBlinkenLib
100 101
 
101 102
 clean:
102 103
 	rm -f BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput libBlinkenLib.$(SHLIBEXT)* libBlinkenLib.a *.o config.h
... ...
@@ -5,8 +5,8 @@
5 5
 
6 6
 include version.mk
7 7
 
8
-UPDATE_FILES=Makefile */Makefile */*.c */*.h
9
-PACK_FILES=BlinkenLib ChangeLog config examples install Makefile
8
+UPDATE_FILES:=Makefile */Makefile */*.c */*.h
9
+PACK_FILES:=BlinkenLib ChangeLog config examples install Makefile
10 10
 
11 11
 .PHONY: all conf clean distclean install uninstall update pack
12 12
 .SUFFIXES:
... ...
@@ -3,9 +3,9 @@
3 3
 # Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4 4
 # a blinkenarea.org project
5 5
 
6
-CC=gcc
7
-INCDIR=-I/sw/include
8
-LIBDIR=-L/sw/lib
6
+CC:=gcc
7
+INCDIR:=-I/sw/include
8
+LIBDIR:=-L/sw/lib
9 9
 
10 10
 .phony: all clean
11 11
 
... ...
@@ -24,14 +24,14 @@ config.cfg: osx.cfg mng.cfg
24 24
 	cat $+ >config.cfg
25 25
 
26 26
 config.mk: config.cfg
27
-	sed 's/^\([A-Z]*\)=\([01]\)$$/BLINKENLIB_CFG_\1=\2/' <$< >$@
27
+	sed 's/^\([A-Z]*\)=\([01]\)$$/BLINKENLIB_CFG_\1:=\2/' <$< >$@
28 28
 
29 29
 config.h: config.cfg Makefile ../version.mk
30 30
 	sed 's/^\([A-Z]*\)=0$$/#undef BLINKENLIB_CFG_\1/;s/^\([A-Z]*\)=1$$/#define BLINKENLIB_CFG_\1/' <$< >$@
31 31
 	echo '#define BLINKENLIB_CONFIG "' | tr -d '\n' >>$@
32 32
 	sed 's/^\([A-Z]*\)=0$$/\1-/;s/^\([A-Z]*\)=1$$/\1+/' <$< | tr '\n' ' ' | sed 's/ *$$//' | tr -d '\n' >>$@
33 33
 	echo '"' >>$@
34
-	grep '^VERSION_[A-Z]*=[0-9]*' ../version.mk | sed 's/^/#define BLINKENLIB_/;s/=/ /' >>$@
34
+	grep '^VERSION_[A-Z]*:=[0-9]*' ../version.mk | sed 's/^/#define BLINKENLIB_/;s/:=/ /' >>$@
35 35
 
36 36
 clean:
37 37
 	rm -f *.cfg config.mk config.h
... ...
@@ -3,35 +3,35 @@
3 3
 # Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4 4
 # a blinkenarea.org project
5 5
 
6
-INSTALL=install
6
+INSTALL:=install
7 7
 
8 8
 include ../version.mk
9 9
 include ../config/config.mk
10 10
 
11 11
 ifeq ($(BLINKENLIB_CFG_OSX),1)
12
-SHLIBEXT=dylib
12
+SHLIBEXT:=dylib
13 13
 else
14
-SHLIBEXT=so
14
+SHLIBEXT:=so
15 15
 endif
16 16
 
17
-ENV_PREFIX=$(shell echo $$PREFIX)
18
-STOW_DIR=/usr/local/stow
19
-STOW_PREFIX=$(STOW_DIR)/BlinkenLib-$(VERSION)
20
-DEF_PREFIX=/usr/local
17
+ENV_PREFIX:=$(shell echo $$PREFIX)
18
+STOW_DIR:=/usr/local/stow
19
+STOW_PREFIX:=$(STOW_DIR)/BlinkenLib-$(VERSION)
20
+DEF_PREFIX:=/usr/local
21 21
 ifneq ($(ENV_PREFIX),)
22
-  PREFIX=$(ENV_PREFIX)
22
+  PREFIX:=$(ENV_PREFIX)
23 23
 else
24 24
   ifeq ($(shell if [ -d $(STOW_DIR) ]; then echo stow; fi),stow)
25
-    PREFIX=$(STOW_PREFIX)
25
+    PREFIX:=$(STOW_PREFIX)
26 26
   else
27
-    PREFIX=$(DEF_PREFIX)
27
+    PREFIX:=$(DEF_PREFIX)
28 28
   endif
29 29
 endif
30 30
 
31
-HEADERS=BlinkenLib.h BlinkenMovie.h BlinkenFrame.h BlinkenColorizer.h \
31
+HEADERS:=BlinkenLib.h BlinkenMovie.h BlinkenFrame.h BlinkenColorizer.h \
32 32
          BlinkenProto.h config.h
33
-LIBS=libBlinkenLib.a libBlinkenLib.$(SHLIBEXT).$(VERSION)
34
-EXECS=BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput
33
+LIBS:=libBlinkenLib.a libBlinkenLib.$(SHLIBEXT).$(VERSION)
34
+EXECS:=BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput
35 35
 
36 36
 .phony: install uninstall
37 37
 
... ...
@@ -1,5 +1,5 @@
1
-VERSION_MAJOR=0
2
-VERSION_MINOR=7
3
-VERSION_REVISION=4
4
-VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
1
+VERSION_MAJOR:=0
2
+VERSION_MINOR:=7
3
+VERSION_REVISION:=5
4
+VERSION:=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
5 5
 
6 6