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