00001 #####################################################################
00002 #
00003 # Name: Makefile
00004 # Created by: Stefan Ritt
00005 #
00006 # Contents: Makefile for MIDAS binaries and examples under unix
00007 #
00008 # $Id: Makefile 4842 2010-09-27 22:49:59Z amaudruz $
00009 #
00010 #####################################################################
00011 #
00012 # Usage:
00013 # gmake To compile the MIDAS library and binaries
00014 # gmake install To install the library and binaries
00015 # gmake examples To compile low-level examples (not necessary)
00016 # gmake static To make static executables for debugging
00017 #
00018 #
00019 # This makefile contains conditional code to determine the operating
00020 # system it is running under by evaluating the OSTYPE environment
00021 # variable. In case this does not work or if the GNU make is not
00022 # available, the conditional code has to be evaluated manually.
00023 # Remove all ifeq - endif blocks except the one belonging to the
00024 # current operating system. From this block remove only the first
00025 # and the last line (the one with the ifeq and endif statement).
00026 #
00027 # "gmake install" will copy MIDAS binaries, the midas library and
00028 # the midas include files to specific directories for each version.
00029 # You may change these directories to match your preferences.
00030 #####################################################################
00031
00032 # get OS type from shell
00033 OSTYPE = $(shell uname)
00034
00035 #
00036 # System direcotries for installation, modify if needed
00037 #
00038
00039 ifndef PREFIX
00040 PREFIX = /usr/local
00041 endif
00042
00043 SYSBIN_DIR = $(PREFIX)/bin
00044 SYSLIB_DIR = $(PREFIX)/lib
00045 SYSINC_DIR = $(PREFIX)/include
00046
00047 #
00048 # Option to set the shared library path on MIDAS executables
00049 #
00050 NEED_RPATH=1
00051
00052 #
00053 # Option to use the static ROOT library libRoot.a
00054 #
00055 # To link midas with the static ROOT library, say "make ... NEED_LIBROOTA=1"
00056 #
00057 NEED_LIBROOTA=
00058
00059 #
00060 # Optional libmysqlclient library for mlogger
00061 #
00062 # To add mySQL support to the logger, say "make ... NEED_MYSQL=1"
00063 #
00064 # Here we try to figure out automatically if mySQL is installed
00065 MYSQL_CONFIG := $(shell which mysql_config 2> /dev/null)
00066 ifdef MYSQL_CONFIG
00067 MYSQLINCDIR := $(shell mysql_config --cflags | sed -e 's,^.*-I\([^ ]*\).*$$,\1,' -e s/\'
00068 NEED_MYSQL := $(shell if [ -e $(MYSQLINCDIR)/mysql.h ]; then echo 1; fi)
00069 endif
00070
00071 #
00072 # Optional ODBC history support
00073 #
00074 HAVE_ODBC := $(shell if [ -e /usr/include/sql.h ]; then echo 1; fi)
00075
00076 #
00077 # Option to use our own implementation of strlcat, strlcpy
00078 #
00079 NEED_STRLCPY=1
00080
00081 #
00082 # Directory in which mxml.c/h resides. This library has to be checked
00083 # out separately from the midas CVS since it's used in several projects
00084 #
00085 MXML_DIR=../mxml
00086
00087 #
00088 # Directory in which mscb.c/h resides. These files are necessary for
00089 # the optional MSCB support in mhttpd
00090 #
00091 MSCB_DIR=./mscb
00092
00093 #
00094 # Optional zlib support for data compression in the mlogger and in the analyzer
00095 #
00096 NEED_ZLIB=
00097
00098 #
00099 # Optional MSCB support for mhttpd
00100 #
00101 NEED_MSCB=1
00102
00103 #####################################################################
00104 # Nothing needs to be modified after this line
00105 #####################################################################
00106
00107 #-----------------------
00108 # Common flags
00109 #
00110 CC = cc $(USERFLAGS)
00111 CXX = g++ $(USERFLAGS)
00112 CFLAGS = -g -O2 -Wall -Wuninitialized -I$(INC_DIR) -I$(DRV_DIR) -I$(MXML_DIR) -I$(MSCB_DIR) -L$(LIB_DIR) -DHAVE_FTPLIB
00113
00114 #-----------------------
00115 # Ovevwrite MAX_EVENT_SIZE with environment variable
00116 #
00117 ifdef MIDAS_MAX_EVENT_SIZE
00118 CFLAGS += -DMAX_EVENT_SIZE=$(MIDAS_MAX_EVENT_SIZE)
00119 endif
00120
00121 #-----------------------
00122 # Cross-compilation, change GCC_PREFIX
00123 #
00124 ifeq ($(OSTYPE),crosscompile)
00125 GCC_PREFIX=$(HOME)/linuxdcc/Cross-Compiler/gcc-4.0.2/build/gcc-4.0.2-glibc-2.3.6/powerpc-405-linux-gnu
00126 GCC_BIN=$(GCC_PREFIX)/bin/powerpc-405-linux-gnu-
00127 LIBS=-L$(HOME)/linuxdcc/userland/lib -pthread -lutil -lrt
00128 CC = $(GCC_BIN)gcc
00129 CXX = $(GCC_BIN)g++
00130 OSTYPE = cross-ppc405
00131 OS_DIR = $(OSTYPE)
00132 CFLAGS += -DOS_LINUX
00133 NEED_MYSQL=
00134 HAVE_ODBC=
00135 endif
00136
00137 #-----------------------
00138 # OSF/1 (DEC UNIX)
00139 #
00140 ifeq ($(HOSTTYPE),alpha)
00141 OSTYPE = osf1
00142 endif
00143
00144 ifeq ($(OSTYPE),osf1)
00145 OS_DIR = osf1
00146 OSFLAGS = -DOS_OSF1
00147 FFLAGS = -nofor_main -D 40000000 -T 20000000
00148 LIBS = -lc -lbsd
00149 SPECIFIC_OS_PRG =
00150 endif
00151
00152 #-----------------------
00153 # Ultrix
00154 #
00155 ifeq ($(HOSTTYPE),mips)
00156 OSTYPE = ultrix
00157 endif
00158
00159 ifeq ($(OSTYPE),ultrix)
00160 OS_DIR = ultrix
00161 OSFLAGS = -DOS_ULTRIX -DNO_PTY
00162 LIBS =
00163 SPECIFIC_OS_PRG =
00164 endif
00165
00166 #-----------------------
00167 # FreeBSD
00168 #
00169 ifeq ($(OSTYPE), FreeBSD)
00170 OS_DIR = freeBSD
00171 OSFLAGS = -DOS_FREEBSD
00172 LIBS = -lbsd -lcompat
00173 SPECIFIC_OS_PRG =
00174 endif
00175
00176 #-----------------------
00177 # MacOSX/Darwin is just a funny Linux
00178 #
00179 ifeq ($(OSTYPE),Darwin)
00180 OSTYPE = darwin
00181 endif
00182
00183 ifeq ($(OSTYPE),darwin)
00184 OS_DIR = darwin
00185 OSFLAGS = -DOS_LINUX -DOS_DARWIN -DHAVE_STRLCPY -fPIC -Wno-unused-function
00186 OSFLAGS += -DUSE_POSIX_SHM
00187 LIBS = -lpthread
00188 SPECIFIC_OS_PRG = $(BIN_DIR)/mlxspeaker
00189 NEED_STRLCPY=
00190 NEED_RANLIB=1
00191 NEED_RPATH=
00192 SHLIB+=$(LIB_DIR)/libmidas-shared.dylib
00193 SHLIB+=$(LIB_DIR)/libmidas-shared.so
00194 endif
00195
00196 #-----------------------
00197 # This is for Cygwin
00198 #
00199 ifeq ($(OSTYPE),CYGWIN_NT-5.1)
00200 OSTYPE = cygwin
00201 endif
00202
00203 ifeq ($(OSTYPE),cygwin)
00204
00205 OS_DIR = cygwin
00206 OSFLAGS = -DOS_LINUX -DOS_CYGWIN -Wno-unused-function
00207 LIBS = -lutil -lpthread
00208 endif
00209
00210 #-----------------------
00211 # This is for Linux
00212 #
00213 ifeq ($(OSTYPE),Linux)
00214 OSTYPE = linux
00215 endif
00216
00217 ifeq ($(OSTYPE),linux)
00218
00219 # >2GB file support
00220 CFLAGS += -D_LARGEFILE64_SOURCE
00221
00222 # include ZLIB support
00223 NEED_ZLIB=1
00224
00225 OS_DIR = linux
00226 OSFLAGS = -DOS_LINUX -fPIC -Wno-unused-function
00227 # add to compile midas in 32-bit mode
00228 # OSFLAGS += -m32
00229 LIBS = -lutil -lpthread -lrt
00230 SPECIFIC_OS_PRG = $(BIN_DIR)/mlxspeaker $(BIN_DIR)/dio
00231 endif
00232
00233 #-----------------------
00234 # This is for Solaris
00235 #
00236 ifeq ($(OSTYPE),solaris)
00237 CC = gcc
00238 OS_DIR = solaris
00239 OSFLAGS = -DOS_SOLARIS
00240 LIBS = -lsocket -lnsl
00241 SPECIFIC_OS_PRG =
00242 endif
00243
00244 #####################################################################
00245 # end of conditional code
00246 #####################################################################
00247
00248 #
00249 # Midas directories
00250 #
00251 INC_DIR = include
00252 SRC_DIR = src
00253 UTL_DIR = utils
00254 DRV_DIR = drivers
00255 EXAM_DIR = examples
00256
00257 #
00258 # Midas operating system dependent directories
00259 #
00260 LIB_DIR = $(OS_DIR)/lib
00261 BIN_DIR = $(OS_DIR)/bin
00262
00263 #
00264 # targets
00265 #
00266 EXAMPLES = $(BIN_DIR)/consume $(BIN_DIR)/produce \
00267 $(BIN_DIR)/rpc_test $(BIN_DIR)/msgdump $(BIN_DIR)/minife \
00268 $(BIN_DIR)/minirc $(BIN_DIR)/odb_test
00269
00270 PROGS = $(BIN_DIR)/mserver $(BIN_DIR)/mhttpd \
00271 $(BIN_DIR)/mlogger $(BIN_DIR)/odbedit \
00272 $(BIN_DIR)/mtape $(BIN_DIR)/mhist \
00273 $(BIN_DIR)/mstat $(BIN_DIR)/mcnaf \
00274 $(BIN_DIR)/mdump \
00275 $(BIN_DIR)/lazylogger \
00276 $(BIN_DIR)/mtransition \
00277 $(BIN_DIR)/mhdump \
00278 $(BIN_DIR)/mchart $(BIN_DIR)/stripchart.tcl \
00279 $(BIN_DIR)/webpaw $(BIN_DIR)/odbhist \
00280 $(BIN_DIR)/melog \
00281 $(BIN_DIR)/mfe_link_test \
00282 $(BIN_DIR)/mana_link_test \
00283 $(SPECIFIC_OS_PRG)
00284
00285 ANALYZER = $(LIB_DIR)/mana.o
00286
00287 ifdef CERNLIB
00288 ANALYZER += $(LIB_DIR)/hmana.o
00289 endif
00290
00291 ifdef ROOTSYS
00292 ANALYZER += $(LIB_DIR)/rmana.o
00293 endif
00294
00295 ifdef HAVE_ODBC
00296 PROGS += $(BIN_DIR)/mh2sql
00297 endif
00298
00299 OBJS = $(LIB_DIR)/midas.o $(LIB_DIR)/system.o $(LIB_DIR)/mrpc.o \
00300 $(LIB_DIR)/odb.o $(LIB_DIR)/ftplib.o \
00301 $(LIB_DIR)/mxml.o \
00302 $(LIB_DIR)/dm_eb.o \
00303 $(LIB_DIR)/history_midas.o \
00304 $(LIB_DIR)/history_sql.o \
00305 $(LIB_DIR)/history.o $(LIB_DIR)/alarm.o $(LIB_DIR)/elog.o
00306
00307 ifdef NEED_STRLCPY
00308 OBJS += $(LIB_DIR)/strlcpy.o
00309 endif
00310
00311 LIBNAME = $(LIB_DIR)/libmidas.a
00312 LIB = $(LIBNAME)
00313 SHLIB = $(LIB_DIR)/libmidas-shared.so
00314
00315 VPATH = $(LIB_DIR):$(INC_DIR)
00316
00317 all: check-mxml \
00318 $(OS_DIR) $(LIB_DIR) $(BIN_DIR) \
00319 $(LIBNAME) $(SHLIB) \
00320 $(ANALYZER) \
00321 $(LIB_DIR)/cnaf_callback.o \
00322 $(LIB_DIR)/mfe.o \
00323 $(LIB_DIR)/fal.o $(PROGS)
00324
00325 dox:
00326 cd doxfiles; doxygen midox.cfg
00327 $(MAKE) dox_images
00328
00329 dox_images: doxfiles/html/midasintro.jpg
00330
00331 doxfiles/html/midasintro.jpg: midasdoc-images.tar.gz
00332 tar xzvf $^
00333 cp -pv images
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710