Merge branch 'Thuffir-master'

Create shared libraries rather than static
This commit is contained in:
joan 2015-06-01 18:32:14 +01:00
commit 4ffd02b8fc
1 changed files with 65 additions and 37 deletions

102
Makefile
View File

@ -1,18 +1,22 @@
#
CC = gcc
AR = ar
RANLIB = ranlib
SIZE = size
CC = gcc
AR = ar
RANLIB = ranlib
SIZE = size
SHLIB = gcc -shared
STRIPLIB = strip --strip-unneeded
CFLAGS += -O3 -Wall
LIB1 = libpigpio.a
LIB1 = libpigpio.so
LIB1_ST = libpigpio.a
OBJ1 = pigpio.o command.o
LIB2 = libpigpiod_if.a
LIB2 = libpigpiod_if.so
LIB2_ST = libpigpiod_if.a
OBJ2 = pigpiod_if.o command.o
LIB = $(LIB1) $(LIB2)
LIB = $(LIB1) $(LIB1_ST) $(LIB2) $(LIB2_ST)
ALL = $(LIB) x_pigpio x_pigpiod_if pig2vcd pigpiod pigs
@ -22,48 +26,62 @@ LL2 = -L. -lpigpiod_if -lpthread -lrt
all: $(ALL)
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
command.o: command.c pigpio.h command.h
$(CC) $(CFLAGS) -fpic -c -o command.o command.c
x_pigpio: x_pigpio.o $(LIB1)
$(CC) -o x_pigpio x_pigpio.c $(LL1)
$(CC) -o x_pigpio x_pigpio.o $(LL1)
x_pigpiod_if: x_pigpiod_if.o $(LIB2)
$(CC) -o x_pigpiod_if x_pigpiod_if.c $(LL2)
$(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL2)
pigpiod: pigpiod.o $(LIB1)
$(CC) -o pigpiod pigpiod.c $(LL1)
$(CC) -o pigpiod pigpiod.o $(LL1)
pigs: pigs.o command.o
$(CC) -o pigs pigs.c command.c
$(CC) -o pigs pigs.o command.o
pig2vcd: pig2vcd.o
$(CC) -o pig2vcd pig2vcd.c
$(CC) -o pig2vcd pig2vcd.o
clean:
rm -f *.o *.i *.s *~ $(ALL)
install: $(LIB)
sudo install -m 0755 -d /opt/pigpio/cgi
sudo install -m 0755 -d /usr/local/include
sudo install -m 0644 pigpio.h /usr/local/include
sudo install -m 0644 pigpiod_if.h /usr/local/include
sudo install -m 0755 -d /usr/local/lib
sudo install -m 0644 libpigpio.a /usr/local/lib
sudo install -m 0644 libpigpiod_if.a /usr/local/lib
sudo install -m 0755 -d /usr/local/bin
sudo install -m 0755 pig2vcd /usr/local/bin
sudo install -m 0755 pigpiod /usr/local/bin
sudo install -m 0755 pigs /usr/local/bin
install: $(ALL)
sudo install -m 0755 -d /opt/pigpio/cgi
sudo install -m 0755 -d /usr/local/include
sudo install -m 0644 pigpio.h /usr/local/include
sudo install -m 0644 pigpiod_if.h /usr/local/include
sudo install -m 0755 -d /usr/local/lib
sudo install -m 0644 libpigpio.a /usr/local/lib
sudo install -m 0755 libpigpio.so /usr/local/lib
sudo install -m 0644 libpigpiod_if.a /usr/local/lib
sudo install -m 0755 libpigpiod_if.so /usr/local/lib
sudo install -m 0755 -d /usr/local/bin
sudo install -m 0755 -s pig2vcd /usr/local/bin
sudo install -m 0755 -s pigpiod /usr/local/bin
sudo install -m 0755 -s pigs /usr/local/bin
sudo python2 setup.py install
sudo python3 setup.py install
sudo install -m 0755 -d /usr/local/man/man1
sudo install -m 0644 *.1 /usr/local/man/man1
sudo install -m 0755 -d /usr/local/man/man3
sudo install -m 0644 *.3 /usr/local/man/man3
sudo install -m 0755 -d /usr/local/man/man1
sudo install -m 0644 *.1 /usr/local/man/man1
sudo install -m 0755 -d /usr/local/man/man3
sudo install -m 0644 *.3 /usr/local/man/man3
sudo ldconfig
uninstall:
sudo rm -f /usr/local/include/pigpio.h
sudo rm -f /usr/local/include/pigpiod_if.h
sudo rm -f /usr/local/lib/libpigpio.a
sudo rm -f /usr/local/lib/libpigpiod_if.a
sudo rm -f /usr/local/lib/libpigpio.so
sudo rm -f /usr/local/lib/libpigpiod_if.so
sudo rm -f /usr/local/bin/pig2vcd
sudo rm -f /usr/local/bin/pigpiod
sudo rm -f /usr/local/bin/pigs
@ -75,24 +93,34 @@ uninstall:
sudo xargs rm -f < /tmp/pigpio >/dev/null
sudo rm -f /usr/local/man/man1/pig*.1
sudo rm -f /usr/local/man/man3/pig*.3
sudo ldconfig
$(LIB1): $(OBJ1)
$(AR) rcs $(LIB1) $(OBJ1)
$(RANLIB) $(LIB1)
$(SIZE) $(LIB1)
$(SHLIB) -o $(LIB1) $(OBJ1)
$(STRIPLIB) $(LIB1)
$(SIZE) $(LIB1)
$(LIB1_ST): $(OBJ1)
$(AR) rcs $(LIB1_ST) $(OBJ1)
$(RANLIB) $(LIB1_ST)
$(STRIPLIB) $(LIB1_ST)
$(SIZE) $(LIB1_ST)
$(LIB2): $(OBJ2)
$(AR) rcs $(LIB2) $(OBJ2)
$(RANLIB) $(LIB2)
$(SIZE) $(LIB2)
$(SHLIB) -o $(LIB2) $(OBJ2)
$(STRIPLIB) $(LIB2)
$(SIZE) $(LIB2)
$(LIB2_ST): $(OBJ2)
$(AR) rcs $(LIB2_ST) $(OBJ2)
$(RANLIB) $(LIB2_ST)
$(STRIPLIB) $(LIB2_ST)
$(SIZE) $(LIB2_ST)
# generated using gcc -MM *.c
command.o: command.c pigpio.h command.h
pig2vcd.o: pig2vcd.c pigpio.h
pigpio.o: pigpio.c pigpio.h command.h custom.cext
pigpiod.o: pigpiod.c pigpio.h
pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h
pigs.o: pigs.c pigpio.h command.h
x_pigpio.o: x_pigpio.c pigpio.h
x_pigpiod_if.o: x_pigpiod_if.c pigpiod_if.h pigpio.h