Permalink
Browse files

First working version of install for the packaging build.

Changes made to Gordon's code:

1.  I've added a top-level Makefile which does some of
    what the build script does, just building and
    installing the two libraries and the gpio command
    at present.

2.  In the library Makefiles this line assumes that the
    binary has been written into DESTDIR, without PREFIX:
      @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so
    This doesn't seem to be the case, however... so I've added
    a PREFIX. Probably I've missed something about how make
    should be invoked, or...?

3.  The package build process requires that DESTDIR is
    used for everything -- so calling "ldconfig" without
    parameterising it for DESTDIR causes an error. I've
    changed it to use DESTDIR (and -n) for now; there is
    probably a better way using "postinst" rules.

4.  The ./devLib/Makefile does a -I., but this doesn't
    pick up the headers in DESTDIR, so I've changed INCLUDE
    there to do so (in the same way the gpio/Makefile does).

5.  The gpio build needs the core library to be build
    first, so I've put both the bare "make" and the "make
    install" under the top-level "install" target.
    Probably non-optimal.

6.  I have changed the gpio install to use the "install"
    command, which doesn't assume that the process is
    running as root.

7.  I have added a compressed version of the man page,
    as that seems to be expected.
  • Loading branch information...
hamishcunningham committed Sep 25, 2013
1 parent 4ac0e83 commit 707cf1bc343e07c9c07eb67c55ed93873c2c67c8
Showing with 48 additions and 24 deletions.
  1. +29 −11 Makefile
  2. +4 −4 devLib/Makefile
  3. +12 −6 gpio/Makefile
  4. +3 −3 wiringPi/Makefile
