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