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
40
41# Object files
42OBJ_ALL=*.o
43SRC=$(wildcard $(SRCDIR)/*.c)
44# The following will expand to the full path of every .o file:
45OBJS=$(SRC:.c=.o)
46
47
48##
49## Targets
50##
51
52# We're only interested in .o and .c prefixes (the following two lines make this
53# Makefile more portable)
54.SUFFIXES:
55.SUFFIXES:.o .c
56
57# .PHONY targets : will be executed even if up to date. See GNU 
58# Make Manual section 4.6 for further details
59.PHONY: clean all mrproper generate $(DIRS) rec_exec install help
60# Of course $(EXEC) isn't phony ! ("and I know phony, I'm a clown-fish" - Marlin :-))
61
62# Default target :
63all: $(EXEC)
64
65$(EXEC): $(OBJS)
66	$(CC) $(LDFLAGS) -o $(EXEC) $(OBJS)
67
68
69%.o: %.c
70	$(CC) -c $(CFLAGS) -o $@ $<
71
72
73help:
74	@ echo "Available targets :" 
75	@ echo "  help : this message."
76	@ echo "  all : build everything and produce $(EXEC) executable."
77	@ echo "  clean : remove all objects file."
78	@ echo "  mrproper : same as clean + remove $(EXEC) + remove files generated by ./configure + remove doc.\
79You'll need to run ./configure again after that."
80	@ echo "  generate : (UNIX )re-create Makefile's in subdirectories. Execute this after deep \
81modificaton of the code when dependencies have changed. This will recreate them."
82	@ echo "  install : does nothing."
83	@ echo "  doc : run doxygen to generate HTML n TeX doc of the code."
84	@ echo "  <DIR> : where <DIR> is one of the sub-dir, to recompile only this very subdir."
85
86doc:
87	@ doxygen $(TOP_DIR)/Doxyfile
88
89install:
90	@ echo "This target does currently nothing. The executable remain in"
91	@ echo "this directory for greater convinience when used in conjunction"
92	$(STRIP) $(EXEC)
93	cp $(EXEC) ${BINDIR}
94	cp ./etc/igmprt.conf ${ETCDIR}
95
96clean:
97	-rm -rf $(TOP_DIR)/src/*.o $(TOP_DIR)/$(EXEC)
98# Make ignore return status of commands begining with '-'
99mrproper: clean
100	-rm $(TOP_DIR)/$(EXEC) 
101	-rm $(TOP_DIR)/*~ 
102	-rm $(TOP_DIR)/src/*~ 
103	-rm $(SRCDIR)/include/conf.h 
104	-rm $(TOP_DIR)/Makefile 
105	-rm $(TOP_DIR)/config.cache
106	-rm -rf $(TOP_DIR)/doc
107