@@ -7,10 +7,13 @@ VERSION=$(shell grep VERSION gpio/gpio.c |head -1 |sed -e 's,[^"]*",,' -e 's,",,
P=wiringpi
D=gpio
PD=package/$(VERSION)
PREFIX=/local
INSTALLED_FILES=\
$(DESTDIR)/usr/sbin/$(D) \
$(DESTDIR)$(PREFIX)/bin/gpio \
$(DESTDIR)$(PREFIX)/lib/*wiringPi* \
$(DESTDIR)$(PREFIX)/include/*wiringPi* \
$(DESTDIR)$(PREFIX)/man/man1/$(D).1.gz
# TODO includes and .so \
$(DESTDIR)/usr/share/man/man1/$(D).1.gz
PACKAGE_FILES=\
$(P)_$(VERSION)*.deb \
$(P)_$(VERSION)*.dsc \
@@ -27,7 +30,7 @@ SNAPD:=$(PD)/snapshots/$(SNAPSHOT)

# functions ##################################################################
do-listing=\
ls $(INSTALLED_FILES) || :
echo; echo '[Listing installed files:]'; ls -l --color $(INSTALLED_FILES) || :

# help #######################################################################
help:
@@ -46,24 +49,39 @@ help:
@echo ' '

# install ####################################################################
# (if DESTDIR is set we assume this is a packaging run, not an install)
# (if DESTDIR is set we can assume this is a packaging run, not an install)
install:
# TODO call subdirs Makes
@echo -n "WiringPi: "
cd wiringPi; $(MAKE) DESTDIR=$$DESTDIR; \
$(MAKE) DESTDIR=$$DESTDIR install
@echo -n "DevLib: "
cd devLib; $(MAKE) DESTDIR=$$DESTDIR; \
$(MAKE) DESTDIR=$$DESTDIR install
@echo -n "GPIO: "
cd gpio; $(MAKE) DESTDIR=$$DESTDIR; \
$(MAKE) DESTDIR=$$DESTDIR install
@$(do-listing)

# uninstall ##################################################################
uninstall:
@echo 'removing WiringPi files: '
# TODO call subdirs Makes
@echo -n "WiringPi: "
cd wiringPi; $(MAKE) DESTDIR=$$DESTDIR uninstall
@echo -n "DevLib: "
cd devLib; $(MAKE) DESTDIR=$$DESTDIR uninstall
@echo -n "GPIO: "
cd gpio; $(MAKE) DESTDIR=$$DESTDIR uninstall
@$(do-listing)
@echo done

# manpage ####################################################################
man: man/$(D).1
cd man; cat $(D).1 |gzip >$(D).1.gz
# clean ######################################################################
clean:
cd wiringPi; $(MAKE) clean
cd devLib; $(MAKE) clean
cd gpio; $(MAKE) clean

# package ####################################################################
package: man package-unstable package-precise
package: package-unstable package-precise
@echo "\nunstable:"
@ls -lh $(PD)/unstable
@echo "\nprecise:"
@@ -139,5 +157,5 @@ list:
@$(do-listing)

# phonies ####################################################################
.PHONY: install uninstall package package-unstable package-precise
.PHONY: install uninstall clean package package-unstable package-precise
.PHONY: package-upload package-clean list
@@ -33,7 +33,7 @@ DYNAMIC=libwiringPiDev.so.$(VERSION)
#DEBUG = -g -O0
DEBUG = -O2
CC = gcc
INCLUDE = -I.
INCLUDE = -I$(DESTDIR)$(PREFIX)/include
CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC

LIBS =
@@ -94,8 +94,8 @@ install: $(DYNAMIC) install-headers
@echo "[Install Dynamic Lib]"
@install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
@install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
@ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so
@ldconfig
@ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so
@ldconfig -n $(DESTDIR)$(PREFIX)/lib

.PHONEY: install-static
install-static: $(STATIC) install-headers
@@ -115,7 +115,7 @@ uninstall:
@rm -f $(DESTDIR)$(PREFIX)/include/lcd.h
@rm -f $(DESTDIR)$(PREFIX)/include/piGlow.h
@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.*
@ldconfig
@ldconfig -n $(DESTDIR)$(PREFIX)/lib


.PHONEY: depend
@@ -55,7 +55,7 @@ gpio: $(OBJ)
.PHONEY: clean
clean:
@echo "[Clean]"
@rm -f $(OBJ) gpio *~ core tags *.bak
@rm -f $(OBJ) gpio *~ core tags *.bak gpio.1.gz

.PHONEY: tags
tags: $(SRC)
@@ -65,17 +65,23 @@ tags: $(SRC)
.PHONEY: install
install:
@echo "[Install]"
@cp gpio $(DESTDIR)$(PREFIX)/bin
@chown root.root $(DESTDIR)$(PREFIX)/bin/gpio
@chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio
@mkdir -p $(DESTDIR)$(PREFIX)/man/man1
@cp gpio.1 $(DESTDIR)$(PREFIX)/man/man1
install -d -m 755 $(DESTDIR)$(PREFIX)/bin
install -d -m 755 $(DESTDIR)$(PREFIX)/lib
install -d -m 755 $(DESTDIR)$(PREFIX)/include
install -d -m 755 $(DESTDIR)$(PREFIX)/man/man1
install -m 4755 gpio $(DESTDIR)$(PREFIX)/bin
cat gpio.1 |gzip >gpio.1.gz
install gpio.1.gz $(DESTDIR)$(PREFIX)/man/man1

# TODO do we need this for the final install?
# @chown root.root $(DESTDIR)$(PREFIX)/bin/gpio

.PHONEY: uninstall
uninstall:
@echo "[UnInstall]"
@rm -f $(DESTDIR)$(PREFIX)/bin/gpio
@rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1
@rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1.gz

.PHONEY: depend
depend:
@@ -121,8 +121,8 @@ install: $(DYNAMIC) install-headers
@echo "[Install Dynamic Lib]"
@install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
@install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
@ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
@ldconfig
@ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so
@ldconfig -n $(DESTDIR)$(PREFIX)/lib

.PHONEY: install-static
install-static: $(STATIC) install-headers
@@ -157,7 +157,7 @@ uninstall:
@rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h
@rm -f $(DESTDIR)$(PREFIX)/include/sn3218.h
@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.*
@ldconfig
@ldconfig -n $(DESTDIR)$(PREFIX)/lib


.PHONEY: depend

0 comments on commit 707cf1b

Please sign in to comment.