Browse Source

Changes to build/make for cross-compiling on non RPi hosts.

pull/61/head
grumpy-dude 6 years ago
parent
commit
0f5b302b75
5 changed files with 260 additions and 164 deletions
  1. +4
    -11
      README.TXT
  2. +41
    -22
      build
  3. +77
    -48
      devLib/Makefile
  4. +62
    -30
      gpio/Makefile
  5. +76
    -53
      wiringPi/Makefile

+ 4
- 11
README.TXT View File

@@ -1,13 +1,12 @@
Note
====

This is an unofficial mirror of WiringPi to support ports (Python/Ruby/etc).
This is an unofficial mirror of WiringPi.

Please do not email Gordon if you have issues, he will not be able to help.

Pull-requests are not currently accepted, since this is a mirror.

For support, comments, questions, etc please join the WiringPi Discord channel: https://discord.gg/SM4WUVG

wiringPi README
===============
@@ -19,18 +18,12 @@ ie.

git clone git://git.drogon.net/wiringPi

The version of wiringPi held on GitHub by "Gadgetoid" is used to build the
wiringPython, Ruby, Perl, etc. wrappers for these other languages. This
version may lag the official Drogon release. Pull requests may not be
This version may lag the official Drogon release. Pull requests may not be
accepted to Github....

Please see

http://wiringpi.com/

for the official documentation, etc. and the best way to submit bug reports, etc.
is by sending an email to projects@drogon.net

Thanks!

-Gordon
for the official documentation, etc. and the best way to submit bug reports,
etc. for the official code is by sending an email to projects@drogon.net

+ 41
- 22
build View File

@@ -31,6 +31,25 @@
# back into education!
#################################################################################

# NOTE: Windows Msys/mingw environment not currently usable - suggest WSL
# (Windows Subsystem for Linux) for cross-compiling on Windows hosts

GCCTARGET=`gcc -dumpmachine`
BUILDTYPE='CROSS'
INVOKESU=sudo

case "$GCCTARGET" in
arm-linux-gnueabihf)
BUILDTYPE='NATIVE';;
# *mingw*)
# INVOKESU= ;;
esac

echo "gcc default architecture: $GCCTARGET"
echo "Build type: $BUILDTYPE"
echo ""


