# 
# configurable options
#  - set DEBUG = 1 to turn on debugging support
#
DEBUG = 0
PROJ_NAME = dhcpcd
KERNELBUILDDIR = $(error kernel build directory required)
INSTALL_DIR = 
PROGS := $(PROJ_NAME).exe
CFLAGS +=

#
# You should not need to modify anything beyond this point
#
include Rules.mak

ifeq '$(DEBUG)' '1'
	PROGS += $(PROGS:.exe=.gdb)
endif

FLTFLAGS += -s 16384
SOURCES = \
	peekfd.c		\
	udpipgen.c		\
	buildmsg.c		\
	signals.c		\
	arp.c			\
	client.c		\
	dhcpcd.c		\
	signals.h		\
	buildmsg.h		\
	client.h		\
	dhcpcd.h		\
	pathnames.h		\
	signals.h		\
	udpipgen.h

OBJS = \
	peekfd.o		\
	udpipgen.o		\
	buildmsg.o		\
	signals.o		\
	arp.o			\
	client.o		\
	dhcpcd.o

CFLAGS += -D__UCLINUX__ #-I$(KERNELBUILDDIR)/include
#CFLAGS += -DDEBUG
CFLAGS += \
    -DPACKAGE=\"dhcpcd\" \
    -DVERSION=\"1.3.22-pl1\" \
    -DSTDC_HEADERS=1 \
    -DHAVE_FCNTL_H=1 \
    -DHAVE_PATHS_H=1 \
    -DHAVE_SYS_IOCTL_H=1 \
    -DHAVE_SYS_TIME_H=1 \
    -DHAVE_SYSLOG_H=1 \
    -DHAVE_UNISTD_H=1 \
    -DHAVE_SYS_TYPES_H=1 \
    -DHAVE_SYS_STAT_H=1 \
    -DHAVE_STDLIB_H=1 \
    -DHAVE_STRING_H=1 \
    -DHAVE_MEMORY_H=1 \
    -DHAVE_STRINGS_H=1 \
    -DHAVE_INTTYPES_H=1 \
    -DHAVE_STDINT_H=1 \
    -DHAVE_UNISTD_H=1 \
    -DTIME_WITH_SYS_TIME=1 \
    -DHAVE_SELECT=1 \
    -DHAVE_SOCKET=1 \
    -DHAVE_UNAME=1 

all: $(PROGS)

$(PROJ_NAME).bin : $(OBJS)

.PHONY: clean
clean:
	-rm -f *.[oad] *.elf *.gdb *.bin *.exe

.PHONY: install
install: all
ifeq "$(INSTALL_DIR)" ""
	$(error No installation directory specified)
endif
	mkdir -p $(INSTALL_DIR)/bin
	install -v $(filter %.exe, $(PROGS)) $(INSTALL_DIR)/bin

