New toy..

Managed to get some nice time off today, read some of the library books, watched Tron, Ghost Busters I, and Spaced Invaders, but most of all got to relax. I’ve also placed my VIMRC file into a cvs repository on my OpenBSD box, that should make syncing changes with my Desktop/Laptop easier, plus allow me to see what I’ve changed hehe.

Had an interesting idea and started playing with some Ruby today also.

Normally when I start a new program I make a new directory in ~/code/Lang/src/ and copy a template makefile over from ../../makefiles/ and edit it to my needs. In one of the library books, I found a GNU Makefile that essentially automates building a C/C++ program where by all C/C++ source files (subject to make handling the dependencies) are compiled into corresponding files and get linked together into the binary, nice little thing when you look at it. With a little tinkering it could probably be made semi-language independent but I don’t really have time to dig into GNU Make’s syntax and features to do that.

I’ve basically written makefiles in the past that should work with just about any ol’make program. For much the same reason I write shell scripts that should run on most any /bin/sh, because I don’t want to edit the freaking thing if I ever meet a Unix like OS it won’t run on lool.

The idea I had was a enlazynating program that by knowing a fair bit about a given languages normal build process (such as C, C++, and Java), it could then automate the process of building it without having to generate a makefile, kind of like a ‘smart-makefile’ of sorts. I’ve got a alias set in my shell so that gcc is called on the command line with my usual settings. I also tend to include a few more once the things done.

It’s probably a stupid idea to do this, a decent BSD or GNU Makefile would likely serve much better (and be worth the learning of each ones extensions to make). But I rather like to be able to just ‘have fun’ playing with and testing stuff.

Right now, it seems to be able to handle a simple compile/link of files in one directory but needs some work to properly link files in subdir’s, lots of other stuff to do. But working on it has been a good way to pass the time.

Currently I classify this as a toy rather then a program for serious usage. But if I ever finish it, I might use it just for the sake of keeping a fairly fast build/test cycle.

If I could, I would’ve made a machine to manage VHS-Tape/DVD-Disk changing but hey, I’m not an inventor when it comes to to building some thing out of thin air…

Here is what I’ve done over the past couple hours, it’s not very good but it’s a starting point for later play.

#!/usr/local/bin/ruby -w
# usage: make [opt] project [dir]
# TODO:
# rdoc...
# handle header files and linking properly in C
# support more then C
# implement a way to set lang opts/debug/profiler stuff correctly
# reduce usage of $globals
# clean up code... looks like sludge

require 'getoptlong'
require 'rdoc/usage'

$lang=nil
$project=''
$startdir=Dir.pwd
$debug=false
$profiler=false
$verbose=false

def main()

opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--lang', '-l', GetoptLong::REQUIRED_ARGUMENT ],
[ '--lang-opts', '-o', GetoptLong::REQUIRED_ARGUMENT ],
[ '--debug', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--prof', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--clean', '-c', GetoptLong::NO_ARGUMENT ],
[ '--verbose', '-v', GetoptLong::NO_ARGUMENT ]
)

begin
opts.each do |opt, arg|
case opt
when '--help'
RDoc::usage()
when '--lang'
proc_lang( arg )
when '--lang-opts'
puts "#{arg} -> --lang-opts not implemented!"
when '--debug'
$debug = true
when '--prof'
$profiler = arg
when '--verbose'
$verbose=true
end
end

if ARGV[0]
$project = ARGV[0]
end
if ARGV[1]
$startdir = ARGV[1]
end
puts ARGV #debug
puts "nn"
n=LangC.new()
n.make()

unless $lang
$stderr.puts( 'WARNING: --lang not set!, defaulting to ISO C99' )
end

# call usage() on *any* error and print the problem
rescue StandardError
puts( $! )
RDoc::usage()

end

end

def proc_lang( str )

