#
# Makefile for Hermes-I/II library for Linux
# Includes HCF, DHF, STA and AP Firmware 
#
# Aug 2002  Richard van Leeuwen
# Apr 2003  Victor Soriano
#

# Define the names of the possible build targets
LIBSTA_H1  = libsta-h1
LIBAP_H1   = libap-h1
LIBSTAP_H1 = libstap-h1
LIBSTA_H2  = libsta-h2
LIBAP_H2   = libap-h2
LIBSTAP_H2 = libstap-h2

TARGETS = $(LIBSTA_H1).a $(LIBAP_H1).a $(LIBSTAP_H1).a \
          $(LIBSTA_H2).a $(LIBAP_H2).a $(LIBSTAP_H2).a

# Get some necessary information about the distribution
KERNEL_VER := $(shell uname -r)
LINUX = /lib/modules/$(KERNEL_VER)/build

# Define relative pathnames for the source package
DIR_DRIVER  = ../include/wireless
DIR_CONFIG  = ../include/hcf
DIR_HCF     = ../hcf
DIR_DHF     = ../hcf
DIR_MMD     = ../hcf
DIR_FW      = ../firmware


# Define the names of the objects for each build target
# Each must be unique to support incremental builds
OBJS_STA_H1 =	$(DIR_HCF)/mmd_sta_h1.o \
		$(DIR_HCF)/hcfio_sta_h1.o \
		$(DIR_HCF)/hcf_sta_h1.o \
		$(DIR_DHF)/dhf_sta_h1.o \
		$(DIR_FW)/sta_h1.o

OBJS_AP_H1 =	$(DIR_HCF)/mmd_ap_h1.o \
		$(DIR_HCF)/hcfio_ap_h1.o \
	        $(DIR_HCF)/hcf_ap_h1.o \
	        $(DIR_DHF)/dhf_ap_h1.o \
                $(DIR_FW)/ap_h1.o

OBJS_STAP_H1 =	$(DIR_HCF)/mmd_stap_h1.o \
		$(DIR_HCF)/hcfio_stap_h1.o \
	        $(DIR_HCF)/hcf_stap_h1.o \
	        $(DIR_DHF)/dhf_stap_h1.o \
		$(DIR_FW)/sta_h1.o \
		$(DIR_FW)/ap_h1.o 

OBJS_STA_H2 =	$(DIR_HCF)/mmd_sta_h2.o \
		$(DIR_HCF)/hcfio_sta_h2.o \
	        $(DIR_HCF)/hcf_sta_h2.o \
	        $(DIR_DHF)/dhf_sta_h2.o \
		$(DIR_FW)/sta_h2.o

OBJS_AP_H2 =	$(DIR_HCF)/mmd_ap_h2.o \
		$(DIR_HCF)/hcfio_ap_h2.o \
	        $(DIR_HCF)/hcf_ap_h2.o \
	        $(DIR_DHF)/dhf_ap_h2.o \
		$(DIR_FW)/ap_h2.o
	        
OBJS_STAP_H2 =	$(DIR_HCF)/mmd_stap_h2.o \
		$(DIR_HCF)/hcfio_stap_h2.o \
	        $(DIR_HCF)/hcf_stap_h2.o \
	        $(DIR_DHF)/dhf_stap_h2.o \
		$(DIR_FW)/sta_h2.o \
		$(DIR_FW)/ap_h2.o
	        
# Define commands and flags for compiling, creating the archive, etc.
RM = rm -f
CC = gcc

AR = ar
ARFLAGS = rcs

COPTS       = -O -Wall 
CINCS       = -I. -I$(DIR_CONFIG) -I$(DIR_DRIVER) -I$(DIR_DHF) -I$(DIR_HCF) -I$(DIR_MMD) -I$(DIR_FW) -I$(LINUX)/include -I../include

CDEFS_COMMON	= -D__KERNEL__ -DMODULE -DWVLAN_49 -DUSE_WPA 
CDEFS_STA_H1	= $(CDEFS_COMMON) -DSTA_ONLY
CDEFS_AP_H1	= $(CDEFS_COMMON) -DAP_ONLY
CDEFS_STAP_H1	= $(CDEFS_COMMON)
CDEFS_STA_H2    = $(CDEFS_COMMON) -DSTA_ONLY -DHERMES2
CDEFS_AP_H2	= $(CDEFS_COMMON) -DAP_ONLY -DHERMES2
CDEFS_STAP_H2	= $(CDEFS_COMMON) -DHERMES2
CDEFS_FW	= $(CDEFS_COMMON)

CFLAGS_STA_H1	= $(COPTS) $(CINCS) $(CDEFS_STA_H1)
CFLAGS_AP_H1	= $(COPTS) $(CINCS) $(CDEFS_AP_H1)
CFLAGS_STAP_H1	= $(COPTS) $(CINCS) $(CDEFS_STAP_H1)
CFLAGS_STA_H2	= $(COPTS) $(CINCS) $(CDEFS_STA_H2)
CFLAGS_AP_H2	= $(COPTS) $(CINCS) $(CDEFS_AP_H2)
CFLAGS_STAP_H2	= $(COPTS) $(CINCS) $(CDEFS_STAP_H2)
CFLAGS_FW	= $(COPTS) $(CINCS) $(CDEFS_FW)


#
# Targets
#

all:: $(TARGETS)

$(LIBSTA_H1).a: $(OBJS_STA_H1)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_STA_H1)

$(LIBAP_H1).a: $(OBJS_AP_H1)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_AP_H1)

$(LIBSTAP_H1).a: $(OBJS_STAP_H1)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_STAP_H1)

$(LIBSTA_H2).a: $(OBJS_STA_H2)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_STA_H2)

$(LIBAP_H2).a: $(OBJS_AP_H2)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_AP_H2)

$(LIBSTAP_H2).a: $(OBJS_STAP_H2)
	$(RM) $@
	$(AR) $(ARFLAGS) $@ $(OBJS_STAP_H2)


clean:
	$(RM) *.a $(DIR_DHF)/*.o $(DIR_DHF)/*.d $(DIR_HCF)/*.o $(DIR_HCF)/*.d $(DIR_MMD)/*.o $(DIR_MMD)/*.d  $(DIR_FW)/*.o $(DIR_FW)/*.d


#
# Rules to build the FW - same for all
#

$(DIR_FW)/sta_h1.o: $(DIR_FW)/sta_h1.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_FW)/sta_h1.o $(CFLAGS_FW) -c $(DIR_FW)/sta_h1.c

$(DIR_FW)/ap_h1.o: $(DIR_FW)/ap_h1.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_FW)/ap_h1.o $(CFLAGS_FW) -c $(DIR_FW)/ap_h1.c

$(DIR_FW)/sta_h2.o: $(DIR_FW)/sta_h2.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_FW)/sta_h2.o $(CFLAGS_FW) -DHERMES2 -c $(DIR_FW)/sta_h2.c
	
$(DIR_FW)/ap_h2.o: $(DIR_FW)/ap_h2.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_FW)/ap_h2.o $(CFLAGS_FW) -c -DHERMES2 $(DIR_FW)/ap_h2.c


#
# Rules to build Hermes-1 STA mode 
#

$(DIR_HCF)/hcfio_sta_h1.o: $(DIR_HCF)/hcfio.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -MD -o $(DIR_HCF)/hcfio_sta_h1.o $(CFLAGS_STA_H1) -c $(DIR_HCF)/hcfio.c

$(DIR_HCF)/hcf_sta_h1.o: $(DIR_HCF)/hcf.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -o $(DIR_HCF)/hcf_sta_h1.o $(CFLAGS_STA_H1) -c $(DIR_HCF)/hcf.c

$(DIR_MMD)/mmd_sta_h1.o: $(DIR_MMD)/mmd.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -o $(DIR_MMD)/mmd_sta_h1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d.h
	$(CC) -o $(DIR_DHF)/dhf_ap_h1.o $(CFLAGS_AP_H1) -c $(DIR_DHF)/dhf.c


#
# Rules to build Hermes-1 STAP mode 
#

$(DIR_HCF)/hcfio_stap_h1.o: $(DIR_HCF)/hcfio.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -MD -o $(DIR_HCF)/hcfio_stap_h1.o $(CFLAGS_STAP_H1) -c $(DIR_HCF)/hcfio.c

$(DIR_HCF)/hcf_stap_h1.o: $(DIR_HCF)/hcf.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -o $(DIR_HCF)/hcf_stap_h1.o $(CFLAGS_STAP_H1) -c $(DIR_HCF)/hcf.c

$(DIR_MMD)/mmd_stap_h1.o: $(DIR_MMD)/mmd.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -o $(DIR_MMD)/mmd_stap_h1.o $(CFLAGS_STAP_H1) -c $(DIR_MMD)/mmd.c

$(DIR_DHF)/dhf_stap_h1.o: $(DIR_DHF)/dhf.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_DHF)/dhf_stap_h1.o $(CFLAGS_STAP_H1) -c $(DIR_DHF)/dhf.c


#
# Rules to build Hermes-2 STA mode
#

$(DIR_HCF)/hcfio_sta_h2.o: $(DIR_HCF)/hcfio.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/h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)/mmd_stap_h2.o: $(DIR_MMD)/mmd.c \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h \
	$(DIR_HCF)/hcfdef.h
	$(CC) -o $(DIR_MMD)/mmd_stap_h2.o $(CFLAGS_STAP_H2) -c $(DIR_MMD)/mmd.c

$(DIR_DHF)/dhf_stap_h2.o: $(DIR_DHF)/dhf.c \
	$(DIR_DHF)/dhf.h \
	$(DIR_HCF)/hcf.h \
	$(DIR_CONFIG)/hcfcfg.h \
	$(DIR_MMD)/mmd.h \
	$(DIR_HCF)/mdd.h
	$(CC) -o $(DIR_DHF)/dhf_stap_h2.o $(CFLAGS_STAP_H2) -c $(DIR_DHF)/dhf.c

#
# End Of File
#
