#
# Copyright (c) 1995-1996,1998,1999,2000 University of Utah and the Flux Group.
# All rights reserved.
# 
# This file is part of the Flux OSKit.  The OSKit is free software, also known
# as "open source;" you can redistribute it and/or modify it under the terms
# of the GNU General Public License (GPL), version 2, as published by the Free
# Software Foundation (FSF).  To explore alternate licensing terms, contact
# the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
# 
# The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GPL for more details.  You should have
# received a copy of the GPL along with the OSKit; see the file COPYING.  If
# not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
#

ifndef _oskit_examples_unix_threads_makerules_
_oskit_examples_unix_threads_makerules__ = yes

#
# Let's build all examples here to ensure the make rules don't get
# out of date
#
TARGETS = dphils http_proxy disktest disktest.real disknet sigtest ipctest \
		http_proxy.real

all: $(TARGETS)

SRCDIRS      += $(OSKIT_SRCDIR)/examples/x86/threads

INCDIRS +=   $(OSKIT_SRCDIR)/freebsd/libc/include			\
	     $(OSKIT_SRCDIR)/freebsd/3.x/src/include			\
	     $(OSKIT_SRCDIR)/freebsd/3.x/src/sys			\
	     $(OSKIT_SRCDIR)/freebsd/3.x/src/lib/libc/i386		\
	     $(OBJDIR)/freebsd/libc_r/objinclude

CLEAN_FILES  +=	$(TARGETS) *.gdb


include $(OSKIT_SRCDIR)/examples/unix/unixmakerules

CLIB          = -loskit_freebsd_c_r -loskit_com -loskit_threads

DEPENDLIBS = $(filter %.a, $(foreach DIR,$(LIBDIRS),$(wildcard $(DIR)/*)))

#
# Specific targets for "real" device versions. Just adds -DREALSTUFF
#
%.real.o: %.c
	$(CC) -c -o $@ $(OSKIT_CFLAGS) $(CFLAGS) -DREALSTUFF $<

dphils: dphils.o $(OBJDIR)/lib/unix_support_pthreads.o $(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

http_proxy: http_proxy.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

http_proxy.real: http_proxy.real.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_bootp -loskit_threads -loskit_unix \
		-loskit_freebsd_net -loskit_linux_dev \
		-loskit_netbsd_fs -loskit_diskpart -loskit_dev \
		$(CLIB) $(CRTEND)

disktest: disktest.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

disktest.real: disktest.real.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_threads -loskit_unix -loskit_linux_dev \
		-loskit_netbsd_fs -loskit_diskpart -loskit_dev \
		$(CLIB) $(CRTEND)

disknet: disknet.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

sigtest: sigtest.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos -loskit_fsnamespace_r \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

inherit-test1: inherit-test1.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

inherit-condtest: inherit-condtest.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

inherit-test4: inherit-test4.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_memfs \
		-loskit_threads -loskit_freebsd_c_r -loskit_bootp \
		-loskit_freebsd_net \
		-loskit_linux_dev -loskit_dev -loskit_kern \
		-loskit_freebsd_c_r -loskit_com -loskit_lmm -loskit_netbsd_fs \
		-loskit_diskpart -loskit_fs -loskit_com \
		-loskit_threads \
		-loskit_freebsd_dev $(CRTEND)

ipctest: ipctest.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

pri-inversion: pri-inversion.o $(OBJDIR)/lib/unix_support_pthreads.o \
		$(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)

test: test.o $(OBJDIR)/lib/unix_support_pthreads.o $(DEPENDLIBS)
	$(CC) -o $@ $(CRT0) $@.o $(LDFLAGS) $(OSKIT_LDFLAGS) \
		$(OBJDIR)/lib/unix_support_pthreads.o \
		-loskit_startup -loskit_clientos \
		-loskit_threads -loskit_unix -loskit_dev \
		$(CLIB) $(CRTEND)
endif
