Author Topic: Paul Smedley's Programming Tips n Tricks  (Read 4765 times)

Ian Manners

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 30
  • -Receive: 18
  • Posts: 243
  • I am the computer, it is me.
    • View Profile
    • OS/2 Site
Paul Smedley's Programming Tips n Tricks
« on: January 07, 2013, 04:56:22 pm »
This will be a collection of Tips, hints, and programming tricks gathered from Paul Smedley's posts.
As these are Paul's writings, I'm not liable for any damage to your system  :o

As time permits and also depending on what others may post, there will be other Sticky threads similar to this one with Tips etc from other contributors.

For those that are not aware you can get Paul's GCC build environment on DVD - http://os2ports.smedley.id.au/index.php?page=BuildEnvDVD

Paul's GCC build environment is an ideal starting point as it gives you a known good baseline to start from.

Yes, it will cost you a small amount of money but you will be supporting someone who has put a lot of effort into both supporting our community, and porting applications that you are probably using somewhere.

 ========= Paul's Build Environment build txt file from his DVD  START =========
Instructions for setup:
- Installation is only supported to drive u: - if you want to install it
  elsewhere, feel free to hack u:\*.cmd and various other scripts that may
  reference u: drive

- unzip buildenv_xxxxxxxx.zip to u:\

- run u:\folder.cmd to create a desktop folder with icons for the various
  versions of the GCC compiler that are included (3.3.5, 3.4.6, 4.3.5, 4.4.5, 4.5.2, 4.5.3)

Building your first command line application:
- Launch a GCC command prompt (4.x suggested)
- change directory to u:\dev\wget-1.12
- type 'ash ./configure --prefix=/wget' at the command prompt
- once configure completes, run 'make'
- there will be an error building the doc directory - but we don't care about that :)
- once make completes, run 'make install'
- wget executables will be found in /wget/bin

=========  Paul's Build Environment build txt file from his DVD  END =========

Porting software to eCS.
In the absolute best case scenario, the process is:
1) extract source
2) run configure using something like:
    ash ./configure --prefix=/name_of_app --disable-shared --enable-static 2>&1 | tee configure.log
    --prefix specifies where we want to install the app - default will be /usr or /usr/local
    --disable-shared tells it not to build shared libraries (in most cases the app won't know how to build shared libraries (ie DLL's)
    --enable-static forces static libraries to be built
    2>&1 | tee configure.log puts the output from configure into a file called configure.log for debugging purposes
3) assuming configure completes:
     make 2>&1 | tee build.log
    runs make, with output of the command pipes into build.log
4) If no, errors.
    make install
    output will be put into the directory specified as prefix in 2)

I'd suggest starting with a simple command line app like wget
This serves two purposes, a) ensures your setup works, and b) ensures that nothing has changed.

The latest wget v1.14 source will require a minor change to be made in lib/spawn.in.h

diff -ur wget-1.14-o/lib/spawn.in.h wget-1.14/lib/spawn.in.h

========= Diff file Start =========
--- wget-1.14-o/lib/spawn.in.h   2012-12-28 19:05:04.000000000 +1030
+++ wget-1.14/lib/spawn.in.h   2012-12-29 15:36:20.000000000 +1030
@@ -32,7 +32,7 @@
 
 /* Get definitions of 'struct sched_param' and 'sigset_t'.
    But avoid namespace pollution on glibc systems.  */
-#if !(defined __GLIBC__ && !defined __UCLIBC__)
+#if !(defined __GLIBC__ && !defined __UCLIBC__) && !defined __KLIBC__
 # include <sched.h>
 # include <signal.h>
 #endif
========= Diff file end =========
« Last Edit: January 07, 2013, 05:18:39 pm by Ian Manners »


Cheers
Ian B Manners