getopt_long for IRIX

IRIX/Nekoware development, porting and related topics.
Forum rules
Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.
User avatar
BSDero
Posts: 217
Joined: Thu Nov 24, 2005 9:11 am
Location: Aguascalientes, Mexico
Contact:

getopt_long for IRIX

Unread postby BSDero » Wed Jul 04, 2012 9:01 pm

Hi guys!!

I was playing with my SGI and needed an Irix implementation of getopt_long(), so I got source code from NetBSD and OpenBSD and created a SGI version of it.

I tested an example program of getopt_long() I found in google and all seems works flawlessly :), except by a one line change. However the behavior is same than gnu's getopt_long().

I got a tar with sources, header, Makefile and test program, it builds with MipsPro in Irix 6.5. If anybody interested, I would like to share this.
__Zacatito__Image 600 MHZ R14000; 17GBytes HD
__Nopalito__Image 200 MHZ R5000; 9GBytes HD
Guadalajara, Jal and Aguascalientes, Ags
Mexico

User avatar
PymbleSoftware
Posts: 1891
Joined: Tue Jul 15, 2008 5:48 pm
Location: P.O. Box 529, Gordon, Sydney, NSW 2072, Australia.
Contact:

Re: getopt_long for IRIX

Unread postby PymbleSoftware » Wed Jul 04, 2012 10:17 pm

BSDero wrote:Hi guys!!

I was playing with my SGI and needed an Irix implementation of getopt_long(), so I got source code from NetBSD and OpenBSD and created a SGI version of it.

I tested an example program of getopt_long() I found in google and all seems works flawlessly :), except by a one line change. However the behavior is same than gnu's getopt_long().

I got a tar with sources, header, Makefile and test program, it builds with MipsPro in Irix 6.5. If anybody interested, I would like to share this.


From memory there is/was something about this on the MIPS Pro nekochan wiki page.. if not I intended to put something on there at the same time I wrote the section on work arounds or porting or something like that..

EDIT
oh, wait nup.. that was the senenv/putenv thing .. I did have a solution for getopt_long() which I intended to put in a section after ..
http://www.nekochan.net/wiki/MIPS_Pro#s ... ng_in_IRIX

I think I did this when porting hercules IBM mainframe emulator to IRIX.. years ago..

R.
死の神はりんごだけ食べる

開いた括弧は必ず閉じる -- あるプログラマー

:Tezro: :Tezro: :Onyx2R: :Onyx2RE: :Onyx2: :O3x04R: :O3x0: :O200: :Octane: :Octane2: :O2: :O2: :Indigo2IMP: :PI: :PI: :1600SW: :1600SW: :Indy: :Indy: :Indy: :Indy: :Indy:
:hpserv: J5600, 2 x Mac, 3 x SUN, Alpha DS20E, Alpha 800 5/550, 3 x RS/6000, Amiga 4000 VideoToaster, Amiga4000 -030, 733MHz Sam440 AmigaOS 4.1 update 1.

HP C7000 BladeSever with 16 Blades 96Gb to 144Gb RAM per blade
HP C3000 Blade Server with 8 Blades 48Gb to 144Gb RAM per blade

Sold: :Indy: :Indy: :Indy: :Indigo: Tandem Himalaya S-Series Nonstop S72000 ServerNet.

Twitter @PymbleSoftware
Current Apps (iOS) -> https://itunes.apple.com/au/artist/pymb ... d553990081
(Android) https://play.google.com/store/apps/deve ... +Ltd&hl=en
(Onyx2) Cortex ---> http://www.facebook.com/pages/Cortex-th ... 11?sk=info
(0300s) Minnie ---> http://www.facebook.com/pages/Minnie-th ... 02?sk=info
Github ---> https://github.com/pymblesoftware

User avatar
canavan
Posts: 754
Joined: Mon Jul 21, 2003 6:19 am

Re: getopt_long for IRIX

Unread postby canavan » Thu Jul 05, 2012 11:49 am

An Implementation of getopt_long is part of gnulib http://www.gnu.org/software/gnulib/MODULES.html#module=getopt-posix. I usually just copy the source files into a suitable directory and add them to the list of .c-Files in the Makefile.

User avatar
PymbleSoftware
Posts: 1891
Joined: Tue Jul 15, 2008 5:48 pm
Location: P.O. Box 529, Gordon, Sydney, NSW 2072, Australia.
Contact:

Re: getopt_long for IRIX

Unread postby PymbleSoftware » Thu Jul 05, 2012 1:44 pm

Updated to the wiki to point back here.... http://www.nekochan.net/wiki/MIPSpro#ge ... ng_in_IRIX

R.
死の神はりんごだけ食べる

開いた括弧は必ず閉じる -- あるプログラマー

:Tezro: :Tezro: :Onyx2R: :Onyx2RE: :Onyx2: :O3x04R: :O3x0: :O200: :Octane: :Octane2: :O2: :O2: :Indigo2IMP: :PI: :PI: :1600SW: :1600SW: :Indy: :Indy: :Indy: :Indy: :Indy:
:hpserv: J5600, 2 x Mac, 3 x SUN, Alpha DS20E, Alpha 800 5/550, 3 x RS/6000, Amiga 4000 VideoToaster, Amiga4000 -030, 733MHz Sam440 AmigaOS 4.1 update 1.

