2015-02-02 22:11:28 +01:00
|
|
|
#
|
2016-10-30 18:50:49 +01:00
|
|
|
# Set CROSS_PREFIX to prepend to all compiler tools at once for easier
|
|
|
|
# cross-compilation.
|
|
|
|
CROSS_PREFIX =
|
|
|
|
CC = $(CROSS_PREFIX)gcc
|
|
|
|
AR = $(CROSS_PREFIX)ar
|
|
|
|
RANLIB = $(CROSS_PREFIX)ranlib
|
|
|
|
SIZE = $(CROSS_PREFIX)size
|
|
|
|
STRIP = $(CROSS_PREFIX)strip
|
|
|
|
SHLIB = $(CC) -shared
|
|
|
|
STRIPLIB = $(STRIP) --strip-unneeded
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2018-11-09 01:02:56 +01:00
|
|
|
SOVERSION = 1
|
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
CFLAGS += -O3 -Wall -pthread
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-05-27 21:00:26 +02:00
|
|
|
LIB1 = libpigpio.so
|
2014-01-12 22:31:59 +01:00
|
|
|
OBJ1 = pigpio.o command.o
|
2013-12-12 11:32:49 +01:00
|
|
|
|
2015-05-27 21:00:26 +02:00
|
|
|
LIB2 = libpigpiod_if.so
|
2014-01-12 22:31:59 +01:00
|
|
|
OBJ2 = pigpiod_if.o command.o
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
LIB3 = libpigpiod_if2.so
|
|
|
|
OBJ3 = pigpiod_if2.o command.o
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
LIB = $(LIB1) $(LIB2) $(LIB3)
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
ALL = $(LIB) x_pigpio x_pigpiod_if x_pigpiod_if2 pig2vcd pigpiod pigs
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
LL1 = -L. -lpigpio -pthread -lrt
|
|
|
|
|
|
|
|
LL2 = -L. -lpigpiod_if -pthread -lrt
|
|
|
|
|
|
|
|
LL3 = -L. -lpigpiod_if2 -pthread -lrt
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2015-12-22 17:44:27 +01:00
|
|
|
prefix = /usr/local
|
|
|
|
exec_prefix = $(prefix)
|
|
|
|
bindir = $(exec_prefix)/bin
|
|
|
|
includedir = $(prefix)/include
|
|
|
|
libdir = $(prefix)/lib
|
|
|
|
mandir = $(prefix)/man
|
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
all: $(ALL)
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2017-09-27 23:20:54 +02:00
|
|
|
lib: $(LIB)
|
|
|
|
|
2015-05-27 21:00:26 +02:00
|
|
|
pigpio.o: pigpio.c pigpio.h command.h custom.cext
|
|
|
|
$(CC) $(CFLAGS) -fpic -c -o pigpio.o pigpio.c
|
|
|
|
|
|
|
|
pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h
|
|
|
|
$(CC) $(CFLAGS) -fpic -c -o pigpiod_if.o pigpiod_if.c
|
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
pigpiod_if2.o: pigpiod_if2.c pigpio.h command.h pigpiod_if2.h
|
|
|
|
$(CC) $(CFLAGS) -fpic -c -o pigpiod_if2.o pigpiod_if2.c
|
|
|
|
|
2015-05-27 21:00:26 +02:00
|
|
|
command.o: command.c pigpio.h command.h
|
|
|
|
$(CC) $(CFLAGS) -fpic -c -o command.o command.c
|
|
|
|
|
2014-03-13 16:50:23 +01:00
|
|
|
x_pigpio: x_pigpio.o $(LIB1)
|
2015-05-27 21:00:26 +02:00
|
|
|
$(CC) -o x_pigpio x_pigpio.o $(LL1)
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
x_pigpiod_if: x_pigpiod_if.o $(LIB2)
|
2015-05-27 21:00:26 +02:00
|
|
|
$(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL2)
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
x_pigpiod_if2: x_pigpiod_if2.o $(LIB3)
|
|
|
|
$(CC) -o x_pigpiod_if2 x_pigpiod_if2.o $(LL3)
|
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
pigpiod: pigpiod.o $(LIB1)
|
2015-05-27 21:00:26 +02:00
|
|
|
$(CC) -o pigpiod pigpiod.o $(LL1)
|
2016-10-30 18:47:48 +01:00
|
|
|
$(STRIP) pigpiod
|
2014-01-12 22:31:59 +01:00
|
|
|
|
|
|
|
pigs: pigs.o command.o
|
2015-05-27 21:00:26 +02:00
|
|
|
$(CC) -o pigs pigs.o command.o
|
2016-10-30 18:47:48 +01:00
|
|
|
$(STRIP) pigs
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
pig2vcd: pig2vcd.o
|
2015-05-27 21:00:26 +02:00
|
|
|
$(CC) -o pig2vcd pig2vcd.o
|
2016-10-30 18:47:48 +01:00
|
|
|
$(STRIP) pig2vcd
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
clean:
|
2018-11-09 01:02:56 +01:00
|
|
|
rm -f *.o *.i *.s *~ $(ALL) *.so.$(SOVERSION)
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2018-11-09 01:30:58 +01:00
|
|
|
ifeq ($(DESTDIR),)
|
|
|
|
PYINSTALLARGS =
|
|
|
|
else
|
|
|
|
PYINSTALLARGS = --root=$(DESTDIR)
|
|
|
|
endif
|
|
|
|
|
2015-05-27 21:00:26 +02:00
|
|
|
install: $(ALL)
|
2018-11-09 01:02:56 +01:00
|
|
|
install -m 0755 -d $(DESTDIR)/opt/pigpio/cgi
|
|
|
|
install -m 0755 -d $(DESTDIR)$(includedir)
|
|
|
|
install -m 0644 pigpio.h $(DESTDIR)$(includedir)
|
|
|
|
install -m 0644 pigpiod_if.h $(DESTDIR)$(includedir)
|
|
|
|
install -m 0644 pigpiod_if2.h $(DESTDIR)$(includedir)
|
|
|
|
install -m 0755 -d $(DESTDIR)$(libdir)
|
|
|
|
install -m 0755 libpigpio.so.$(SOVERSION) $(DESTDIR)$(libdir)
|
|
|
|
install -m 0755 libpigpiod_if.so.$(SOVERSION) $(DESTDIR)$(libdir)
|
|
|
|
install -m 0755 libpigpiod_if2.so.$(SOVERSION) $(DESTDIR)$(libdir)
|
|
|
|
cd $(DESTDIR)$(libdir) && ln -fs libpigpio.so.$(SOVERSION) libpigpio.so
|
|
|
|
cd $(DESTDIR)$(libdir) && ln -fs libpigpiod_if.so.$(SOVERSION) libpigpiod_if.so
|
|
|
|
cd $(DESTDIR)$(libdir) && ln -fs libpigpiod_if2.so.$(SOVERSION) libpigpiod_if2.so
|
|
|
|
install -m 0755 -d $(DESTDIR)$(bindir)
|
|
|
|
install -m 0755 pig2vcd $(DESTDIR)$(bindir)
|
|
|
|
install -m 0755 pigpiod $(DESTDIR)$(bindir)
|
|
|
|
install -m 0755 pigs $(DESTDIR)$(bindir)
|
2018-11-09 01:30:58 +01:00
|
|
|
if which python2; then python2 setup.py install $(PYINSTALLARGS); fi
|
|
|
|
if which python3; then python3 setup.py install $(PYINSTALLARGS); fi
|
2018-11-09 01:02:56 +01:00
|
|
|
install -m 0755 -d $(DESTDIR)$(mandir)/man1
|
2019-01-10 14:50:19 +01:00
|
|
|
install -m 0644 p*.1 $(DESTDIR)$(mandir)/man1
|
2018-11-09 01:02:56 +01:00
|
|
|
install -m 0755 -d $(DESTDIR)$(mandir)/man3
|
2019-01-10 14:50:19 +01:00
|
|
|
install -m 0644 p*.3 $(DESTDIR)$(mandir)/man3
|
2018-11-09 01:02:56 +01:00
|
|
|
ifeq ($(DESTDIR),)
|
2015-08-30 10:40:42 +02:00
|
|
|
ldconfig
|
2018-11-09 01:02:56 +01:00
|
|
|
endif
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
uninstall:
|
2015-12-22 17:44:27 +01:00
|
|
|
rm -f $(DESTDIR)$(includedir)/pigpio.h
|
|
|
|
rm -f $(DESTDIR)$(includedir)/pigpiod_if.h
|
|
|
|
rm -f $(DESTDIR)$(includedir)/pigpiod_if2.h
|
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpio.so
|
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so
|
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so
|
2018-11-09 01:02:56 +01:00
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpio.so.$(SOVERSION)
|
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so.$(SOVERSION)
|
|
|
|
rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so.$(SOVERSION)
|
2015-12-22 17:44:27 +01:00
|
|
|
rm -f $(DESTDIR)$(bindir)/pig2vcd
|
|
|
|
rm -f $(DESTDIR)$(bindir)/pigpiod
|
|
|
|
rm -f $(DESTDIR)$(bindir)/pigs
|
2018-11-09 01:30:58 +01:00
|
|
|
if which python2; then python2 setup.py install $(PYINSTALLARGS) --record /tmp/pigpio >/dev/null; sed 's!^!$(DESTDIR)!' < /tmp/pigpio | xargs rm -f >/dev/null; fi
|
|
|
|
if which python3; then python3 setup.py install $(PYINSTALLARGS) --record /tmp/pigpio >/dev/null; sed 's!^!$(DESTDIR)!' < /tmp/pigpio | xargs rm -f >/dev/null; fi
|
2015-12-22 17:44:27 +01:00
|
|
|
rm -f $(DESTDIR)$(mandir)/man1/pig*.1
|
2018-11-09 01:32:38 +01:00
|
|
|
rm -f $(DESTDIR)$(mandir)/man1/libpigpio*.1
|
2015-12-22 17:44:27 +01:00
|
|
|
rm -f $(DESTDIR)$(mandir)/man3/pig*.3
|
2018-11-09 01:30:58 +01:00
|
|
|
ifeq ($(DESTDIR),)
|
2015-08-30 10:40:42 +02:00
|
|
|
ldconfig
|
2018-11-09 01:30:58 +01:00
|
|
|
endif
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
$(LIB1): $(OBJ1)
|
2018-11-09 01:02:56 +01:00
|
|
|
$(SHLIB) -Wl,-soname,$(LIB1).$(SOVERSION) -o $(LIB1).$(SOVERSION) $(OBJ1)
|
|
|
|
ln -fs $(LIB1).$(SOVERSION) $(LIB1)
|
2015-05-27 21:00:26 +02:00
|
|
|
$(STRIPLIB) $(LIB1)
|
|
|
|
$(SIZE) $(LIB1)
|
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
$(LIB2): $(OBJ2)
|
2018-11-09 01:02:56 +01:00
|
|
|
$(SHLIB) -Wl,-soname,$(LIB2).$(SOVERSION) -o $(LIB2).$(SOVERSION) $(OBJ2)
|
|
|
|
ln -fs $(LIB2).$(SOVERSION) $(LIB2)
|
2015-05-27 21:00:26 +02:00
|
|
|
$(STRIPLIB) $(LIB2)
|
|
|
|
$(SIZE) $(LIB2)
|
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
$(LIB3): $(OBJ3)
|
2018-11-09 01:02:56 +01:00
|
|
|
$(SHLIB) -Wl,-soname,$(LIB3).$(SOVERSION) -o $(LIB3).$(SOVERSION) $(OBJ3)
|
|
|
|
ln -fs $(LIB3).$(SOVERSION) $(LIB3)
|
2015-11-10 15:57:12 +01:00
|
|
|
$(STRIPLIB) $(LIB3)
|
|
|
|
$(SIZE) $(LIB3)
|
|
|
|
|
2014-01-12 22:31:59 +01:00
|
|
|
# generated using gcc -MM *.c
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2013-12-12 11:32:49 +01:00
|
|
|
pig2vcd.o: pig2vcd.c pigpio.h
|
2014-01-21 20:04:59 +01:00
|
|
|
pigpiod.o: pigpiod.c pigpio.h
|
2018-03-11 14:24:54 +01:00
|
|
|
pigs.o: pigs.c pigpio.h command.h pigs.h
|
2015-02-02 22:11:28 +01:00
|
|
|
x_pigpio.o: x_pigpio.c pigpio.h
|
|
|
|
x_pigpiod_if.o: x_pigpiod_if.c pigpiod_if.h pigpio.h
|
2015-11-10 15:57:12 +01:00
|
|
|
x_pigpiod_if2.o: x_pigpiod_if2.c pigpiod_if2.h pigpio.h
|
2015-12-31 18:01:34 +01:00
|
|
|
|