Annotation of sbbs/src/build/common.gmake, revision 1.1.1.2

1.1       root        1: # build/Common.gmake
                      2: #
1.1.1.2 ! root        3: # Global build system setup file (for GNU Make and gcc)
1.1       root        4: #
1.1.1.2 ! root        5: # $Id: Common.gmake,v 1.77 2011/08/11 19:13:22 deuce Exp $
1.1       root        6: #
                      7: #############################################################################
                      8: # @format.tab-size 4           (Plain Text/Source Code File Header)                    #
                      9: # @format.use-tabs true        (see http://www.synchro.net/ptsc_hdr.html)                      #
                     10: #                                                                                                                                                      #
1.1.1.2 ! root       11: # Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html          #
1.1       root       12: #                                                                                                                                                      #
                     13: # This program is free software; you can redistribute it and/or                                #
                     14: # modify it under the terms of the GNU General Public License                          #
                     15: # as published by the Free Software Foundation; either version 2                       #
                     16: # of the License, or (at your option) any later version.                                       #
                     17: # See the GNU General Public License for more details: gpl.txt or                      #
                     18: # http://www.fsf.org/copyleft/gpl.html                                                                         #
                     19: #                                                                                                                                                      #
                     20: # Anonymous FTP access to the most recent released source is available at      #
                     21: # ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net      #
                     22: #                                                                                                                                                      #
                     23: # Anonymous CVS access to the development source and modification history      #
                     24: # is available at cvs.synchro.net:/cvsroot/sbbs, example:                                      #
                     25: # cvs -d :pserver:[email protected]:/cvsroot/sbbs login                                #
                     26: #     (just hit return, no password is necessary)                                                      #
                     27: # cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src         #
                     28: #                                                                                                                                                      #
                     29: # For Synchronet coding style and modification guidelines, see                         #
                     30: # http://www.synchro.net/source.html                                                                           #
                     31: #                                                                                                                                                      #
                     32: # You are encouraged to submit any modifications (preferably in Unix diff      #
                     33: # format) via e-mail to [email protected]                                                                       #
                     34: #                                                                                                                                                      #
                     35: # Note: If this box doesn't appear square, then you need to fix your tabs.     #
                     36: #############################################################################
                     37: #                                                                                                                                                      #
                     38: #############################################################################
                     39: #                                                                                                                                                      #
                     40: # Common macro setup for GNU make                                                                                      #
                     41: #                                                                                                                                                      #
                     42: # Common Build Macros REQUIRED:                                                                                                #
                     43: #  SRC_ROOT                    - *MUST* be set to the src dir                                                  #
                     44: #                                                                                                                                                      #
                     45: # Common Build Macros Used:                                                                                                    #
                     46: #  DEBUG                       - Create a debug build                                                                  #
                     47: #  PROFILE                     - Generates binaries which generate gprof details               #
                     48: #                                        (GCC/DEBUG only)                                                                              #
                     49: #  UPROFILE                    - Generates binaries which generate profile-driven              #
                     50: #                                        optimization data                                                                             #
                     51: #                                        (GCC/DEBUG only)                                                                              #
                     52: #  GCOV                                - Generates binaries that produce gcov data                             #
                     53: #                                        (GCC/DEBUG only)                                                                              #
                     54: #  RELEASE                     - Create a release build                                                                #
                     55: #                                        (Mutually exclusive, if both are set, RELEASE                 #
                     56: #                                              is cleared)                                                                                     #
                     57: #  USE_UPROFILE                - Builds using information generated by UPROFILE.               #
                     58: #                                        (RELEASE builds only)                                                                 #
                     59: #  DONT_CLOBBER_CC     - Do not change the default setting of CC                               #
                     60: #  OBJPATH_SUFFIX      - Suffix appended to OBJPATH usefull for compiling              #
                     61: #                                        different options of the same source file                             #
                     62: #  STATIC                      - Create a statically linked build if possible                  #
                     63: #                                                                                                                                                      #
                     64: # Common Build Macros Defined:                                                                                         #
                     65: #  DELETE                      - Delete files (Preferrably verbose)                                    #
                     66: #  MTOBJODIR           - Object output dir                                                                             #
                     67: #  OBJODIR                     - Object output dir                                                                             #
                     68: #  LIBODIR                     - Library output dir                                                                    #
                     69: #  EXEODIR                     - Executable output dir                                                                 #
                     70: #  DEBUG                       - Set for debug builds                                                                  #
                     71: #  RELEASE                     - Set for release builds                                                                #
                     72: #                                        One of DEBUG or RELEASE is always set!                                #
                     73: #  QUIET                       - Target command prefix to show/not show commands               #
                     74: #                                        (Toggled off by setting VERBOSE)                                              #
                     75: #  CFLAGS                      - Common C and C++ compiler flags                                               #
                     76: #  CCFLAGS                     - C specific compiler flags                                                             #
                     77: #  CXXFLAGS                    - C++ specific compiler flags                                                   #
                     78: #  LDFLAGS                     - Linker flags                                                                                  #
                     79: #  CC                          - C compiler                                                                                    #
                     80: #  CXX                         - C++ compiler                                                                                  #
                     81: #  EXEFILE                     - Executable file extension (Includes .)                                #
                     82: #  OFILE                       - Object file extension (Includes .)                                    #
                     83: #  SOFILE                      - Shared object (DLL) file extension (Includes .)               #
                     84: #  LIBFILE                     - Static library file extension (Include .)                             #
                     85: #  LIBPREFIX           - Prefix to library filename                                                    #
                     86: #  LIBS                                - Library names (Appropriate for dependencies)                  #
                     87: #  LIB_LDFLAGS         - Libraries appropriate for link command-line usage             #
                     88: #  COMPILE_MSG         - Message saying a target is being compiled                             #
                     89: #  DIRSEP                      - The directory seperator this system likes most                #
                     90: #  VERSION                     - Synchronet version number in MAJOR.MINOR format               #
                     91: #                                        (Numeric ONLY)                                                                                #
                     92: #  OUTPUT                      - Compiler flag specifying output filename                              #
                     93: #  LOUTPUT                     - Linker flag specifying output filename                                #
                     94: #  XPDEV_SRC           - Path to xpdev                                                                                 #
                     95: #  UIFC_SRC                    - Path to uifc                                                                                  #
                     96: #  CIOLIB_SRC          - Path to ciolib                                                                                #
                     97: #  SMBLIB_SRC          - Path to smblib                                                                                #
                     98: #  MT_CFLAGS           - CFLAGS for building MT objects                                                #
                     99: #  MT_LDFLAGS          - LDFLAGS for linking MT targets                                                #
                    100: #  UL_PRE                      - Use Library prefix (*nix is -l)                                               #
                    101: #  UL_SUF                      - Use Library siffix (bcc is .lib)                                              #
                    102: #                                                                                                                                                      #
                    103: # Common Targets Defined:                                                                                                      #
                    104: #  Implicit C and C++ targets                                                                                          #
                    105: #  "clean" target                                                                                                                      # 
                    106: #  Output directory targets                                                                                                    #
                    107: #                                                                                                                                                      #
                    108: #############################################################################
                    109: 
                    110: # Set VERSION
                    111: ifndef VERSION
1.1.1.2 ! root      112:  VERSION       :=      3.15
1.1       root      113: endif
                    114: 
                    115: # Put local (optional) macro definitions in localdefs.mk
                    116: -include localdefs.mk
                    117: -include $(SRC_ROOT)/build/localdefs.mk
                    118: 
                    119: # Set DEBUG
                    120: ifdef DEBUG
                    121:  ifdef RELEASE
                    122:   $(error Both DEBUG and RELEASE are defined)
                    123:  endif
                    124: endif
                    125: 
                    126: ifndef DEBUG
                    127:  ifndef RELEASE
                    128:   DEBUG        :=      1
                    129:  endif
                    130: endif
                    131: 
                    132: ifdef DEBUG
                    133:  ifdef PROFILE
                    134:   CFLAGS       +=      -pg
                    135:   LDFLAGS      +=      -pg
                    136:  endif
                    137:  ifdef UPROFILE
                    138:   CFLAGS       +=      -fprofile-generate
                    139:   LDFLAGS      +=      -fprofile-generate
                    140:  endif
                    141:  ifdef GCOV
                    142:   CFLAGS       +=      -fprofile-arcs -ftest-coverage
                    143:   LDFLAGS      +=      -fprofile-arcs -ftest-coverage
                    144:  endif
                    145: else
                    146:  ifdef USE_UPROFILE
                    147:   CFLAGS       +=      -fprofile-use
                    148:   LDFLAGS      +=      -fprofile-use
                    149:  endif
                    150: endif
                    151: 
                    152: # VERBOSE/QUIET
                    153: ifndef VERBOSE
                    154:  QUIET :=      @
                    155: endif
                    156: 
                    157: # Compiler-specific options
                    158: CFLAGS +=      -MMD
                    159: ifdef BUILD_DEPENDS
                    160:  ifdef DONT_CLOBBER_CC
                    161:   CC                   ?=      gcc
                    162:  else
                    163:   CC                   :=      gcc
                    164:  endif
                    165:  CCPRE                 :=      $(CC)
                    166:  CC                            :=      $(SRC_ROOT)/build/mkdep -a
                    167:  CXX                   :=      $(SRC_ROOT)/build/mkdep -a
                    168:  LD                            :=      echo
                    169:  COMPILE_MSG   :=  Depending
                    170:  AR                            :=      echo
                    171:  RANLIB                        :=      echo
                    172: else
                    173:  ifdef DONT_CLOBBER_CC
                    174:   CC                   ?=      gcc
                    175:  else
                    176:   CC                   :=      gcc
                    177:  endif
                    178:  CCPRE                 :=      $(CC)
                    179:  CXX                   ?=      g++
                    180:  LD                            ?=      ld
                    181:  COMPILE_MSG   := Compiling
                    182:  AR                            ?=      ar
                    183:  RANLIB                        ?=      ranlib
                    184: endif
                    185: 
                    186: ifdef DEBUG
                    187:  BUILD =       debug
                    188: else
                    189:  BUILD =       release
                    190: endif
                    191: BUILDPATH      ?=      $(BUILD)
                    192: 
                    193: # Get OS
                    194: ifndef os
                    195:  os            :=      $(shell uname)
                    196: endif
                    197: os      :=     $(shell echo $(os) | tr '[A-Z]' '[a-z]' | tr ' ' '_')
                    198: 
                    199: machine                :=      $(shell if uname -m | egrep -v "(i[3456789]*|x)86" > /dev/null; then uname -m | tr "[A-Z]" "[a-z]" | tr " " "_" ; fi)
