How To Make Linux PackagesMaking a man page
Appropriate locations to put man pages
|
Dependencies:
The two lines below are an example of a dependency. The first line defines the dependency relationship, and the second line defines the command line. There may be several command lines.
test_example : this.o that.o cc -o george this.o that.o
In the example the dependency relationship defines this.o and that.o are required. The program george is generated. Normally the program name is the same as the dependency label "test_example".
Make predefined macros:
Below is an example Make file I created to compile and install a project with 3 source binaries (spooldata, stripchars, lmax) and 1 script file (printst) along with 3 man pages and 1 configuration file. NOTE: All commands must begin with the TAB character.
# Make file for the project myproject
SHELL = /bin/bash
BINLOC = /usr/local/tmp
CONFLOC = /usr/local/etc
MANLOC = /usr/man
EXEC1 = spooldata
EXEC2 = stripchars
EXEC3 = lmax
SHUTILS = printst
CONFFILES = spooldata.conf
MANFILES = stripchars.1 spooldata.8 spooldata.conf.5
PRUTILS = $(EXEC1) $(EXEC2) $(EXEC3)
OBJS1 = $(EXEC1:=.o)
OBJS2 = $(EXEC2:=.o)
OBJS3 = $(EXEC3:=.o)
SRCS1 = $(EXEC1:=.c)
SRCS2 = $(EXEC2:=.c)
SRCS3 = $(EXEC3:=.c)
.SUFFIXES : .c .o
# CC = gcc
# $(PRUTILS): $($@.o) #One way to do it, but won't work with GNU make
# $(CC) -o $@ $@.o
all: $(PRUTILS) #invoked when "make all" typed. Does make for EXEC1, EXEC2, EXEC3.
$(EXEC1): $(OBJS1)
$(CC) -o $(EXEC1) $(OBJS1)
$(EXEC2): $(OBJS2)
$(CC) -o $(EXEC2) $(OBJS2)
$(EXEC3): $(OBJS3)
$(CC) -o $(EXEC3) $(OBJS3)
.c.o: #Uses suffix rule to compile c file to get object file
$(CC) -c $<
#$(OBJS1): $(SRCS1) #These lines are replaced by suffix rule above.
# $(CC) -c $(SRCS1)
#$(OBJS2): $(SRCS2)
# $(CC) -c $(SRCS2)
#$(OBJS3): $(SRCS3)
# $(CC) -c $(SRCS3)
install:
@if \ #creates directory if necessary
[ ! -d $(BINLOC) ]; \
then \
mkdir $(BINLOC); \
fi
@for i in $(PRUTILS); do \ #Copies files in PRUTILS to their proper location
cp $$i $(BINLOC)/$$i; \
chmod +x $(BINLOC)/$$i; \
echo copying $$i to $(BINLOC)/$$i; \
done ; \
@for i in $(SHUTILS); do \
cp $$i $(BINLOC)/$$i; \
chmod +x $(BINLOC)/$$i; \
echo copying $$i to $(BINLOC)/$$i; \
done
@if \
[ ! -d $(CONFLOC) ]; \
then \
mkdir $(CONFLOC); \
fi
@for i in $(CONFFILES); do \
cp $$i $(CONFLOC)/$$i; \
echo copying $$i to $(CONFLOC)/$$i; \
done
@for i in $(MANFILES); do \
PAGENO=$${i#$${i%[0-9]}}; \
cp $$i $(MANLOC)/man$$PAGENO/$$i; \
echo copying $$i to $(MANLOC)/man$$PAGENO/$$i; \
done
clean:
rm -f *.o
| tar cf myproject.tar /usr/local/myproject | Takes all files in myproject and puts them in new archive file. | tar rf myproject.tar ./thisfile | Adds thisfile to myproject.tar | gzip myproject.tar | Replaces myproject.tar with the file myproject.tar.gz | gzip –9 myproject.tar | Uses most compact compression, default is 6. Fastest is 1. |
tar cvfz myprint-1.0.0.tar.gz myprint-1.0.0
cp myprint-1.0.0.tar.gz /usr/src/redhat/SOURCES
Summary: My print package Name: myprint Version: 1.0.0 Release: 1 Copyright: GPL Group: Development/Tools Source: /usr/local/myprint-1.0.0.tar.gz Vendor: Mycompany Packager: George %description This print package does everything I want it to do, including sending me a notice when files are printed. %prep %setup %build make all RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install make install $RPM_BUILD_ROOT %clean make clean $RPM_BUILD_ROOT %files %defattr(-,root,root) %config /usr/local/etc/spooldata.conf /usr/local/bin/stripchars /usr/local/bin/printst /usr/local/bin/spooldata /usr/local/bin/lmax /usr/man/man1/stripchars.1 /usr/man/man1/printst.1 /usr/man/man1/lmax.1 /usr/man/man8/spooldata.8 /usr/man/man5/spooldata.conf.5
rpm -ba myprint-1.0.0.spec
A further explanation of the spec file:
Source0: printst Source1: spooldata
It is easier to wrap everything into a tarred and zipped file as shown above.
Amusements/Games Amusements/Graphics Applications/Archiving Applications/Communications Applications/Databases Applications/Editors Applications/Emulators Applications/Engineering Applications/File Applications/Internet Applications/Multimedia Applications/Productivity Applications/Publishing Applications/System Applications/Text Development/Debuggers Development/Languages Development/Libraries Development/System Development/Tools Documentation System Environment/Base System Environment/Daemons System Environment/Kernel System Environment/Libraries System Environment/Shells User Interface/Desktops User Interface/X User Interface/X Hardware Support
rm –rf $RPM_BUILD_DIR/hbprint-1.3.0
tar xvzf $RPM_SOURCE_DIR/hbprint-1.3.0.tgz
make all
make install