Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | From ca25788e2563bad0d554deb9f4300d1e7d062825 Mon Sep 17 00:00:00 2001 |
| 2 | From: Aurelian Zanoschi <aurelian17@gmail.com> |
| 3 | Date: Mon, 31 Jul 2017 20:25:15 +0300 |
| 4 | Subject: [PATCH] Add initial cross compile support |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 5 | |
| 6 | --- |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | devLib/Makefile | 54 +++++++++++++++++++++++++-------------------- |
| 8 | examples/Gertboard/Makefile | 22 +++++++++++------- |
| 9 | examples/Makefile | 22 +++++++++++------- |
| 10 | examples/PiFace/Makefile | 22 +++++++++++------- |
| 11 | examples/PiGlow/Makefile | 4 ++-- |
| 12 | examples/q2w/Makefile | 4 ++-- |
| 13 | gpio/Makefile | 29 ++++++++++++------------ |
| 14 | wiringPi/Makefile | 52 ++++++++++++++++++++++++------------------- |
| 15 | 8 files changed, 120 insertions(+), 89 deletions(-) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 16 | |
| 17 | diff --git a/devLib/Makefile b/devLib/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 18 | index cf665d6..040c03a 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 19 | --- a/devLib/Makefile |
| 20 | +++ b/devLib/Makefile |
| 21 | @@ -31,15 +31,19 @@ ifneq ($V,1) |
| 22 | Q ?= @ |
| 23 | endif |
| 24 | |
| 25 | -STATIC=libwiringPiDev.a |
| 26 | -DYNAMIC=libwiringPiDev.so.$(VERSION) |
| 27 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 28 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 29 | |
| 30 | -#DEBUG = -g -O0 |
| 31 | -DEBUG = -O2 |
| 32 | -CC = gcc |
| 33 | -INCLUDE = -I. |
| 34 | -DEFS = -D_GNU_SOURCE |
| 35 | -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC |
| 36 | +BASE_NAME=libwiringPiDev |
| 37 | +STATIC=$(BASE_NAME).a |
| 38 | +DYNAMIC=$(BASE_NAME).so.$(VERSION) |
| 39 | + |
| 40 | +#DEBUG ?= -g -O0 |
| 41 | +DEBUG ?= -O2 |
| 42 | +CC ?= gcc |
| 43 | +INCLUDE ?= -I. |
| 44 | +DEFS ?= -D_GNU_SOURCE |
| 45 | +CFLAGS ?= $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC |
| 46 | |
| 47 | LIBS = |
| 48 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | @@ -68,16 +72,16 @@ $(STATIC): $(OBJ) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 50 | |
| 51 | $(DYNAMIC): $(OBJ) |
| 52 | $Q echo "[Link (Dynamic)]" |
| 53 | - $Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ) |
Patrick Williams | b2e6a9b | 2017-02-23 20:31:26 -0600 | [diff] [blame] | 54 | + $Q $(CC) -shared $(LDFLAGS) -Wl,-soname,$(BASE_NAME).so.$(DYN_VERS_MAJ) -o $(BASE_NAME).so -lpthread $(OBJ) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 55 | |
| 56 | .c.o: |
| 57 | $Q echo [Compile] $< |
| 58 | - $Q $(CC) -c $(CFLAGS) $< -o $@ |
| 59 | + $Q $(CC) -c $(CFLAGS) -fPIC $< -o $@ |
| 60 | |
| 61 | .PHONY: clean |
| 62 | clean: |
| 63 | $Q echo "[Clean]" |
| 64 | - $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.* |
| 65 | + $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak $(BASE_NAME).so* $(BASE_NAME).a |
| 66 | |
| 67 | .PHONY: tags |
| 68 | tags: $(SRC) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 69 | @@ -88,22 +92,22 @@ tags: $(SRC) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 70 | .PHONY: install |
| 71 | install: $(DYNAMIC) |
| 72 | $Q echo "[Install Headers]" |
| 73 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include |
| 74 | - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include |
| 75 | + $Q install -m 0755 -d $(INCLUDE_DIR) |
| 76 | + $Q install -m 0644 $(HEADERS) $(INCLUDE_DIR) |
| 77 | $Q echo "[Install Dynamic Lib]" |
| 78 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib |
| 79 | - $Q install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) |
| 80 | - $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so |
| 81 | - $Q $(LDCONFIG) |
| 82 | + $Q install -m 0755 -d $(LIB_DIR) |
| 83 | + $Q install -m 0755 $(BASE_NAME).so $(LIB_DIR)/$(DYNAMIC) |
| 84 | + $Q ln -sf $(DYNAMIC) $(LIB_DIR)/$(BASE_NAME).so |
| 85 | + $Q ln -sf $(DYNAMIC) $(LIB_DIR)/$(BASE_NAME).so.$(DYN_VERS_MAJ) |
| 86 | |
| 87 | .PHONY: install-static |
| 88 | install-static: $(STATIC) |
| 89 | $Q echo "[Install Headers]" |
| 90 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include |
| 91 | - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include |
| 92 | + $Q install -m 0755 -d $(INCLUDE_DIR) |
| 93 | + $Q install -m 0644 $(HEADERS) $(INCLUDE_DIR) |
| 94 | $Q echo "[Install Static Lib]" |
| 95 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib |
| 96 | - $Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib |
| 97 | + $Q install -m 0755 -d $(LIB_DIR) |
| 98 | + $Q install -m 0755 $(STATIC) $(LIB_DIR) |
| 99 | |
| 100 | .PHONY: install-deb |
| 101 | install-deb: $(DYNAMIC) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | @@ -118,9 +122,11 @@ install-deb: $(DYNAMIC) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 103 | .PHONY: uninstall |
| 104 | uninstall: |
| 105 | $Q echo "[UnInstall]" |
| 106 | - $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS) |
| 107 | - $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPiDev.* |
| 108 | - $Q $(LDCONFIG) |
| 109 | + $Q cd $(INCLUDE_DIR) && rm -f $(HEADERS) |
| 110 | + $Q rm -f $(LIB_DIR)/$(STATIC) |
| 111 | + $Q rm -f $(LIB_DIR)/$(DYNAMIC) |
| 112 | + $Q rm -f $(LIB_DIR)/$(BASE_NAME).so |
| 113 | + $Q rm -f $(LIB_DIR)/$(BASE_NAME).so.$(DYN_VERS_MAJ) |
| 114 | |
| 115 | |
| 116 | .PHONY: depend |
| 117 | diff --git a/examples/Gertboard/Makefile b/examples/Gertboard/Makefile |
| 118 | index 1939ad6..98d1415 100644 |
| 119 | --- a/examples/Gertboard/Makefile |
| 120 | +++ b/examples/Gertboard/Makefile |
| 121 | @@ -9,14 +9,20 @@ ifneq ($V,1) |
| 122 | Q ?= @ |
| 123 | endif |
| 124 | |
| 125 | -#DEBUG = -g -O0 |
| 126 | -DEBUG = -O3 |
| 127 | -CC = gcc |
| 128 | -INCLUDE = -I/usr/local/include |
| 129 | -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 130 | - |
| 131 | -LDFLAGS = -L/usr/local/lib |
| 132 | -LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm |
| 133 | +DESTDIR?=/usr |
| 134 | +PREFIX?=/local |
| 135 | + |
| 136 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 137 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 138 | + |
| 139 | +#DEBUG ?= -g -O0 |
| 140 | +DEBUG ?= -O3 |
| 141 | +CC ?= gcc |
| 142 | +INCLUDE ?= -I$(INCLUDE_DIR) |
| 143 | +CFLAGS ?= $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 144 | + |
| 145 | +LDFLAGS ?= -L$(LIB_DIR) |
| 146 | +LDLIBS ?= -lwiringPi -lwiringPiDev -lpthread -lm |
| 147 | |
| 148 | # Should not alter anything below this line |
| 149 | ############################################################################### |
| 150 | diff --git a/examples/Makefile b/examples/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 151 | index 6d87885..8623816 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 152 | --- a/examples/Makefile |
| 153 | +++ b/examples/Makefile |
| 154 | @@ -26,14 +26,20 @@ ifneq ($V,1) |
| 155 | Q ?= @ |
| 156 | endif |
| 157 | |
| 158 | -#DEBUG = -g -O0 |
| 159 | -DEBUG = -O3 |
| 160 | -CC = gcc |
| 161 | -INCLUDE = -I/usr/local/include |
| 162 | -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 163 | - |
| 164 | -LDFLAGS = -L/usr/local/lib |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 165 | -LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 166 | +DESTDIR?=/usr |
| 167 | +PREFIX?=/local |
| 168 | + |
| 169 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 170 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 171 | + |
| 172 | +#DEBUG ?= -g -O0 |
| 173 | +DEBUG ?= -O3 |
| 174 | +CC ?= gcc |
| 175 | +INCLUDE ?= -I$(INCLUDE_DIR) |
| 176 | +CFLAGS ?= $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 177 | + |
| 178 | +LDFLAGS ?= -L$(LIB_DIR) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 179 | +LDLIBS ?= -lwiringPi -lwiringPiDev -lpthread -lm -lcrypt -lrt |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 180 | |
| 181 | # Should not alter anything below this line |
| 182 | ############################################################################### |
| 183 | diff --git a/examples/PiFace/Makefile b/examples/PiFace/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 184 | index f937c14..ad030b3 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 185 | --- a/examples/PiFace/Makefile |
| 186 | +++ b/examples/PiFace/Makefile |
| 187 | @@ -26,14 +26,20 @@ ifneq ($V,1) |
| 188 | Q ?= @ |
| 189 | endif |
| 190 | |
| 191 | -#DEBUG = -g -O0 |
| 192 | -DEBUG = -O3 |
| 193 | -CC = gcc |
| 194 | -INCLUDE = -I/usr/local/include |
| 195 | -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 196 | - |
| 197 | -LDFLAGS = -L/usr/local/lib |
| 198 | -LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm |
| 199 | +DESTDIR?=/usr |
| 200 | +PREFIX?=/local |
| 201 | + |
| 202 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 203 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 204 | + |
| 205 | +#DEBUG ?= -g -O0 |
| 206 | +DEBUG ?= -O3 |
| 207 | +CC ?= gcc |
| 208 | +INCLUDE ?= -I$(INCLUDE_DIR) |
| 209 | +CFLAGS ?= $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 210 | + |
| 211 | +LDFLAGS ?= -L$(LIB_DIR) |
| 212 | +LDLIBS ?= -lwiringPi -lwiringPiDev -lpthread -lm |
| 213 | |
| 214 | # Should not alter anything below this line |
| 215 | ############################################################################### |
| 216 | diff --git a/examples/PiGlow/Makefile b/examples/PiGlow/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 217 | index f182db7..d1ea74f 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 218 | --- a/examples/PiGlow/Makefile |
| 219 | +++ b/examples/PiGlow/Makefile |
| 220 | @@ -29,10 +29,10 @@ endif |
| 221 | #DEBUG = -g -O0 |
| 222 | DEBUG = -O3 |
| 223 | CC = gcc |
| 224 | -INCLUDE = -I/usr/local/include |
| 225 | +INCLUDE = -I../wiringPi -I../wiringPiDev |
| 226 | CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 227 | |
| 228 | -LDFLAGS = -L/usr/local/lib |
| 229 | +LDFLAGS = -L../wiringPi -L../wiringPiDev |
| 230 | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm |
| 231 | |
| 232 | # Should not alter anything below this line |
| 233 | diff --git a/examples/q2w/Makefile b/examples/q2w/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 234 | index 8f773bf..14aa6e4 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 235 | --- a/examples/q2w/Makefile |
| 236 | +++ b/examples/q2w/Makefile |
| 237 | @@ -29,10 +29,10 @@ endif |
| 238 | #DEBUG = -g -O0 |
| 239 | DEBUG = -O3 |
| 240 | CC = gcc |
| 241 | -INCLUDE = -I/usr/local/include |
| 242 | +INCLUDE = -I../wiringPi -I../devLib |
| 243 | CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe |
| 244 | |
| 245 | -LDFLAGS = -L/usr/local/lib |
| 246 | +LDFLAGS = -L../wiringPi -L../devLib |
| 247 | LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm |
| 248 | |
| 249 | ############################################################################### |
| 250 | diff --git a/gpio/Makefile b/gpio/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 251 | index f41a005..22753ee 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 252 | --- a/gpio/Makefile |
| 253 | +++ b/gpio/Makefile |
| 254 | @@ -30,13 +30,17 @@ ifneq ($V,1) |
| 255 | Q ?= @ |
| 256 | endif |
| 257 | |
| 258 | -#DEBUG = -g -O0 |
| 259 | -DEBUG = -O2 |
| 260 | -CC = gcc |
| 261 | -INCLUDE = -I$(DESTDIR)$(PREFIX)/include |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 262 | -CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 263 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 264 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 265 | +BIN_DIR?=$(DESTDIR)$(PREFIX)/bin |
| 266 | |
| 267 | -LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib |
| 268 | +#DEBUG ?= -g -O0 |
| 269 | +DEBUG ?= -O2 |
| 270 | +CC ?= gcc |
| 271 | +INCLUDE ?= -I$(INCLUDE_DIR) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 272 | +CFLAGS ?= $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 273 | + |
| 274 | +LDFLAGS ?= -L$(LIB_DIR) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 275 | LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 276 | |
| 277 | # May not need to alter anything below this line |
| 278 | @@ -72,13 +76,10 @@ tags: $(SRC) |
| 279 | .PHONY: install |
| 280 | install: gpio |
| 281 | $Q echo "[Install]" |
| 282 | - $Q cp gpio $(DESTDIR)$(PREFIX)/bin |
| 283 | -ifneq ($(WIRINGPI_SUID),0) |
| 284 | - $Q chown root.root $(DESTDIR)$(PREFIX)/bin/gpio |
| 285 | - $Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio |
| 286 | -endif |
| 287 | - $Q mkdir -p $(DESTDIR)$(PREFIX)/man/man1 |
| 288 | - $Q cp gpio.1 $(DESTDIR)$(PREFIX)/man/man1 |
| 289 | + $Q install -d $(BIN_DIR) |
| 290 | + $Q install -m 4755 -o root -g root gpio $(BIN_DIR) |
| 291 | + $Q install -d $(DESTDIR)$(PREFIX)/share/man/man1 |
| 292 | + $Q install -m 644 -o root -g root gpio.1 $(DESTDIR)$(PREFIX)/share/man/man1 |
| 293 | |
| 294 | .PHONY: install-deb |
| 295 | install-deb: gpio |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 296 | @@ -91,7 +92,7 @@ install-deb: gpio |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 297 | .PHONY: uninstall |
| 298 | uninstall: |
| 299 | $Q echo "[UnInstall]" |
| 300 | - $Q rm -f $(DESTDIR)$(PREFIX)/bin/gpio |
| 301 | + $Q rm -f $(BIN_DIR)/gpio |
| 302 | $Q rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1 |
| 303 | |
| 304 | .PHONY: depend |
| 305 | diff --git a/wiringPi/Makefile b/wiringPi/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 306 | index e1868b9..750d290 100644 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 307 | --- a/wiringPi/Makefile |
| 308 | +++ b/wiringPi/Makefile |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 309 | @@ -25,21 +25,25 @@ VERSION=$(shell cat ../VERSION) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 310 | DESTDIR?=/usr |
| 311 | PREFIX?=/local |
| 312 | |
| 313 | +INCLUDE_DIR?=$(DESTDIR)$(PREFIX)/include |
| 314 | +LIB_DIR?=$(DESTDIR)$(PREFIX)/lib |
| 315 | + |
| 316 | LDCONFIG?=ldconfig |
| 317 | |
| 318 | ifneq ($V,1) |
| 319 | Q ?= @ |
| 320 | endif |
| 321 | |
| 322 | -STATIC=libwiringPi.a |
| 323 | -DYNAMIC=libwiringPi.so.$(VERSION) |
| 324 | +BASE_NAME=libwiringPi |
| 325 | +STATIC=$(BASE_NAME).a |
| 326 | +DYNAMIC=$(BASE_NAME).so.$(VERSION) |
| 327 | |
| 328 | -#DEBUG = -g -O0 |
| 329 | -DEBUG = -O2 |
| 330 | -CC = gcc |
| 331 | -INCLUDE = -I. |
| 332 | +#DEBUG ?= -g -O0 |
| 333 | +DEBUG ?= -O2 |
| 334 | +CC ?= gcc |
| 335 | +INCLUDE ?= -I. |
| 336 | DEFS = -D_GNU_SOURCE |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 337 | -CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC |
| 338 | +CFLAGS = $(DEBUG) $(DEFS) $(INCLUDE) -Wformat=2 -Wall -Wextra -Winline -pipe -fPIC |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 339 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 340 | LIBS = -lm -lpthread -lrt -lcrypt |
| 341 | |
| 342 | @@ -78,17 +82,17 @@ $(STATIC): $(OBJ) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 343 | |
| 344 | $(DYNAMIC): $(OBJ) |
| 345 | $Q echo "[Link (Dynamic)]" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 346 | - $Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(LIBS) $(OBJ) |
| 347 | + $Q $(CC) $(LDFLAGS) -shared -Wl,-soname,$(BASE_NAME).so.$(DYN_VERS_MAJ) -o $(BASE_NAME).so $(OBJ) $(LIBS) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 348 | |
| 349 | .c.o: |
| 350 | $Q echo [Compile] $< |
| 351 | - $Q $(CC) -c $(CFLAGS) $< -o $@ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 352 | + $Q $(CC) $(CFLAGS) $(LIBS) -c $< -o $@ |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 353 | |
| 354 | |
| 355 | .PHONY: clean |
| 356 | clean: |
| 357 | $Q echo "[Clean]" |
| 358 | - $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.* |
| 359 | + $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak $(BASE_NAME).so* $(BASE_NAME).a |
| 360 | |
| 361 | .PHONY: tags |
| 362 | tags: $(SRC) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 363 | @@ -99,22 +103,22 @@ tags: $(SRC) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 364 | .PHONY: install |
| 365 | install: $(DYNAMIC) |
| 366 | $Q echo "[Install Headers]" |
| 367 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include |
| 368 | - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include |
| 369 | + $Q install -m 0755 -d $(INCLUDE_DIR) |
| 370 | + $Q install -m 0644 $(HEADERS) $(INCLUDE_DIR) |
| 371 | $Q echo "[Install Dynamic Lib]" |
| 372 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib |
| 373 | - $Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) |
| 374 | - $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so |
| 375 | - $Q $(LDCONFIG) |
| 376 | + $Q install -m 0755 -d $(LIB_DIR) |
| 377 | + $Q install -m 0755 $(BASE_NAME).so $(LIB_DIR)/$(DYNAMIC) |
| 378 | + $Q ln -sf $(DYNAMIC) $(LIB_DIR)/$(BASE_NAME).so |
| 379 | + $Q ln -sf $(DYNAMIC) $(LIB_DIR)/$(BASE_NAME).so.$(DYN_VERS_MAJ) |
| 380 | |
| 381 | .PHONY: install-static |
| 382 | install-static: $(STATIC) |
| 383 | $Q echo "[Install Headers]" |
| 384 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include |
| 385 | - $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include |
| 386 | + $Q install -m 0755 -d $(INCLUDE_DIR) |
| 387 | + $Q install -m 0644 $(HEADERS) $(INCLUDE_DIR) |
| 388 | $Q echo "[Install Static Lib]" |
| 389 | - $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib |
| 390 | - $Q install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib |
| 391 | + $Q install -m 0755 -d $(LIB_DIR) |
| 392 | + $Q install -m 0755 $(STATIC) $(LIB_DIR) |
| 393 | |
| 394 | .PHONY: install-deb |
| 395 | install-deb: $(DYNAMIC) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 396 | @@ -129,9 +133,11 @@ install-deb: $(DYNAMIC) |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 397 | .PHONY: uninstall |
| 398 | uninstall: |
| 399 | $Q echo "[UnInstall]" |
| 400 | - $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS) |
| 401 | - $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.* |
| 402 | - $Q $(LDCONFIG) |
| 403 | + $Q cd $(INCLUDE_DIR) && rm -f $(HEADERS) |
| 404 | + $Q rm -f $(LIB_DIR)/$(STATIC) |
| 405 | + $Q rm -f $(LIB_DIR)/$(DYNAMIC) |
| 406 | + $Q rm -f $(LIB_DIR)/$(BASE_NAME).so |
| 407 | + $Q rm -f $(LIB_DIR)/$(BASE_NAME).so.$(DYN_VERS_MAJ) |
| 408 | |
| 409 | |
| 410 | .PHONY: depend |
| 411 | -- |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 412 | 2.7.4 |
Patrick Williams | 8b8bc41 | 2016-08-17 15:02:23 -0500 | [diff] [blame] | 413 | |