Compiling and Distributing Via an RPM

only for RuBoard - do not distribute or recompile

Compiling and Distributing Via an RPM

The makefiles for the application are covered first, followed by the RPM spec file. The makefiles for the KBI and tabular executables are given in Listings Listing 13.1 and Listing 13.2; the other makefiles (those for the pie chart, the bar/line chart, and the scatter plot chart) are the same as that in Listing 13.2, except that the name of the executable is different for each one.

The Makefiles

Listing 13.1 is the makefile for the KBI executable. It is the controlling application that calls the other executables, which is why it has a slightly more complicated install section than those in Listings 13.2 and 13.3.

Listing 13.1 Makefile for the KBI Executable
  # Makefile for the KBI Application.   # Chapters 11, 12, and 13. */  CC = gcc -Wall  MYSQL-INCLUDES = -I/usr/include/mysql  MYSQL-LIBS = -L/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lz  GTK-CONFIG = `gtk-config --cflags --libs`  GTK-INCLUDES = `gtk-config --cflags`  GTK-LINKS = `gtk-config --libs`  kbi : main.o interface.o support.o callbacks.o kbi_utils.o        $(CC) -o kbi *.o $(GTK-CONFIG) $(MYSQL-INCLUDES) $(MYSQL-LIBS)        cp -f kbi /usr/local/bin/kbi  main.o : main.c        $(CC) -c main.c $(GTK-INCLUDES)  interface.o : interface.c        $(CC) -c interface.c $(GTK-INCLUDES)  support.o : support.c        $(CC) -c support.c $(GTK-INCLUDES)  callbacks.o : callbacks.c        $(CC) -c callbacks.c $(GTK-INCLUDES)  kbi_utils.o : kbi_utils.c        $(CC) -c kbi_utils.c $(GTK-INCLUDES) $(MYSQL-INCLUDES)  # Note that you can force a full rebuild by calling   #  make clean  before calling  make  or  make install  . By removing   # all the intermediate object files, you force a full   # rebuild of the KBI executable. When  make  goes to compare   # the time of the KBI exe to that of the *.o files and finds   # no *.o files, it re-runs all the rules to make the object   # files. Then, of course, the *.o files are newer than the   # last KBI executable, so the exe is rebuilt. */  clean::        rm -f *.o  EXE_LOCATION = /usr/local/bin/  MENU_LOCATION = "/usr/share/gnome/apps/In House Applications/"  # In the commands below   #      The  -f  after  cp  tells  cp  to overwrite an existing file of   #             the same name in the target location if such a file   #             already exists. */  install : kbi        cp -f "Key Business Indicators.desktop" $(MENU_LOCATION)        cp -f kbi $(EXE_LOCATION)kbi        chmod 755 $(EXE_LOCATION)kbi        echo Key Business Indicators Application Installed. 

Listings 13.2 and 13.3 are the makefiles for the tabular and pie executables, respectively.The fundamental difference between them is that the makefile for tabular (Listing 13.2) includes ddc.c , whereas the pie program make fi le compiles piechart_utils.c .

Listing 13.2 Makefile for the Tabular Executable
  # Makefile for the KBI Application.   # Chapters 11, 12, and 13. */  CC = gcc -Wall  MYSQL-INCLUDES = -I/usr/include/mysql  MYSQL-LIBS = -L/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lz  GTK-CONFIG = `gtk-config --cflags --libs`  GTK-INCLUDES = `gtk-config --cflags`  GTK-LINKS = `gtk-config --libs`  tabular : main.o interface.o support.o callbacks.o ddc.o        $(CC) -o tabular *.o $(GTK-CONFIG) $(MYSQL-INCLUDES) $(MYSQL-LIBS)        cp -f tabular /usr/local/bin/tabular  main.o : main.c        $(CC) -c main.c $(GTK-INCLUDES)  interface.o : interface.c        $(CC) -c interface.c $(GTK-INCLUDES)  support.o : support.c        $(CC) -c support.c $(GTK-INCLUDES)  callbacks.o : callbacks.c        $(CC) -c callbacks.c $(GTK-INCLUDES) $(MYSQL-INCLUDES)  ddc.o : ddc.c        $(CC) -c ddc.c $(GTK-INCLUDES) $(MYSQL-INCLUDES)  clean::        rm -f *.o  EXE_LOCATION = /usr/local/bin/  # In the commands below   #     The  -f  after  cp  tells  cp  to overwrite an existing file of   #            the same name in the target location if such a file   #            already exists. */  install : tabular        cp -f tabular $(EXE_LOCATION)tabular        chmod 755 $(EXE_LOCATION)tabular        echo Tabular Graph Installed. 

Listing 13.3 is the makefile for the pie chart executable. It is the same basic structure as the tabular and KBI makefiles in Listings 13.1 and 13.2. The makefiles for bar_line and scatter will be the same as Listing 13.3, except the name of the executable will be different, of course.

