Modify makefiles to find libraries on more platforms

r3060 | dcl | 2011-02-18 11:04:57 +1100 (Fri, 18 Feb 2011) | 1 line
This commit is contained in:
Douglas Clowes
2011-02-18 11:04:57 +11:00
parent 4a1607e430
commit 7f4b0de463
2 changed files with 63 additions and 9 deletions

View File

@@ -15,13 +15,13 @@ default: all
# PSI rules and variables
EXTRA=nintf.o
PSI_CLEAN_MATRIX = rm -f ../*.o ../psi/*.o; $(MAKE) -C ../matrix $(MFLAGS) clean
PSI_CFLAGS = -I./ -I$(HDFROOT)/include -DDO_NOT_SELECT_BEFORE_SEND -DHDF5 -DNXXML\
PSI_CFLAGS = -I./ $(INC_HDF5) $(INC_TCL8) -DDO_NOT_SELECT_BEFORE_SEND -DHDF5 -DNXXML\
-DCYGNUS -DNONINTF -std=gnu99 -g $(DFORTIFY)\
-Wall -Wextra -Wno-unused
PSI_SLIBS = matrix/libmatrix.a
PSI_LIBS = -L$(HDFROOT)/lib $(NILIB)\
-ltcl8.4 $(HDFROOT)/lib/libhdf5.a \
-ldl -lz -lm -lc /usr/lib/libmxml.a /usr/local/lib/libjson.a
PSI_LIBS = \
$(LIB_TCL8) $(LIB_HDF5) -lpthread \
-ldl -lz -lm -lc $(LIB_MXML) $(LIB_JSON)
../%.o : ../%.c
cd ..; $(CC) -c $(PSI_CFLAGS) $*.c -o $*.o
@@ -35,14 +35,67 @@ PSI_LIBS = -L$(HDFROOT)/lib $(NILIB)\
# ANSTO rules and variables
CC = gcc
INCFLAGS = -Ihardsup -I.. -I/opt/gnome/include
INCFLAGS = -Ihardsup -I.. $(INC_TCL8)
# NOTE -std=gnu99 adds c99 support with gnu extensions, it eliminates implicit function warnings
# for c99 functions like roundf. We don't use -std=c99 because it generates compiler errors in
# code modules that use the timeval struct without including sys/time.h, c99 also generates
# implicit function declaration warnings on string functions like strdup.
# On different systems, there may be different versions of libraries or they
# may be in different locations. This code tries to find the include files and
# libraries required in descending order of preference.
# TCL 8.4 or 8.5
LIB_TCL8 := $(firstword $(wildcard /usr/lib/libtcl.so /usr/lib/libtcl8.4.so /usr/lib/libtcl8.5.so))
ifeq (,$(LIB_TCL8))
$(warning LIB_TCL8 not found)
else
LIB_TCL8 := -L$(dir $(LIB_TCL8)) -l$(subst lib,,$(basename $(notdir $(LIB_TCL8))))
$(info LIB_TCL8 = $(LIB_TCL8))
endif
#
INC_TCL8 := $(firstword $(wildcard /usr/include/tcl.h /usr/include/tcl8.4/tcl.h /usr/lib/tcl8.5/tcl.h))
ifeq (,$(INC_TCL8))
$(warning INC_TCL8 not found)
else
INC_TCL8 := -isystem $(dir $(INC_TCL8))
$(info INC_TCL8 = $(INC_TCL8))
endif
# HDF5
LIB_HDF5 := $(firstword $(wildcard /usr/lib/libhdf5.a /usr/local/lib/libhdf5.a))
ifeq (,$(LIB_HDF5))
$(warning LIB_HDF5 not found)
endif
#
INC_HDF5 := $(firstword $(wildcard /usr/include/hdf5.h /usr/local/include/hdf5.h))
ifeq (,$(INC_HDF5))
$(warning INC_HDF5 not found)
else
INC_HDF5 := -I$(dir $(INC_HDF5))
endif
# JSON-C
LIB_JSON := $(firstword $(wildcard /usr/lib/libjson.a /usr/local/lib/libjson.a))
ifeq (,$(LIB_JSON))
$(warning LIB_JSON not found)
endif
# MXML
LIB_MXML := $(firstword $(wildcard /usr/lib/libmxml.a /usr/local/lib/libmxml.a))
ifeq (,$(LIB_MXML))
$(warning LIB_MXML not found)
endif
# GHTTP
LIB_HTTP := $(firstword $(wildcard /usr/lib/libghttp.a /usr/local/lib/libghttp.a))
ifeq (,$(LIB_HTTP))
$(warning LIB_HTTP not found)
endif
#
DEBUGFLAGS = -Wall -Wextra -Wno-unused -Wno-comment -Wno-switch
CFLAGS = -g $(INCFLAGS) $(DEBUGFLAGS) -std=gnu99
HDFROOT=/usr/local
SRC = ./../..
SITENAME = _ansto
@@ -67,8 +120,9 @@ TANGOLIBS = \
/usr/local/lib/libomniORB4.a \
/usr/local/lib/libomnithread.a
GHTTP_LIBS = \
/opt/gnome/lib/libghttp.a
$(LIB_HTTP)
#OBJ= site_ansto.o batch.o buffer.o ruli.o protocol.o sinfox.o \
# motor_asim.o motor_dmc2280.o motor_pdx.o \
@@ -122,7 +176,7 @@ libansto.a: $(OBJ)
ranlib libansto.a
libhardsup:
$(MAKE) -C hardsup/
$(MAKE) -C hardsup/ INC_TCL8="$(INC_TCL8)"
anstohm.o : anstohm.cpp
$(CXX) -c anstohm.cpp $(CFLAGS) $(CXXFLAGS) -Wno-all

View File

@@ -8,7 +8,7 @@
SRC = .
CC = gcc
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC) -I../.. -Wall -Wno-unused -Wextra
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC) -I../.. $(INC_TCL8) -Wall -Wno-unused -Wextra
HOBJ= nhq200util.o itc4util.o lh45util.o lakeshore340util.o west4100util.o asynsrv_utility.o geterrno.o strjoin.o chopper.o modbustcp.o sct_galilprot.o sct_modbusprot.o sct_oxfordprot.o sct_orhvpsprot.o sct_velselprot.o sct_usbtmcprot.o sct_rfamp.o sinqhttpprot.o sct_protek608.o