#!/usr/bin/make -f
###############################################################
# Copyright 1998 VMware, Inc.  All rights reserved. -- VMware Confidential
###############################################################
#
# VMware vmppuser makefile to be distributed externally
#

DRIVER = vmppuser

####
####  The code is actually identical for SMP vs. UP, but if you
#### Have CONFIG_MODVERSIONS in your kernel, the symbols will 
#### come out differently smp vs. non-smp so we will build with
#### different names just to disambiguate.  If you have an SMP
#### kernel (i.e. uniprocessor but with SMP support or more than
#### one processor) please uncomment the SUPPORT_SMP line.
####
#SUPPORT_SMP=1

# Header directory for the running kernel
HEADER_DIR = /usr/src/linux/include

# Grep program
GREP = /bin/grep

check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
	> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)

ifdef SUPPORT_SMP
DRIVERNAME = $(DRIVER)-smp-$(shell uname -r)
else
DRIVERNAME = $(DRIVER)-up-$(shell uname -r)
endif

CC_WARNINGS = -Wall -Wstrict-prototypes
# Don't use -pipe or egcs-2.91.66 (shipped with RedHat) will die
CC_KFLAGS = -D__KERNEL__ -DMODULE -fomit-frame-pointer -fno-strength-reduce \
            -DCPU=586 -fno-common -DKBUILD_MODNAME=$(DRIVER)
CC_KFLAGS += $(call check_gcc,-falign-loops=2 -falign-jumps=2 -falign-functions=2, \
	    -malign-loops=2 -malign-jumps=2 -malign-functions=2)
CC_KFLAGS += $(call check_gcc,-march=i586,-m486)
CC_KFLAGS += $(call check_gcc,-fno-strict-aliasing,)
INCLUDE = -I. -I$(HEADER_DIR)
CFLAGS = -O $(CC_WARNINGS) $(CC_KFLAGS) $(INCLUDE)

ifdef SUPPORT_SMP
CFLAGS += -DSUPPORT_SMP
endif

OBJS = ppuser-stub.o

default: all

all: $(DRIVERNAME)

$(DRIVERNAME): $(OBJS)
	$(LD) -r -o $@ $^

../$(DRIVER).o: $(DRIVERNAME)
	cp -f $< $@

auto-build: ../$(DRIVER).o

clean:
	rm -f $(DRIVERNAME) ../$(DRIVERNAME) $(OBJS)

.PHONY: default all auto-build clean

.SILENT:
