# Generated automatically from Makefile.in by configure.
# $Id: Makefile,v 1.1 2000/05/05 20:15:21 prigaux Exp $

srcdir=.
prefix=/usr
exec_prefix=
sbindir=${exec_prefix}/sbin
mandir=${prefix}/man
insmod_static=no

ARCH		= i386
CC		= gcc
CFLAGS		= -O2 -Wall
LDFLAGS		= 
HOSTCC		= gcc
HOSTCFLAGS	= -O2 -Wall
AR		= ar
RANLIB		= ranlib
INSTALL		= install
STRIP		= -s

DEFSNOARCH	:= -I$(srcdir)/../include -D_GNU_SOURCE  -DCOMPAT_2_0=1  $(EXTRA_DEFS)
DEFS		:= -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH)

PROGS		:= 

# COMB is the list of utilities to combine with insmod into one executable
COMB		:= rmmod modprobe lsmod ksyms
COMBDEFS	:= $(addprefix -DCOMBINE_, $(COMB))
COMB_STATIC	:= $(addsuffix .static, $(COMB))

TARGETS_REAL	:= $(filter-out $(COMB),$(PROGS))
TARGETS	:= libmodutils.a(insmod.o rmmod.o)

ifeq ($(insmod_static),yes)
TARGETS_REAL	+= insmod.static
TARGETS		+= insmod.static $(COMB_STATIC)
endif

INSMODOBJS	:= insmod.o
MODINFOOBJS	:= modinfo.o

ifeq (no,yes)
INSMODOBJS	+= insmod_64.o
MODINFOOBJS	+= modinfo_64.o
DEFSNOARCH	+= -DCOMMON_3264
DEFS		+= -DONLY_32
DEFS64		:= -DELF_MACHINE_H='"elf_sparc64.h"' -DARCH_sparc64 -DONLY_64
endif

INSMODOBJS	+= $(addsuffix .o, $(COMB))

#=====================================================================

# Rule for building "to-be-combined" modutils object files
%.o: %.c
	$(CC) $(CFLAGS) $(DEFSNOARCH) $(DEFS) $(COMBDEFS) -c -o $@ $<

# Rule for building 64 bit versions, only used when building common code
# for 32 and 64 bit systems.
%_64.o: %.c
	$(CC) $(CFLAGS) $(DEFSNOARCH) $(DEFS64) $(COMBDEFS) -c -o $@ $<

# Rule for building "normal" modutils executables (non-combined)
%: %.c ../util/libutil.a
	$(CC) $(CFLAGS) $(DEFSNOARCH) $(DEFS) -o $@ $^ $(LDFLAGS)

#=====================================================================

all: $(TARGETS)

insmod: $(INSMODOBJS) ../obj/libobj.a ../util/libutil.a
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

insmod.static: $(INSMODOBJS) ../obj/libobj.a ../util/libutil.a
	$(CC) -static $(CFLAGS) -o $@ $^ $(LDFLAGS)

$(COMB): insmod
	ln -sf $< $@

$(COMB_STATIC): insmod.static
	ln -sf $< $@

modinfo: $(MODINFOOBJS) ../obj/libobj.a ../util/libutil.a
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

install install-bin: all
	@set -x;\
	for i in $(TARGETS_REAL); do \
	$(INSTALL) $(STRIP) $$i $(sbindir); done;
	for i in $(srcdir)/insmod_ksymoops_clean $(srcdir)/kernelversion; do \
	$(INSTALL) $$i $(sbindir); done;
	for i in $(COMB); do \
	ln -sf insmod $(sbindir)/$$i; \
	(test "$(insmod_static)" = yes && \
		ln -sf insmod.static $(sbindir)/$$i.static) || true; \
	done

clean:
	rm -f *.o $(PROGS) *.static libmodutils.a

realclean: clean
	rm -f .depend

distclean: realclean
	rm -f Makefile

dep depend .depend: $(addsuffix .c, $(PROGS))
	$(CC) -M $(CFLAGS) $(DEFSNOARCH) $(DEFS) $^ > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
