12.3. Steps for building, installing, packaging

Create the directory where the package lives, plus any auxiliary directories:

	root@pumpy:/u/pkgsrc/lang(1765)# cd /usr/pkgsrc/lang
	root@pumpy:/u/pkgsrc/lang(1765)# mkdir bison
	root@pumpy:/u/pkgsrc/lang(1766)# cd bison
	root@pumpy:/u/pkgsrc/lang/bison(1768)# mkdir files patches pkg
  

Create Makefile, pkg/COMMENT, pkg/DESCR and pkg/PLIST as in Files above, then continue with fetching the distfile:

	root@pumpy:/u/pkgsrc/lang/bison(1769)# make fetch
	>> bison-1.25.tar.gz doesn't seem to exist on this system.
	>> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
	Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://www-proxy.myisp.com:80/)
	ftp: Error retrieving file: 500 Internal error
	 
	>> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
	Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://www-proxy.myisp.com:80/)
	ftp: Error retrieving file: 500 Internal error
	 
	>> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
	Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://www-proxy.myisp.com:80/)
	Successfully retrieved file.
  

Generate the checksum of the distfile into files/md5:

	root@pumpy:/u/pkgsrc/lang/bison(1770)# make makesum
	root@pumpy:/u/pkgsrc/lang/bison(1771)#
  

Now compile:

	root@pumpy:/u/pkgsrc/lang/bison(1777)# make
	>> Checksum OK for bison-1.25.tar.gz.
	===>  Extracting for bison-1.25
	===>  Patching for bison-1.25
	===>   Ignoring empty patch directory
	===>  Configuring for bison-1.25
	creating cache ./config.cache
	checking for gcc... cc
	checking whether we are using GNU C... yes
	checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
	checking how to run the C preprocessor... cc -E
	checking for minix/config.h... no
	checking for POSIXized ISC... no
	checking whether cross-compiling... no
	checking for ANSI C header files... yes
	checking for string.h... yes
	checking for stdlib.h... yes
	checking for memory.h... yes
	checking for working const... yes
	checking for working alloca.h... no
	checking for alloca... yes
	checking for strerror... yes
	updating cache ./config.cache
	creating ./config.status
	creating Makefile
	===>  Building for bison-1.25
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g LR0.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g allocate.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g closure.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g conflicts.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g derives.c
	cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\"  -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1  -g  ./files.c 
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getargs.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g gram.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lalr.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lex.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g main.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g nullable.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g output.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g print.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reader.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reduce.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g symtab.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g warshall.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g version.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt.c
	cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt1.c
	cc  -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o                        getopt.o getopt1.o  
	./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
	rm -f bison.s1
	sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
  

Everything seems OK, so install the files:

	root@pumpy:/u/pkgsrc/lang/bison(1785)# make install
	>> Checksum OK for bison-1.25.tar.gz.
	===>  Installing for bison-1.25
	sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
	rm -f /usr/pkg/bin/bison
	cd /usr/pkg/share; rm -f bison.simple bison.hairy
	rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
	install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
	/usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
	/usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
	cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
	/usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
	===>  Registering installation for bison-1.25
  

You can now use bison, and also - if you decide so - remove it with ``pkg_delete bison-1.25''. Should you decide that you want a binary package, do this now:

	root@pumpy:/u/pkgsrc/lang/bison(1786)# make package
	>> Checksum OK for bison-1.25.tar.gz.
	===>  Building package for bison-1.25
	Creating package bison-1.25.tgz
	Registering depends:.
	Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
  

Now that you don't need the source and object files any more, clean up:

	root@pumpy:/u/pkgsrc/lang/bison(1787)# make clean
	===>  Cleaning for bison-1.25