xref: /freebsd/contrib/bsddialog/lib/Makefile (revision e92ffd9b626833ebdbf2742c8ffddc6cd94b963e)
1# Any copyright is dedicated to the Public Domain, see:
2#     <http://creativecommons.org/publicdomain/zero/1.0/>
3#
4# Written in 2021 by Alfonso Sabato Siciliano
5
6VERSION = 0.0.2
7LIBRARY = bsddialog
8LIBRARY_SO = lib${LIBRARY:=.so}
9HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h
10SOURCES = barbox.c formbox.c infobox.c libbsddialog.c lib_util.c menubox.c \
11	messagebox.c textbox.c theme.c timebox.c
12OBJECTS= ${SOURCES:.c=.o}
13CFLAGS = -I/usr/local/include -fPIC -Wall -Wextra
14LDFLAGS = -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings \
15	-Wl,--warn-shared-textrel -Wl,-soname,${LIBRARY_SO}.${VERSION}
16
17.if defined(DEBUG)
18# `make -DDEBUG`
19CFLAGS += -g
20.else
21CFLAGS += -O2 -pipe -std=gnu99 -Wno-format-zero-length \
22	-fstack-protector-strong -Qunused-arguments
23.endif
24
25.if defined(PORTNCURSES)
26# PORT ncurses `make -DPORTNCURSES`
27CFLAGS += -DPORTNCURSES -I/usr/local/include
28LDFLAGS += -L/usr/local/lib -lformw -lncursesw -ltinfow
29.else
30# BASE ncurses
31LDFLAGS += -L/usr/lib -lformw -lncursesw -ltinfow
32.endif
33
34INSTALL_PREFIX=/usr/local
35LN = ln -s -f
36RM = rm -f
37CP = cp
38GZIP = gzip -cn
39LDCONFIG = /sbin/ldconfig -m
40MAN= ${OUTPUT}.3
41GZIP= gzip -cn
42MANDIR= /usr/local/share/man/man3
43INSTALL= install
44RM= rm -f
45
46#all : man ${LIBRARY}
47all : ${LIBRARY}
48
49${LIBRARY}: ${OBJECTS}
50	${CC} ${LDFLAGS} ${.ALLSRC} -o ${LIBRARY_SO}.${VERSION}
51	# LN for devel
52	${LN} ${LIBRARY_SO}.${VERSION} ${LIBRARY_SO}
53
54.c.o:
55	${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
56
57man:
58	${GZIP} ${LIBRARY}.3 > ${LIBRARY}.3.gz
59
60clean:
61	${RM} ${LIBRARY_SO}* *.o *~ *.gz
62
63
64install:
65	${CP} ${LIBRARY}.h ${INSTALL_PREFIX}/include
66	${CP} ${LIBRARY_SO}.${VERSION} ${INSTALL_PREFIX}/lib/
67	${LN} ${INSTALL_PREFIX}/lib/${LIBRARY_SO}.${VERSION} ${INSTALL_PREFIX}/lib/${LIBRARY_SO}
68	${LDCONFIG} ${INSTALL_PREFIX}/lib
69	${CP} ${LIBRARY}.3.gz ${INSTALL_PREFIX}/man/man3/
70
71unistall:
72	${RM} ${INSTALL_PREFIX}/include/${LIBRARY}.h
73	${RM} ${INSTALL_PREFIX}/lib/${LIBRARY_SO}
74	${RM} ${INSTALL_PREFIX}/lib/${LIBRARY_SO}.${VERSION}
75	${LDCONFIG} ${INSTALL_PREFIX}/lib
76	${RM} ${INSTALL_PREFIX}/man/man3/${LIBRARY}.3.gz
77