SlackGrade - The Slackware Update Wizard

*** BUILD MODES ***
SlackGrade can be compiled in 2 modes:
- stand-alone utility
- embedded component
The first is self-explanatory. The second, embedded component, means
you can build SlackGrade as a built-in component in your own wxGTK
based projects, by adding just a few lines of code.

 SlackGrade was originally designed to run as a built-in component
of the XPKGTOOL project, then modified to run also in stand-alone mode.
For detailed information about how to build SlackGrade in embedded mode,
please read carefuly the next sections.

 XPKGTOOL: A Slackware Package Manager for X
Is distributed under GPL license and is available at:
http://xpkgtool.sourceforge.net

*** BUILDING SLACKGRADE IN STAND-ALONE MODE ***
If you want to use or it's already using XPKGTOOL 0.0.8a or above versions,
probably you don't need SlackGrade as a stand-alone utility.
However, if you want to build SlackGrade in stand-alone mode, just follow
the instructions below.

No one configure script is included until this moment. This way, make sure you
have compiled and instaled the following software packages before build SlackGrade:
- wxGTK* 2.4.0 or above (recommended: 2.4.2)
- wxxrc library, included with wxGTK sources, under WXDIR/contrib/src/xrc
* wxGTK is available for download at: http://www.wxwidgets.org

It's important to say that the Makefile included with SlackGrade source is pre-configured
to build a binary with a static version of wxGTK, but you can, if you prefer, build it
with a shared version of wxGTK, as seen in the build instructions below.

To build SlackGrade as a stand-alone utility, just run the following commands:
(assuming you're under the SlackGrade root directory)
# cd src
# make
this will build a binary linked with the static wxGTK libraries. however, some build
tests using the wxGTK shared libraries were made with success without modifications
in the make script.
but if you're experiencing build problems with shared libraries you can try build it
using the makefile's SHARED environment variable:
# make SHARED=yes
as an extra option, if you want to use a compiler cache tool, such ccache, during the
compilation, you can pass it as an argument to the make script, through the EXTRA
environment variable. below, an example for ccache:
# make EXTRA=ccache
after this, if compilation succeds, the binary file will stay on the (SLACKGRADE_DIR)/bin
directory. You can reduce the final binary size with the 'strip' binutil and 'upx' tool
through the following command:
# make pack
to remove the intermediary object files created after the build process, just do:
# make clean
to remove object files, as well the binary file, do:
# make cleanall
to install SlackGrade, just do (as root):
# make install
this will copy the binary file to /usr/local/bin directory and other necessary files
to /usr/local/share/slackgrade directory.
To launch SlackGrade, just type:
# slackgrade
You can uninstall SlackGrade from the system by running:
# make uninstall


*** BUILDING SLACKGRADE AS AN EMBEDDED COMPONENT ***
To embed SlackGrade in other wxGTK based project is simple, but requires
some attention in the directory structure for the host project.
To explain this, see the directory structure for the XPKGTOOL root tree:
1. The main directory: xpkgtool
2. The source directory: xpkgtool/src (where XPKGTOOL sources are in)
3. The 'util' directory: xpkgtool/util (where built-in components are in)
4. The SlackGrade directory: xpkgtool/util/slackgrade (SlackGrade root tree)
Then, supposing you have a project called 'myproject', you can embed SlackGrade
by keeping this structure:
# myproject			(MYPROJECT)
# myproject/src			(MYPROJECT_SRC)
# myproject/util		(MYPROJECT_UTIL)
# myproject/util/slackgrade	(MYPROJECT_SLGR)

Well, obviously, you can modify this structure editing the SlackGrade sources.

Now, just embed SlackGrade by calling it from your project:
Edit MYPROJECT_SLGR/src/common.h
Change HOST_APP definition to from xpkgtool/ to myproject/
Now, in your source, supposing you have a class member called CallSlackGrade():
(assuming a source file in MYPROJECT_SRC directory)

//
// // SlackGrade header
// #include "../util/slackgrade/src/slackgrade.h"
//
// // ...your code...
//
// int MyProject::CallSlackGrade()
// {
//	SlackGradeDlg *m_slackgrade = new SlackGradeDlg();
//	int exicode = m_slackgrade->ShowModal();
//	delete m_slackgrade;
//	return exitcode;
// }
//

The exitcode variable will inform if SlackGrade was closed by pressing Cancel
button or by closing the window directly. Possible values are:
SLGR_EXIT_CLOSE  - user closed the window
SLGR_EXIT_CANCEL - user pressed the Cancel button
SLGR_EXIT_FINISH - user pressed the Finish button

Plus, if you want a toolbar icon for SlackGrade, a 32x32 icon is available:
# MYPROJECT_SLGR/src/xpm/slackgrade32.xpm

This is all the code you need add in your project to embed SlackGrade. :)

