include Makefile.config

DIRS = ddcprobe serial_probe share/po Newt c resize_fat
PREFIX = 
SBINDEST = $(PREFIX)/usr/sbin
ETCDEST = $(PREFIX)/etc/gtk
DATADIR = $(PREFIX)/usr/share
BINDEST = $(PREFIX)/usr/bin
LIBDEST = $(PREFIX)/usr/lib/libDrakX
BINX11DEST = $(PREFIX)/usr/X11R6/bin
LIBX11DEST = $(PREFIX)/usr/X11R6/lib/X11

.PHONY: $(DIRS)

all: $(DIRS)

$(DIRS):
	install -d auto
	rm standalone ; ln -s . standalone
	rm -f po/DrakX.pot # force rebuild of po's
	$(MAKE) -C $@

install:
	install -d $(BINDEST) $(ETCDEST) $(SBINDEST) $(DATADIR) $(LIBDEST) $(BINX11DEST) $(LIBX11DEST) $(LIBDEST)/po $(DIRS:%=$(LIBDEST)/%)
	install -d $(LIBDEST)/sbus_probing
	install $(STANDALONEPMS) $(SBINDEST)
	install -s ddcprobe/ddcxinfos serial_probe/serial_probe $(SBINDEST)
	ln -s ../../$(patsubst $(PREFIX)/usr%,%,$(SBINDEST))/XFdrake $(BINX11DEST)/Xdrakres

	for i in *.pm ; do perl -pe '$$_ = "\n" if /\s*use\s+(diagnostics|vars|strict)/' $$i > $(LIBDEST)/$$i ; done
	install -m 644 share/diskdrake.rc $(ETCDEST)
	install -m 644 share/wizard.rc $(ETCDEST)
	install -m 644 share/po/*.po $(LIBDEST)/po
	install -m 644 $(patsubst %,Newt/%.pm,Newt) $(LIBDEST)/Newt
	install -m 644 $(patsubst %,c/%.pm,stuff) $(LIBDEST)/c
	install -m 644 $(patsubst %,sbus_probing/%.pm,main) $(LIBDEST)/sbus_probing
	install -m 644 $(patsubst %,resize_fat/%.pm,main any boot_sector c_rewritten dir_entry directory fat info_sector io) $(LIBDEST)/resize_fat
	cp -rf auto icons $(LIBDEST)
	bzip2 -9 $(LIBDEST)/po/*.po
	find $(LIBDEST) -name "*.so" | xargs strip