Propagate target OS from configure to Makefile
authorAaron Carroll <aaronc@cse.unsw.edu.au>
Thu, 14 Mar 2013 05:57:38 +0000 (16:57 +1100)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Mar 2013 14:01:58 +0000 (15:01 +0100)
Propagate target OS from configure to Makefile (CONFIG_TARGET_OS) to avoid
duplicating the check in Makefile.  Also allow CROSS_COMPILE for the toolchain
prefix, which is common (e.g. Linux).

Signed-off-by: Aaron Carroll <aaronc@cse.unsw.edu.au>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
configure

index 7a175552d4121d7e040c612ddb07555a2fe1d177..ea96a898e431fb01710673e2bd10155c7f8e7df3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,6 @@ CFLAGS  = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
 LIBS   = -lm $(EXTLIBS)
 PROGS  = fio
 SCRIPTS = fio_generate_plots
-UNAME  := $(shell uname)
 
 ifneq ($(wildcard config-host.mak),)
 all:
@@ -80,42 +79,42 @@ ifndef CONFIG_INET_ATON
   SOURCE += lib/inet_aton.c
 endif
 
-ifeq ($(UNAME), Linux)
+ifeq ($(CONFIG_TARGET_OS), Linux)
   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
                engines/binject.c profiles/tiobench.c
   LIBS += -lpthread -ldl
   LDFLAGS += -rdynamic
 endif
-ifeq ($(UNAME), Android)
+ifeq ($(CONFIG_TARGET_OS), Android)
   SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
   LIBS += -ldl
   LDFLAGS += -rdynamic
 endif
-ifeq ($(UNAME), SunOS)
+ifeq ($(CONFIG_TARGET_OS), SunOS)
   LIBS  += -lpthread -ldl
   CPPFLAGS += -D__EXTENSIONS__
 endif
-ifeq ($(UNAME), FreeBSD)
+ifeq ($(CONFIG_TARGET_OS), FreeBSD)
   LIBS  += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
-ifeq ($(UNAME), NetBSD)
+ifeq ($(CONFIG_TARGET_OS), NetBSD)
   LIBS  += -lpthread -lrt
   LDFLAGS += -rdynamic
 endif
-ifeq ($(UNAME), AIX)
+ifeq ($(CONFIG_TARGET_OS), AIX)
   LIBS  += -lpthread -ldl -lrt
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
 endif
-ifeq ($(UNAME), HP-UX)
+ifeq ($(CONFIG_TARGET_OS), HP-UX)
   LIBS   += -lpthread -ldl -lrt
   CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
 endif
-ifeq ($(UNAME), Darwin)
+ifeq ($(CONFIG_TARGET_OS), Darwin)
   LIBS  += -lpthread -ldl
 endif
-ifneq (,$(findstring CYGWIN,$(UNAME)))
+ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
   SOURCE += os/windows/posix.c
   LIBS  += -lpthread -lpsapi -lws2_32
@@ -169,7 +168,7 @@ INSTALL = install
 prefix = /usr/local
 bindir = $(prefix)/bin
 
-ifeq ($(UNAME), Darwin)
+ifeq ($(CONFIG_TARGET_OS), Darwin)
 mandir = /usr/share/man
 else
 mandir = $(prefix)/man
index d3649710c1703e39374adcbb9e74f2fcea0ea56a..1fa9b635ade84b3fe8f9eedfd0789176ab7bb795 100755 (executable)
--- a/configure
+++ b/configure
@@ -126,6 +126,7 @@ output_sym() {
 targetos=""
 cpu=""
 
+cross_prefix=${cross_prefix-${CROSS_COMPILE}}
 cc="${CC-${cross_prefix}gcc}"
 
 show_help="no"
@@ -173,6 +174,12 @@ else
   targetos=`uname -s`
 fi
 
+echo "# Automatically generated by configure - do not modify" > $config_host_mak
+printf "# Configured with:" >> $config_host_mak
+printf " '%s'" "$0" "$@" >> $config_host_mak
+echo >> $config_host_mak
+echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
+
 # Some host OSes need non-standard checks for which CPU to use.
 # Note that these checks are broken for cross-compilation: if you're
 # cross-compiling to one of these OSes then you'll need to specify
@@ -929,11 +936,6 @@ echo "RLIMIT_MEMLOCK                $rlimit_memlock"
 
 #############################################################################
 
-echo "# Automatically generated by configure - do not modify" > $config_host_mak
-printf "# Configured with:" >> $config_host_mak
-printf " '%s'" "$0" "$@" >> $config_host_mak
-echo >> $config_host_mak
-
 if test "$wordsize" = "64" ; then
   output_sym "CONFIG_64BIT"
 elif test "$wordsize" = "32" ; then