Makefile
author bmakuc <blaz.makuc@smarteh.si>
Wed, 27 Nov 2019 14:53:22 +0100
changeset 4 99009b24d401
parent 2 19bf8e678c42
permissions -rw-r--r--
Variables start_addr and count were read from query_packet using function mb_ntoh_safe. It looks like some compilers change the pointer alignment if the first byte starts at an odd address. Because mb_ntoh_safe uses pointers slave address and count (number of registers) were not read correctly from the buffer when several modbus slaves were present in network. In this temporary solution pointer aritmetics is replaced by simple 256 multiplication.

default: all

all:  libmb.a libmb.so

OBJ_FILES = mb_ascii.o mb_rtu.o mb_tcp.o mb_master.o mb_slave.o mb_slave_and_master.o sin_util.o

libmb.a:  $(OBJ_FILES)
	$(AR) cr libmb.a $(OBJ_FILES)

libmb.so: $(OBJ_FILES)
	$(CC) -shared -fPIC -o libmb.so $(OBJ_FILES)

clean:
	-rm -rf *.o libmb.a libmb.so



# use gcc
# CC = gcc

#get warnings, debugging information and optimization
# CFLAGS  = -Wall -Wpointer-arith -Wstrict-prototypes -Wwrite-strings
# CFLAGS += -Werror
# CFLAGS += -ggdb -O3 -funroll-loops
# Note: if the optimizer crashes, we'll leave out the -O3 for those files

# Required for compilation with beremiz, and to create shared object library
CFLAGS += -fPIC



#how to make things from other directories if they are missing
../% /%:
	$(MAKE) -C $(@D) $(@F)

Makefile.depend depend:
#	gcc -MM -MG -I$(LLIB) *.c \
	gcc -MM -MG *.c \
		| perl -pe 's/:/ Makefile.depend:/' \
		> Makefile.depend

include Makefile.depend