1.1.1.2 ! root      200: machine                :=      $(shell if uname -m | egrep "64" > /dev/null; then uname -m | tr "[A-Z]" "[a-z]" | tr " " "_" ; else echo $(machine) ; fi)
        !           201: ifeq ($(os),darwin)
        !           202:  ifeq ("$(machine)","")
        !           203:   ifeq ($(shell sysctl hw.optional.x86_64),hw.optional.x86_64: 1)
        !           204:    machine     := x86_64
        !           205:   endif
        !           206:  endif
        !           207: endif
        !           208: 
        !           209: ifeq ($(machine),x86_64)
        !           210:  machine       := x64
        !           211: endif
        !           212: CFLAGS +=      -fpic
1.1       root      213: ifeq ($(machine),sparc64)
                    214:  CFLAGS +=      -D__BIG_ENDIAN__
                    215: endif
                    216: ifeq ($(machine),sun4u)
                    217:  CFLAGS +=      -D__BIG_ENDIAN__
                    218: endif
                    219: ifeq ($(machine),power_macintosh)
                    220:  CFLAGS +=      -D__BIG_ENDIAN__
                    221: endif
                    222: ifeq ($(machine),mac68k)
                    223:  CFLAGS +=      -D__BIG_ENDIAN__
                    224: endif
                    225: ifeq ($(machine),)
                    226:  machine       :=      $(os)
                    227: else
                    228:  machine       :=      $(os).$(machine)
                    229: endif
                    230: 
