3b727ca
# Makefile.dist for libdhcp4client
3b727ca
#
3b727ca
# We get the libdhcp4client library from the patched ISC source code.  We
3b727ca
# rebuild key C files with -DLIBDHCP to turn on the library features we
3b727ca
# need.  Normal build results in standard ISC code (i.e., not LIBDHCP
3b727ca
# stuff enabled).  We then link together a static library and a shared
3b727ca
# library with the new resulting objects.
3b727ca
#
3b727ca
# David Cantrell <dcantrell@redhat.com>
3b727ca
3b727ca
# What version of ISC DHCP is this?
3b727ca
VER   = $(shell grep DHCP_VERSION ../../includes/version.h | head -1 | cut -d '"' -f 2 | cut -d 'V' -f 2 | cut -d '-' -f 1)
3b727ca
3b727ca
PROGS = libdhcp4client.a libdhcp4client-$(VER).so.0
3b727ca
3b727ca
# NOTE: The ordering of these file lists is important!  We are using the
3b727ca
# whole program optimization features of gcc, so the order matters here.
3b727ca
3b727ca
# Source files shared by all objects
3b727ca
COMMON_SRCS = client_clparse.c client_dhclient.c common_alloc.c common_bpf.c \
3b727ca
              common_comapi.c common_conflex.c common_discover.c \
3b727ca
              common_dispatch.c common_dns.c common_ethernet.c \
3b727ca
              common_execute.c common_inet.c common_lpf.c common_memory.c \
3b727ca
              common_options.c common_packet.c common_parse.c common_print.c \
3b727ca
              common_socket.c common_tables.c common_tr.c common_tree.c \
3b727ca
              dst_dst_api.c dst_base64.c dst_hmac_link.c dst_md5_dgst.c \
3b727ca
              omapip_alloc.c omapip_array.c omapip_auth.c omapip_buffer.c \
3b727ca
              omapip_connection.c omapip_convert.c omapip_dispatch.c \
3b727ca
              omapip_errwarn.c omapip_handle.c omapip_hash.c \
3b727ca
              omapip_listener.c omapip_mrtrace.c omapip_result.c \
3b727ca
              omapip_support.c omapip_toisc.c omapip_trace.c
3b727ca
3b727ca
# Source files for libdhcp4client.o
3b727ca
CLIENT_SRCS = common_ctrace.c common_dlpi.c common_nit.c common_upf.c \
3b727ca
              dst_dst_support.c dst_prandom.c omapip_generic.c \
3b727ca
              omapip_message.c omapip_protocol.c
3b727ca
3b727ca
# Source files for libres.o (minires)
3b727ca
MINIRES_SRCS = minires_ns_date.c minires_ns_name.c minires_ns_parse.c \
3b727ca
               minires_ns_samedomain.c minires_ns_sign.c minires_ns_verify.c \
3b727ca
               minires_res_comp.c minires_res_findzonecut.c \
3b727ca
               minires_res_init.c minires_res_mkquery.c \
3b727ca
               minires_res_mkupdate.c minires_res_query.c minires_res_send.c \
3b727ca
               minires_res_sendsigned.c minires_res_update.c
3b727ca
773a3f1
# ISC dhcp headers we need to copy to /usr/include/dhcp4client
773a3f1
DHCP_HEADERS = dhcpd.h cdefs.h osdep.h arpa/nameser.h minires/minires.h \
773a3f1
               site.h cf/linux.h dhcp.h statement.h tree.h inet.h dhctoken.h \
773a3f1
               omapip/omapip_p.h failover.h ctrace.h minires/resolv.h \
773a3f1
               minires/res_update.h omapip/convert.h omapip/hash.h \
773a3f1
               omapip/trace.h
773a3f1
3b727ca
HDRS = dhcp4client.h libdhcp_control.h
3b727ca
SRCS = $(COMMON_SRCS) $(CLIENT_SRCS)
3b727ca
OBJS = $(SRCS:.c=.o)
3b727ca
3b727ca
INCLUDES = -I$(TOP) -I$(TOP)/includes -I$(TOP)/dst -I.
3b727ca
CFLAGS   = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) \
3b727ca
           -DCLIENT_PATH=${CLIENT_PATH} -DLIBDHCP -DUSE_MD5
