Monday 9 March 2009

Detecting endianness when making a FreeBSD port makefile

The title really says it all, my porting foo and Google foo was insufficent when I was working on a port for the IMS Corpus Workbench this weekend. I had to turn to the good people at #bsdports@EFnet and to aid me was @stass. He supplied me with what I at time suspected to be the only way, to use a regexp to extract the information from endian.h (yuck!). Here are the two options he provided.

LITTLE_ENDIAN!= ${EGREP} \
'^#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$' \
/usr/include/machine/endian.h | ${AWK} '{if ($3 == \
"_LITTLE_ENDIAN") print 1;}'

LITTLE_ENDIAN!= ${AWK} \
'/^#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$/
{if ($3 == "_LITTLE_ENDIAN") print 1;}' \
/usr/include/machine/endian.h

These work just fine for an ordinary shell but the same thing in a makefile needs some small adjustments. I prefered the purely AWK one, so here it is.

LITTLE_ENDIAN= ${AWK} \
'/^\#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$$/ ' + \
'{if ($$3 == "_LITTLE_ENDIAN") print 1;}' /usr/include/machine/endian.h

Now hopefully the Google Bot will crawl over this and allow the next porter to find what I could not. Once again, thank you @stass. =)

16 comments:

Anonymous said...

pApolwCeorbmkjfmm [url=http://gadaf.fi/oldnavycoupons]old navy coupons[/url] rstikzTsorp

Anonymous said...

Thаnk you for eѵeгy other excellent рoѕt.
Τhe plаce else maу anуonе gеt that kinԁ of
infοrmation in such a pеrfect means of wгitіng?

I have а presentation subsequent ωeek, and I'm at the search for such info.

Check out my page: instant cash loans

Anonymous said...

Link exchange is nothing else but it is simply placing the other person's web site link on your page at proper place and other person will also do similar in favor of you.

Feel free to visit my web blog: ロレックスレプリカ

Anonymous said...

I couldn't refrain from commenting. Well written!

Also visit my page; ロレックススーパーコピー

Anonymous said...

Good day! Would you mind if I share your blog with my
facebook group? There's a lot of people that I think would really enjoy your content. Please let me know. Cheers

Also visit my site トリーバーチ

Anonymous said...

My partner and I stumbled over here by a different page and thought I might as well check things out.
I like what I see so i am just following you. Look forward to looking over your web page repeatedly.



My site; ミュウミュウ 財布

Anonymous said...

Asking questions are truly fastidious thing if you are not understanding
something entirely, however this post gives pleasant understanding yet.



my weblog: クロエ

Anonymous said...

Definitely believe that that you said. Your favorite
reason seemed to be at the net the simplest thing to be mindful of.
I say to you, I certainly get annoyed even as other people consider worries that they just don't understand about. You managed to hit the nail upon the top as smartly as outlined out the entire thing with no need side-effects , folks can take a signal. Will likely be again to get more. Thank you

Here is my web page ... www.turnaroundace.com

Anonymous said...

This design is steller! You definitely know how to keep a
reader entertained. Between your wit and your videos, I was
almost moved to start my own blog (well, almost.
..HaHa!) Great job. I really loved what you had to say, and more than that, how you presented
it. Too cool!

my blog post; コーチ

Anonymous said...

Thanks very nice blog!

My web blog - クリスチャンルブタン

Anonymous said...

Just wish to say your article is as surprising.
The clarity in your submit is just great and i could assume
you're an expert in this subject. Well with your permission allow me to grasp your feed to keep updated with approaching post. Thank you one million and please carry on the enjoyable work.

Feel free to visit my weblog クロエ

Anonymous said...

Pretty! This was an extremely wonderful article.
Thank you for providing this info.

My homepage; トリーバーチ

Anonymous said...

This piece of writing offers clear idea designed for the new visitors of blogging, that actually how to do running
a blog.

Here is my website - ルブタン 新作

Anonymous said...

Hi I am so excited I found your website, I really found you by error,
while I was searching on Google for something else, Nonetheless I am here now and would just like to say cheers for a tremendous post and
a all round enjoyable blog (I also love the theme/design), I don’t have time to
look over it all at the minute but I have bookmarked it and also added in your RSS
feeds, so when I have time I will be back to read more, Please do keep up the fantastic b.


Feel free to visit my page クロエ アウトレット

Anonymous said...

There is certainly a lot to find out about this subject.

I love all of the points you made.

Also visit my homepage; コーチ

Anonymous said...

I'm really enjoying the design and layout of your site. It's a very easy on the eyes which makes it much more pleasant
for me to come here and visit more often. Did you hire out a developer to create your theme?
Outstanding work!

Here is my weblog; トリーバーチ