Now, the compilation:
When compiling SlackGrade as an embedded component, you must supply to the
compiler the _SLACKGRADE_EMBEDDED_ definition for each SlackGrade target file.
For GCC: -D_SLACKGRADE_EMBEDDED_
Below, a template for a Makefile to compile SlackGrade as an embedded component:

#=================================== CUT HERE ==========================================
#
#CXX = $(shell wx-config --cxx)				# wx c++ compiler
#WXFL = -lwx_gtk_xrc-2.4 $(shell wx-config --libs)	# wx LDFLAGS
#WXFC = $(shell wx-config --cxxflags)			# wx CXXFLAGS
#OBJ = <your .o objects>
## ...other definitions here...
#
## SlackGrade definitions
#SLGR_DIR = ../util/slackgrade
#SLGR_SRC = ../util/slackgrade/src
#SLGR_H = $(SLGR_SRC)/slackgrade.h
#SLGR_RULE = slackgrade.o svrconf.o sgabout.o sgproxy.o sgblist.o
#SLGR_OBJ = $(SLGR_RULE)
#SLGR_FLAG = -D_SLACKGRADE_EMBEDDED_
#
# main target
#myproject: $(OBJ) $(SLGR_RULE)
#	$(CXX) -Wall -o ../bin/myproject $(OBJ) $(SLGR_OBJ) $(WXFL)
#
## ...other targets here...
#
## SlackGrade targets
#slackgrade.o: $(SLGR_SRC)/slackgrade.cpp $(SLGR_SRC)/slackgrade.h $(SLGR_SRC)/svrconf.h $(SLGR_SRC)/common.h $(SLGR_SRC)/pkginfo.h $(SLGR_SRC)/sgabout.h $(SLGR_SRC)/sgproxy.h $(SLGR_SRC)/sgblist.h
#	$(CXX) -Wall -O2 -pthread $(SLGR_FLAG) $(WXFC) -o slackgrade.o -c $(SLGR_SRC)/slackgrade.cpp
#
#svrconf.o: $(SLGR_SRC)/svrconf.cpp $(SLGR_SRC)/svrconf.h $(SLGR_SRC)/common.h
#	$(CXX) -Wall -O2 -pthread $(SLGR_FLAG) $(WXFC) -o svrconf.o -c $(SLGR_SRC)/svrconf.cpp
#
#sgabout.o: $(SLGR_SRC)/sgabout.cpp $(SLGR_SRC)/sgabout.h
#	$(CXX) -Wall -O2 -pthread $(SLGR_FLAG) $(WXFC) -o sgabout.o -c $(SLGR_SRC)/sgabout.cpp
#
#sgproxy.o: sgproxy.cpp sgproxy.h common.h
#	$(CXX) -Wall -O2 -pthread $(SLGR_FLAG) $(WXFC) -o sgproxy.o -c sgproxy.cpp
#
#sgblist.o: sgblist.cpp sgblist.h common.h
#	$(CXX) -Wall -O2 -pthread $(SLGR_FLAG) $(WXFC) -o sgblist.o -c sgblist.cpp
#
#install:
#	...your installation definitions here...
#	mkdir /usr/local/share/myproject
#	cp -r $(SLGR_DIR)/share/* /usr/local/share/myproject
#
## ...adictional targets here (clean, cleanall, distclean, etc)...
#
#=================================== CUT HERE ==========================================

Notice in the "install" target that you must copy the contents of SLGR_DIR/share to
# /usr/local/share/myproject. This is essential. Without this, SlackGrade cannot find the needed
files to work.

You can also read the XPKGTOOL source code for a real example.
XPKGTOOL sources are available at http://xpkgtool.sourceforge.net
Or you can browse XPKGTOOL CVS tree at:
http://cvs.sourceforge.net/viewcvs.py/xpkgtool/


*** CVS ***
You can get the latest (unstable) development sources of SlackGrade through CVS:
# cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/slackgrade login
When prompted for a password, just press <enter>, then checkout for SlackGrade:
# cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/slackgrade co slackgrade
Done. A root tree containing the latest sources for SlackGrade is on the current directory.
You can now logout from CVS:
# cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/slackgrade logout
Now, just enter in SlackGrade root then follow the build instructions above.
However, remember: development versions may not work well as expected.

To find for new versions and get other info please visit the SlackGrade web page at:
http://slackgrade.sourceforge.net

Apologize my imperfect English.

Have fun :)

Marcelo A. B. Slomp
Brazil
mslomp@linuxmail.org
