Hackbeach’17[1] took in the beaches of Gokana, in Karnataka. I was a bit short on
cash, so I could not spend the whole week by the beach and had to leave
early. During the short period I was there I met with Jag[2].

Jag was quite an interesting person, he did a Masters in Economics and worked
for companies like Infogrames working on FMV sequences of AAA titles for orignal
Playstation 1. I was quite taken back by this, I never had met someone who
worked on PS1 titles, a console that played a very important part in my teenage
days and had influenced me a lot in what I have become as of the time of writing
this blog.

Jag eventually introduced me to this software DIN, which is a recursive acronymn
for DIN Is Noise a musical synth software. He is also the author of the
software. He quit his job to dedicate his time fully to the development of DIN.
During our discussions I asked him if he had tried out BSD as an option to run
his software and he mentioned that he hasn’t tried out BSD, hence he also does
not know if DIN can run on BSD.

And this looked like a good opportunity for me to work on another application to
write up a ports script for.

Making it build

I went through the README[4] on how to build DIN, to get the list of
dependencies and came up with a basic script to complete things up to the
“Extract phase”, as always the FreeBSD Porter’s Handbook[5] is a very handy
companion.

Getting it to build was slightly tougher, using clang and clang++ as the
compilers it tends to nitpick about the smallest of discrepancies.

1
2
3
din.cc:667:16: error: cast from pointer to smaller type 'int' loses information
      int id = (int) di.tracked_drone;
               ^~~~~~~~~~~~~~~~~~~~~~

The issue here is we are converting a pointer type to int, back in the days
when most of the home systems were running on 32-bit hardware, your pointer in C
would be 32-bits wide which makes sense. And according to the wikipedia
article[6], an int in C is expected to be 16-bitsbut this can be 16-bits or
32-bits depending on implementation. According to the GCC ReferenceManual[7],
int is 32-bits wide. Now type casting, a 32-bits pointer to int might be a
short hand way of getting a random integer value which can be used for something
else.

A simple solution was to just typecast it into uintptr_t[8], which is
guarenteed to hold a pointer.

1
int id = (uintptr_t) di.tracked_drone;

Replacing similar occurances through out the file helped overcome this error.

The next error was quite simple about a missing data type called jack_time_t long long which I changed to jack_time_t and the issue was resolved.

There was a bit of fiddling that I needed to with the Tcl/Tk libraries since the
original Makefile had versions hardcoded and this had to be passed into the
build system via the ports script. Once again the Porter’s handbook[10] was quite
effective in helping me out here.

And finally

# file din
din: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 11.1, FreeBSD-style, not stripped

Working with people who can sync

On a side note, when all these fixes were happening, I was having exchanges
with Jag on the errors and the fixes.

Generally when I deal with people who have written some code and point out
mistakes or errors, they get all emotional on me and next thing you know they
see you as an enemy, at least my past experience has been like this. This is due
to the fact that I mostly worked in an IT environment with individuals who have
less than two functional brain cells and cannot take professional opinions in a
professional manner instead take it up personally.

Not with Jag though, it was the smoothest of the exchanges with civilized
logical dialogs on why he made the decisions and the proposed fixes were were
accepted by him since it also meant that fixes were being made on problems that
he was not aware that existed.

Getting to the install phase

Once the build is completed we enter the “stage phase” where the actions of
make install is now carried out in a staging directory which resembles the
/usr layout as mentioned in hier(7) where installation is carried out before a
package is created in FreeBSD for use by pkg(1) the binary package installer
with FreeBSD.

Here I met with some interesting problems due to file names which are used by
DIN. There are a lot of files with country names, a project done by Jag, where
musical tones are generated based on the shape of the country and the files
contain data to reconstruct the shape of the countries. Countries that contained
special characters like ( or ' were causing unwanted escapes in the commands
that were copying the files.

Cocos_(Keeling)_Islands
Cote_d'Ivoire

Convertering the above to

Cocos__Keeling__Islands
Cote_d_Ivoire

Made the scripts work. And once again Jag was quick to take note of these
changes and then apply them back to his working repository.

Conclusion

So after a couple of days of work, email exchanges we had a working copy of the
ports script[9] that can build and install DIN version 29. But the real test does
not like in building the application but in executing and making sure it
works. Unfortunately I do not have a system which runs FreeBSD with a GUI.

References

  1. Hackbeach - https://hackbeach.in
  2. Jagannathan Sampath - https://dinisnoise.org/?what=bio
  3. DIN Is Noise - https://dinisnoise.org
  4. How to build DIN - https://dinisnoise.org/README/
  5. FreeBSD Porter’s Handbook - https://www.freebsd.org/doc/en/books/porters-handbook/
  6. C Data Types - https://en.wikipedia.org/wiki/C_data_types
  7. Int data type in GCC - https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Integer-Types
  8. Defintion of uintptr_t - https://en.cppreference.com/w/cpp/types/integer
  9. DIN Is Noise port script - https://github.com/fraggerfox/din-pkgsrc
  10. Tcl/Tk handing in Ports - https://www.freebsd.org/doc/en/books/porters-handbook/using-tcl.html