Benches macOS

11

determing architecture in a makefile

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I have a program that I'd like to build on both intel and ppc Macs running Leopard.

I'd like to have my makefile handle the job. I tried to determine the architecture by ..

ARCH = $(if $(findstring i386,$(MACHTYPE)),i386,powerpc)

But within the makefile MACHTYPE is empty. From the terminal, I get what I'd expect.

$ echo $MACHTYPE

i386-apple-darwin9.0

My eventual goal is to define a library for g95

FLIB = -L/sw/lib/gcc-lib/$(ARCH)-apple-darwin9/4.0.3/ -lf95

If anyone can help, I'd appreciate it.

TiA

11 replies

Sign in or join Beachball Help to reply.

  1. 0

    Learning Annex Certified

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    It doesn't seem to be defined as an actual environment variable nor does it seem to be accurate.

    Apple's generally recommended procedures are outlined here:

    http://devworld.apple.com/DOCUMENTATION/Porting/Conceptual/PortingUnix/compiling /compiling.html#//apple_ref/doc/uid/TP40002850-BAJCFEBA

  2. 0

    Ben Abbott1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I'd prefer to avoid the whole "configure" thing.

    What do you mean by

    It doesn't seem to be defined as an actual environment variable nor does it seem to be accurate.

    As MACHTYPE is definitely an environment variable on both my intel and ppc based laptops, I assume you refer to something else?

  3. 0

    Learning Annex Certified

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Try printenv. See it listed?

    http://toxicsoftware.com/bashweirdness_on_mac_os_x_intelboxes1/

  4. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    MACHTYPE is not defined on my iMac.

    You can use


    ARCH=$(uname -p)
    or
    ARCH=$(arch)

  5. 0

    Ben Abbott1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I like you suggestion but when I try setting ARCH by ...

    ARCH=$(uname -p)

    in my makefile, the makefile variable ARCH is empty.

  6. 0

    Ben Abbott1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Ok, I see your point; "printenv MACHTYPE" doesn't show anything.

    So what is happening whe I run "echo $MACHTYPE"?

  7. 0

    etresoft

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Why not just build both architectures?

  8. 0

    Ben Abbott1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I'm compiling a mex-file for Matlab. Matlab is not a universal app. Also, I don't have the necessary libraries for both architectures on one machine.

  9. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Sorry I was confusing with shell scripts.

    In Makefile, you can use


    ARCH = $(shell uname -p)
    ARCH = $(shell uname -m)
    ARCH = $(shell arch)

  10. 0

    Ben Abbott1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Jun,

    I did some reading and found I could get your suggestion working by ...

    ARCH := $(shell uname -p)

    Thanks

  11. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    MACHTYPE is a bash shell local variable. make only sees environment variables