pigpio/Makefile

165 lines
5.4 KiB
Makefile
Raw Permalink Normal View History

2015-02-02 22:11:28 +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
LIB1 = libpigpio.so
2014-01-12 22:31:59 +01:00
OBJ1 = pigpio.o command.o
2013-12-12 11:32:49 +01: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
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)
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
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)
$(CC) -o x_pigpio x_pigpio.o $(LL1)
2014-03-13 16:50:23 +01:00
x_pigpiod_if: x_pigpiod_if.o $(LIB2)
$(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)
$(CC) -o pigpiod pigpiod.o $(LL1)
$(STRIP) pigpiod
2014-01-12 22:31:59 +01:00
pigs: pigs.o command.o
$(CC) -o pigs pigs.o command.o
$(STRIP) pigs
2013-12-12 11:27:22 +01:00
2014-01-12 22:31:59 +01:00
pig2vcd: pig2vcd.o
$(CC) -o pig2vcd pig2vcd.o
$(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
ifeq ($(DESTDIR),)
PYINSTALLARGS =
else
PYINSTALLARGS = --root=$(DESTDIR)
endif
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)
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
install -m 0644 p*.1 $(DESTDIR)$(mandir)/man1
2018-11-09 01:02:56 +01:00
install -m 0755 -d $(DESTDIR)$(mandir)/man3
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:
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)
rm -f $(DESTDIR)$(bindir)/pig2vcd
rm -f $(DESTDIR)$(bindir)/pigpiod
rm -f $(DESTDIR)$(bindir)/pigs
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
rm -f $(DESTDIR)$(mandir)/man1/pig*.1
rm -f $(DESTDIR)$(mandir)/man1/libpigpio*.1
rm -f $(DESTDIR)$(mandir)/man3/pig*.3
ifeq ($(DESTDIR),)
2015-08-30 10:40:42 +02:00
ldconfig
endif
2013-12-12 11:27:22 +01:00
2014-01-12 22:31:59 +01:00
$(LIB1): $(OBJ1)
$(SHLIB) -pthread -Wl,-soname,$(LIB1).$(SOVERSION) -o $(LIB1).$(SOVERSION) $(OBJ1)
2018-11-09 01:02:56 +01:00
ln -fs $(LIB1).$(SOVERSION) $(LIB1)
$(STRIPLIB) $(LIB1)
$(SIZE) $(LIB1)
2014-01-12 22:31:59 +01:00
$(LIB2): $(OBJ2)
$(SHLIB) -pthread -Wl,-soname,$(LIB2).$(SOVERSION) -o $(LIB2).$(SOVERSION) $(OBJ2)
2018-11-09 01:02:56 +01:00
ln -fs $(LIB2).$(SOVERSION) $(LIB2)
$(STRIPLIB) $(LIB2)
$(SIZE) $(LIB2)
2015-11-10 15:57:12 +01:00
$(LIB3): $(OBJ3)
$(SHLIB) -pthread -Wl,-soname,$(LIB3).$(SOVERSION) -o $(LIB3).$(SOVERSION) $(OBJ3)
2018-11-09 01:02:56 +01:00
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
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