
include	../Makerules
include	../Makeconfig

#CFLAGS=-g -Wall -O2 -nostdinc -I/usr/local/lib/gcc-lib/i486-sysv4/2.4.5/include/ -I/home/eric/linux/usr/include/
#CFLAGS=-g -Wall -O2 -fPIC
#CC=/usr/local/bin/gcc
#
# For SVr4/ELF systems, libc.so.1 contains both the dynamic linker and libc.
#
SRC1S = resolve.S
SRC2S = elfinterp.c hash.c readelflib1.c  boot1.c

SRCS	= $(SRC1S) $(SRC2S)
ASMS	= $(SCR1S:.S=.s) $(SRC2S:.c=.s)
OBJ1S	= $(SRC1S:.S=.o)
OBJ2S	= $(SRC2S:.c=.o)
OBJS	= $(OBJ1S) $(OBJ2S)

LIBSRC = libctype.o    libi386.o    libsignal.o	  libstdlib.o globals.o \
	libsysdeps.o   libcvt.o     libmalloc.o   libstdio.o	  libstring.o \
	libsvr4.o	libdirent.o liblocale.o	  libtime.o	libpwd.o

ifdef PIC
../libc.so.1: Makefile elfinterp.o hash.o readelflib1.o  resolve.o boot1.o $(LIBSRC)
	$(LD) -e _dl_boot -G -o ../libc.so.1 boot1.o elfinterp.o resolve.o hash.o \
	readelflib1.o $(LIBSRC)
	$(NM) -x ../libc.so.1 | grep _dl_boot | sed 's/|0x0/ 0x8/g' | grep FUNC | \
	awk '{print "add-symbol-file /usr/lib/libc.so.1 " $$2}' > .gdbinit

else
../libc.so.1: Makefile crt0.o elfinterp.o hash.o readelflib1.o  resolve.o $(LIBSRC)
	$(LD) -T elf_i386.x -e __interpreter_entry -o ../libc.so.1 crt0.o \
	elfinterp.o \
	resolve.o hash.o readelflib1.o $(LIBSRC)
endif

test: test.o ../libc.so.1
	ld -o test -I ../libc.so.1 test.o ../libc.so.1

test.o: test.c
	$(CC) -c test.c

globals.o: globals.c

dist:
	tar cf - * | gzip > linuxelf.tar.z

clean:
	rm -f *.o

dep:
	$(CPP) $(CFLAGS) -M $(SRCS) > .depend

dummy:

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