1.1.1.2 ! root      231: ifeq ($(shell if [ -f /usr/include/inttypes.h ] ; then echo YES ; fi),YES)
        !           232:  CFLAGS        +=      -DHAS_INTTYPES_H
        !           233: endif
        !           234: 
        !           235: CCPRE := $(lastword $(subst /, ,$(CCPRE)))
1.1       root      236: LIBODIR :=     $(CCPRE).$(machine).lib.$(BUILDPATH)
                    237: OBJODIR :=     $(CCPRE).$(machine).obj.$(BUILDPATH)
                    238: MTOBJODIR :=   $(CCPRE).$(machine).obj.$(BUILDPATH)-mt
                    239: EXEODIR :=     $(CCPRE).$(machine).exe.$(BUILDPATH)
                    240: LDFLAGS        +=      -L$(LIBODIR)
                    241: 
                    242: ifeq ($(os),openbsd)
                    243:  DELETE :=     rm -f
                    244: else
                    245:  ifeq ($(os),sunos)
                    246:   DELETE :=    rm -f
                    247:  else
1.1.1.2 ! root      248:   DELETE       =       rm -f
1.1       root      249:  endif
                    250: endif
                    251: 
                    252: LIBPREFIX      := lib
                    253: DIRSEP         := /
                    254: OFILE          := .o
                    255: EXEFILE                :=
                    256: SOFILE         := .so
                    257: LIBFILE                := .a
                    258: UL_PRE         :=      -l
                    259: UL_SUF         :=      
                    260: 
                    261: OUTPUT         :=      -o
                    262: LOUTPUT                :=      -o
                    263: 
                    264: ifdef STATIC
                    265:  LDFLAGS       +=      -static
                    266:  CFLAGS                +=      -DSTATIC_LINK
                    267: endif
                    268: 
                    269: ifeq ($(os),openbsd)
                    270:  SOFILE        :=      $(SOFILE).$(VERSION)
                    271: else
                    272:  ifeq ($(os),darwin)
                    273:   SOFILE =     .dylib
                    274:   RANLIB +=    -s
                    275:  endif
                    276: endif
                    277: 
                    278: # OS Specific Flags
                    279: ifeq ($(os),sunos)    # Solaris
                    280:  CFLAGS        += -D__solaris__ -DNEEDS_DAEMON -DNEEDS_FORKPTY -DNEEDS_CFMAKERAW
                    281:  # Solaris 10 provides setenv()
                    282:  ifeq ($(shell if [ `uname -r | sed 's/\.//'` -lt 510 ] ; then echo "Yes" ; else echo "No" ; fi),Yes)
                    283:   CFLAGS += -DNEEDS_SETENV
                    284:  endif
                    285:  LDFLAGS       +=      -L/opt/sfw/lib
                    286: endif
                    287: ifeq ($(os),netbsd)    # NetBSD
                    288:  CFLAGS        +=      -D__unix__ -I/usr/pkg/include
                    289: endif
                    290: ifeq ($(os),darwin)
                    291:  CFLAGS +=  -D__unix__ -fno-common -D__DARWIN__
                    292: endif
                    293: 
                    294: # PThread-specific flags
                    295: ifeq ($(os),linux)    # Linux
                    296:  ifndef THREADS_ACTUALLY_WORK
                    297:   CFLAGS    += -D_THREAD_SUID_BROKEN
                    298:  endif
                    299: endif
                    300: MT_CFLAGS    += -D_THREAD_SAFE -D_REENTRANT
                    301: CFLAGS    += -D_THREAD_SAFE -D_REENTRANT -D__EXTENSIONS__
                    302: ifeq ($(os),freebsd)    # FreeBSD
                    303:  MT_CFLAGS    += -DUSE_XP_SEMAPHORES
                    304:  MT_LDFLAGS    +=    -pthread
                    305:  LDFLAGS    +=    -pthread
                    306:  XP_SEM    :=    1
                    307: else
                    308:  ifeq ($(os),openbsd)    # OpenBSD
                    309:   MT_CFLAGS    += -DUSE_XP_SEMAPHORES
                    310:   MT_LDFLAGS    +=    -pthread
                    311:   LDFLAGS    +=    -pthread
                    312:   XP_SEM    :=    1
                    313:  else
                    314:   ifeq ($(os),netbsd)    # NetBSD
                    315:    MT_CFLAGS   +=      -DUSE_XP_SEMAPHORES
                    316:    MT_LDFLAGS    +=   -L/usr/pkg/lib
                    317:    XP_SEM    :=    1
                    318:   else
                    319:    ifeq ($(os),qnx)    # QNX
                    320:    else
                    321:     ifeq ($(os),darwin)    # Darwin/Mac OS X
                    322:      CFLAGS    += -D__unix__ 
                    323:      MT_CFLAGS    += -DUSE_XP_SEMAPHORES -D__DARWIN__
                    324:      XP_SEM    := 1
                    325:     else
                    326:      ifeq ($(os),sunos)  # Solaris
                    327:       XP_SEM :=    1
                    328:       MT_CFLAGS    +=    -D_POSIX_PTHREAD_SEMANTICS
                    329:       MT_CFLAGS    += -DUSE_XP_SEMAPHORES
                    330:       # This makes ctime_r() be the correct one.
                    331:       CFLAGS      += -D_POSIX_PTHREAD_SEMANTICS
                    332:      else            # Linux / Other UNIX
                    333:       XP_SEM :=    1
                    334:       MT_CFLAGS    += -DUSE_XP_SEMAPHORES
                    335:      endif
                    336:     endif
                    337:    endif
                    338:   endif
                    339:  endif
                    340: endif
                    341: 
                    342: SHLIBOPTS   :=  -shared
                    343: ifeq ($(os),darwin)
                    344:  MKSHLIB        :=  libtool -dynamic -framework System -lcc_dynamic
                    345:  MKSHPPLIB      :=  libtool -dynamic -framework System -lcc_dynamic -lstdc++
                    346:  SHLIBOPTS  :=
                    347: else
                    348:  ifeq ($(os),sunos)
                    349:   MKSHLIB       :=  /usr/ccs/bin/ld -G
                    350:   MKSHPPLIB     :=  /usr/ccs/bin/ld -G
                    351:   SHLIBOPTS :=
                    352:  else
                    353:   MKSHLIB       :=  $(CC)
                    354:   MKSHPPLIB     :=  $(CXX)
                    355:  endif
                    356: endif
                    357: 
                    358: # Paths
                    359: XPDEV_SRC      :=      $(SRC_ROOT)$(DIRSEP)xpdev
                    360: CIOLIB_SRC     :=      $(SRC_ROOT)$(DIRSEP)conio
                    361: SMBLIB_SRC     :=      $(SRC_ROOT)$(DIRSEP)smblib
                    362: UIFC_SRC       :=      $(SRC_ROOT)$(DIRSEP)uifc
                    363: 
