Hi ,
Please answer my query:
I want to create a common make file for one of mylibrary such that it should work on both Sun as well as Linux on 32 and 64 bit system.
The flow is sth like this:
But the above line throwing an error in line 3 as "Makefile, line 18: Unexpected end of line seen"
I tried hard but to no avail.
Please guide me where i am incorrect.
Moreover i will extend this conditional compilation to sth like this:
if$(OS) == solaris and machine== 64
BINDIR= ../../lib/solaris/64
elseif $(OS) == solaris and machine== 32
BINDIR= ../../lib/solaris/32
if$(OS) == linux and machine== 64
BINDIR= ../../lib/linux/64
elseif $(OS) == linux and machine== 32
BINDIR= ../../lib/linux/32
endif
# Sat Feb 28 17:09:10 CST 2009
main: sub
@echo " BINDIR is $(BINDIR)"
sub:
ifndef OS
@echo " Error, OS not defined."
@exit 1
endif
ifeq "$(OS)" "solaris"
BINDIR := ../../lib/solaris/64
else
BINDIR := ../../lib/solaris/32
endif
# if$(OS) == solaris
# BINDIR= ../../lib/solaris/64
# else
# BINDIR= ../../lib/solaris/32
# endif
When make is used as in this script:
#!/usr/bin/env bash
# @(#) s1 Demonstrate GNU make test features.
echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) make
set -o nounset
echo
echo " OS not defined:"
make
echo
echo " OS set to solaris:"
make OS=solaris
echo
echo " OS set to linux:"
make OS=linux
exit 0
produces:
% ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.11-x1, i686
Distribution : Xandros Desktop 3.0.3 Business
GNU bash 2.05b.0
GNU Make 3.80
OS not defined:
Error, OS not defined.
make: *** Error 1
OS set to solaris:
BINDIR is ../../lib/solaris/64
OS set to linux:
BINDIR is ../../lib/solaris/32
I tried this on Solaris 10, without much hope, and I got the same error message you did.
In order to process this kind of Makefile on Solaris, you would need GNU make.
The topic of make and makefiles is complex, so perhaps the guidance below will be of some value.