#
# Makefile for the ipsec routines
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definition is now in the main makefile...

CRYPTO_DIR := crypto

TR_DIR := transforms


O_OBJS := 
OX_OBJS := 
M_OBJS :=
MI_OBJS :=

ALL_SUB_DIRS := $(TR_DIR) $(CRYPTO_DIR)

all_targets: ipsec.o

CRYPTO_OBJS := $(CRYPTO_DIR)/crypto.o

TR_OBJS := $(TR_DIR)/ipsec_transforms.o

IPSEC_OBJS := sadb.o ipsec_util.o ipsec_output.o ipsec_input.o transform.o $(TR_OBJS) $(CRYPTO_OBJS)

ifeq ($(CONFIG_IPSEC),y)
O_OBJS += $(IPSEC_OBJS) 
O_OBJS +=  ipsec_register.o
IPSEC_DEP := crypto_dir transform_dir
ipsec.o: $(IPSEC_DEP) $(O_OBJS)
	$(LD) $(LD_RFLAG) -r -o $@ $(O_OBJS)

else
ifeq ($(CONFIG_IPSEC),m)
OX_OBJS +=  ipsec_register.o
MOD_LIST_NAME := IPSEC_MODULES
MI_OBJS += $(IPSEC_OBJS)
M_OBJS += ipsec_mod.o
ipsec.o: $(OX_OBJS)
	$(LD) $(LD_RFLAG) -r -o $@ $(OX_OBJS)
endif
endif

include $(TOPDIR)/Rules.make

crypto_dir:
	make -C $(CRYPTO_DIR) all

transform_dir:
	make -C $(TR_DIR) all

ipsec_mod.o: crypto_dir transform_dir $(MI_OBJS) $(MIX_OBJS)
	$(LD) $(LD_RFLAG) -r -o $@ $(MI_OBJS) $(MIX_OBJS)
