# HG changeset patch # User Guido Berhoerster # Date 1505944671 -7200 # Node ID 616385fa1fd9e19a76f07f6734e3bbd5d0ca5c99 # Parent eb5ce870eb162581a6d26c74cdd044450f3e91a2 Build common functions as a library that can be reused diff -r eb5ce870eb16 -r 616385fa1fd9 Makefile --- a/Makefile Wed Sep 20 23:49:31 2017 +0200 +++ b/Makefile Wed Sep 20 23:57:51 2017 +0200 @@ -145,6 +145,10 @@ LIBCOMPAT_LIB = compat/libcompat.a LIBCOMPAT_LIB_MEMBERS = $(LIBCOMPAT_OBJS:%.o=$(LIBCOMPAT_LIB)(%.o)) +LIBPWM_OBJS = util.o +LIBPWM_LIB = libpwm.a +LIBPWM_LIB_MEMBERS = $(LIBPWM_OBJS:%.o=$(LIBPWM_LIB)(%.o)) + PWM_OBJS = cmd.o \ io.o \ pager.o \ @@ -152,11 +156,10 @@ pw.o \ pwfile.o \ pwm.o \ - tok.o \ - util.o + tok.o PWM_BIN = $(PACKAGE) -OBJS = $(LIBCOMPAT_OBJS) $(PWM_OBJS) +OBJS = $(LIBCOMPAT_OBJS) $(LIBPWM_OBJS) $(PWM_OBJS) MANPAGES = pwm.1 @@ -176,12 +179,12 @@ endif ifeq ($(HAVE_ARC4RANDOM),1) XCPPFLAGS += -DHAVE_ARC4RANDOM - PWM_OBJS += rand-arc4random.o + LIBPWM_OBJS += rand-arc4random.o else ifeq ($(HAVE_GETRANDOM),1) XCPPFLAGS += -DHAVE_GETRANDOM - PWM_OBJS += rand-getrandom.o + LIBPWM_OBJS += rand-getrandom.o else - PWM_OBJS += rand-dev-random.o + LIBPWM_OBJS += rand-dev-random.o endif ifeq ($(HAVE_CLOSEFROM),1) XCPPFLAGS += -DHAVE_CLOSEFROM @@ -218,7 +221,9 @@ $(LIBCOMPAT_LIB): $(LIBCOMPAT_LIB_MEMBERS) -$(PWM_BIN): $(PWM_OBJS) $(LIBCOMPAT_LIB) +$(LIBPWM_LIB): $(LIBPWM_LIB_MEMBERS) + +$(PWM_BIN): $(PWM_OBJS) $(LIBPWM_LIB) $(LIBCOMPAT_LIB) $(LINK.o) $^ $(LDLIBS) -o $@ $(eval $(call generate-manpage-rule,$(MANPAGES))) @@ -244,7 +249,7 @@ done clean: - rm -f $(LIBCOMPAT_LIB) $(PWM_BIN) $(OBJS) $(MANPAGES) + rm -f $(LIBCOMPAT_LIB) $(LIBPWM_LIB) $(PWM_BIN) $(OBJS) $(MANPAGES) clobber: clean rm -f $(patsubst %.o,%.d,$(OBJS))