#
# Main Makefile for makedist build scripts
#

include /var/makedist/.defs.inc
include /var/makedist/.Makefile.inc

default:
	@echo "Error: no target specified."

ifdef VARSFILE
   include $(VARSFILE)
endif

ifndef SOURCESMODE
ifndef BUILDSMODE
#
# deps operation mode
#
ifdef TARGET
include $(TARGETSDIR)/$(TARGET)/Makefile.defs
endif

include $(DEPSFILE)-$(ARCH)

RPMDIR =
INSTALLED =

$(ALL_PACKAGES):
	@[ `echo " $$INSTALLED " | grep -c " $@ "` -eq 0 ] && \
	echo -n "$@ " || :

all_packages: $(ALL_PACKAGES)

#include Makefile.globdefs

ifdef TARGET
include $(TARGETSDIR)/$(TARGET)/Makefile
endif
endif
endif

ifdef SOURCESMODE
#
# find sources operation mode
#
include $(SOURCESFILE)-$(ARCH)
$(ALL_SOURCES):
	@A=$@; echo -n "$${A/_} "
# FIXME: using PORT_FROM_ARCH because sources have build deps that might be missing in target arch
#include $(SOURCESFILE)-$(PORT_FROM_ARCH)
#$(ALL_SOURCES):
#	echo -n "$@ " || :
#include $(SOURCESFILE)-$(ARCH)
#$(MISSING_SOURCES):
#	echo -n "$@ " || :

endif

ifdef BUILDSMODE
#
# find sources operation mode
#
# FIXME: using PORT_FROM_ARCH because sources have build deps that might be missing in target arch
include $(BUILDSFILE)-$(ARCH)
$(ALL_BUILDS):
	echo -n "$@ " || :
endif
