#!/usr/bin/make -s

#
# Make File
#

.SILENT :

CC = g++
target = mls

# build should be 'Release' or 'Debug'
BUILD = Debug
VPATH = %.cpp \
	$(BUILD)

ccflags = -fPIC -w -fno-inline -fexceptions
defs = -DLINUX -D_REENTRANT
release = $(target)-linux

ifeq ($(BUILD),Debug)
	#debug builds..
	flags = -g $(ccflags) $(defs)
	defs += -D_DEBUG
	tag = d
else
	#release builds
	flags = -s -Os $(ccflags) $(defs)
endif

# Base size: 9100783
# Static libgcc: 9125736

# libraries
libs =		-static-libgcc \
			-L../$(BUILD) \
			-lsharedmime1$(tag)
			
#include paths for .h files
incpath =	-I../libsharedmime

# all the objects required
depends =	mls.o

			
# Executable target
$(target) : $(depends)
	@echo Linking $(target) [$(BUILD)]
	$(CC) --disable-shared --enable-static \
			-Wl,-export-dynamic -f -o $(target) $(addprefix $(BUILD)/,$(depends)) $(libs)
	@echo Done.

#-shared  

# Source files
%.o : %.cpp
	@echo $(<F)
	ls $(BUILD) > /dev/null 2> /dev/null || mkdir $(BUILD)
	$(CC) $(incpath) $(flags) -c $< -o $(BUILD)/$(@F)

clean :
	rm $(BUILD)/*.o