############################################################################
#             __________               __   ___.                  
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___  
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /  
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <   
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/ 
# $Id$
#
# Copyright (C) 2002 by Felix Arends
#
# All files in this archive are subject to the GNU General Public License.
# See the file COPYING in the source tree root for full license agreement.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
############################################################################


#CHANGE THIS FIELD TO SPECIFY RECORDER OR PLAYER (Player does not work very well atm)
TARGET = RECORDER

FIRMWAREDIR = ../../firmware
DRIVERS = $(FIRMWAREDIR)/drivers
COMMON = $(FIRMWAREDIR)/common
APPSCOMMON = ../common
TOOLSDIR = ..\..\tools
SIMDIR = ../win32/
APPDIR = ../../apps/
PLAYERDIR = $(APPDIR)player/
RECDIR = $(APPDIR)recorder/
RM = del
LANGUAGE = english
FONT = $(FIRMWAREDIR)/fonts/clR6x8.bdf

!IF ("$(TARGET)" == "RECORDER")
DISPLAY = -DHAVE_LCD_BITMAP
KEYPAD = -DHAVE_RECORDER_KEYPAD
MODEL_SPECIFIC_DIR = $(RECDIR)
!ELSE
DISPLAY = -DHAVE_LCD_CHARCELLS
KEYPAD = -DHAVE_PLAYER_KEYPAD
MODEL_SPECIFIC_DIR = $(PLAYERDIR)
!ENDIF

CC = cl
RC = rc
LINK = link
DEFINES = $(DEFINES) -DWIN32 -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR $(KEYPAD) $(DISPLAY) -DAPPSVERSION=\"WIN32SIM\"
LDFLAGS = /OUT:uisw32.exe /SUBSYSTEM:windows /NOLOGO /MACHINE:IX86 kernel32.lib user32.lib gdi32.lib
INCLUDES = -I$(FIRMWAREDIR)/export -I$(DRIVERS) -I$(COMMON) -I$(APPSCOMMON) -I$(SIMDIR) -I$(APPDIR) -I$(MODEL_SPECIFIC_DIR)
LIBS = /DEFAULTLIB:gdi32.lib /DEFAULTLIB:user32.lib /NODEFAULTLIB:libc.lib

CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) /MD /Fd"Release/vc70.pdb" /c

SRCS =	*.c \
	$(DRIVERS)/power.c \
	$(APPDIR)*.c \
	$(APPSCOMMON)/lcd-common.c $(APPSCOMMON)/mpegplay.c $(APPSCOMMON)/sim_icons.c $(APPSCOMMON)/stubs.c \
	$(FIRMWAREDIR)/mpeg.c $(FIRMWAREDIR)/id3.c $(FIRMWAREDIR)/usb.c $(FIRMWAREDIR)/mpeg.c $(FIRMWAREDIR)/font.c $(FIRMWAREDIR)/powermgmt.c \
        $(COMMON)/sprintf.c $(COMMON)/strtok.c $(COMMON)/errno.c 

!IF ("$(DISPLAY)" == "-DHAVE_LCD_BITMAP")
SRCS = $(SRCS) $(RECDIR)/bmp.c $(RECDIR)/bounce.c  $(RECDIR)/cube.c  $(RECDIR)/icons.c  $(RECDIR)/keyboard.c $(RECDIR)/peakmeter.c \
       $(RECDIR)/snow.c $(RECDIR)/sokoban.c $(RECDIR)/tetris.c $(RECDIR)/widgets.c $(RECDIR)/wormlet.c $(DRIVERS)/lcd-recorder.c
!ELSE
SRCS = $(SRCS) $(APPSCOMMON)/lcd-playersim.c $(DRIVERS)/lcd-player.c $(PLAYERDIR)*.c
!ENDIF

OBJS = lang.obj $(SRCS:.c=.obj) uisw32.res

all : uisw32.exe

$(APPDIR)credits.raw:
  perl $(APPDIR)credits.pl < ../../docs/CREDITS > $(APPDIR)credits.raw

kernel.obj:
  $(CC) $(CFLAGS) *.c

sysfont.c: $(FONT)
  $(TOOLSDIR)\convbdf -c -o sysfont.c $(FONT)

sysfont.obj: sysfont.c
  $(CC) $(CFLAGS) sysfont.c

uisw32.exe: $(APPDIR)credits.raw $(OBJS) sysfont.obj kernel.obj
 $(LINK) $(LIBS) $(LDFLAGS) *.obj uisw32.res

uisw32.res:
 $(RC) /r uisw32.rc

build.lang: $(APPDIR)/lang/$(LANGUAGE).lang
	perl $(TOOLSDIR)/uplang $(APPDIR)/lang/english.lang $(APPDIR)/lang/$(LANGUAGE).lang > build.lang

lang.obj: build.lang
	perl -s $(TOOLSDIR)/genlang -p=lang build.lang
	$(CC) $(CFLAGS) -c lang.c -o lang.obj

clean:
 $(RM) *.obj ..\..\apps\lang.c ..\..\apps\lang.h ..\..\apps\credits.raw lang.build uisw32.res uisw32.exe
