| 1 | #  -*- makefile -*- | 
|---|
| 2 | # ######################### PEIDA++ ############################# | 
|---|
| 3 | # ##### LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA ##### | 
|---|
| 4 | # ############################################################### | 
|---|
| 5 | # General setup GNU Makefile for EROS. To be included in all makefiles. | 
|---|
| 6 | # Define  makefile variables according to CPU | 
|---|
| 7 | # MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 Linux ... } | 
|---|
| 8 | # and compilers {g++, cxx, KCC, xlC, aCC, ...} | 
|---|
| 9 | # | 
|---|
| 10 | # Makefile variables set are: | 
|---|
| 11 | # - Path to Exec, Include, Libs, Obj directories (from DPCDEVREP env. var.) | 
|---|
| 12 | #     i.e. variables LIB, OBJ, EXE, INC | 
|---|
| 13 | #--------------------------------------------------------------------------- | 
|---|
| 14 |  | 
|---|
| 15 | # define MACHEROS from uname | 
|---|
| 16 | MACHEROS := $(shell echo `uname`) | 
|---|
| 17 | # define the -D option | 
|---|
| 18 | MACHEROSD := $(shell echo `uname | sed 's/-//'`) | 
|---|
| 19 | # Le sous-repertoire des objets specifique machine-compilo | 
|---|
| 20 | #   OSF1 : Alpha avec gcc | 
|---|
| 21 | #   OSF1-cxx : Alpha avec cxx | 
|---|
| 22 |  | 
|---|
| 23 | #### C++ | 
|---|
| 24 | ifdef EROSCXX | 
|---|
| 25 | CXX := $(EROSCXX) | 
|---|
| 26 | endif | 
|---|
| 27 |  | 
|---|
| 28 | ifeq ($(CXX),gcc) | 
|---|
| 29 | override CXX := g++ | 
|---|
| 30 | endif | 
|---|
| 31 |  | 
|---|
| 32 | ifeq ($(EROSCXX),egcs++) | 
|---|
| 33 | # en fait de compilo de egcs++ s'appelle g++ ! | 
|---|
| 34 | # comme il faut bien differentier ln -s /usr/bin/g++ /usr/bin/egcs++ | 
|---|
| 35 | override CXX := egcs++ | 
|---|
| 36 | endif | 
|---|
| 37 |  | 
|---|
| 38 | ifeq ($(CC),xlC) | 
|---|
| 39 | override CXX := xlC | 
|---|
| 40 | endif | 
|---|
| 41 |  | 
|---|
| 42 | #### C | 
|---|
| 43 | ifeq ($(CXX), xlC) | 
|---|
| 44 | override CC := xlC | 
|---|
| 45 | endif | 
|---|
| 46 |  | 
|---|
| 47 | ifeq ($(CXX), g++) | 
|---|
| 48 | CC := gcc | 
|---|
| 49 | endif | 
|---|
| 50 |  | 
|---|
| 51 | ifeq ($(EROSCXX), egcs++) | 
|---|
| 52 | CC := egcs | 
|---|
| 53 | endif | 
|---|
| 54 |  | 
|---|
| 55 | #### Fortran (tout ce qui est lie au Fortran est defini ici ############# | 
|---|
| 56 | FC = f77 | 
|---|
| 57 | ifeq (${MACHEROS},Linux) | 
|---|
| 58 | #  override FC := f77 | 
|---|
| 59 | override FC := g77 | 
|---|
| 60 | endif | 
|---|
| 61 |  | 
|---|
| 62 | ifeq (${MACHEROS},OSF1) | 
|---|
| 63 | LIBFORT = -lfor -lFutil -lots -lUfor | 
|---|
| 64 | endif | 
|---|
| 65 | ifeq (${MACHEROS},Linux) | 
|---|
| 66 | LIBFORT = -lf2c | 
|---|
| 67 | endif | 
|---|
| 68 | ######################################################################### | 
|---|
| 69 |  | 
|---|
| 70 |  | 
|---|
| 71 | MACHDIR := $(MACHEROS)-$(CXX) | 
|---|
| 72 |  | 
|---|
| 73 |  | 
|---|
| 74 | #- | 
|---|
| 75 | #-   Define Makefile paths | 
|---|
| 76 | #-  (NE PAS TOUCHER CES LIGNES: generation automatique de MakefileUser.h) | 
|---|
| 77 | #- | 
|---|
| 78 | PP  := ${DPCDEVREP}/${MACHDIR}/ | 
|---|
| 79 | LIB := ${PP}/Libs/ | 
|---|
| 80 | SLB := ${PP}/ShLibs/ | 
|---|
| 81 | OBJ := ${PP}/Objs/ | 
|---|
| 82 | EXE := ${PP}/Exec/ | 
|---|
| 83 | INC := ${DPCDEVREP}/Include/ | 
|---|
| 84 | GLB := /usr/local/lib/ | 
|---|
| 85 | #-- | 
|---|
| 86 |  | 
|---|
| 87 | #-   Flag for optimisation/ debug | 
|---|
| 88 | # Pour forcer sans debug, DBGFLAG = -g0 | 
|---|
| 89 | ifndef OPTFLAG | 
|---|
| 90 | OPTFLAG  := -O | 
|---|
| 91 | endif | 
|---|
| 92 |  | 
|---|
| 93 | ifndef DBGFLAG | 
|---|
| 94 | DBGFLAG  := -g | 
|---|
| 95 | #  Probleme sur DEC/OSF1 -g avec g++/egcs pose probleme a l'assembleur | 
|---|
| 96 | #                    Reza 09/99 - On met -gcoff | 
|---|
| 97 | ifeq (${MACHEROS},OSF1) | 
|---|
| 98 | ifeq ($(CXX), g++) | 
|---|
| 99 | override DBGFLAG := -gcoff | 
|---|
| 100 | endif | 
|---|
| 101 | endif | 
|---|
| 102 | endif | 
|---|
| 103 |  | 
|---|
| 104 | # DBGFLAG a -g0 veut dire pas de debug. Tout le monde a ca par defaut... | 
|---|
| 105 | ifeq ($(DBGFLAG), -g0) | 
|---|
| 106 | override DBGFLAG := | 
|---|
| 107 | endif | 
|---|
| 108 |  | 
|---|
| 109 | # xlC ne connait pas -O0, par defaut il n'optimise pas. | 
|---|
| 110 | ifeq ($(OPTFLAG), -O0) | 
|---|
| 111 | ifeq ($(CC), xlC) | 
|---|
| 112 | override OPTFLAG := | 
|---|
| 113 | endif | 
|---|
| 114 | endif | 
|---|
| 115 |  | 
|---|
| 116 | AR       := ar | 
|---|
| 117 | ARFLAGS  := -rcs | 
|---|
| 118 |  | 
|---|
| 119 | # le gnu ar ne fonctionne pas bien sur OSF... | 
|---|
| 120 | ifeq (${MACHEROS},OSF1) | 
|---|
| 121 | AR       := /usr/bin/ar | 
|---|
| 122 | endif | 
|---|
| 123 | # et sur AIX il nous sort des tas de warnings inutiles | 
|---|
| 124 | ifeq ($(MACHEROS),AIX) | 
|---|
| 125 | AR := /usr/bin/ar | 
|---|
| 126 | endif | 
|---|
| 127 |  | 
|---|
| 128 | #   Avec certains compilateurs C++ (KCC, aCC) , il faut fabriquer les librairies et | 
|---|
| 129 | # les shared libs avec la meme commande | 
|---|
| 130 | override ARCXX := $(AR) | 
|---|
| 131 | override ARCXXFLAGS := $(ARFLAGS) | 
|---|
| 132 | #RZ0999 ifeq ($(CXX),KCC) | 
|---|
| 133 | #RZ0999 override  ARCXX  := KCC | 
|---|
| 134 | #RZ0999 override ARCXXFLAGS  := -o | 
|---|
| 135 | #RZ0999 endif | 
|---|
| 136 | ifeq ($(CXX),aCC) | 
|---|
| 137 | override ARCXX  := aCC | 
|---|
| 138 | override ARCXXFLAGS  := -o | 
|---|
| 139 | endif | 
|---|
| 140 |  | 
|---|
| 141 | # Les chemins speciaux pour includes systemes et bibliotheques | 
|---|
| 142 | ifeq (${MACHEROS},HP-UX) | 
|---|
| 143 | XLDLIBS := -L. | 
|---|
| 144 | XCFLAGS := -I. | 
|---|
| 145 | endif | 
|---|
| 146 |  | 
|---|
| 147 |  | 
|---|
| 148 | #  Pour compiler PI, sous Linux, les includes et libs se trouve souvent ds /usr/X11/include /usr/X11/lib/ | 
|---|
| 149 | ifeq (${MACHEROS},Linux) | 
|---|
| 150 | XLDLIBS := -L/usr/X11/lib -L/usr/X11R6/lib | 
|---|
| 151 | XCFLAGS := -I/usr/X11/include -I/usr/X11R6/include | 
|---|
| 152 | LDLIBS := -ldl | 
|---|
| 153 | endif | 
|---|
| 154 |  | 
|---|
| 155 |  | 
|---|
| 156 | # Chemin pour la librairie cfitsio | 
|---|
| 157 | # les *.h doivent etre sous $CFITSIODIR | 
|---|
| 158 | # la librairie *.a sous $CFITSIODIR | 
|---|
| 159 | ifdef CFITSIODIR | 
|---|
| 160 | FITSIOREP := -I$(CFITSIODIR) | 
|---|
| 161 | FITSIOLIB := -L$(CFITSIODIR)/$(MACHDIR) -lcfitsio | 
|---|
| 162 | endif | 
|---|
| 163 |  | 
|---|
| 164 | #  S'il y a des flags particulier pour un module de compilation | 
|---|
| 165 | #ifndef MODULECPPFLAGS | 
|---|
| 166 | override MODULECPPFLAGS := | 
|---|
| 167 | #endif | 
|---|
| 168 |  | 
|---|
| 169 | CPPFLAGS     :=  -I${INC} $(FITSIOREP) -D${MACHEROSD} $(MODULECPPFLAGS) | 
|---|
| 170 |  | 
|---|
| 171 | # Les options selon les divers compilateurs | 
|---|
| 172 | # GNU | 
|---|
| 173 | ifeq ($(CC), gcc) | 
|---|
| 174 | CFLAGS       := -Wall -Wpointer-arith \ | 
|---|
| 175 | -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \ | 
|---|
| 176 | $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 177 | LDLIBS       := $(LDLIBS) $(XLDLIBS) | 
|---|
| 178 | endif | 
|---|
| 179 | ifeq ($(CC), egcs) | 
|---|
| 180 | CFLAGS       := -Wall -Wpointer-arith \ | 
|---|
| 181 | -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \ | 
|---|
| 182 | $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 183 | LDLIBS       := $(LDLIBS) $(XLDLIBS) | 
|---|
| 184 | endif | 
|---|
| 185 |  | 
|---|
| 186 | ifeq ($(CXX), g++) | 
|---|
| 187 | CXXFLAGS       := -Wall -Wpointer-arith \ | 
|---|
| 188 | -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \ | 
|---|
| 189 | $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 190 | LDLIBS      := $(LDLIBS) $(XLDLIBS) | 
|---|
| 191 | #  ifdef NOSHLIB | 
|---|
| 192 | #    LDFLAGS := -static | 
|---|
| 193 | #  endif | 
|---|
| 194 | endif | 
|---|
| 195 | ifeq ($(CXX), egcs++) | 
|---|
| 196 | CXXFLAGS       := -Wall -Wpointer-arith \ | 
|---|
| 197 | -Wmissing-prototypes -Wsynth -I$(INC) $(XCFLAGS) \ | 
|---|
| 198 | $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 199 | LDLIBS      := $(LDLIBS) $(XLDLIBS) | 
|---|
| 200 | ifdef NOSHLIB | 
|---|
| 201 | LDFLAGS := -static | 
|---|
| 202 | endif | 
|---|
| 203 | endif | 
|---|
| 204 |  | 
|---|
| 205 | # Compilateur C natif HP-UX | 
|---|
| 206 | ifeq (${MACHEROS},HP-UX) | 
|---|
| 207 | ifeq ($(CC),cc) | 
|---|
| 208 | CFLAGS       :=  +Z -Aa -Ae $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 209 | FFLAGS       :=  -Aa -I${INC}   -D${MACHEROSD} | 
|---|
| 210 | CPPFLAGS     :=  -I${INC}  -I$(INC)/tnt -D${MACHEROSD} \ | 
|---|
| 211 | -D_HPUX_SOURCE $(MODULECPPFLAGS) | 
|---|
| 212 | LDLIBS      := $(XLDLIBS) | 
|---|
| 213 | override NOSHLIB := Y | 
|---|
| 214 |  | 
|---|
| 215 | endif | 
|---|
| 216 | ifeq ($(CXX),aCC) | 
|---|
| 217 | CXXFLAGS := $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) +Z -D__aCC__ | 
|---|
| 218 | #  -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h | 
|---|
| 219 | endif | 
|---|
| 220 | endif | 
|---|
| 221 |  | 
|---|
| 222 | # AIX, xlC comme compilateur C et C++ | 
|---|
| 223 | ifeq ($(CXX), xlC) | 
|---|
| 224 | CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) $(XCFLAGS) | 
|---|
| 225 | CPPFLAGS := -I$(INC)/Syst -I${INC}  -I$(INC)/tnt -D${MACHEROSD} $(MODULECPPFLAGS) | 
|---|
| 226 | CXXFLAGS     := $(CFLAGS) -D__xlC -DCOMPILER_EXCEPTIONS | 
|---|
| 227 | # -DCOMPILER_EXCEPTIONS defini ds defs.h | 
|---|
| 228 | LDLIBS      := $(XLDLIBS) | 
|---|
| 229 |  | 
|---|
| 230 | # Pour faire des bibliotheques partagees, il faut faire un truc du | 
|---|
| 231 | # style | 
|---|
| 232 | #ld -o shrsub.o subs1.o subs2.o -bE:shrsub.exp -bM:SRE -lc | 
|---|
| 233 |  | 
|---|
| 234 | # Pour le moment on ne se fatigue pas, tant pis | 
|---|
| 235 | override NOSHLIB := Y | 
|---|
| 236 |  | 
|---|
| 237 | # Et puis 1540-293: (W) est un FAUX warning, on supprime les warnings | 
|---|
| 238 | CXXFLAGS := -qflag=e $(CXXFLAGS) | 
|---|
| 239 | endif | 
|---|
| 240 |  | 
|---|
| 241 |  | 
|---|
| 242 | ifeq ($(CXX), cxx) | 
|---|
| 243 | ifeq ($(DBGFLAG), -g) | 
|---|
| 244 | ifdef OPTFLAG | 
|---|
| 245 | override DBGFLAG := -g1 | 
|---|
| 246 | endif | 
|---|
| 247 | #    ifdef XOPT | 
|---|
| 248 | #      override DBGFLAG := -g1 | 
|---|
| 249 | #    endif | 
|---|
| 250 | endif | 
|---|
| 251 |  | 
|---|
| 252 | # chemin pour repository CXX | 
|---|
| 253 | REP := $(OBJ)/cxxrep/ | 
|---|
| 254 | REPPI := $(OBJ)/cxxrep_PI/ | 
|---|
| 255 | REPCXX := -ptr $(OBJ)/cxxrep/ | 
|---|
| 256 | ifdef MODULECXXREPNAME | 
|---|
| 257 | REPCXX := -ptr $(OBJ)/cxxrep_$(MODULECXXREPNAME)/  -ptr $(OBJ)/cxxrep/ | 
|---|
| 258 | REPM := $(OBJ)/cxxrep_$(MODULECXXREPNAME)/ | 
|---|
| 259 | endif | 
|---|
| 260 |  | 
|---|
| 261 | LDLIBS      := $(XLDLIBS) -lrt | 
|---|
| 262 |  | 
|---|
| 263 | CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS  \ | 
|---|
| 264 | $(REPCXX) -no_implicit_include | 
|---|
| 265 | CFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 266 | #  CXXFLAGS := $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \ | 
|---|
| 267 | #             -nopt -define_templates | 
|---|
| 268 | ifeq ($(XOPT), 1) | 
|---|
| 269 | override DBGFLAG := | 
|---|
| 270 | CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \ | 
|---|
| 271 | $(REPCXX) -fp_reorder \ | 
|---|
| 272 | -O5 -inline speed -tune host | 
|---|
| 273 | endif | 
|---|
| 274 | ifeq ($(XOPT), 2) | 
|---|
| 275 | override DBGFLAG := | 
|---|
| 276 | CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \ | 
|---|
| 277 | $(REPCXX) -fp_reorder \ | 
|---|
| 278 | -O5 -inline speed -tune host \ | 
|---|
| 279 | -assume trusted_short_alignment | 
|---|
| 280 | endif | 
|---|
| 281 | ifeq ($(XOPT), 3) | 
|---|
| 282 | override DBGFLAG := | 
|---|
| 283 | CXXFLAGS := $(DBGFLAG) $(MYCFLAGS) -DCOMPILER_EXCEPTIONS \ | 
|---|
| 284 | $(REPCXX) -fp_reorder \ | 
|---|
| 285 | -O5 -inline speed -tune host \ | 
|---|
| 286 | -assume trusted_short_alignment \ | 
|---|
| 287 | -non_shared -om | 
|---|
| 288 | override NOSHLIB := Y | 
|---|
| 289 | endif | 
|---|
| 290 |  | 
|---|
| 291 | # le fichier X11/Xlib.h contient des declarations de fonctions sans type | 
|---|
| 292 | # Cela genere un grand nombre de warning avec cxx V6 | 
|---|
| 293 | # La variable MODULEDECCXXFLAGS permet de specifier des options de compilation | 
|---|
| 294 | # pour un module donne | 
|---|
| 295 | ifdef MODULEDECCXXFLAGS | 
|---|
| 296 | CXXFLAGS := $(CXXFLAGS) $(MODULEDECCXXFLAGS) | 
|---|
| 297 | endif | 
|---|
| 298 | endif | 
|---|
| 299 | ifeq ($(CC),cc) | 
|---|
| 300 | ifeq ($(MACHEROS),OSF1) | 
|---|
| 301 | ifeq ($(XOPT), 1) | 
|---|
| 302 | CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \ | 
|---|
| 303 | -O4 -inline speed -tune host | 
|---|
| 304 | endif | 
|---|
| 305 | ifeq ($(XOPT), 2) | 
|---|
| 306 | CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \ | 
|---|
| 307 | -O4 -inline speed -tune host \ | 
|---|
| 308 | -assume trusted_short_alignment -fast | 
|---|
| 309 | endif | 
|---|
| 310 | ifeq ($(XOPT), 3) | 
|---|
| 311 | CFLAGS :=  $(DBGFLAG) $(MYCFLAGS) -fp_reorder \ | 
|---|
| 312 | -O4 -inline speed -tune host \ | 
|---|
| 313 | -assume trusted_short_alignment -fast \ | 
|---|
| 314 | -non_shared -om | 
|---|
| 315 | endif | 
|---|
| 316 | endif | 
|---|
| 317 | endif | 
|---|
| 318 |  | 
|---|
| 319 | # --- Compilateur KAI  (OK pour v 3.3) | 
|---|
| 320 | ifeq ($(CXX), KCC) | 
|---|
| 321 | CXXFLAGS     :=  --exceptions --rtti  --auto_instantiation --one_instantiation_per_object -D__KCC__ | 
|---|
| 322 | # Flag --one_instantiation_per_object mis - Reza 02/03/99 | 
|---|
| 323 | # -DCOMPILER_EXCEPTIONS -D__ANSI_TEMPLATES__  definis ds defs.h | 
|---|
| 324 | endif | 
|---|
| 325 |  | 
|---|
| 326 | # --- Compilateur natif CC de SGI | 
|---|
| 327 | ifeq ($(MACHEROS), IRIX64) | 
|---|
| 328 | ifeq ($(CXX), CC) | 
|---|
| 329 | CXXFLAGS     :=  -prelink -D__SGICC__ | 
|---|
| 330 | LINK.cc := CC $(CPPFLAGS) -D__SGICC__ $(DBGFLAG) $(OPTFLAG) | 
|---|
| 331 | endif | 
|---|
| 332 | endif | 
|---|
| 333 |  | 
|---|
| 334 | # Autres compilateurs natifs. | 
|---|
| 335 |  | 
|---|
| 336 | #  CFLAGS       :=  -I$(INC) $(XCFLAGS) $(OPTFLAG) $(DBGFLAG) $(MYCFLAGS) | 
|---|
| 337 | #  CXXFLAGS     := $(CFLAGS) | 
|---|
| 338 | #  LDLIBS      := $(XLDLIBS) | 
|---|
| 339 |  | 
|---|
| 340 | #- redefine implicit rule. Les .o sont dans $(OBJ). | 
|---|
| 341 | $(OBJ)%.o:%.c | 
|---|
| 342 | $(COMPILE.c) -o $@ $< | 
|---|
| 343 |  | 
|---|
| 344 | $(OBJ)%.o:%.cc | 
|---|
| 345 | $(COMPILE.cc) -o $@ $< | 
|---|
| 346 |  | 
|---|
| 347 | $(OBJ)%.o:%.f | 
|---|
| 348 | $(COMPILE.f) -o $@ $< | 
|---|
| 349 |  | 
|---|
| 350 | #OSF1 | 
|---|
| 351 | #LDFC est f77 | 
|---|
| 352 | #LDFCFLAGS est rien | 
|---|
| 353 |  | 
|---|
| 354 | #parfois | 
|---|
| 355 | #LDFC est cc | 
|---|
| 356 | #LDFCFLAGS est -ltruc | 
|---|
| 357 |  | 
|---|
| 358 | #------------------------------------------------- End of Makefile.h ------- | 
|---|