check_make_ok() {
if [ $? != 0 ]; then
echo ""
@@ -43,7 +62,6 @@ check_make_ok() {
fi
}

sudo=${WIRINGPI_SUDO-sudo}

if [ x$1 = "xclean" ]; then
cd wiringPi
@@ -72,32 +90,33 @@ fi

if [ x$1 = "xuninstall" ]; then
cd wiringPi
echo -n "wiringPi: " ; $sudo make uninstall
echo -n "wiringPi: " ; $INVOKESU make uninstall
cd ../devLib
echo -n "DevLib: " ; $sudo make uninstall
echo -n "DevLib: " ; $INVOKESU make uninstall
cd ../gpio
echo -n "gpio: " ; $sudo make uninstall
echo -n "gpio: " ; $INVOKESU make uninstall
exit
fi


# Only if you know what you're doing!

if [ x$1 = "xdebian" ]; then
here=`pwd`
cd debian-template/wiringPi
rm -rf usr
cd $here/wiringPi
cd ../../wiringPi
make install-deb
cd $here/devLib
cd ../devLib
make install-deb INCLUDE='-I. -I../wiringPi'
cd $here/gpio
cd ../gpio
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
cd $here/debian-template
cd ../debian-template
fakeroot dpkg-deb --build wiringPi
mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
mv wiringPi.deb wiringpi-`cat ../VERSION`-1.deb
exit
fi


if [ x$1 != "x" ]; then
echo "Usage: $0 [clean | uninstall]"
exit 1
@@ -107,7 +126,7 @@ fi
echo "====================="
echo

hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
# hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`

# if [ x$hardware != "xBCM2708" ]; then
# echo ""
@@ -126,41 +145,41 @@ fi


echo
echo "WiringPi Library"
echo "--- WiringPi Library"
cd wiringPi
$sudo make uninstall
$INVOKESU make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
$INVOKESU make install-static
else
make -j5
check_make_ok
$sudo make install
$INVOKESU make install
fi
check_make_ok

echo
echo "WiringPi Devices Library"
echo "--- WiringPi Devices Library"
cd ../devLib
$sudo make uninstall
$INVOKESU make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
$INVOKESU make install-static
else
make -j5
check_make_ok
$sudo make install
$INVOKESU make install
fi
check_make_ok

echo
echo "GPIO Utility"
echo "--- GPIO Utility"
cd ../gpio
make -j5
check_make_ok
$sudo make install
$INVOKESU make install
check_make_ok

# echo
@@ -168,7 +187,7 @@ fi
# cd ../wiringPiD
# make -j5
# check_make_ok
# $sudo make install
# $INVOKESU make install
# check_make_ok

# echo


+ 77
- 48
devLib/Makefile View File

@@ -20,112 +20,141 @@
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
PROJECT = wiringPi
VERSION = $(shell cat ../VERSION)

VERSION=$(shell cat ../VERSION)
DESTDIR?=/usr
PREFIX?=/local

LDCONFIG?=ldconfig
BASE_INSTALL_DIR ?= usr/
LOCAL_INSTALL_DIR ?= local/
PROJ_INSTALL_DIR ?= $(PROJECT)/
ARCHITECTURE_INSTALL_DIR ?= armhf/

PUBLIC_INCLUDE_DIR = /$(BASE_INSTALL_DIR)include/
PUBLIC_LIB_DIR = /$(BASE_INSTALL_DIR)lib/
LOCAL_INCLUDE_DIR = /$(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)include/
LOCAL_LIB_DIR = /$(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)lib/$(PROJ_INSTALL_DIR)/$(ARCHITECTURE_INSTALL_DIR)

DEB_TEMPLATE_DIR = ../debian-template/$(PROJECT)/


LDCONFIG ?= ldconfig


ifneq ($V,1)
Q ?= @
endif

STATIC=libwiringPiDev.a
DYNAMIC=libwiringPiDev.so.$(VERSION)

#DEBUG = -g -O0
DEBUG = -O2
CC = gcc
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
STATIC_LIB = lib$(PROJECT)Dev.a
DYNAMIC_LIB = lib$(PROJECT)Dev.so


CC = arm-linux-gnueabihf-gcc
#DEBUG = -g -O0
DEBUG = -O2
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
LIBS =

###############################################################################

SRC = ds1302.c maxdetect.c piNes.c \
gertboard.c piFace.c \
lcd128x64.c lcd.c \
scrollPhat.c \
piGlow.c
SOURCES = ds1302.c maxdetect.c piNes.c \
gertboard.c piFace.c \
lcd128x64.c lcd.c \
scrollPhat.c \
piGlow.c

OBJS = $(SOURCES:.c=.o)

HEADERS = ds1302.h gertboard.h lcd128x64.h lcd.h maxdetect.h piFace.h piGlow.h piNes.h \
scrollPhat.h

OBJ = $(SRC:.c=.o)

HEADERS = ds1302.h gertboard.h lcd128x64.h lcd.h maxdetect.h piFace.h piGlow.h piNes.h\
scrollPhat.h
all: $(DYNAMIC_LIB).$(VERSION)

all: $(DYNAMIC)

static: $(STATIC)
static: $(STATIC_LIB)

$(STATIC): $(OBJ)

$(STATIC_LIB): $(OBJS)
$Q echo "[Link (Static)]"
$Q ar rcs $(STATIC) $(OBJ)
$Q ranlib $(STATIC)
# @size $(STATIC)
$Q ar rcs $(STATIC_LIB) $(OBJS)
$Q ranlib $(STATIC_LIB)
# @size $(STATIC_LIB)


$(DYNAMIC): $(OBJ)
$(DYNAMIC_LIB).$(VERSION): $(OBJS)
$Q echo "[Link (Dynamic)]"
$Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
$Q $(CC) -shared -Wl,-soname,$(DYNAMIC_LIB)$(WIRINGPI_SONAME_SUFFIX) -o $(DYNAMIC_LIB).$(VERSION) -lpthread $(OBJS)


.c.o:
$Q echo [Compile] $<
$Q $(CC) -c $(CFLAGS) $< -o $@


.PHONY: clean
clean:
$Q echo "[Clean]"
$Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.*
$Q rm -f $(OBJS) $(OBJ_I2C) *~ core tags Makefile.bak lib$(PROJECT)Dev*.*


.PHONY: tags
tags: $(SRC)
$Q echo [ctags]
$Q ctags $(SRC)
$Q ctags $(SOURCES)


.PHONY: install
install: $(DYNAMIC)
install: $(DYNAMIC_LIB).$(VERSION)
$Q echo "[Install Headers]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
$Q install -m 0755 -d $(LOCAL_INCLUDE_DIR)
$Q install -m 0644 $(HEADERS) $(LOCAL_INCLUDE_DIR)

$Q echo "[Install Dynamic Lib]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so
$Q install -m 0755 -d $(LOCAL_LIB_DIR)
$Q install -m 0755 $(DYNAMIC_LIB).$(VERSION) $(LOCAL_LIB_DIR)$(DYNAMIC_LIB).$(VERSION)
$Q ln -sf $(LOCAL_LIB_DIR)$(DYNAMIC_LIB).$(VERSION) $(PUBLIC_LIB_DIR)$(DYNAMIC_LIB)
$Q $(LDCONFIG)


.PHONY: install-static
install-static: $(STATIC)
$Q echo "[Install Headers]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
$Q install -m 0755 -d $(LOCAL_INCLUDE_DIR)
$Q install -m 0644 $(HEADERS) $(LOCAL_INCLUDE_DIR)

$Q echo "[Install Static Lib]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 -d $(LOCAL_LIB_DIR)
$Q install -m 0755 $(STATIC_LIB) $(LOCAL_LIB_DIR)


.PHONY: install-deb
install-deb: $(DYNAMIC)
$Q echo "[Install Headers: deb]"
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include
$Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include
$Q install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_INCLUDE_DIR)
$Q install -m 0644 $(HEADERS) $(DEB_TEMPLATE_DIR)$(PUBLIC_INCLUDE_DIR)

