Re: portable makefiles

From: Billy N. Patton (b-patton_at_ti.com)
Date: 08/30/04


Date: Mon, 30 Aug 2004 10:56:02 -0500
To: Tim Grunewald <tgrunewa@netscape.net>

Tim Grunewald wrote:
> Hi,
>
> I am trying to figure out how to assign make macros like CC, CFLAGS,
> LDFLAGS and such by platform. Our current platforms are Linux and
> Aix. I tried using if statements, but this doesn't work. Basically,
> I would like it to be able to work like this: "If Aix, then set CC,
> CFLAGS, ... for Aix, else set them for Linux." In the near future, we
> are planning on using the GNU compiler and GNU make for all platforms.
> My goal is to have one makefile for both platforms, so we don't have
> to use the "-f" option.
>
> I would like the makefile to be intelligent, in that the person
> running make doesn't have to remember to add an additional option. I
> would like to keep the usage to "make" and "make program".
>
> Tim Grunewald

Here is a snippett from my makefile. I use only gnu make

Youe could define for gcc and anyther parameters in the same way I have
the Cpu_type and Inst

define Cpu_type
    if [ `/bin/uname -s` = 'SunOS' ] ; then echo SunOS ; \
    elif [ `/bin/uname -s` = 'Linux' ] ; then echo Linux ; \
    fi
endef

define Inst
    if [ `/bin/uname -s` = 'SunOS' ] ; then echo /usr/local/bin/install
  ; \
    elif [ `/bin/uname -s` = 'Linux' ] ; then echo /usr/bin/install ; \
    fi
endef

CPP = purify -windows=no -log-file=purify.log g++
CPP = purify g++
CPP = g++
INC =
CPPFLAGS = -g3 -Wall -DDEBUG_LAFFREAD
CPPFLAGS = -O3 -Wall
CPPFLAGS = -g3 -O2 -Wall
CPPFLAGS = -g3 -Wall $(INC)
OS = $(shell $(Cpu_type))
INSTALL = $(shell $(Inst))
OLIBS =
MKDIR = /bin/mkdir -p
PREFIX = .
MAKE_SH = /data/cdmg/dev/cdmg_toolbox/programs/make_sh
INS_DIR = $(PREFIX)/bin/$(OS)
LIB = $(OS)/libcdmg.a
TLIB = $(OS)/libcdmgT.a

-- 
    ___  _ ____       ___       __  __
   / _ )(_) / /_ __  / _ \___ _/ /_/ /____  ___
  / _  / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/   \_,_/\__/\__/\___/_//_/
            /___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455,  b-patton@ti.com

Quantcast