1.1.1.2 ! root      364: # SDL ciolib enabled by default for the moment.
        !           365: ifndef WITHOUT_SDL
        !           366:  ifndef USE_SDL_AUDIO
        !           367:   USE_SDL      :=      1
        !           368:  endif
1.1       root      369: endif
                    370: 
                    371: # Pull in lib-specific flags
                    372: -include               $(XPDEV_SRC)$(DIRSEP)Common.make
                    373: -include               $(XPDEV_SRC)$(DIRSEP)Common.gmake
                    374: -include               $(SMBLIB_SRC)$(DIRSEP)Common.make
                    375: -include               $(SMBLIB_SRC)$(DIRSEP)Common.gmake
                    376: -include               $(CIOLIB_SRC)$(DIRSEP)Common.make
                    377: -include               $(CIOLIB_SRC)$(DIRSEP)Common.gmake
                    378: -include               $(UIFC_SRC)$(DIRSEP)Common.make
                    379: -include               $(UIFC_SRC)$(DIRSEP)Common.gmake
                    380: 
                    381: ifdef DEBUG
                    382:  CFLAGS        +=      -ggdb
                    383:  CFLAGS        +=      -D_DEBUG
                    384: else # RELEASE
                    385:  # -finline functions breaks the baja build badly.
                    386:  # This also means that -O3 won't work either.
                    387:  CFLAGS        := -O2 -fomit-frame-pointer -ffast-math -funroll-loops $(CFLAGS)
                    388: endif
                    389: 
                    390: -include targets.mk
                    391: -include $(SRC_ROOT)/build/rules.mk
                    392: -include objects.mk            # defines $(OBJS)
                    393: 
                    394: # Implicit C Compile Rule
                    395: $(OBJODIR)/%$(OFILE) : %.c $(BUILD_DEPENDS)
                    396:        @echo $(COMPILE_MSG) $<
                    397:        $(QUIET)$(CC) $(CFLAGS) $(CCFLAGS) -o $@ -c $<
                    398: 
                    399: # Implicit C++ Compile Rule
                    400: $(OBJODIR)/%$(OFILE) : %.cpp $(BUILD_DEPENDS)
                    401:        @echo $(COMPILE_MSG) $<
                    402:        $(QUIET)$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $<
                    403: 
                    404: # Implicit MT C Compile Rule
                    405: $(MTOBJODIR)/%$(OFILE) : %.c $(BUILD_DEPENDS)
                    406:        @echo $(COMPILE_MSG) $<
                    407:        $(QUIET)$(CC) $(CFLAGS) $(CCFLAGS) $(MT_CFLAGS) -o $@ -c $<
                    408: 
                    409: # Implicit MT C++ Compile Rule
                    410: $(MTOBJODIR)/%$(OFILE) : %.cpp $(BUILD_DEPENDS)
                    411:        @echo $(COMPILE_MSG) $<
                    412:        $(QUIET)$(CXX) $(CFLAGS) $(CXXFLAGS) $(MT_CFLAGS) -o $@ -c $<
                    413: 
                    414: depend:
                    415:        $(QUIET)$(DELETE) $(OBJODIR)/.depend
                    416:        $(QUIET)$(DELETE) $(MTOBJODIR)/.depend
                    417:        $(QUIET)$(DELETE) $(LIBODIR)/.depend
                    418:        $(QUIET)$(DELETE) $(EXEODIR)/.depend
                    419:        $(QUIET)$(MAKE) BUILD_DEPENDS=FORCE
                    420: 
                    421: FORCE:
                    422: 
                    423: -include $(MTOBJODIR)/.depend
                    424: -include $(OBJODIR)/.depend
                    425: -include $(LIBODIR)/.depend
                    426: -include $(EXEODIR)/.depend
                    427: -include $(MTOBJODIR)/*.d
                    428: -include $(OBJODIR)/*.d
                    429: -include $(LIBODIR)/*.d
                    430: -include $(EXEODIR)/*.d
                    431: 
                    432: $(XPDEV_LIB): xpdev
                    433: xpdev:
                    434:        $(MAKE) -C $(XPDEV_SRC) lib
                    435: 
                    436: $(XPDEV-MT_LIB): xpdev-mt
                    437: xpdev-mt:
                    438:        $(MAKE) -C $(XPDEV_SRC) mtlib
                    439: 
                    440: $(SMBLIB): smblib
                    441: smblib:
                    442:        $(MAKE) -C $(SMBLIB_SRC) lib
                    443: 
                    444: $(CIOLIB-MT): ciolib-mt
                    445: ciolib-mt:
                    446:        $(MAKE) -C $(CIOLIB_SRC) mtlib
                    447: 
                    448: $(UIFCLIB): uifc
                    449: uifc:
                    450:        $(MAKE) -C $(UIFC_SRC) lib
                    451: 
                    452: $(UIFCLIB-MT): uifc-mt
                    453: uifc-mt:
                    454:        $(MAKE) -C $(UIFC_SRC) mtlib

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.