$Q echo "[Install Dynamic Lib: deb]"
install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib
install -m 0755 libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so
install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)
install -m 0755 $(DYNAMIC_LIB).$(VERSION) $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)/$(DYNAMIC_LIB).$(VERSION)
ln -sf $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)/$(DYNAMIC_LIB).$(VERSION) $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)/$(DYNAMIC_LIB)


.PHONY: uninstall
uninstall:
$Q echo "[UnInstall]"
$Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
$Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPiDev.*
$Q cd $(LOCAL_INCLUDE_DIR) && rm -f $(HEADERS)
$Q if [ -d "$(LOCAL_LIB_DIR)" ]; then cd $(LOCAL_LIB_DIR) && rm -f $(DYNAMIC_LIB).* && rm -f $(STATIC_LIB).*; fi
$Q cd $(PUBLIC_LIB_DIR) && rm -f $(DYNAMIC_LIB)
$Q $(LDCONFIG)


.PHONY: depend
depend:
makedepend -Y $(SRC)
makedepend -Y $(SOURCES)


# DO NOT DELETE



+ 62
- 30
gpio/Makefile View File

@@ -22,81 +22,113 @@
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
PROJECT = wiringPi
VERSION = $(shell cat ../VERSION)


BASE_INSTALL_DIR ?= usr/
LOCAL_INSTALL_DIR ?= local/
PROJ_INSTALL_DIR ?= $(PROJECT)/
ARCHITECTURE_INSTALL_DIR ?= armhf/

PUBLIC_BIN_DIR = $(BASE_INSTALL_DIR)bin/
PUBLIC_INCLUDE_DIR = $(BASE_INSTALL_DIR)include/
PUBLIC_LIB_DIR = $(BASE_INSTALL_DIR)lib/
PUBLIC_MAN_DIR = $(BASE_INSTALL_DIR)share/man/man1/

LOCAL_BIN_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)bin/
LOCAL_INCLUDE_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)include/
LOCAL_LIB_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)lib/$(PROJ_INSTALL_DIR)/$(ARCHITECTURE_INSTALL_DIR)
LOCAL_MAN_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)share/man/man1/

DEB_TEMPLATE_DIR = ../debian-template/$(PROJECT)/

DESTDIR?=/usr
PREFIX?=/local

ifneq ($V,1)
Q ?= @
endif

#DEBUG = -g -O0
DEBUG = -O2
CC = gcc
INCLUDE = -I$(DESTDIR)$(PREFIX)/include
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe

LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
CC = arm-linux-gnueabihf-gcc
#DEBUG = -g -O0
DEBUG = -O2
INCLUDE = -I/$(LOCAL_INCLUDE_DIR)
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
LDFLAGS = -L/$(LOCAL_LIB_DIR)
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt

# May not need to alter anything below this line
###############################################################################
SOURCES = gpio.c readall.c

SRC = gpio.c readall.c
OBJS = $(SOURCES:.c=.o)

OBJ = $(SRC:.c=.o)

all: gpio

version.h: ../VERSION
$Q echo Need to run newVersion above.

gpio: $(OBJ)

gpio: $(OBJS)
$Q echo [Link]
$Q $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS)
$Q $(CC) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)


.c.o:
$Q echo [Compile] $<
$Q $(CC) -c $(CFLAGS) $< -o $@