3b727ca
3b727ca
all: $(PROGS)
3b727ca
3b727ca
install: all
3b727ca
	install -p -m 0755 -D libdhcp4client-$(VER).so.0 $(DESTDIR)$(LIBDIR)/libdhcp4client-$(VER).so.0
3b727ca
	ln -sf libdhcp4client-$(VER).so.0 $(DESTDIR)/$(LIBDIR)/libdhcp4client.so
3b727ca
	install -p -m 0644 -D libdhcp4client.a $(DESTDIR)$(LIBDIR)/libdhcp4client.a
3b727ca
	install -p -m 0644 -D dhcp4client.h $(DESTDIR)$(INCDIR)/dhcp4client/dhcp4client.h
3b727ca
	install -p -m 0644 -D libdhcp_control.h $(DESTDIR)$(INCDIR)/dhcp4client/libdhcp_control.h
773a3f1
	for hdr in $(DHCP_HEADERS) ; do \
773a3f1
		install -p -m 0644 -D $(TOP)/includes/$${hdr} $(DESTDIR)$(INCDIR)/dhcp4client/$${hdr} ; \
773a3f1
	done
3b727ca
3b727ca
depend:
3b727ca
	$(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRCS)
3b727ca
3b727ca
clean:
3b727ca
	-rm -f $(OBJS)
3b727ca
3b727ca
realclean: clean
3b727ca
	-rm -f $(PROG) *~ #*
3b727ca
3b727ca
distclean: realclean
3b727ca
	-rm -f Makefile
3b727ca
3b727ca
# This isn't the cleanest way to set up links, but I prefer this so I don't
3b727ca
# need object targets for each subdirectory.  The idea is simple.  Since
3b727ca
# libdhcp4client is a linked together wad of objects from across the source
3b727ca
# tree, we change / to _ when linking source files here.  Follow this example:
3b727ca
#
3b727ca
# We need to use client/dhclient.c, so we make this link:
3b727ca
#     rm -f client_dhclient.c
3b727ca
#     ln -s $(TOP)/client/dhclient.c client_dhclient.c
3b727ca
#
3b727ca
# Simple.  Given the way the ISC build system works, this is the easiest to
3b727ca
# maintain and least invasive.
3b727ca
#
3b727ca
# David Cantrell <dcantrell@redhat.com>
3b727ca
links:
3b727ca
	@for target in $(SRCS); do \
3b727ca
		source="`echo $$target | sed -e 's|_|/|'`"; \
3b727ca
		if [ ! -b $$target ]; then \
3b727ca
			rm -f $$target; \
3b727ca
		fi; \
3b727ca
		ln -s $(TOP)/$$source $$target; \
3b727ca
	done; \
3b727ca
	for hdr in $(HDRS); do \
3b727ca
		if [ ! -b $$hdr ]; then \
3b727ca
			rm -f $$hdr; \
3b727ca
		fi; \
3b727ca
		ln -s $(TOP)/libdhcp4client/$$hdr $$hdr; \
3b727ca
	done
3b727ca
3b727ca
# minires is difficult to build because it overrides things in common and dst,
3b727ca
# so we just link with the already built libres.a since we need it all anyway
3b727ca
libres.a:
3b727ca
	if [ ! -f ../minires/$@ ]; then \
3b727ca
		$(MAKE) -C ../minires; \
3b727ca
	fi; \
3b727ca
	ln ../minires/libres.a .; \
3b727ca
	$(AR) x libres.a
3b727ca
3b727ca
# Create the libraries
3b727ca
# minires/res_query.o contains an undefined symbol __h_errno_set, is not
3b727ca
# used by any dhcp code, and is optimized out by the linker when producing
3b727ca
# the dhclient executable or a shared library
3b727ca
libdhcp4client.a: $(OBJS) libres.a
3b727ca
	$(AR) crus $@ $(OBJS) `$(AR) t libres.a | grep -v res_query.o`
3b727ca
3b727ca
libdhcp4client-$(VER).so.0: $(OBJS) libres.a
3b727ca
	$(CC) -shared -o $@ -Wl,-soname,$@ $(OBJS) `$(AR) t libres.a | grep -v res_query.o`
3b727ca
3b727ca
# Dependencies (semi-automatically-generated)