STRIP= strip --remove-section=.note --remove-section=.comment busybox
LDFLAGS= -s

arch=$(shell dpkg --print-architecture)

# -D_GNU_SOURCE is needed because environ is used in init.c
ifdef INCLUDE_DINSTALL
  CFLAGS=-g -Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE \
	-DINCLUDE_DINSTALL
  LIBRARIES= -lnewt -lslang -lc
ifeq ($(arch),sparc)
  LIBRARIES+= -lm
endif
  OBJECTS=$(patsubst %.c,%.o,$(wildcard *.c)) \
          $(patsubst %.c,%.o,$(wildcard ../dinstall/*.c)) \
	  ../libfdisk/libfdisk.a
else
  CFLAGS=-g -Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE 
  LIBRARIES=-lc
  OBJECTS=$(patsubst %.c,%.o,$(wildcard *.c))
endif

all: busybox

busybox: $(OBJECTS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES)
	$(STRIP)

../libfdisk/libfdisk.a: force
	$(MAKE) -C ../libfdisk libfdisk.a

clean:
	- rm -f $(OBJECTS) busybox *~

distclean: clean
	- rm -f busybox

force:
