umakefile 2.1 KB
Newer Older
oberion's avatar
oberion committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#-- uncomment this to enable debugging
#DEBUG:=-g -DDEBUG

#-- what compiler are you using?
CC:=gcc


###### YOU SHOULD NOT CHANGE BELOW THIS LINE ######

VERSION:=1.4.0
SRCS:=api.c

CFLAGS:=-Wall -Wstrict-prototypes -Wno-variadic-macros -pedantic -c -fPIC ${DEBUG}
CLINKS:=-lpthread -lrt ${DEBUG}
DEFINES:=-D__UMAKEFILE

SRCS:=${sort ${SRCS}}

.PHONY: all run new clean main


# all - do everything (default) #
all: ./lib/libxbee.so.$(VERSION) main
	@echo "*** Done! ***"


# run - remake main and then run #
run: main
	./bin/main


# new - clean and do everything again #
new: clean all


# clean - remove any compiled files and PDFs #
clean:
	rm -f ./*~
	rm -f ./sample/*~
	rm -f ./obj/*.o
	rm -f ./lib/libxbee.so*
	rm -f ./bin/main
  
# install - installs library #
install: /usr/lib/libxbee.so.$(VERSION) /usr/include/xbee.h

/usr/lib/libxbee.so.$(VERSION): ./lib/libxbee.so.$(VERSION)
	cp ./lib/libxbee.so.$(VERSION) /usr/lib/libxbee.so.$(VERSION) -f
	@chmod 755 /usr/lib/libxbee.so.$(VERSION)
	@chown root:root /usr/lib/libxbee.so.$(VERSION)
	ln ./libxbee.so.$(VERSION) /usr/lib/libxbee.so.1 -sf
	@chown root:root /usr/lib/libxbee.so.1
	ln ./libxbee.so.$(VERSION) /usr/lib/libxbee.so -sf
	@chown root:root /usr/lib/libxbee.so

/usr/include/xbee.h: ./xbee.h
	cp ./xbee.h /usr/include/xbee.h -f
	@chmod 644 /usr/include/xbee.h
	@chown root:root /usr/include/xbee.h

uninstall:
	rm /usr/lib/libxbee.so.$(VERSION) -f
	rm /usr/lib/libxbee.so.1 -f
	rm /usr/lib/libxbee.so -f	
	rm /usr/include/xbee.h -f
  
# main - compile & link objects #
main: ./bin/main

./bin/main: ./obj/api.o ./bin/ ./main.c
	${CC} ${CLINKS} ./main.c ./obj/api.o -o ./bin/main ${DEBUG}

./bin/:
	mkdir ./bin/

./lib/libxbee.so.$(VERSION): ./lib/ ${addprefix ./obj/,${SRCS:.c=.o}} ./xbee.h
	gcc -shared -Wl,-soname,libxbee.so.1 -o ./lib/libxbee.so.$(VERSION) ./obj/*.o -lrt
	ln ./libxbee.so.$(VERSION) ./lib/libxbee.so.1 -sf
	ln ./libxbee.so.$(VERSION) ./lib/libxbee.so -sf

./lib/:
	mkdir ./lib/

./obj/:
	mkdir ./obj/

./obj/%.o: ./obj/ %.c %.h xbee.h
	${CC} ${CFLAGS} ${DEFINES} ${DEBUG} $*.c -o $@

./obj/%.o: ./obj/ %.c xbee.h
	${CC} ${CFLAGS} ${DEFINES} ${DEBUG} $*.c -o $@