Commit 97212bff authored by thomas's avatar thomas
Browse files

updated build system

git-svn-id: https://svn.grrrr.org/ext/trunk@921 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 532f98c7
DEFS=$(DEFS) /DFLEXT_EXPORTS
# override product name
OUTNAME=$(FLEXTNAME)
# general settings
!include $(BUILDPATH)config-$(PLATFORM)-$(RTSYS)-$(COMPILER).txt
###############################
# these are project specific
# project-specific definitions
# package info
!include $(USRINFO)
......@@ -19,10 +19,43 @@
##############################
!ifndef TARGETMODE
!ifdef DEBUG
TARGETMODE=debug
!else
TARGETMODE=release
!endif
!endif
!ifndef TARGETTYPE
!ifdef SHARED
TARGETTYPE=shared
!else
!ifdef THREADED
TARGETTYPE=multi
!else
TARGETTYPE=single
!endif
!endif
!endif
##############################
# flext-specific make stuff
!include $(BUILDPATH)bmake.inc
!include $(BUILDPATH)bmake-$(BUILDCLASS).inc
##############################
# platform-specific make stuff
!include $(BUILDPATH)$(PLATFORM)\$(RTSYS)\make-$(COMPILER).inc
!include $(BUILDPATH)$(PLATFORM)\$(RTSYS)\make-$(COMPILER)-$(BUILDCLASS).inc
##############################
# general make stuff
!include $(BUILDPATH)$(PLATFORM)\make-$(COMPILER).inc
!include $(BUILDPATH)$(PLATFORM)\make-$(COMPILER)-$(BUILDCLASS).inc
##############################################
# flext defines
##############################################
!ifdef SHARED
# --- shared ---
DEFS=$(DEFS) /DFLEXT_SHARED
!else
!ifdef THREADED
# --- static multi-threaded ---
DEFS=$(DEFS) /DFLEXT_THREADS
!else
# --- static single-threaded ---
!endif
!endif
##############################################
# name of flext library
##############################################
!ifdef SHARED
!ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_d
!else
FLEXTNAME=flext-$(RTSYS)
!endif
!else
!ifdef THREADED
!ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_td
!else
FLEXTNAME=flext-$(RTSYS)_t
!endif
!else
!ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_sd
!else
FLEXTNAME=flext-$(RTSYS)_s
!endif
!endif
!endif # SHARED
##############################################
# product name and folder
##############################################
OUTNAME=$(NAME)
OUTSUB=$(TARGETMODE)-$(TARGETTYPE)
......@@ -5,20 +5,48 @@
# COMPILER - msvc/gcc/mingw/cygwin
# BUILDPATH including trailing \
###############################################
# package info
USRINFO=package.txt
!include $(USRINFO)
###############################################
# check variables
!ifndef BUILDCLASS
!error BUILDCLASS must be specified in $(USRINFO)
!endif
!ifndef BUILDMODE
!error BUILDMODE must be specified in $(USRINFO)
!endif
!ifndef BUILDTYPE
!error BUILDTYPE must be specified in $(USRINFO)
!endif
##############################
!ifndef TARGETMODE
TARGETMODE=$(BUILDMODE)
!endif
!ifndef TARGETTYPE
TARGETTYPE=$(BUILDTYPE)
!endif
###############################################
SYSCONFIG=$(BUILDPATH)config-$(PLATFORM)-$(RTSYS)-$(COMPILER).txt
SYSDEFAULT=$(BUILDPATH)$(PLATFORM)\$(RTSYS)\config-$(COMPILER).def
OPTIONS=-f $(BUILDPATH)bmake-sub.mak -N \
PLATFORM=$(PLATFORM) RTSYS=$(RTSYS) COMPILER=$(COMPILER) \
BUILDPATH=$(BUILDPATH) USRINFO=$(USRINFO)
###############################################
!ifdef BUILDDIR
USRCONFIG=config.txt
......@@ -29,85 +57,14 @@ USRMAKE=$(BUILDDIR)\makefile-$(PLATFORM)-$(COMPILER).inc
OPTIONS=$(OPTIONS) USRCONFIG=$(USRCONFIG) USRMAKE=$(USRMAKE)
!endif
###############################################
# include file describing default target dependencies
!ifdef FLEXTBUILD
all: flext
!else
all: build-sr
shared: build-tr
!endif
flext: flext-release flext-debug
flext-release: build-dr build-tr build-sr
flext-debug: build-dd build-td build-sd
install: install-dr install-tr install-sr install-dd install-td install-sd
clean: clean-dr clean-tr clean-sr clean-dd clean-td clean-sd
build-sr: config
$(MAKE) $(OPTIONS) _all_
build-sd: config
$(MAKE) $(OPTIONS) DEBUG=1 _all_
build-tr: config
$(MAKE) $(OPTIONS) THREADED=1 _all_
build-td: config
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _all_
build-dr: config
$(MAKE) $(OPTIONS) SHARED=1 _all_
build-dd: config
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _all_
install-sr:
$(MAKE) $(OPTIONS) _install_
install-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _install_
install-tr:
$(MAKE) $(OPTIONS) THREADED=1 _install_
install-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _install_
install-dr:
$(MAKE) $(OPTIONS) SHARED=1 _install_
install-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _install_
clean-sr:
$(MAKE) $(OPTIONS) _clean_
clean-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _clean_
clean-tr:
$(MAKE) $(OPTIONS) THREADED=1 _clean_
clean-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _clean_
clean-dr:
$(MAKE) $(OPTIONS) SHARED=1 _clean_
clean-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _clean_
!include $(BUILDPATH)targets.inc
config: $(USRMAKE) $(SYSCONFIG) $(USRCONFIG)
!include $(BUILDPATH)targets-$(BUILDCLASS).inc
###############################################
.precious: $(SYSCONFIG) $(USRCONFIG)
......
##############################################
# flext defines
##############################################
ifdef SHARED
# --- shared ---
DEFS+=-DFLEXT_SHARED
else
ifdef THREADED
# --- static multi-threaded ---
DEFS+=-DFLEXT_THREADS
else
# --- static single-threaded ---
endif
endif
ifdef FLEXTBUILD
DEFS+=-DFLEXT_EXPORTS
endif
##############################################
# name of flext library
##############################################
ifdef SHARED
ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_d
else
FLEXTNAME=flext-$(RTSYS)
endif
else
ifdef THREADED
ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_td
else
FLEXTNAME=flext-$(RTSYS)_t
endif
else
ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_d
else
FLEXTNAME=flext-$(RTSYS)
endif
endif
endif # SHARED
##############################################
# build subdirectories
##############################################
ifdef FLEXTBUILD
ifdef SHARED
ifdef DEBUG
OUTSUB=dd
else
OUTSUB=dr
endif
else # SHARED
ifdef THREADED
ifdef DEBUG
OUTSUB=td
else
OUTSUB=tr
endif
else
ifdef DEBUG
OUTSUB=sd
else
OUTSUB=sr
endif
endif
endif # SHARED
else # FLEXTBUILD
OUTSUB=.
endif # FLEXTBUILD
......@@ -2,6 +2,7 @@
!include $(BUILDPATH)config-$(PLATFORM)-$(RTSYS)-$(COMPILER).txt
##############################
# project-specific definitions
# package info
!include $(USRINFO)
......
# build class specific settings
INCPATH=$(INCPATH) -I$(FLEXTINC)
LIBPATH=$(LIBPATH) -L$(FLEXTLIB)
LIBS=$(LIBS) $(FLEXTNAME).lib
!endif
##############################################
# default target
build: $(TARGET)
$(OUTPATH):
if not exist $@ mkdir $@ > nul
$(TARGETPATH): $(OUTPATH)
if not exist $@ mkdir $@ > nul
SETUPFUNCTION=$(NAME)_setup
$(TARGETPATH)\$(NAME).def:
@echo EXPORTS $(SETUPFUNCTION) = _$(SETUPFUNCTION) > $<
# this next line fixes a strange problem with implib - lacking underscore?!
@echo IMPORTS _rtext_retext=PD.rtext_retext >> $<
$(TARGET) :: $(TARGETPATH)\$(NAME).def
{$(SRCDIR)}.cpp{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
{$(SRCDIR)}.c{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(OBJS)
@cd $(TARGETPATH)
ilink32 $(LDFLAGS) $(LIBPATH) -L. $(OBJS) ,$(<F),,$(LIBS),$(NAME).def
@cd ..\..
##############################################
# remove build
clean:
-del /q $(TARGET) > nul
-cd $(TARGETPATH)
-del /q $(OBJS) > nul
##############################################
$(INSTPATH):
if not exist $@ mkdir $@ > nul
install: $(INSTPATH)
copy $(TARGET) $(INSTPATH) > nul
# build class specific settings
##############################################
# default target
build: $(TARGET)
$(OUTPATH):
if not exist $@ mkdir $@ > nul
$(TARGETPATH): $(OUTPATH)
if not exist $@ mkdir $@ > nul
{$(SRCDIR)}.cpp{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
{$(SRCDIR)}.c{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
$(TARGETPATH)\pd.lib : $(PDPATH)\bin\pd.dll
implib -a $< $**
$(TARGETPATH)\pthreadVC.lib : $(PDPATH)\bin\pthreadVC.dll
implib -a $< $**
PDTARGETS=$(TARGETPATH)\pd.lib $(TARGETPATH)\pthreadVC.lib
$(TARGET) :: $(TARGETPATH) $(PDTARGETS)
$(TARGET) :: $(OBJS)
@cd $(TARGETPATH)
!ifdef SHARED
ilink32 $(LDFLAGS) $(LIBPATH) -L. $(OBJS) ,$(<F),,$(LIBS)
implib -a $(<B).lib $(<F)
!else
-del $(<F)
tlib "$(<F)" +$(OBJS: = +)
!endif
@cd ..\..
##############################################
clean:
-del /q $(TARGET) > nul
-cd $(TARGETPATH)
-del /q $(OBJS) > nul
##############################################
!ifdef SHARED
FLEXTLIBINST=$(FLEXTSHLIB)
!else
FLEXTLIBINST=$(FLEXTLIB)
!endif
$(FLEXTINC):
if not exist $@ mkdir $@ > nul
#install:: $(FLEXTINC)
!if "$(FLEXTINC)" != "$(FLEXTLIB)"
$(FLEXTLIB):
if not exist $@ mkdir $@ > nul
install:: $(FLEXTLIB)
!endif
!if "$(FLEXTLIBINST)" != "$(FLEXTLIB)" && "$(FLEXTLIBINST)" != "$(FLEXTINC)"
$(FLEXTLIBINST):
if not exist $@ mkdir $@ > nul
install:: $(FLEXTLIBINST)
!endif
install:: $(FLEXTINC)
copy $(TARGET) $(FLEXTLIBINST) > nul
!ifdef SHARED
# copy import library
copy $(TARGET:.dll=.lib) $(FLEXTLIB) > nul
!endif
# copy headers
for %%i in ($(HDRS)) do @copy $(SRCDIR)\%%i $(FLEXTINC) > nul
# copy import libraries
for %%i in ($(PDTARGETS)) do @copy %%i $(FLEXTLIBINST) > nul
!ifndef FLEXTBUILD
INCPATH=$(INCPATH) -I$(FLEXTPATH)
LIBPATH=$(LIBPATH) -L$(FLEXTPATH)
LIBS=$(LIBS) $(FLEXTNAME).lib
!endif
!ifdef BCCPATH
INCPATH=$(INCPATH) -I$(BCCPATH)\include
LIBPATH=$(LIBPATH) -L$(BCCPATH)\lib
!endif
LIBS=$(LIBS) cw32.lib import32.lib C0D32.OBJ
CFLAGS=$(CFLAGS) -tWD -tWM -w-8004 -w-8027 -w-8057
LDFLAGS=$(LDFLAGS) /C /Tpd
##############################################
# use multithreaded static libraries
!ifdef DEBUG
CFLAGS=$(CFLAGS) -v -D_DEBUG
LDFLAGS=$(LDFLAGS) /v
!else
CFLAGS=$(CFLAGS) $(OFLAGS) -DNDEBUG
!endif
TARGETPATH=$(OUTPATH)\$(OUTSUB)
TARGET=$(TARGETPATH)\$(OUTNAME).$(EXT)
##############################################
# use precompiled headers
!ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
!ifdef SHARED
EXT=dll
!ifndef PRECOMPILE
CFLAGS=$(CFLAGS) -Hh=flext.h
!else
EXT=lib
BUILDLIB=1
!endif
!else
OUTNAME=$(NAME)
CFLAGS=$(CFLAGS) -Hh=$(PRECOMPILE)
!endif
# location of precompiled file
CFLAGS=$(CFLAGS) -H=$(TARGETPATH)\precompiled.pch
##############################################
TARGETPATH=$(OUTPATH)\$(OUTSUB)
TARGET=$(TARGETPATH)\$(OUTNAME).$(EXT)
LIBS=$(LIBS) cw32.lib import32.lib C0D32.OBJ
CFLAGS=$(CFLAGS) -tWD -tWM -w-8004 -w-8027 -w-8057
LDFLAGS=$(LDFLAGS) /C /Tpd
##############################################
!ifdef PDPATH
$(TARGETPATH)\pd.lib : $(PDPATH)\bin\pd.dll
implib -a $< $**
$(TARGETPATH)\pthreadVC.lib : $(PDPATH)\bin\pthreadVC.dll
implib -a $< $**
PDTARGETS=$(TARGETPATH)\pd.lib $(TARGETPATH)\pthreadVC.lib
!ifdef DEBUG
CFLAGS=$(CFLAGS) -v -D_DEBUG
LDFLAGS=$(LDFLAGS) /v
!else
CFLAGS=$(CFLAGS) $(OFLAGS) -DNDEBUG
!endif
##############################################
# default target
_all_: $(TARGET)
# convert both *.c and *.cpp
OBJSTMP= $(SRCS:.c=.obj)
OBJS= $(OBJSTMP:.objpp=.obj)
$(TARGETPATH):
if not exist $(OUTPATH) mkdir $(OUTPATH) > nul
if not exist $@ mkdir $@ > nul
!ifndef FLEXTBUILD
SETUPFUNCTION=$(NAME)_setup
$(TARGETPATH)\$(NAME).def:
@echo EXPORTS $(SETUPFUNCTION) = _$(SETUPFUNCTION) > $<
# this next line fixes a strange problem with implib - lacking underscore?!
@echo IMPORTS _rtext_retext=PD.rtext_retext >> $<
$(TARGET) :: $(TARGETPATH)\$(NAME).def
!endif
{$(SRCDIR)}.cpp{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
{$(SRCDIR)}.c{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
$(TARGET) :: $(TARGETPATH) $(PDTARGETS)
$(TARGET) :: $(OBJS)
cd $(TARGETPATH)
!ifdef BUILDLIB
-del $(<F)
tlib "$(<F)" +$(OBJS: = +)
cd ..
!else
ilink32 $(LDFLAGS) $(LIBPATH) -L. $(OBJS) ,$(<F),,$(LIBS),$(NAME).def
!endif
cd ..
##############################################
_clean_:
-del /q $(TARGET) > nul
-cd $(TARGETPATH)
-del /