HP C7000 BladeSever with 16 Blades 96Gb to 144Gb RAM per blade
HP C3000 Blade Server with 8 Blades 48Gb to 144Gb RAM per blade

Sold: :Indy: :Indy: :Indy: :Indigo: Tandem Himalaya S-Series Nonstop S72000 ServerNet.

Twitter @PymbleSoftware
Current Apps (iOS) -> https://itunes.apple.com/au/artist/pymb ... d553990081
(Android) https://play.google.com/store/apps/deve ... +Ltd&hl=en
(Onyx2) Cortex ---> http://www.facebook.com/pages/Cortex-th ... 11?sk=info
(0300s) Minnie ---> http://www.facebook.com/pages/Minnie-th ... 02?sk=info
Github ---> https://github.com/pymblesoftware

User avatar
BSDero
Posts: 217
Joined: Thu Nov 24, 2005 9:11 am
Location: Aguascalientes, Mexico
Contact:

Re: getopt_long for IRIX

Unread postby BSDero » Wed Jul 11, 2012 8:08 am

In those GCC-isms related issues I've found *bsd source code easier to port and maintain witrhout all that flags and thinks like that. Source code is way easier to port, clear and maintain.
__Zacatito__Image 600 MHZ R14000; 17GBytes HD
__Nopalito__Image 200 MHZ R5000; 9GBytes HD
Guadalajara, Jal and Aguascalientes, Ags
Mexico

User avatar
necron2600
Posts: 275
Joined: Tue May 26, 2015 10:38 pm
Location: Boston

Re: getopt_long for IRIX

Unread postby necron2600 » Tue Sep 12, 2017 12:17 pm

For anyone who has trouble with getopt_long and IRIX..
I know we have a Wiki on this that says "google around for the example code to implement this" .. which was not very helpful for me.
Granted, once I figured it out, it now seems easy but it took some time for me to get to that point. I want this thread to help anyone else with this problem.

Attached is a tarball with ya_getopt .. Yet-Another getopt implementation.. compiles on IRIX and I tested it already (however not very extensively! so hopefully nothing breaks from this).

Tarball contains:
tar tpf ../getopt_long-in-irix.tar

Code: Select all

getopt_long-in-irix/ya_getopt.c
getopt_long-in-irix/ya_getopt.h
getopt_long-in-irix/libya_getopt.so
getopt_long-in-irix/README


the .c and .h are from ya_getopt. libya_getopt.so is a compiled shared library on IRIX 6.5/mips4 with GCC (we all love GCC right? ;)

The README has some rough notes for anyone who may find themselves in a getopt_long() missing situation and may be clueless as to what to do:

Here is the README (its rough notes.. )

Code: Select all

# These are notes for getopt_lang() in IRIX (GCC)

# Yet Another GetOpt implementation (drop-in)
https://github.com/kubo/ya_getopt

# COMPILE shared library (GCC)
# http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html
gcc -c -Wall -Werror -fpic ya_getopt.c
gcc -shared -o libya_getopt.so ya_getopt.o

# LINK with your code (examples)
gcc -Wall -o test main.c -lya_getopt
# LINK with your code specifying .so library directory location
gcc -L/whereis/ya_getopt/ -Wall -o test main.c -lya_getopt

# Copy ya_getopt.h to your source and edit relevant files:
#include "ya_getopt.h"

# Replace getopt_long() calls in your code to ya_getopt_long()

# Example Makefile changes (and/or Environment variable adjustments)
LDFLAGS = -L/usr/nekoware/lib -L/usr/lib32 -L/whereis/ya_getopt/
LIBS = -lya_getopt

# Note:
Ensure libya_getopt.so is stored somewhere where the binary can access
Such as /usr/local/lib/


It does compile with MIPSpro as well:
cc -c ya_getopt.c
cc -shared -o libya_getopt.so ya_getopt.o

Thanks again to Kubo @ https://github.com/kubo/ya_getopt for his ya_getopt code.

getopt_long-in-irix.tar
(90 KiB) Downloaded 4 times
Last edited by foetz on Tue Sep 12, 2017 1:03 pm, edited 1 time in total.
Reason: merged

User avatar
duck
Donor
Donor
Posts: 743
Joined: Mon Oct 27, 2003 5:22 pm
Location: Jakobstad, Finland
Contact:

Re: getopt_long for IRIX

Unread postby duck » Fri Sep 15, 2017 11:57 pm

NetBSD's pkgsrc has a package with netbsd-compatibility functions that include getopt_long. It's called libnbcompat. This works on IRIX, and might provide other useful things if you are feeling porty.

http://pkgsrc.se/pkgtools/libnbcompat
http://cdn.netbsd.org/pub/pkgsrc/curren ... pat/files/

The files in files/ should be enough to compile and you won't need the pkgsrc tree.

Edit: added URL to the files
:Octane: halo, octane Image knightrider, d i g i t a l AlphaPC164, pond, soekris net6501, misc cool stuff in a rack
N.B.: I tend to talk out of my ass. Do not take it too seriously.


Return to “SGI: Development”

Who is online

Users browsing this forum: No registered users and 3 guests