# @(#) makefile for compiling udpxy for/on Asus WL500g
#
# Copyright 2008 Pavel V. Cherenkov
#
#  This file is part of udpxy.
#
#  udpxy is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  udpxy is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with udpxy.  If not, see <http://www.gnu.org/licenses/>.
#

.SUFFIXES : .o .c .d

EXEC = udpxy
CFLAGS = -W -Wall -Werror --pedantic

COMMON_OPT =
DEBUG_OPT = $(COMMON_OPT) -g -DTRACE_MODULE
PROD_OPT = $(COMMON_OPT) -DNDEBUG -DTRACE_MODULE
LEAN_OPT = -DNDEBUG

MKDEPOPT = -M

SRC = udpxy.c rparse.c util.c prbuf.c ifaddr.c ctx.c mkpg.c \
	  rtp.c uopt.c dpkt.c netop.c extrn.c udpxrec.c main.c
OBJ = ${SRC:.c=.o}
DEP = ${SRC:.c=.d}


CORES = core.* core

.c.d :
	$(CC) $(CFLAGS) $(MKDEPOPT) $< -o $@

.c.o :
	$(CC) $(CFLAGS) $(CDEFS) $(COPT) -c $< -o $@

release:
	@echo -e "\nMaking a [release] version (use 'debug' target as an alternative)\n"
	@make all "COPT=${PROD_OPT}"

debug:
	@echo -e "\nMaking a [debug] version (use 'release' target as an alternative)\n"
	@make all "COPT=${DEBUG_OPT}"

lean:
	@echo -e "\nMaking a [lean] version (minimal size)\n"
	@make all "COPT=${LEAN_OPT}"

all:	$(DEP) $(EXEC)

deps:
	$(CC) $(CFLAGS) $(MKDEPOPT) $(SRC)

-include $(DEP)
$(DEP): $(SRC)

$(EXEC) : $(OBJ)
	@rm -f $(EXEC)
	$(CC) $(CFLAGS) $(COPT) -o $(EXEC) $(OBJ)
	@ls -l $(EXEC)

strip:
	@echo "Stripping $(EXEC)"
	@strip $(EXEC)
	@ls -l $(EXEC)

touch:
	touch $(SRC)

clean:
	rm -f $(CORES) $(DEP) $(OBJ) $(EXEC) $(DEBUG_EXEC)

# __EOF__

