all_target( util_lib.a stub_gen )

CFLAGS = $(STD_C_FLAGS)

#if MALLOC_DEBUG
MALLOC_OBJ = malloc.o
#endif

#if !HAS_FLOCK
FLOCK_OBJ = flock.o
#endif

#if !HAVE_SETEUID
SETEUID_OBJ = seteuid.o
#endif

#if !HAVE_SETEGID
SETEGID_OBJ = setegid.o
#endif

#if !HAVE_GETDTABLESIZE
GETDTABLESIZE_OBJ = getdtablesize.o
#endif

#if !HAVE_GETWD
GETWD_OBJ = getwd.o
#endif

#if !HAVE_GETPAGESIZE
GETPAGESIZE_OBJ = getpagesize.o
#endif

#if !HAVE_SETLINEBUF
SETLINEBUF_OBJ = setlinebuf.o
#endif

#ifndef HAS_INET_NTOA
INET_NTOA_OBJ = inet_ntoa.o
#endif

#if IS_LINUX
PERS_OBJ = condor_pers.o
#else
PERS_OBJ = 
#endif

#if IS_LINUX
FDPASS_OBJ = fdpass.o
#endif

#define ObjectFiles \
	blankline.o do_connect.o except.o \
	dprintf.o dprintf_common.o dprintf_config.o \
	ltrunc.o mkargv.o proc.o signames.o \
	get_port_range.o \
	detach.o update_rusage.o cronos.o \
	$(FLOCK_OBJ) \
	email.o email_file.o \
	$(GETDTABLESIZE_OBJ) $(MALLOC_OBJ)\
	$(SETEGID_OBJ) $(SETEUID_OBJ) $(GETPAGESIZE_OBJ) $(SETLINEBUF_OBJ) \
	$(GETWD_OBJ) ckpt_name.o \
	lock_file.NON_POSIX.o getmnt.o $(INET_NTOA_OBJ) \
	syscall_numbers.o sig_install.o internet.o startup_info.o escapes.o\
	ckpt_util.o get_random_num.o rotate_file.o \
	setsyscalls.o match_prefix.o sleep.o basename.o strcmp_until.o\
	filename_tools.o d_format_time.o chomp.o strupr.o globus_utils.o \
	string_funcs.o \
	condor_universe.o condor_perms.o access_euid.o \
	condor_snutils.o printf_format.o nullfile.o copy_file.o \
	get_exec_path.o exit_utils.o condor_blkng_full_disk_io.o \
	condor_full_io.o condor_pidenvid.o condor_create_id.o \
	condor_netdb.o fs_util.o condor_mkstemp.o $(PERS_OBJ) \
	$(FDPASS_OBJ)

test: test.o util_lib.a
	$(CC) $(CFLAGS) -o test test.o util_lib.a

test_snprintf: test_snprintf.o util_lib.a
	$(CC) $(CFLAGS) -o test_snprintf test_snprintf.o util_lib.a

test_uids: test_uids.o
	$(CC) $(CFLAGS) -o test_uids test_uids.o

test_exit_utils: test_exit_utils.o
	$(CC) $(CFLAGS) -o test_exit_utils test_exit_utils.o util_lib.a

test_basename: test_basename.o
	$(CC) $(CFLAGS) -o test_basename test_basename.o basename.o

test_fs_util: fs_util.c
	$(CC) $(CFLAGS) -DFS_UTIL_TEST -o $@ $<

clean::
	rm -f test_fs_util

clean::
	rm -f test_spawn.o

test_get_exec_path: test_get_exec_path.o util_lib.a
	$(CC) $(CFLAGS) -o test_get_exec_path test_get_exec_path.o util_lib.a

library_target(util_lib.a,ObjectFiles)

stub_gen: y.tab.o lex.yy.o
	$(CC) $(CFLAGS) -o stub_gen y.tab.o lex.yy.o $(LEXLIB) $(NOWRAP_LDFLAGS)

clean::
	rm -f stub_gen y.tab.o lex.yy.o 

lex.yy.c: stub_gen_lex.l scanner.h y.tab.h
	$(LEX) stub_gen_lex.l
clean::
	rm -f lex.yy.c

y.tab.h: y.tab.c

y.tab.c: stub_gen_yacc.y scanner.h
	$(YACC) -d stub_gen_yacc.y
clean::
	rm -f y.tab.c y.tab.h

IMPORT_LINKS = ../../config/import_links
import_objs(../h,syscall_numbers.c)

release:: all
stripped:: all
static:: all
html:
testbin::

#if IS_LINUX
c_plus_nowrap_target(fdpass_test,fdpass_test.o fdpass.o,$(STD_LIBS))
#endif
