#   This file is part of VBA Express.
#
#   Copyright (c) 2005-2006 Achraf cherti <achrafcherti@gmail.com>
# 
#   VBA Express is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   VBA Express is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with VBA Express; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

ifeq ($(PREFIX),)
PREFIX = /usr
endif


# Pour le debug
#CFLAGS = -g -DLINUX `fltk-config --cxxflags` `sdl-config --cflags` -Isrc -Wall -pedantic -ansi

# pour le release AVEC FLU
CFLAGS = -Os -DUSE_FLU -DLINUX `fltk-config --cxxflags` `sdl-config --cflags` -Isrc -Wall
LIBS = `flu-config --ldstaticflags` `fltk-config --use-images --ldstaticflags` `sdl-config --libs` -lXpm


# pour le release "SANS" FLU
#CFLAGS = -Os -DLINUX `fltk-config --cxxflags` `sdl-config --cflags` -Isrc -Wall
#LIBS = `fltk-config --use-images --ldstaticflags` `sdl-config --libs` -lXpm

CC  = g++
RM = rm -f
CP = cp

all: first src/astring.o src/Fl_Nice.o src/interface.o src/lcfg.o src/readme.o src/sdl_key.o src/spath.o src/vbaconfig.o src/vbaexpress.o vbaexpress

first : 
	sh ./misc/make_readme.sh

src/astring.o : src/astring.cpp
	$(CC) -c src/astring.cpp $(CFLAGS) -o src/astring.o

src/Fl_Nice.o : src/Fl_Nice.cpp
	$(CC) -c src/Fl_Nice.cpp $(CFLAGS) -o src/Fl_Nice.o

src/interface.o : src/interface.cpp
	$(CC) -c src/interface.cpp $(CFLAGS) -o src/interface.o

src/lcfg.o : src/lcfg.c
	$(CC) -c src/lcfg.c $(CFLAGS) -o src/lcfg.o

src/readme.o : src/readme.cpp
	$(CC) -c src/readme.cpp $(CFLAGS) -o src/readme.o

src/sdl_key.o : src/sdl_key.cpp
	$(CC) -c src/sdl_key.cpp $(CFLAGS) -o src/sdl_key.o

src/spath.o : src/spath.c
	$(CC) -c src/spath.c $(CFLAGS) -o src/spath.o

src/vbaconfig.o : src/vbaconfig.cpp
	$(CC) -c src/vbaconfig.cpp $(CFLAGS) -o src/vbaconfig.o

src/vbaexpress.o : src/vbaexpress.cpp
	$(CC) -c src/vbaexpress.cpp $(CFLAGS) -o src/vbaexpress.o

vbaexpress :src/astring.o src/Fl_Nice.o src/interface.o src/lcfg.o src/readme.o src/sdl_key.o src/spath.o src/vbaconfig.o src/vbaexpress.o
	$(CC) src/astring.o src/Fl_Nice.o src/interface.o src/lcfg.o src/readme.o src/sdl_key.o src/spath.o src/vbaconfig.o src/vbaexpress.o -o vbaexpress $(LIBS)

clean :
	rm -f src/*.o vbaexpress

install :
	mkdir -p $(PREFIX)/bin
	mkdir -p $(PREFIX)/share/applications
	mkdir -p $(PREFIX)/share/pixmaps
	cp vbaexpress $(PREFIX)/bin
	cp misc/vbaexpress.desktop $(PREFIX)/share/applications
	cp misc/vbaexpress.png $(PREFIX)/share/pixmaps
	chmod 755 $(PREFIX)/bin/vbaexpress
	chmod 644 $(PREFIX)/share/pixmaps/vbaexpress.png $(PREFIX)/share/applications/vbaexpress.desktop
	mkdir -p $(PREFIX)/share/vbaexpress/skin
	chmod 755 $(PREFIX)/share/vbaexpress/skin
	cp skin/* $(PREFIX)/share/vbaexpress/skin
	chmod 644 $(PREFIX)/share/vbaexpress/skin/*

uninstall :
	rm -f $(PREFIX)/bin/vbaexpress $(PREFIX)/share/pixmaps/vbaexpress.png $(PREFIX)/share/applications/vbaexpress.desktop
	rm -f $(PREFIX)/share/vbaexpress/skin/*
	rmdir $(PREFIX)/share/vbaexpress/skin
	rmdir $(PREFIX)/share/vbaexpress
	
