[cs631apue] libmagic and Makefile

Jan Schaumann jschauma at stevens.edu
Wed Dec 11 22:56:22 EST 2013


lbustama <lbustama at stevens.edu> wrote:

> Is anyone else using magic.h to determine the file's mime type. It works  
> fine on linux-lab, and the NetBSD instance that we have access to, but  
> it's not installed on the Illumos image.
>
> Professor,  Is there a way we could get libmagic/magic.h installed on  
> the Illumos image?

I just added the 'file' package, which contains:

$ pkg_info -L file
Information for file-5.11:

Files:
/opt/local/bin/file
/opt/local/include/magic.h
/opt/local/lib/libmagic.la
/opt/local/lib/libmagic.a
/opt/local/lib/libmagic.so
/opt/local/lib/libmagic.so.1
/opt/local/lib/libmagic.so.1.0.0
/opt/local/man/man1/file.1
/opt/local/man/man3/libmagic.3
/opt/local/man/man5/magic.5
/opt/local/share/misc/magic.mgc


> Also, I noticed that the versions of make installed on the different  
> servers have different syntax for conditional statement, and they don't  
> recognize the conditional statements used on the other versions.

Correct: different unix versions use different versions of make(1).
This can be very frustrating due to the different features they support.

> I  ended up with 2 different makefiles: one for linux-labs and one for
> FreeBSD and Illumos.  Are we expected to somehow come up with one
> Makefile that works on all Three instances, or can we have different
> ones?

You should be able to write a single Makefile that is the lowest common
denominator and works on all platforms.

However, it is also acceptable to provide different Makefiles for
different platforms.  (You could even go as far as having multiple
per-platform Makefiles with one master Makefile that checks what
platform you're on and then runs make again with the right Makefile for
that platform, but that gets kind of silly quickly.)

-Jan


More information about the cs631apue mailing list