Listing 13.3 Makefile for the Pie Program
  # Makefile for the KBI Application.   # Chapters 11, 12, and 13. */  CC = gcc -Wall  MYSQL-INCLUDES = -I/usr/include/mysql  MYSQL-LIBS = -L/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lz  GTK-CONFIG = `gtk-config --cflags --libs`  GTK-INCLUDES = `gtk-config --cflags`  GTK-LINKS = `gtk-config --libs`  pie : main.o interface.o support.o callbacks.o piechart_utils.o        $(CC) -o pie *.o $(GTK-CONFIG) $(MYSQL-INCLUDES) $(MYSQL-LIBS)  cp -f pie /usr/local/bin/pie  main.o : main.c        $(CC) -c main.c $(GTK-INCLUDES)  interface.o : interface.c        $(CC) -c interface.c $(GTK-INCLUDES)  support.o : support.c        $(CC) -c support.c $(GTK-INCLUDES)  callbacks.o : callbacks.c        $(CC) -c callbacks.c $(GTK-INCLUDES)  piechart_utils.o : piechart_utils.c        $(CC) -c piechart_utils.c $(GTK-INCLUDES) $(MYSQL-INCLUDES)  clean::        rm -f *.o  EXE_LOCATION = /usr/local/bin/  #  In the commands below   #     The  -f  after  cp  tells  cp  to overwrite an existing file of   #            the same name in the target location if such a file   #            already exists.  install : pie        cp -f pie $(EXE_LOCATION)pie        chmod 755 $(EXE_LOCATION)pie        echo Pie Chart Installed. 

The RPM Spec File

Listing 13.4 is the kbi.spec file used to create the RPM. This spec file differs in several fundamental ways from that of the Worldwide Commissions Application in Chapter 9, Constructing the Commissions Application, and Chapter 10, Commission Calculations Deployment.

The Preamble, description, and prep sections are essentially the same. The build section is empty, however, because each of the executables is built separately using its own makefile . The install section consists of copying the executables to /usr/local/bin where the KBI executable can find them. The %files section includes the files from the development machine s /usr/local/bin directory; the makefiles copy them to that location as part of the make process to ensure that /usr/local/bin always contains the latest executables.

Listing 13.4 kbi.spec: The RPM Spec File for the KBI ( group of) Applications
  # The spec file for building the RPM to distribute the   # KBI Application built in Chapters 11 and 12.   # The Preamble Section  Summary: Key Business Applications  Name: kbi  Version: 0.1  Release: 1  Copyright: Proprietary  Group: Applications/Databases  Packager: Matt Stucky <stuckym@prodigy.net>  %description  In house application for executive reporting on "key business  indicators"  # Preparation Section  %prep  # Clean out the RPM build and source directories in preparation for   # the build.  rm -rf $RPM_BUILD_DIR/*  rm -rf $RPM_SOURCE_DIR/*  cd /mnt/DOS_hda2/newriders/book/ch12/  cp kbi/src/kbi      $RPM_BUILD_DIR  cp r1/src/tabular         $RPM_BUILD_DIR  cp r2/src/pie             $RPM_BUILD_DIR  cp r3/src/bar_line        $RPM_BUILD_DIR  cp r4/src/scatter         $RPM_BUILD_DIR  cp "kbi/src/Key Business Indicators.desktop" $$RPM_BUILD_DIR  # These next two sections are simple because the   #  makefile  has already been created with a  make install  included.  %build  # This application will not distribute the source.   # Therefore, there is no source to build.  %install  # Unlike the previous RPM spec file, this one has no "make install"   # because it distributes several packages in binary only.  cp -f kbi       /usr/local/bin  cp -f tabular   /usr/local/bin  cp -f pie       /usr/local/bin  cp -f bar_line  /usr/local/bin  cp -f scatter   /usr/local/bin  cp -f "Key Business Indicators.desktop" "/usr/share/gnome/apps/In House  Applications"  # Finally, a list of the files needed for the application to install.  %files  /usr/local/bin/kbi  /usr/local/bin/tabular  /usr/local/bin/pie  /usr/local/bin/bar_line  /usr/local/bin/scatter  "/mnt/DOS_hda2/newriders/book/ch12/kbi/src/Key Business Indicators.desktop" 

Figure 13.1 shows the KBI application installed using the RPM. The appropriate menu choice has been added to the GNOME menu, and the GNOMERPM displays the installed package.

Figure 13.1. The KBI group of applications is installed. The menu bar shows the In House Application start menu, the file manager shows the contents of /usr/local/bin, and the GNOMERPM window shows the installed package.
graphics/13fig01.gif

To build the RPM file, enter the following command:

 % rpm -bb kbi.spec 

The -bb switch tells RPM to build only the binary .rpm file, not the source .rpm file.

only for RuBoard - do not distribute or recompile


MySQL Building User Interfaces
MySQL: Building User Interfaces (Landmark)
ISBN: 073571049X
EAN: 2147483647
Year: 2001
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net