.PHONY: clean
clean:
$Q echo "[Clean]"
$Q rm -f $(OBJ) gpio *~ core tags *.bak
$Q rm -f $(OBJS) gpio *~ core tags *.bak


.PHONY: tags
tags: $(SRC)
tags: $(SOURCES)
$Q echo [ctags]
$Q ctags $(SRC)
$Q ctags $(SOURCES)


.PHONY: install
install: gpio
$Q echo "[Install]"
$Q cp gpio $(DESTDIR)$(PREFIX)/bin
ifneq ($(WIRINGPI_SUID),0)
$Q chown root.root $(DESTDIR)$(PREFIX)/bin/gpio
$Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio
endif
$Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
$Q cp gpio.1 $(DESTDIR)$(PREFIX)/share/man/man1
$Q if [ "$(shell gcc -dumpmachine)" != "arm-linux-gnueabihf" ]; then \
echo " *** Cross-build environment, NOT installing binaries ***"; \
else \
cp gpio /$(LOCAL_BIN_DIR); \
if [ "$(WIRINGPI_SUID)" != "0" ]; then \
chown root.root /$(LOCAL_BIN_DIR)gpio; \
chmod 4755 /$(LOCAL_BIN_DIR)gpio; \
fi; \
mkdir -p /$(LOCAL_MAN_DIR); \
cp gpio.1 /$(LOCAL_MAN_DIR); \
fi;


.PHONY: install-deb
install-deb: gpio
$Q echo "[Install: deb]"
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/bin
$Q install -m 0755 gpio ~/wiringPi/debian-template/wiringPi/usr/bin
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/share/man/man1
$Q install -m 0644 gpio.1 ~/wiringPi/debian-template/wiringPi/usr/share/man/man1
$Q install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_BIN_DIR)
$Q install -m 0755 gpio $(DEB_TEMPLATE_DIR)$(PUBLIC_BIN_DIR)
$Q install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_MAN_DIR)
$Q install -m 0644 gpio.1 $(DEB_TEMPLATE_DIR)$(PUBLIC_MAN_DIR)


.PHONY: uninstall
uninstall:
$Q echo "[UnInstall]"
$Q rm -f $(DESTDIR)$(PREFIX)/bin/gpio
$Q rm -f $(DESTDIR)$(PREFIX)/share/man/man1/gpio.1
$Q rm -f /$(LOCAL_BIN_DIR)gpio
$Q rm -f /$(LOCAL_MAN_DIR)gpio.1


.PHONY: depend
depend:
makedepend -Y $(SRC)
makedepend -Y $(SOURCES)


# DO NOT DELETE



+ 76
- 53
wiringPi/Makefile View File

@@ -20,62 +20,80 @@
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
PROJECT = wiringPi
VERSION = $(shell cat ../VERSION)

VERSION=$(shell cat ../VERSION)
DESTDIR?=/usr
PREFIX?=/local

LDCONFIG?=ldconfig
BASE_INSTALL_DIR ?= usr/
LOCAL_INSTALL_DIR ?= local/
PROJ_INSTALL_DIR ?= $(PROJECT)/
ARCHITECTURE_INSTALL_DIR ?= armhf/

PUBLIC_INCLUDE_DIR = $(BASE_INSTALL_DIR)include/
PUBLIC_LIB_DIR = $(BASE_INSTALL_DIR)lib/
LOCAL_INCLUDE_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)include/
LOCAL_LIB_DIR = $(BASE_INSTALL_DIR)$(LOCAL_INSTALL_DIR)lib/$(PROJ_INSTALL_DIR)$(ARCHITECTURE_INSTALL_DIR)

DEB_TEMPLATE_DIR = ../debian-template/$(PROJECT)/


LDCONFIG ?= ldconfig


ifneq ($V,1)
Q ?= @
endif

STATIC=libwiringPi.a
DYNAMIC=libwiringPi.so.$(VERSION)

#DEBUG = -g -O0
DEBUG = -O2
CC = gcc
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
#CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC
STATIC_LIB = lib$(PROJECT).a
DYNAMIC_LIB = lib$(PROJECT).so


LIBS = -lm -lpthread -lrt -lcrypt
CC = arm-linux-gnueabihf-gcc
#DEBUG = -g -O0
DEBUG = -O2
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
#CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC
LIBS = -lm -lpthread -lrt -lcrypt

###############################################################################

