DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

CC=@CC@
CFLAGS=@CFLAGS@ -D_GNU_SOURCE -DADMINDIR=\"@ADMINDIR@\" -DARCH_TEXT='"$(DEB_HOST_ARCH)"' -DOS_TEXT='"$(DEB_HOST_ARCH_OS)"'
OBJS=$(subst .c,.o,$(wildcard *.c))
BIN=udpkg
BUSYBOX=@BUSYBOXDIR@
LIBS=-ldebian-installer
STRIP=@STRIP@

ifdef DEBUG
CFLAGS:=$(CFLAGS) -DDODEBUG
endif

all: $(BIN)

# Size optimized and stripped binary target.
small: CFLAGS += -Os -fomit-frame-pointer
small: clean $(BIN)
	$(STRIP) --remove-section=.comment --remove-section=.note $(BIN)
	ls -l $(BIN)

$(BIN): $(OBJS)
	$(CC) -o $(BIN) $(OBJS) $(LIBS)

clean:
	-rm -f $(BIN) $(OBJS) *~

distclean: clean
	-rm -f config.status config.log config.cache makefile config.h
	-rm -rf autom4te.cache

*.o: udpkg.h
