# Makefile.am - use automake to generate Makefile.in # # Copyright (C) 2006-2007 West Consulting # Copyright (C) 2006-2014 Arthur de Jong # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA sbin_PROGRAMS = nslcd AM_CPPFLAGS=-I$(top_srcdir) -D_XOPEN_SOURCE=500 # for pthread_rwlock AM_CFLAGS = -std=c99 $(PTHREAD_CFLAGS) -Wall -Werror -Wextra -Wno-unused-parameter nslcd_SOURCES = nslcd.c ../nslcd.h ../common/nslcd-prot.h \ ../common/inotify_helpers.h \ ../compat/attrs.h \ log.c log.h \ common.c common.h \ dispatch.c dispatch.h \ cfg.c cfg.h \ nsswitch.c invalidator.c \ db_config.c db_pam.c db_passwd.c db_shadow.c \ hackers.c hackers_watch.c hackers_parse.c \ hackers.h hackers_watch.h hackers_parse.h nslcd_LDADD = ../common/libtio.a ../common/libdict.a \ ../common/libexpr.a ../common/libinotify_helpers.a \ ../compat/libcompat.a \ -lcrypt -lyaml @nslcd_LIBS@ @PTHREAD_LIBS@ $(patsubst %.c,%.o,$(shell grep -lF common.h *.c)): dispatch.h dispatch.c: $(filter db_%.c,$(nslcd_SOURCES)) $(filter-out .deps/%,$(MAKEFILE_LIST)) { \ echo '#define _XOPEN_SOURCE 500 /* for pthread_rwlock_t */' && \ echo '#include "common.h"' && \ echo '#include "log.h"' && \ { \ echo '#define NSLCD_HANDLE(db, fn) case NSLCD_ACTION_##db##_##fn: (void)nslcd_##db##_##fn(fp, session); break;' && \ echo '#define NSLCD_HANDLE_UID(db, fn) case NSLCD_ACTION_##db##_##fn: (void)nslcd_##db##_##fn(fp, session, uid); break;' && \ echo 'void dispatch(TFILE *fp, int32_t action, struct session *session, uid_t uid) {' && \ echo ' switch (action) {' && \ sed -n 's/^NSLCD_HANDLE.*/ &)/p' $(filter %.c,$^) && \ echo ' default:' && \ echo ' log_log(LOG_WARNING, "invalid request id: 0x%08x", (unsigned int)action);' && \ echo ' }' ; \ echo '}' ; \ } | cpp | sed '/^#/d' ; \ } > $@ dispatch.h: $(filter db_%.c,$(nslcd_SOURCES)) $(filter-out .deps/%,$(MAKEFILE_LIST)) { \ echo '#define NSLCD_HANDLE(db, fn) int nslcd_##db##_##fn(TFILE *fp, struct session *);' && \ echo '#define NSLCD_HANDLE_UID(db, fn) int nslcd_##db##_##fn(TFILE *fp, struct session *, uid_t);' && \ echo 'void dispatch(TFILE *fp, int32_t action, struct session *session, uid_t uid);' && \ sed -n 's/^NSLCD_HANDLE.*/&)/p' $(filter %.c,$^); \ } | cpp | sed '/^#/d' > $@