case str
when 'c','C'
# set up for C
$lang=str
when 'c++','cpp','C++','C++','cc','CC','cxx','CXX'
# set up for C++
when 'java','Java'
# set up for Java
when 'Perl','pl', 'plx'
# Setup for Perl
when 'Python','py'
# Setup for Python
when 'Ruby','rb'
# set up for Ruby ;-)
end
end

class Lang

def make()
end

def each( startdir, &block )
dp = Dir.open(startdir) do |dir|
dir.each do |node|
if node == '.' or node == '..'
next
end
p = File.expand_path( node, startdir )
yield( p )
if File.directory?( p )
self.each( p, &block )
end
end
end
end

end # !class Lang


class LangC < Lang

@@compiler = 'gcc'
@@cflags = "-Wall -Wpointer-arith -Wcast-qual -Wcast-align " +
"-Wconversion -Waggregate-return -Wstrict-prototypes " +
"-Wmissing-prototypes -Wmissing-declarations " +
"-Wredundant-decls -Winline -Wnested-externs " +
"-std=c99 -march=i686 -pipe "
@@ldfags = nil
@@debug = '-g'
@@prof = nil
@filelist = Array.new()

# The very bloody boring constructor which serves only to override the
# defaults for our static class variables.
#
def initialize( compiler=false, cflags=false, ldflags=false,
debug=false, prof=false )

if compiler then @@compiler = compiler end
if cflags then @@cflags = cflags end
if ldflags then @@ldfags = ldflags end
if debug then @@debug = debug end
if prof then @@prof = prof end
@@ldflags=nil;@@prof=nil#debug

end

# Assemble project
def make()

@filelist = Array.new()
self.compile()
self.link()

end

# Walk the directory tree and compile all .c files into .o
#
def compile()

$stdout.puts '------- COMPILING -------' if $verbose

self.each( $startdir ) do |file|
if file =~ /.*.c$/
p = file.to_s.gsub( File.extname(file),".o" )
@filelist.push( p )
# Don't compile unless the source is newer then the object files
if File.exists?( p )
next unless timecheck(file,p)
end

system( "#{@@compiler} #{@@cflags} #{@@debug} #{@@prof} " +
"#{file} -c -o #{p}" )
end
end
end

# Walk the directory tree and link all object files
def link()

$stdout.puts '------- LINKING -------' if $verbose

@filelist.each do |obj|
system( "#{@@compiler} #{@@cflags} #{@@ldflags} #{@@debug} " +
"#{@@prof} #{obj} -o #{$startdir}/#{$project}" )
end
end

# Return true if first filename has a newer time stamp then the second
#
def timecheck( f1, f2 )
File.mtime( f1 ) > File.mtime( f2 ) ? true : false
end

end

if __FILE__ == $0
main()
end

Operation: Sit on my Ass, starts…. NOW !!!

I got off wok early today, about 1400 local and home for lunch by 1445, hit the Forums over at www.sasclan.org, ate, and got my movies list ready… Taking the rest of the day off as a personal vacation/holiday.

Blog, radio, tv, food, code, books, e.t.c 🙂

Raided my bookshelves bottom shelf for the VHS collection. We’ve got like 150-250 VHS tapes in the house but I’ve maintained only a small collection (20-40) in my room, so I know where to find them lol. We’ve taped just about every thing but watch almost none of it unless it’s on TV HAHAHA ! It set off my nose but I’ve complied my watch list, probably will take me a few weeks but it’s nice considering that I have not seen most of them in ages.

Links the the plot outlines on the Internet Movie Database (IMDB) for convenience.

Robot Jox
Indiana Jones and the Last Crusade
Dune — A great book also
The Three Amigos
Dear GOD — A goodie I found on late-tv years ago.
Mission Impossible
Legend of Drunken Master
Ghost Busters I and II
Ernest Goes to Jail
Jackie Chan’s First Strike
The Freshmen
Tron
Hot Shots
Spaced Invaders
Hook
El Dorado

Not all of them are my favorites although a few are, they all are however good movies xD

Late night wise-cracks

“It’s 5:50 a.m., Do you know where your stack pointer is?”

