1include ../config.mk
2include ../config.in
3
4SHELL=/bin/sh
5
6BINDIR=$(TARGETDIR)/usr/sbin
7ETCDIR=$(TARGETDIR)/etc
8
9##
10## Variables
11##
12
13# Final executable
14EXEC=gproxy
15
16# Directories
17TOP_DIR=.
18SRCDIR:=$(TOP_DIR)/src
19
20# Compiler flags
21#CFLAGS+=-D@OS@ 
22CFLAGS+=-O2 -Wall 
23CFLAGS+= -I$(SRCDIR)/include -I../../acos/include -I../../acos/shared 
24
25ifeq ($(CONFIG_STATIC_PPPOE),y)
26CFLAGS  += -DSTATIC_PPPOE
27else
28CFLAGS  += -USTATIC_PPPOE
29endif
30
31#-I/usr/include
32#CC=@CC@
33
34THREAD_LIBS= -lpthread
35
36# Linker flags
37LDFLAGS += $(THREAD_LIBS)
38LDFLAGS	+= -L$(ROUTERDIR)/nvram -L$(INSTALLDIR)/nvram/usr/lib -lnvram
39LDFLAGS += -L../../acos/shared -L$(TARGETDIR)/shared/usr/lib -lacos_shared -L../../acos/acos_nat_cli -lnat
40#Foxconn add start by Hank 07/30/2012
41#For Kernel 2.6.36
42ifeq ($(CONFIG_KERNEL_2_6_36),y)
43LDFLAGS	+= -lgcc_s
44endif
45#Foxconn add end by Hank 07/30/2012
46
47# Object files
48OBJ_ALL=*.o
49SRC=$(wildcard $(SRCDIR)/*.c)
50# The following will expand to the full path of every .o file:
51OBJS=$(SRC:.c=.o)
52
53
54##
55## Targets
56##
57
58# We're only interested in .o and .c prefixes (the following two lines make this
59# Makefile more portable)
60.SUFFIXES:
61.SUFFIXES:.o .c
62
63# .PHONY targets : will be executed even if up to date. See GNU 
64# Make Manual section 4.6 for further details
65.PHONY: clean all mrproper generate $(DIRS) rec_exec install help
66# Of course $(EXEC) isn't phony ! ("and I know phony, I'm a clown-fish" - Marlin :-))
67
68# Default target :
69all: $(EXEC)
70
71
72$(EXEC): $(OBJS)
73	$(CC) $(LDFLAGS) -o $(EXEC) $(OBJS)
74
75
76%.o: %.c
77	$(CC) -c $(CFLAGS) -o $@ $<
78
79
80help:
81	@ echo "Available targets :" 
82	@ echo "  help : this message."
83	@ echo "  all : build everything and produce $(EXEC) executable."
84	@ echo "  clean : remove all objects file."
85	@ echo "  mrproper : same as clean + remove $(EXEC) + remove files generated by ./configure + remove doc.\
86You'll need to run ./configure again after that."
87	@ echo "  generate : (UNIX )re-create Makefile's in subdirectories. Execute this after deep \
88modificaton of the code when dependencies have changed. This will recreate them."
89	@ echo "  install : does nothing."
90	@ echo "  doc : run doxygen to generate HTML n TeX doc of the code."
91	@ echo "  <DIR> : where <DIR> is one of the sub-dir, to recompile only this very subdir."
92
93doc:
94	@ doxygen $(TOP_DIR)/Doxyfile
95
96install:
97	@ echo "This target does currently nothing. The executable remain in"
98	@ echo "this directory for greater convinience when used in conjunction"
99	$(STRIP) $(EXEC)
100	cp $(EXEC) ${BINDIR}
101	cp ./etc/igmprt.conf ${ETCDIR}
102
103clean:
104	-rm -rf $(TOP_DIR)/src/*.o $(TOP_DIR)/$(EXEC)
105# Make ignore return status of commands begining with '-'
106mrproper: clean
107	-rm $(TOP_DIR)/$(EXEC) 
108	-rm $(TOP_DIR)/*~ 
109	-rm $(TOP_DIR)/src/*~ 
110	-rm $(SRCDIR)/include/conf.h 
111	-rm $(TOP_DIR)/Makefile 
112	-rm $(TOP_DIR)/config.cache
113	-rm -rf $(TOP_DIR)/doc
114