1
2######################################################################
3# Makefile template for simple projects.  Just fill in the blanks and
4# add or adjust variables as needed.  Remove unnecessary lines if
5# desired.
6#
7# To override any variables conditionally set (with ?=), run
8#
9#       make VAR=value
10# e.g.
11#       make PREFIX=/opt/local CC=gcc CFLAGS=-O2 LFLAGS1="-L/usr/X11R6 -lX11"
12#
13# Author:
14#    Jason Bacon
15#
16######################################################################
17
18################################
19# Files to be installed by make
20
21LIB1    = libroboctl.a
22LIBS    = ${LIB1}
23
24HEADERS = rct_machdep.h rct_nxt.h rct_nxt_output.h \
25	rct_protos.h rct_rcx.h rct_pic.h roboctl.h
26
27MAN3    = roboctl.3
28
29###################################################
30# List object files that comprise BIN1, BIN2, etc.
31
32OBJS1   = rct.o nxt.o nxt_direct_cmd.o nxt_system_cmd.o \
33	    rcx.o usb.o brick.o get_home_dir.o debug.o pic.o vex.o strings.o
34OBJS    = ${OBJS1}
35
36#####################################
37# Compile, link, and install options
38
39PREFIX          ?= /usr/local
40LOCALBASE       ?= /usr/local
41MANPREFIX       ?= /usr/local
42
43CC      ?= cc
44INCLUDES?= -I. -I${LOCALBASE}/include
45#CFLAGS  ?= -O -pipe -Wall
46CFLAGS  = -g -pipe -Wall
47CFLAGS  += ${INCLUDES}
48
49INSTALL ?= install
50LN      ?= ln
51RM      ?= rm
52AR      ?= ar
53RANLIB  ?= ranlib
54PRINTF  ?= printf
55
56
57#####################################
58# Standard targets required by ports
59
60all:    ${BINS} ${LIBS}
61
62# Link rules
63${LIB1}:        ${OBJS1}
64	${AR} r ${LIB1} ${OBJS1}
65	${RANLIB} ${LIB1}
66
67############################################################################
68# Include dependencies generated by "make depend", if they exist.
69# These rules explicitly list dependencies for each object file.
70# See "depend" target below.  If Makefile.depend does not exist, use
71# generic source compile rules.  These have some limitations, so you
72# may prefer to create explicit rules for each target file.  This can
73# be done automatically using "cpp -M" or "cpp -MM".  Run "man cpp"
74# for more information, or see the "depend" target below.
75
76include Makefile.depend
77
78############################################################################
79# Self-generate dependencies the old-fashioned way
80
81depend:
82	rm -f Makefile.depend
83	for file in *.c; do \
84		${CPP} -MM ${INCLUDES} $${file} >> Makefile.depend; \
85		${PRINTF} "\t\$${CC} -c \$${CFLAGS} $${file}\n\n" >> Makefile.depend; \
86	done
87
88
89############################################################################
90# Generate a header containing prototypes for C files
91
92protos:
93	(cproto ${INCLUDES} *.c > temp_protos.h && mv -f temp_protos.h rct_protos.h)
94
95# Remove generated files (objs and nroff output from man pages)
96clean:
97	rm -f ${OBJS} ${BINS} ${LIBS} *.nr
98
99# Keep backup files during normal clean, but provide an option to remove them
100realclean: clean
101	rm -f .*.bak *.bak *.BAK
102
103dox:
104	doxygen
105
106install: all
107	mkdir -p ${PREFIX}/bin ${PREFIX}/lib ${PREFIX}/include/roboctl ${MANPREFIX}/man/man3
108	@for file in ${HEADERS}; do \
109		${INSTALL} -c -m 0444 $${file} ${PREFIX}/include/roboctl; \
110	done
111	@for file in ${LIBS}; do \
112		${INSTALL} -c -m 0444 $${file} ${PREFIX}/lib; \
113	done
114	@for file in ${MAN3}; do \
115		${INSTALL} -c -m 0444 Dox/man/man3/$${file} ${MANPREFIX}/man/man3; \
116	done
117
118uninstall:
119	${RM} -rf ${PREFIX}/include/roboctl
120	@for file in ${LIBS}; do \
121		${RM} ${PREFIX}/lib/$${file}; \
122	done
123	@for file in ${MAN3}; do \
124		${RM} ${MANPREFIX}/man/man3/$${file}; \
125	done
126