Commit d06e9d2b authored by thomas's avatar thomas
Browse files

updated build system

git-svn-id: https://svn.grrrr.org/ext/trunk@923 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent ad23759b
DEFS+=-DFLEXT_EXPORTS
# override product name
OUTNAME=$(FLEXTNAME)
......@@ -2,28 +2,60 @@
include $(BUILDPATH)config-$(PLATFORM)-$(RTSYS)-$(COMPILER).txt
###############################
# these are project specific
# project specific definitions
# package info
include $(USRINFO)
# special settings
ifdef USRCONFIG
include $(USRCONFIG)
include $(USRCONFIG)
endif
# package specific make stuff
ifdef USRMAKE
include $(USRMAKE)
include $(USRMAKE)
endif
##############################
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 definitions
# flext-specific make stuff
include $(BUILDPATH)gnumake.inc
include $(BUILDPATH)gnumake-$(BUILDCLASS).inc
##############################
# platform-specific make stuff
include $(BUILDPATH)$(PLATFORM)/$(RTSYS)/gnumake-$(COMPILER).inc
include $(BUILDPATH)$(PLATFORM)/$(RTSYS)/gnumake-$(COMPILER)-$(BUILDCLASS).inc
##############################
# general make stuff
include $(BUILDPATH)$(PLATFORM)/gnumake-$(COMPILER).inc
include $(BUILDPATH)$(PLATFORM)/gnumake-$(COMPILER)-$(BUILDCLASS).inc
......@@ -17,11 +17,6 @@ else
endif
endif
ifdef FLEXTBUILD
DEFS+=-DFLEXT_EXPORTS
endif
##############################################
# name of flext library
##############################################
......@@ -44,46 +39,17 @@ FLEXTNAME=flext-$(RTSYS)_t
endif
else
ifdef DEBUG
FLEXTNAME=flext-$(RTSYS)_d
FLEXTNAME=flext-$(RTSYS)_sd
else
FLEXTNAME=flext-$(RTSYS)
FLEXTNAME=flext-$(RTSYS)_s
endif
endif
endif # SHARED
##############################################
# build subdirectories
# product name and folder
##############################################
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
OUTNAME=$(NAME)
OUTSUB=$(TARGETMODE)-$(TARGETTYPE)
......@@ -5,11 +5,39 @@
# 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
###############################################
ifeq ($(PLATFORM),win)
# substitute eventual \ by /
......@@ -18,15 +46,16 @@ else
UBUILDPATH=$(BUILDPATH)
endif
###############################################
SYSCONFIG=$(UBUILDPATH)config-$(PLATFORM)-$(RTSYS)-$(COMPILER).txt
SYSDEFAULT=$(UBUILDPATH)$(PLATFORM)/$(RTSYS)/config-$(COMPILER).def
OPTIONS=-f $(UBUILDPATH)gnumake-sub.mak \
PLATFORM=$(PLATFORM) RTSYS=$(RTSYS) COMPILER=$(COMPILER) \
BUILDPATH=$(UBUILDPATH) USRINFO=$(USRINFO)
###############################################
ifdef BUILDDIR
USRCONFIG=config.txt
......@@ -37,86 +66,14 @@ USRMAKE=$(BUILDDIR)/makefile-$(PLATFORM)-$(COMPILER).inc
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)
......
# build class specific settings
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS += $(FLEXTPATH)/$(FLEXTNAME).a
endif
##############################################
# default target
build: $(TARGET)
$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
touch $@
$(OUTPATH):
-mkdir -p $@
$(TARGETPATH): $(OUTPATH)
-mkdir -p $@
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $(COBJS) $(CPPOBJS) $(LIBS)
chmod 755 $@
##############################################
clean:
rm $(COBJS) $(CPPOBJS) $(TARGET)
##############################################
$(INSTPATH):
-mkdir -p $@
install: $(INSTPATH)
install $(TARGET) $(INSTPATH)
# build class specific settings
##############################################
# default target
build: $(TARGET)
$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
touch $@
$(OUTPATH):
-mkdir -p $@
$(TARGETPATH): $(OUTPATH)
-mkdir -p $@
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
ifdef SHARED
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $(COBJS) $(CPPOBJS) $(LIBS)
chmod 755 $@
else
$(AR) rc $@ $(COBJS) $(CPPOBJS)
endif
##############################################
clean:
rm $(COBJS) $(CPPOBJS) $(TARGET)
##############################################
ifdef SHARED
FLEXTLIBINST=$(FLEXTSHLIB)
else
FLEXTLIBINST=$(FLEXTLIB)
endif
$(FLEXTINC):
-mkdir -p $@
$(FLEXTLIBINST):
-mkdir -p $@
install: $(FLEXTINC) $(FLEXTLIBINST)
install $(TARGET) $(FLEXTLIBINST)
install $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTINC)
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).a
endif
##############################################
TARGETPATH=$(OUTPATH)/$(OUTSUB)
TARGET=$(TARGETPATH)/$(OUTNAME).$(EXT)
##############################################
LDFLAGS += -shared -Wl,-x
......@@ -17,75 +18,7 @@ endif
##############################################
ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
ifdef SHARED
EXT=dll
else
EXT=a
BUILDLIB=1
endif
else
OUTNAME=$(NAME)
endif
##############################################
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,$(TARGETPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(TARGETPATH)/%.opp,$(filter %.cpp,$(SRCS)))
# default target
_all_: $(TARGET)
$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
touch $@
$(TARGETPATH):
-mkdir -p $@
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(DEFS) $(INCPATH) $< -o $@
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
ifdef BUILDLIB
$(AR) rc $@ $(COBJS) $(CPPOBJS)
else
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $(COBJS) $(CPPOBJS) $(LIBS)
chmod 755 $@
endif
##############################################
_clean_:
rm $(COBJS) $(CPPOBJS) $(TARGET)
##############################################
$(INSTPATH):
-mkdir -p $@
$(FLEXTPATH):
-mkdir -p $@
_install_:: $(INSTPATH) $(FLEXTPATH)
_install_:: $(TARGET)
ifdef FLEXTBUILD
cp $(TARGET) $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTPATH)
else
install $(TARGET) $(INSTPATH)
endif
# build class specific settings
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).lib
endif
LDFLAGS += -shared -Wl,-x
##############################################
ifdef DEBUG
CFLAGS += -g -D_DEBUG
else
CFLAGS += $(OFLAGS) -DNDEBUG
LDFLAGS += -Wl,-S
endif
##############################################
ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
ifdef SHARED
EXT=dll
else
EXT=lib
BUILDLIB=1
endif
else
OUTNAME=$(NAME)
endif
##############################################
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,$(TARGETPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(TARGETPATH)/%.opp,$(filter %.cpp,$(SRCS)))
# default target
_all_: $(TARGET)
build: $(TARGET)
#$(CSRCS) $(CPPSRCS): $(patsubst %,$(SRCDIR)/%,$(HDRS))
# touch $@
$(TARGETPATH):
-mkdir $(subst /,\,$(OUTPATH))
$(OUTPATH):
-mkdir $(subst /,\,$@)
$(TARGETPATH): $(OUTPATH)
-mkdir $(subst /,\,$@)
$(TARGETPATH)/%.opp : $(SRCDIR)/%.cpp
......@@ -63,31 +29,17 @@ $(TARGETPATH)/%.o : $(SRCDIR)/%.c
$(TARGET) :: $(TARGETPATH)
$(TARGET) :: $(COBJS) $(CPPOBJS)
ifdef BUILDLIB
$(AR) rc $@ $(COBJS) $(CPPOBJS)
else
$(CXX) $(LDFLAGS) $(LIBPATH) -o $@ $(COBJS) $(CPPOBJS) $(LIBS)
endif
##############################################
_clean_:
clean:
-del $(subst /,\,$(COBJS) $(CPPOBJS) $(TARGET))
##############################################
$(FLEXTPATH):
-mkdir $(subst /,\,$@)
$(INSTPATH):
-mkdir $(subst /,\,$@)
_install_:: $(INSTPATH) $(FLEXTPATH)
_install_:: $(TARGET)
ifdef FLEXTBUILD
copy $(subst /,\,$(TARGET) $(FLEXTPATH))
-for %%i in ($(subst /,\,$(patsubst %,$(SRCDIR)/%,$(HDRS)))) do @copy %%i $(subst /,\,$(FLEXTPATH)) > nul
else
install:: $(INSTPATH)
copy $(subst /,\,$(TARGET) $(INSTPATH))
endif
ifndef FLEXTBUILD
INCPATH += -I$(FLEXTPATH)
LIBPATH += -L$(FLEXTPATH)
LIBS+=$(FLEXTPATH)/$(FLEXTNAME).lib
endif
LDFLAGS += -shared -Wl,-x
##############################################
ifdef DEBUG
CFLAGS += -g -D_DEBUG
else
CFLAGS += $(OFLAGS) -DNDEBUG
LDFLAGS += -Wl,-S
endif
##############################################
ifdef FLEXTBUILD
OUTNAME=$(FLEXTNAME)
ifdef SHARED
EXT=dll
else
EXT=lib
BUILDLIB=1
endif
else
OUTNAME=$(NAME)
endif
# build class specific settings
##############################################
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,$(TARGETPATH)/%.o,$(filter %.c,$(SRCS)))
CPPOBJS=$(patsubst %.cpp,$(