SRC = wiringPi.c \
wiringSerial.c wiringShift.c \
piHiPri.c piThread.c \
wiringPiSPI.c wiringPiI2C.c \
softPwm.c softTone.c \
mcp23008.c mcp23016.c mcp23017.c \
mcp23s08.c mcp23s17.c \
sr595.c \
pcf8574.c pcf8591.c \
mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
max31855.c max5322.c ads1115.c \
sn3218.c \
bmp180.c htu21d.c ds18b20.c rht03.c \
drcSerial.c drcNet.c \
pseudoPins.c \
wpiExtensions.c
SOURCES = wiringPi.c \
wiringSerial.c wiringShift.c \
piHiPri.c piThread.c \
wiringPiSPI.c wiringPiI2C.c \
softPwm.c softTone.c \
mcp23008.c mcp23016.c mcp23017.c \
mcp23s08.c mcp23s17.c \
sr595.c \
pcf8574.c pcf8591.c \
mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
max31855.c max5322.c ads1115.c \
sn3218.c \
bmp180.c htu21d.c ds18b20.c rht03.c \
drcSerial.c drcNet.c \
pseudoPins.c \
wpiExtensions.c

HEADERS = $(shell ls *.h)

OBJ = $(SRC:.c=.o)
OBJS = $(SOURCES:.c=.o)


all: $(DYNAMIC_LIB).$(VERSION)

all: $(DYNAMIC)

.PHONY: static
static:
$Q cat noMoreStatic
$Q cat noMoreStatic

$(DYNAMIC): $(OBJ)

$(DYNAMIC_LIB).$(VERSION): $(OBJS)
$Q echo "[Link (Dynamic)]"
$Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(LIBS) $(OBJ)
$Q $(CC) -shared -Wl,-soname,$(DYNAMIC_LIB)$(WIRINGPI_SONAME_SUFFIX) -o $(DYNAMIC_LIB).$(VERSION) $(LIBS) $(OBJS)


.c.o:
$Q echo [Compile] $<
@@ -85,46 +103,51 @@ $(DYNAMIC): $(OBJ)
.PHONY: clean
clean:
$Q echo "[Clean]"
$Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
$Q rm -f $(OBJS) $(OBJ_I2C) *~ core tags Makefile.bak lib$(PROJECT).*


.PHONY: tags
tags: $(SRC)
tags: $(SOURCES)
$Q echo [ctags]
$Q ctags $(SRC)
$Q ctags $(SOURCES)


.PHONY: install
install: $(DYNAMIC)
install: $(DYNAMIC_LIB).$(VERSION)
$Q echo "[Install Headers]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
$Q install -m 0644 $(HEADERS) /$(PUBLIC_INCLUDE_DIR)
$Q echo "[Install Dynamic Lib]"
$Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
$Q install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
$Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
$Q install -m 0755 -d /$(LOCAL_LIB_DIR)
$Q install -m 0755 $(DYNAMIC_LIB).$(VERSION) /$(LOCAL_LIB_DIR)$(DYNAMIC_LIB).$(VERSION)
$Q ln -sf /$(LOCAL_LIB_DIR)$(DYNAMIC_LIB).$(VERSION) /$(PUBLIC_LIB_DIR)$(DYNAMIC_LIB)
$Q $(LDCONFIG)


.PHONY: install-deb
install-deb: $(DYNAMIC)
install-deb: $(DYNAMIC_LIB).$(VERSION)
$Q echo "[Install Headers: deb]"
$Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include
$Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include
$Q install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_INCLUDE_DIR)
$Q install -m 0644 $(HEADERS) $(DEB_TEMPLATE_DIR)$(PUBLIC_INCLUDE_DIR)

$Q echo "[Install Dynamic Lib: deb]"
install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib
install -m 0755 libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)
ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so
install -m 0755 -d $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)
install -m 0755 libwiringPi.so.$(VERSION) $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)$(DYNAMIC_LIB).$(VERSION)
ln -sf $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)$(DYNAMIC_LIB).$(VERSION) $(DEB_TEMPLATE_DIR)$(PUBLIC_LIB_DIR)$(DYNAMIC_LIB)


.PHONY: uninstall
uninstall:
$Q echo "[UnInstall]"
$Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
$Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.*
$Q cd /$(PUBLIC_INCLUDE_DIR) && rm -f $(HEADERS)
$Q if [ -d "/$(LOCAL_LIB_DIR)" ]; then cd /$(LOCAL_LIB_DIR) && rm -f $(DYNAMIC_LIB).*; fi;
$Q cd /$(PUBLIC_LIB_DIR) && rm -f $(DYNAMIC_LIB)
$Q $(LDCONFIG)


.PHONY: depend
depend:
makedepend -Y $(SRC) $(SRC_I2C)
makedepend -Y $(SOURCES) $(SRC_I2C)

# DO NOT DELETE



Loading…
Cancel
Save