#!/usr/bin/make -f
#############################################################
# Copyright (C) 1998-2000 VMware, Inc.
# All Rights Reserved
# $Id: Makefile,v 1.8 2000/12/17 23:10:38 fields 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

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

CC = gcc

CC_WARNINGS = -Wall -Wstrict-prototypes
CC_KFLAGS = -D__KERNEL__ -DMODULE -fomit-frame-pointer -fno-strength-reduce \
	-pipe -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 \
	-DCPU=586 -D__VMNET_USE_FILE -DTOTAL_BYTES_TRACE \
	-DPACIA_TRACE_DEBUG_PRINT_SKB
#	-DCPU=586 -DPACIA_TRACE -D__VMNET_USE_FILE
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 \
	print_string.o utils.o

LIBS =

default: all

all: $(DRIVER).o

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

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

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

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

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

.PHONY: default all auto-build clean

.SILENT:

%.d: %.c
	echo "$(CFLAGS)\n" \
	set -e; $(CC) -MM $(CFLAGS) $< \
		| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	 [ -s $@ ] || rm -f $@ 

include $(OBJS:.o=.d)