I saw this one and I couldn’t help but smile 🙂

Especially since if I get any decent edits done, it’s usually after 0500 when I get to sleep.. and a fair bit of time using GDB hehehe.

“Programming is a lot like sex. One mistake and you could have to support it the rest of your life.”

“You can’t make a program without broken egos”

“There are two ways to write error-free programs; only the third one works. “

“You never finish a program, you just stop working on it.”

I started at ~1230, it’s now ~1630 and I’ve gotton shit done…

You’ve just got to love my family….

Ready to scream

The official rage list…

  • I’m f***ing tired of not being able to get stuff done in the afternoon.
  • I’m f***ing tired of being driven out of my skull.
  • I’m f***ing tired of having my train of thought derailed.
  • I’m f***ing tired of of being annoyed.
  • I’m f***ing tired of being interrupted.
  • I’m f***ing tired of not being able to concentrate.
  • I’m f***ing tired of being antagonised by computer-illiterate scum.
  • I’m f***ing tired of being barked, screeched, and shouted at.
  • I’m f***ing tired of having to live like this.
  • I’m f***ing tired of being tortured whenever I try to learn some thing.
  • I’m f***ing tired of having to stay up till 4am or later.
  • I’m f***ing tired of not being able to do f***ing any thing other wise.
  • I’m f***ing tired of watching my home work pile up.
  • I’m f***ing tired of not being able to rest when I’m *not* trying to do some f***ing thing.
  • I’m f***ing tired of being denied a chance to follow my goals.
  • I’m f***ing tired of this.

and I’m about ready to explode !!!

This mother f***ing rat ass sucking hell hole is pushing the limit. I’ve got over 4,500 pages to read — and I’m going to start knocking the damn walls down if I have to, but I am FINISHING THESE f***ing BOOKS.

There is no where else to go to read, study, nap, or any damn other thing. And my family makes it very hard to do any of those.

That means either this house learns to live with my work load or face the consequences. I should fuk’n start evicting people by force…. Let them enjoy freezing their ass off outside for a few hours.. While I get things *DONE* for a change.

Why, just why can’t I just once let myself be as cruel and vindictive as the rest… Instead of suffering aggravation after one another and hating that I feel like hating back…

Is it to much to ask to sit down and read a damn blasted book before I have to get back to work? I think not !!!!!!!!!!!!

I need a frigging vacation….. big time

Library takedown

The new reading list:

Maximum Security: A Hacker’s Guide to Protecting Your Internet Site and Network — I wonder what the last chapter I read was last time I checked it out hehe.

Upgrading and Repairing Servers — I’d love to learn more and it’s got some stuff that interests me a lot on the bare hardware-level.

Learning Java, Second Edition — Useful because the book I own on Java was published ~1996.

The TCP/IP Guide: A Comprehensive, Illustrated Internet Protocols Reference — Probably will put me to sleep but is useful to have on hand, should I have time to read it.

Linux® Programming Bible — Old (2000’ish I think) but worth a thumb through in case I learn any thing I missed from it. I think it even includes a basic unix shell in the code listing, which is nice because one of my projects was trying to implement a bare bones shell in ruby.

Not counting indexes, glossaries, or appendixes (one of which as A-D I think): There are 4746 pages in all !

Counting every books last page with a pg# on it, we have 5381 pages total !!!

Borg wars?

Far be it from me not to admit I have some crazy dreams… laugh out loud.

I dreamed that I was aboard a Sovereign class starship on escort duty in the middle of a bitter United Federation of Planets Vs Borg war.

Surrounded by a swarm of smaller borg scout-strike craft and most of the convoy assimilated. The Soverign class ship tried fighting off the swarm but it didn’t do any good, just to many ships to keep remodulating our weapons to.

So the Captain ordered all power transfered from weapons to what was left of our forward shield grid…

And we chased down and rammed every last one of those little bastards head on at warp speed!

Using the reinforced frontal shields and the navigational deflector to take the brunt of the damage and the Structural Itegerty Field (SIF) to keep us in one piece… Crazist dang thing I’ve ever seen but it worked great haha! The littler ships were just to much smaller then us, that they couldn’t hold up to the force of impact of such a massive force 😉

The fictional-fact that most of what were left of the ships shield emitters would’ve been to damaged by heat build up beyond use if we tried that after duking it out in combat so hard… Is probably irrelivent as far as dreams go lol but still.

Hmm, maybe I should’ve skept reading star trek tech-manuals when I was little hehe.

Writer’s Block: Current Favorites

Tell us your current favorite: book, movie, CD, video game.

Live Jorunal Writer’s Block

Book:
The Thrawn Trilogy by Timothy Zahn, Mara Jade is definitely my favorite charactor in Star Wars and watching, uhh reading. The Thrawn Trilogy and Duology, my favorite parts are the relationship between Luke Skywalker and Mara Jade. Grand Admiral Thrawn is also one of a good example of a decent commander, especially for an imperial…
Movie:

I’d say I probably like to many movies to be able to honestly nail it on any specific one now. I generally enjoy Comedy, Science Fiction, and Action movies as well as Classics.
CD:

N/A, haven’t boughten any CD’s in ages, I don’t really follow music… If I had money odds are it would go for a mixture of Country, Rock & Roll, and Metal….
Video Game:

SWAT3, the best of the best. I’ve yet to meet a better Tactical FPS Game then SWAT3. The net code blows but the game play is just freaking awesome

“Betty Davis advised to know who your friends are and also know your enemies. When asked how one can identify ones enemies she said “anyone who interferes with your work”

I’m beginning to agree…

FreeBSD + Java?

How easy is it…

The JDK and JRE packages on the FreeBSD Foundation require the following to install and run correctly:

inputproto-1.4.2.1, javavmwrapper-2.3, kbproto-1.0.3, libICE-1.0.4,1, libSM-1.0.3,1, libX11-1.1.3,1, libXau-1.0.3_2, libXdmcp-1.0.2, libXext-1.0.3,1, libXi-1.1.3,1, libXp-1.0.0,1, libXt-1.0.5, libXtst-1.0.3, pkg-config-0.22, printproto-1.0.3, recordproto-1.13.2, xextproto-7.0.2, xproto-7.0.10_1, xtrans-1.0.4

If you run a Desktop based system with Xorg installed most of these are probably already there, on my laptop which has KDE 3.5.7 for the GUI all I had to do was install one package first:

pkg_add -r javavmwrapper

If you don’t have a required package it will tell you what you need to install when you try to pkg_add Java. Most probably can be pkg_add -r’d unless you want to the ports.

I then went over to the FreeBSD Foundation website to download Java

If you only want to run Java programs, you will need the JRE (Java Runetime Environment) but if you wish to develop Java programs you’ll require the JDK (Java Development Kit).

The packages currently are for FreeBSD 5.5/i386 and FreeBSD 6.1/i386 and amd64. Just download the one that matches your FreeBSD major branch and CPU Architecture. I fetched both JRE and JDK for FreeBSD 6.1/i386 which is about a 70MB download combined, my Laptop runs PC-BSD v1.4 so the underlaying system is FreeBSD 6.2-Stable, no problems so far.

You need to accept the license agreement to download and when you pkg_add, just scroll to the bottom and type ‘yes’ and press enter, you can probably use the shift+g command to jump to the bottom of the license.

I think because of the terms that the JRE/JDK were licensed for distro we’ve got to live with the manual download. Once you’ve got your packages downloaded, just do a :

pkg_add ./diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz

of course replacing ./ with the path (if necessary) and the filename with the proper one. Tip: If you don’t want to typo it, use tab completion in your shell. I usually just download things to /tmp and cd over to it. You also need to be root in order to run pkg_add with any possibility of success. Depending on ones shell a ‘rehash’ command might also be needed before the programs can be found in the command prompt.

which tells me that java and javac are working, and it passed the test of compiling a small test program and running it.