#!/usr/bin/make -f
#############################################################
# Copyright (C) 1998-2002 VMware, Inc.
# All Rights Reserved
# $Id: Makefile.dist,v 1.2.48.1 2002/04/02 22:01:26 hpreg Exp $
#############################################################
####
####  VMware vmnet Makefile to be distributed externally
####
####

DRIVER = vmnet

####
####  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

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

COMPILER_VERSION := $(shell $(CC) --version)
IS_GCC_30 := $(shell if echo $(COMPILER_VERSION) | $(GREP) -q '^3\.0'; then echo yes; else echo no; fi)

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 \
            -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=586
# Gcc 3.0 deprecates -m486 --hpreg
ifeq ($(IS_GCC_30),yes)
CC_KFLAGS += -march=i586
else
CC_KFLAGS += -m486
endif
INCLUDE = -I. -I$(HEADER_DIR)

CFLAGS = -O $(CC_WARNINGS) $(CC_KFLAGS) $(INCLUDE)

ifdef SUPPORT_SMP
CFLAGS += -DSUPPORT_SMP
endif

OBJS = driver.o hub.o userif.o netif.o bridge.o procfs.o

LIBS =

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:
