KLIPSDIR:= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)/..

EXTRA_CFLAGS:=-I$(KLIPSDIR) -I$(KLIPSDIR)/libfreeswan -I$(KLIPSDIR)/ext/include
ifeq ($(CONFIG_IPSEC_DEBUG),y)
EXTRA_CFLAGS += -g
endif
EXTRA_CFLAGS += -Wall -Wpointer-arith -Wstrict-prototypes

MOD_LIST_NAME := NET_MISC_MODULES

#O_TARGET := ipsec_ext_static.o

subdir-  := 
subdir-n := 
subdir-y :=
subdir-m :=

obj-y := ipsec_ext_static_init.o

ARCH_ASM-y :=
ARCH_ASM-$(CONFIG_M586)		:= i586
ARCH_ASM-$(CONFIG_M586TSC)	:= i586
ARCH_ASM-$(CONFIG_M586MMX)	:= i586
ARCH_ASM-$(CONFIG_MK6)		:= i586
ARCH_ASM-$(CONFIG_M686)		:= i686
ARCH_ASM-$(CONFIG_MPENTIUMIII)	:= i686
ARCH_ASM-$(CONFIG_MPENTIUM4)	:= i686
ARCH_ASM-$(CONFIG_MK7)		:= i686
ARCH_ASM-$(CONFIG_MCRUSOE)	:= i586
ARCH_ASM-$(CONFIG_MWINCHIPC6)	:= i586
ARCH_ASM-$(CONFIG_MWINCHIP2)	:= i586
ARCH_ASM-$(CONFIG_MWINCHIP3D)	:= i586
ARCH_ASM-$(CONFIG_USERMODE)	:= i586

ARCH_ASM :=$(ARCH_ASM-y)
ifdef NO_ASM
ARCH_ASM :=
endif

# The algorithm makefiles may put dependences, short-circuit them
null:

makefiles=$(wildcard Makefile.ext_*)
ifneq ($(makefiles), "")
#include Makefile.ext_aes
#include Makefile.ext_aes-opt
include $(makefiles)
endif

# These rules translate from new to old makefile rules
# Translate to Rules.make lists.
multi-used      := $(filter $(list-multi), $(obj-y) $(obj-m))
multi-objs      := $(foreach m, $(multi-used), $($(basename $(m))-objs))
active-objs     := $(sort $(multi-objs) $(obj-y) $(obj-m))
O_OBJS          := $(obj-y)
M_OBJS          := $(obj-m)
MIX_OBJS        := $(filter $(export-objs), $(active-objs))
#OX_OBJS := $(export-objs)
SUB_DIRS := $(subdir-y)
ALL_SUB_DIRS := $(subdir-y) $(subdir-m)
MOD_SUB_DIRS := $(subdir-m)


ifdef TOPDIR
include $(TOPDIR)/Rules.make
endif

ipsec_ext_static.o: $(obj-y) 
	rm -f $@
	$(LD) $(LD_EXTRAFLAGS) $(obj-y) -r -o $@

$(obj-y) $(obj-m):  $(TOPDIR)/include/linux/config.h $(TOPDIR)/include/linux/autoconf.h ../ipsec_ext.h
$(ext_obj-y) $(ext_obj-m): $(TOPDIR)/include/linux/config.h $(TOPDIR)/include/linux/autoconf.h ../ipsec_ext.h


ext_modules: $(EXT_MODULES)
	@echo "EXT_MODULES=$(EXT_MODULES)"


#
# Construct ext. init. function: call ipsec_ALGO_init() for every static algo
# Needed when there are static algos (with static or modular ipsec.o)
#
ipsec_ext_static_init.c: $(TOPDIR)/include/linux/autoconf.h Makefile $(makefiles) include/mk-static_init.c.sh
	@echo "Re-creating $@"
	$(SHELL) include/mk-static_init.c.sh $(static_init-func-y) > $@

clean:
	@for i in $(EXT_SUBDIRS);do make -C $$i clean;done
	-rm -f *.o ipsec_ext_static_init.c

