Commit f445d2f9 authored by thomas's avatar thomas
Browse files

updated build system

git-svn-id: https://svn.grrrr.org/ext/trunk@914 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 8f3f7b3a
......@@ -28,7 +28,7 @@
:syntax
@echo .
@echo SYNTAX: buildext [platform] [system] [compiler] {target}
@echo SYNTAX: build [platform] [system] [compiler] {target}
@echo platform ... win / lnx / mac
@echo system ... pd / max
@echo compiler ... msvc / gcc / mingw / cygwin / bcc / icc
......
flext=${0%/*}/
if [ "$flext" = "$0"/ ]; then flext=./ ; fi
# Arguments:
# $1 - platform (win/lnx/mac)
......@@ -20,7 +21,7 @@ then
sh $subbatch $platform $rtsys $target $5 $6 $7 $8 $9
else
echo
echo SYNTAX: buildext [platform] [system] [compiler] {target}
echo SYNTAX: build.sh [platform] [system] [compiler] {target}
echo platform ... win / lnx / mac
echo system ..... pd / max
echo compiler ... msvc / gcc / mingw / cygwin / bcc / icc
......
......@@ -19,6 +19,7 @@ OPTIONS=-f $(BUILDPATH)bmake-sub.mak -N \
PLATFORM=$(PLATFORM) RTSYS=$(RTSYS) COMPILER=$(COMPILER) \
BUILDPATH=$(BUILDPATH) USRINFO=$(USRINFO)
!ifdef BUILDDIR
USRCONFIG=config.txt
USRDEFAULT=$(BUILDDIR)\config-$(PLATFORM).def
......@@ -29,45 +30,80 @@ OPTIONS=$(OPTIONS) USRCONFIG=$(USRCONFIG) USRMAKE=$(USRMAKE)
!endif
all: config
$(MAKE) $(OPTIONS) all
!ifdef FLEXTBUILD
all: flext
!else
all: build-sr
all-debug: config
$(MAKE) $(OPTIONS) DEBUG=1 $@
shared: build-tr
!endif
all-shared: config
$(MAKE) $(OPTIONS) SHARED=1 $@
flext: flext-release flext-debug
all-shared-debug: config
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 $@
flext-release: build-dr build-tr build-sr
clean install:
$(MAKE) $(OPTIONS) $@
flext-debug: build-dd build-td build-sd
install: install-dr install-tr install-sr install-dd install-td install-sd
flext: flext-release flext-debug
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_
flext-release: flext-single-release flext-threaded-release flext-shared-release
install-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _install_
flext-debug: flext-single-debug flext-threaded-debug flext-shared-debug
flext-single-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 all
clean-sr:
$(MAKE) $(OPTIONS) _clean_
flext-single-debug: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 DEBUG=1 all
clean-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _clean_
flext-threaded-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 THREADED=1 all
clean-tr:
$(MAKE) $(OPTIONS) THREADED=1 _clean_
flext-threaded-debug: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 THREADED=1 DEBUG=1 all
clean-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _clean_
flext-shared-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 SHARED=1 all
clean-dr:
$(MAKE) $(OPTIONS) SHARED=1 _clean_
flext-shared-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 SHARED=1 DEBUG=1 all
clean-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _clean_
config: $(USRMAKE) $(SYSCONFIG) $(USRCONFIG)
......
......@@ -4,12 +4,12 @@
ifdef SHARED
# --- shared ---
DEFS=$(DEFS) -DFLEXT_SHARED
DEFS+=-DFLEXT_SHARED
else
ifdef THREADED
# --- static multi-threaded ---
DEFS=$(DEFS) -DFLEXT_THREADS
DEFS+=-DFLEXT_THREADS
else
# --- static single-threaded ---
......@@ -19,7 +19,7 @@ endif
ifdef FLEXTBUILD
DEFS=$(DEFS) -DFLEXT_EXPORTS
DEFS+=-DFLEXT_EXPORTS
endif
##############################################
......
......@@ -38,45 +38,81 @@ OPTIONS+=USRCONFIG=$(USRCONFIG) USRMAKE=$(USRMAKE)
endif
all: config
$(MAKE) $(OPTIONS) all
ifdef FLEXTBUILD
all: flext
else
all: build-sr
all-debug: config
$(MAKE) $(OPTIONS) DEBUG=1 $@
shared: build-tr
endif
all-shared: config
$(MAKE) $(OPTIONS) SHARED=1 $@
flext: flext-release flext-debug
all-shared-debug: config
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 $@
flext-release: build-dr build-tr build-sr
clean install:
$(MAKE) $(OPTIONS) $@
flext-debug: build-dd build-td build-sd
install: install-dr install-tr install-sr install-dd install-td install-sd
flext: flext-release flext-debug
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_
flext-release: flext-single-release flext-threaded-release flext-shared-release
flext-debug: flext-single-debug flext-threaded-debug flext-shared-debug
clean-sr:
$(MAKE) $(OPTIONS) _clean_
flext-single-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 all
clean-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _clean_
flext-single-debug: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 DEBUG=1 all
clean-tr:
$(MAKE) $(OPTIONS) THREADED=1 _clean_
flext-threaded-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 THREADED=1 all
clean-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _clean_
flext-threaded-debug: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 THREADED=1 DEBUG=1 all
clean-dr:
$(MAKE) $(OPTIONS) SHARED=1 _clean_
flext-shared-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 SHARED=1 all
clean-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _clean_
flext-shared-release: config
$(MAKE) $(OPTIONS) FLEXTBUILD=1 SHARED=1 DEBUG=1 all
config: $(USRMAKE) $(SYSCONFIG) $(USRCONFIG)
......
......@@ -49,10 +49,10 @@ 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-dr: config
build-sr: config
$(MAKE) $(OPTIONS) _all_
build-dd: config
build-sd: config
$(MAKE) $(OPTIONS) DEBUG=1 _all_
build-tr: config
......@@ -61,17 +61,17 @@ build-tr: config
build-td: config
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _all_
build-sr: config
build-dr: config
$(MAKE) $(OPTIONS) SHARED=1 _all_
build-sd: config
build-dd: config
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _all_
install-dr:
install-sr:
$(MAKE) $(OPTIONS) _install_
install-dd:
install-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _install_
install-tr:
......@@ -80,17 +80,17 @@ install-tr:
install-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _install_
install-sr:
install-dr:
$(MAKE) $(OPTIONS) SHARED=1 _install_
install-sd:
install-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _install_
clean-dr:
clean-sr:
$(MAKE) $(OPTIONS) _clean_
clean-dd:
clean-sd:
$(MAKE) $(OPTIONS) DEBUG=1 _clean_
clean-tr:
......@@ -99,10 +99,10 @@ clean-tr:
clean-td:
$(MAKE) $(OPTIONS) THREADED=1 DEBUG=1 _clean_
clean-sr:
clean-dr:
$(MAKE) $(OPTIONS) SHARED=1 _clean_
clean-sd:
clean-dd:
$(MAKE) $(OPTIONS) SHARED=1 DEBUG=1 _clean_
......
!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 user32.lib kernel32.lib
LIBS=$(LIBS) cw32.lib import32.lib C0D32.OBJ
CFLAGS=$(CFLAGS) -tWD -tWM -w-8004 -w-8027 -w-8057
LDFLAGS=$(LDFLAGS) /C /Tpd
......@@ -20,66 +23,106 @@ LDFLAGS=$(LDFLAGS) /v
CFLAGS=$(CFLAGS) $(OFLAGS) -DNDEBUG
!endif
##############################################
!ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
!ifdef SHARED
# --- shared ---
DEFS=$(DEFS) -DFLEXT_SHARED
EXT=dll
!else
EXT=lib
BUILDLIB=1
!endif
!else
!ifdef THREADED
# --- static multi-threaded ---
DEFS=$(DEFS) -DFLEXT_THREADS
OUTNAME=$(NAME)
!endif
!else
# --- static single-threaded ---
##############################################
!endif
!endif
TARGETPATH=$(OUTPATH)\$(OUTSUB)
TARGET=$(TARGETPATH)\$(OUTNAME).$(EXT)
##############################################
TARGET=$(OUTPATH)\$(NAME).$(EXT)
!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
!endif
##############################################
# default target
all: $(OUTPATH) print $(TARGET)
_all_: $(TARGET)
# convert both *.c and *.cpp
OBJSTMP= $(SRCS:.c=.obj)
OBJS= $(OBJSTMP:.objpp=.obj)
print:
echo $(OBJS)
$(OUTPATH):
@-if not exist $< mkdir $<
$(TARGETPATH):
if not exist $(OUTPATH) mkdir $(OUTPATH) > nul
if not exist $@ mkdir $@ > nul
!ifndef FLEXTBUILD
SETUPFUNCTION=$(NAME)_setup
$(OUTPATH)\$(NAME).def:
$(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$(OUTPATH) $<
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
{$(SRCDIR)}.c{}.obj:
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(OUTPATH) $<
bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(TARGETPATH) $<
$(TARGET) :: $(OUTPATH) $(OUTPATH)\$(NAME).def
$(TARGET) :: $(TARGETPATH) $(PDTARGETS)
$(TARGET) :: $(OBJS)
cd $(OUTPATH)
ilink32 $(LDFLAGS) $(LIBPATH) $** ,..\$<,,$(LIBS),$(NAME).def
cd $(TARGETPATH)
!ifdef BUILDLIB
-del $(<F)
tlib "$(<F)" +$(**: = +)
cd ..
!else
ilink32 $(LDFLAGS) $(LIBPATH) -L. $** ,$(<F),,$(LIBS),$(NAME).def
!endif
cd ..
##############################################
_clean_:
-del /q $(TARGET) > nul
-cd $(TARGETPATH)
-del /q $(OBJS) > nul
##############################################
$(INSTPATH):
-mkdir $@
if not exist $@ mkdir $@ > nul
# remove build
clean:
-del /q $(OUTPATH) > nul
-rmdir $(OUTPATH) > nul
$(FLEXTPATH):
if not exist $@ mkdir $@ > nul
# install build
install: $(INSTPATH) $(TARGET)
_install_ :: $(INSTPATH) $(FLEXTPATH)
_install_ :: $(TARGET)
!ifdef FLEXTBUILD
-copy $(TARGET) $(FLEXTPATH) > nul
@cd $(SRCDIR)
-for %%i in ($(HDRS)) do @copy %%i $(FLEXTPATH) > nul
!else
copy $(TARGET) $(INSTPATH) > nul
!endif
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).a
endif
LDFLAGS += -shared -Wl,-x
LIBS += -luser32 -lkernel32
##############################################
ifdef DEBUG
CFLAGS += -g -D_DEBUG
......@@ -11,60 +17,76 @@ endif
##############################################
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
ifdef SHARED
# --- shared ---
DEFS += -DFLEXT_SHARED
EXT=dll
else
ifdef THREADED
# --- static multi-threaded ---
DEFS += -DFLEXT_THREADS
else
# --- static single-threaded ---
EXT=a
BUILDLIB=1
endif
else
OUTNAME=$(NAME)
endif
##############################################
TARGET=$(OUTPATH)/$(NAME).$(EXT)
TARGETPATH=$(OUTPATH)/$(OUTSUB)
TARGET=$(TARGETPATH)/$(OUTNAME).$(EXT)
##############################################
CSRCS=$(patsubst %.c,$(SRCDIR)/%.c,$(filter %.c,$(SRCS)))
CPPSRCS=$(patsubst %.cpp,$(SRCDIR)/%.cpp,$(filter %.cpp,$(SRCS)))
COBJS=$(patsubst %.c,$(OUTPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(OUTPATH)/%.opp,$(filter %.cpp,$(SRCS)))
COBJS=$(patsubst %.c,$(TARGETPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(TARGETPATH)/%.opp,$(filter %.cpp,$(SRCS)))
# default target
all: $(OUTPATH) $(TARGET)
_all_: $(TARGET)
$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
touch $@
$(OUTPATH):
mkdir $(OUTPATH)
$(TARGETPATH):
-mkdir $(OUTPATH)
-mkdir $@
$(OUTPATH)/%.opp : $(SRCDIR)/%.cpp
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(OUTPATH)/%.o : $(SRCDIR)/%.c
$(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGET) : $(COBJS) $(CPPOBJS)
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
ifdef BUILDLIB
$(AR) rc $@ $^
else
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $^ $(LIBS)
chmod 755 $@
endif
##############################################
_clean_:
rm $(COBJS) $(CPPOBJS) $(TARGET)
##############################################
$(INSTPATH):
mkdir $(INSTPATH)
-mkdir $@
install:: $(INSTPATH)
$(FLEXTPATH):
-mkdir $@
install:: $(TARGET)
install $^ $(INSTPATH)
_install_:: $(INSTPATH) $(FLEXTPATH)
.PHONY: clean
clean:
$(RM) $(COBJS) $(CPPOBJS) $(TARGET)
_install_:: $(TARGET)
ifdef FLEXTBUILD
cp $^ $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTPATH)
else
install $^ $(INSTPATH)
endif
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).lib
endif
LDFLAGS += -shared -Wl,-x
LIBS += -luser32 -lkernel32
##############################################