# Makefile to configure and make modutils

# CROSS = mipsisa32-elf-
# #---------------
# CC =     $(CROSS)gcc
# AR =     $(CROSS)ar
# # LD =     $(CROSS)ld
# LD =     $(CROSS)gcc
# NM =     $(CROSS)nm
# RANLIB = $(CROSS)ranlib
# CP = 	 cp

CFLAGS += -Wno-traditional -Wno-cast-qual

LIBS := $(LIBS) $(LDADD)

BUILDCC := gcc
BUILDCFLAGS := -O2 -Wall

PREFIX=$(shell pwd)/../

INSTALL=install -c

.EXPORT_ALL_VARIABLES:


all: build
	FLTFLAGS="-s40960" $(MAKE) ${MAKEFILES} -C build

build:
	mkdir -p build
ifeq	(${MACHINE_BINARY}, i386)
	(cd build ; ac_cv_prog_cc_works=yes; export ac_cv_prog_cc_works; ../modutils-2.4.12/configure --prefix=$(PREFIX) --disable-strip)
else
	(cd build ; ac_cv_prog_cc_works=yes ac_cv_prog_cc_cross=yes; export ac_cv_prog_cc_works ac_cv_prog_cc_cross; ../modutils-2.4.12/configure --host=mipsisa32-unknown-linux --prefix=$(PREFIX) --disable-strip)
endif

install: all
	${SU} "$(MAKE) ${MAKEFILES} -C build install";

clean:
	rm -rf build

