The pmkscan tool
The pmkscan tool is aimed to help the developer to generate pmkfiles
and makefiles. The work is done automatically by pmkscan, you just need
to provide the location of the source and some miscelaneous options
like recursivity, discards, ...
Here are two samples of what pmkscan produce with the pmk sources :
Sample of pmkfile :
# pmkfile generated by pmkscan (2005-11-05 18:14).
SETTINGS {
# list of template files
TARGET = ("Makefile.pmk", "compat/config.h.pmk")
}
# main defines (NEED MANUAL EDITION)
DEFINE {
PACKAGE = "mypackage"
VERSION = "0.0"
BINDIR = "\$(PREFIX)/bin"
SBINDIR = "\$(PREFIX)/sbin"
MANDIR = "\$(PREFIX)/man"
DATADIR = "\$(PREFIX)/share/\$(PACKAGE)"
MAN1DIR = "\$(MANDIR)/man1"
MAN5DIR = "\$(MANDIR)/man5"
MAN8DIR = "\$(MANDIR)/man8"
CONFDIR = "extra tag to edit"
PRIVSEP_USER = "extra tag to edit"
}
# check type bool
CHECK_TYPE(c_type_bool) {
REQUIRED = FALSE
NAME = "bool"
LANG = "C"
HEADER = "stdbool.h"
}
# check type intmax_t
CHECK_TYPE(c_type_intmax_t) {
REQUIRED = FALSE
NAME = "intmax_t"
LANG = "C"
HEADER = "stdint.h"
}
# check type ptrdiff_t
CHECK_TYPE(c_type_ptrdiff_t) {
REQUIRED = FALSE
NAME = "ptrdiff_t"
LANG = "C"
HEADER = "stddef.h"
}
# check type wchar_t
CHECK_TYPE(c_type_wchar_t) {
REQUIRED = FALSE
NAME = "wchar_t"
LANG = "C"
HEADER = "wchar.h"
}
# check header ctype.h
CHECK_HEADER(c_header_ctype_h) {
REQUIRED = FALSE
NAME = "ctype.h"
LANG = "C"
FUNCTION = ("isblank")
}
# check header dirent.h
CHECK_HEADER(c_header_dirent_h) {
REQUIRED = FALSE
NAME = "dirent.h"
LANG = "C"
}
# check header libgen.h
CHECK_HEADER(c_header_libgen_h) {
REQUIRED = FALSE
NAME = "libgen.h"
LANG = "C"
FUNCTION = ("basename", "dirname")
}
# check header stdio.h
CHECK_HEADER(c_header_stdio_h) {
REQUIRED = FALSE
NAME = "stdio.h"
LANG = "C"
FUNCTION = ("snprintf", "vsnprintf")
}
# check header string.h
CHECK_HEADER(c_header_string_h) {
REQUIRED = FALSE
NAME = "string.h"
LANG = "C"
FUNCTION = ("strdup", "strlcat", "strlcpy")
}
# check header sys/param.h
CHECK_HEADER(c_header_sys_param_h) {
REQUIRED = FALSE
NAME = "sys/param.h"
LANG = "C"
}
# check header unistd.h
CHECK_HEADER(c_header_unistd_h) {
REQUIRED = FALSE
NAME = "unistd.h"
LANG = "C"
FUNCTION = ("mkstemps")
}
# check library gen
CHECK_LIB(c_library_gen) {
REQUIRED = FALSE
NAME = "gen"
LANG = "C"
FUNCTION = ("basename", "dirname")
}
Sample of makefile :
# Makefile template generated by pmkscan (2005-11-05 18:14).
CPP= @CPP@
# language specific
AS= @AS@
ASFLAGS=
CC= @CC@
CFLAGS= @CFLAGS@
# misc stuff
LINKER= @CC@
# LDFLAGS shall contain -lc if used with ld
LDFLAGS= @LDFLAGS@
INSTALL= @INSTALL@
INSTALL_BIN= $(INSTALL) -m 755
INSTALL_DATA= $(INSTALL) -m 644
INSTALL_DIR= $(INSTALL) -d -m 755
INSTALL_MAN= $(INSTALL) -m 644
INSTALL_SBIN= $(INSTALL) -m 755
RM= rm
RMFLAGS= -rf
PACKAGE= @PACKAGE@
VERSION= @VERSION@
# extra tags
CONFDIR= @CONFDIR@
PRIVSEP_USER= @PRIVSEP_USER@
# specific directories
PREFIX= @PREFIX@
BINDIR= @BINDIR@
SBINDIR= @SBINDIR@
DATADIR= @DATADIR@
MANDIR= @MANDIR@
MAN1DIR= @MAN1DIR@
MAN5DIR= @MAN5DIR@
MAN8DIR= @MAN8DIR@
SYSCONFDIR= @SYSCONFDIR@
.SUFFIXES: .o .s .c .C .cc .cxx .cpp
# assembly suffix
# we use CPP to be more portable
.s.o:
$(CPP) $< | sed '/^#/d' > tmp_asm.s
$(AS) $(ASFLAGS) -o $@ tmp_asm.s
$(RM) $(RMFLAGS) tmp_asm.s
# C suffixes
.c.o:
$(CC) $(CFLAGS) -o $@ -c $<
.C.o:
$(CC) $(CFLAGS) -o $@ -c $<
.cc.o:
$(CC) $(CFLAGS) -o $@ -c $<
#
# object dependency lists
#
AUTOCONF_SRCS= autoconf.c autoconf.h cfgtool.h common.h compat/config.h \
compat/pmk_ctype.h compat/pmk_libgen.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h compat/pmk_sys_types.h \
compat/pmk_unistd.h dynarray.h errmsg.h functool.h \
hash.h hash_tools.h parse.h pathtools.h pmk.h pmk_obj.h \
premake.h prseng.h
CFGTOOL_SRCS= cfgtool.c cfgtool.h common.h compat/config.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.h errmsg.h hash.h parse.h \
pmk_obj.h premake.h prseng.h
CODEBUILD_SRCS= codebuild.c codebuild.h common.h compat/config.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.h errmsg.h hash.h pmk_obj.h \
premake.h
COMMON_SRCS= common.c common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_unistd.h dynarray.h errmsg.h hash.h pmk_obj.h \
premake.h
COMPAT_SRCS= compat.c compat.h compat/config.h compat/pmk_ctype.h \
compat/pmk_libgen.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_sys_types.h compat/pmk_unistd.h
DETECT_SRCS= common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_unistd.h detect.c detect.h dynarray.h \
errmsg.h hash.h parse.h pmk_obj.h premake.h prseng.h
DETECT_CPU_SRCS= common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_sys_types.h cpu_arch_def.h \
detect_cpu.c detect_cpu.h detect_cpu_asm.h \
dynarray.h errmsg.h hash.h parse.h pmk_obj.h \
premake.h prseng.h
DETECT_CPU_ASM_SRCS= cpu_arch_def.h detect_cpu_asm.s
DYNARRAY_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.c dynarray.h
FUNC_SRCS= autoconf.h cfgtool.h codebuild.h common.h compat/config.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h compat/pmk_unistd.h detect.h \
dynarray.h errmsg.h func.c func.h functool.h hash.h \
hash_tools.h parse.h pkgconfig.h pmk.h pmk_obj.h \
premake.h prseng.h
FUNCTOOL_SRCS= cfgtool.h common.h compat/config.h compat/pmk_ctype.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h compat/pmk_unistd.h dynarray.h \
errmsg.h functool.c functool.h hash.h hash_tools.h \
parse.h pmk.h pmk_obj.h premake.h prseng.h
HASH_SRCS= common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h dynarray.h \
errmsg.h hash.c hash.h pmk_obj.h premake.h
HASH_TOOLS_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.h errmsg.h hash.h \
hash_tools.c hash_tools.h pmk_obj.h premake.h
PARSE_SRCS= common.h compat/config.h compat/pmk_ctype.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.h errmsg.h hash.h parse.c \
parse.h pmk_obj.h premake.h prseng.h
PARSE_LANG_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h parse_lang.c parse_lang.h \
prseng.h
PATHTOOLS_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h pathtools.c pathtools.h
PKGCONFIG_SRCS= common.h compat/config.h compat/pmk_ctype.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h compat/pmk_sys_types.h dynarray.h \
errmsg.h hash.h hash_tools.h parse.h pkgconfig.c \
pkgconfig.h pmk_obj.h premake.h prseng.h
PMK_SRCS= autoconf.h cfgtool.h common.h compat/config.h \
compat/pmk_ctype.h compat/pmk_libgen.h \
compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h compat/pmk_sys_types.h \
compat/pmk_unistd.h dynarray.h errmsg.h func.h hash.h \
hash_tools.h parse.h pathtools.h pmk.c pmk.h pmk_obj.h \
premake.h prseng.h
PMK_OBJ_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h dynarray.h hash.h pmk_obj.c \
pmk_obj.h
PMKINSTALL_SRCS= common.h compat/config.h compat/pmk_ctype.h \
compat/pmk_libgen.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_sys_types.h compat/pmk_unistd.h \
dynarray.h errmsg.h hash.h pathtools.h pmk_obj.h \
pmkinstall.c pmkinstall.h premake.h
PMKPC_SRCS= cfgtool.h common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h dynarray.h \
errmsg.h hash.h hash_tools.h parse.h pkgconfig.h \
pmk_obj.h pmkpc.c pmkpc.h premake.h prseng.h
PMKSCAN_SRCS= common.h compat/config.h compat/pmk_ctype.h \
compat/pmk_libgen.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_sys_types.h compat/pmk_unistd.h dynarray.h \
errmsg.h hash.h hash_tools.h parse.h parse_lang.h \
pathtools.h pmk_obj.h pmkscan.c pmkscan.h premake.h \
prseng.h tags.h
PMKSETUP_SRCS= common.h compat/config.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h \
compat/pmk_sys_types.h compat/pmk_unistd.h \
cpu_arch_def.h detect_cpu.h dynarray.h errmsg.h hash.h \
parse.h pmk_obj.h pmksetup.c pmksetup.h premake.h \
prseng.h
PRSENG_SRCS= compat/config.h compat/pmk_stdbool.h compat/pmk_stdio.h \
compat/pmk_string.h prseng.c prseng.h
TAGS_SRCS= compat/config.h compat/pmk_ctype.h compat/pmk_stdbool.h \
compat/pmk_stdio.h compat/pmk_string.h tags.c tags.h
#
# target dependency lists
#
PMK_OBJS= autoconf.o cfgtool.o codebuild.o common.o compat.o detect.o \
dynarray.o func.o functool.o hash.o hash_tools.o parse.o \
pathtools.o pkgconfig.o pmk.o pmk_obj.o prseng.o
PMKINSTALL_OBJS= common.o compat.o dynarray.o hash.o pathtools.o \
pmk_obj.o pmkinstall.o
PMKPC_OBJS= cfgtool.o common.o compat.o dynarray.o hash.o hash_tools.o \
parse.o pkgconfig.o pmk_obj.o pmkpc.o prseng.o
PMKSCAN_OBJS= common.o compat.o dynarray.o hash.o hash_tools.o parse.o \
parse_lang.o pathtools.o pmk_obj.o pmkscan.o prseng.o \
tags.o
PMKSETUP_OBJS= common.o compat.o detect_cpu.o detect_cpu_asm.o \
dynarray.o hash.o parse.o pmk_obj.o pmksetup.o prseng.o
#
# target lists
#
ALL_TARGETS= pmk pmkinstall pmkpc pmkscan pmksetup
ALL_CLEAN_TARGETS= pmk_clean pmkinstall_clean pmkpc_clean pmkscan_clean \
pmksetup_clean
INSTALL_TARGETS= install_bin install_sbin install_man install_data
DEINSTALL_TARGETS= deinstall_bin deinstall_sbin deinstall_man deinstall_data
# by default we consider all binaries as non privileged
BIN_FILES= $(ALL_TARGETS)
# move privileged binaries here if needed
SBIN_FILES=
MAN1_FILES= man/pmk.1 man/pmkinstall.1 man/pmkpc.1 man/pmkscan.1
MAN5_FILES= man/pmk.conf.5 man/pmkfile.5 man/pmksyntax.5 man/scanfile.5
MAN8_FILES= man/pmksetup.8
DATA_FILES= data/pmkcfgtool.dat data/pmkcomp.dat data/pmkcpu.dat \
data/pmkscan.dat
#
# generic targets
#
all: $(ALL_TARGETS)
clean: $(ALL_CLEAN_TARGETS)
install: all $(INSTALL_TARGETS)
deinstall: $(DEINSTALL_TARGETS)
install_bin:
# install binaries
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
@for f in $(BIN_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_BIN) $$f $(DESTDIR)$(BINDIR)/$$d\n"; \
$(INSTALL_BIN) $$f $(DESTDIR)$(BINDIR)/$$d; \
done
install_sbin:
# install privileged binaries
$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
@for f in $(SBIN_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_SBIN) $$f $(DESTDIR)$(SBINDIR)/$$d\n"; \
$(INSTALL_SBIN) $$f $(DESTDIR)$(SBINDIR)/$$d; \
done
deinstall_bin:
# deinstall binaries
@for f in $(BIN_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)$(BINDIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)$(BINDIR)/$$d; \
done
deinstall_sbin:
# deinstall privileged binaries
@for f in $(SBIN_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)$(SBINDIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)$(SBINDIR)/$$d; \
done
install_man:
# install manual pages
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)
# man1
$(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
@for f in $(MAN1_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_DATA) $$f $(DESTDIR)$(MAN1DIR)/$$d\n"; \
$(INSTALL_DATA) $$f $(DESTDIR)/$(MAN1DIR)/$$d; \
done
# man5
$(INSTALL_DIR) $(DESTDIR)$(MAN5DIR)
@for f in $(MAN5_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_DATA) $$f $(DESTDIR)$(MAN5DIR)/$$d\n"; \
$(INSTALL_DATA) $$f $(DESTDIR)/$(MAN5DIR)/$$d; \
done
# man8
$(INSTALL_DIR) $(DESTDIR)$(MAN8DIR)
@for f in $(MAN8_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_DATA) $$f $(DESTDIR)$(MAN8DIR)/$$d\n"; \
$(INSTALL_DATA) $$f $(DESTDIR)/$(MAN8DIR)/$$d; \
done
deinstall_man:
# deinstall manual pages
# man1
@for f in $(MAN1_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN1DIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN1DIR)/$$d; \
done
# man5
@for f in $(MAN5_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN5DIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN5DIR)/$$d; \
done
# man8
@for f in $(MAN8_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN8DIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)/$(MAN8DIR)/$$d; \
done
install_data:
# install data files
$(INSTALL_DIR) $(DESTDIR)$(DATADIR)
@for f in $(DATA_FILES); do \
d=`basename $$f`; \
printf "$(INSTALL_DATA) $$f $(DESTDIR)$(DATADIR)/$$d\n"; \
$(INSTALL_DATA) $$f $(DESTDIR)$(DATADIR)/$$d; \
done
deinstall_data:
# deinstall data files
@for f in $(DATA_FILES); do \
d=`basename $$f`; \
printf "$(RM) $(RMFLAGS) $(DESTDIR)$(DATADIR)/$$d\n"; \
$(RM) $(RMFLAGS) $(DESTDIR)$(DATADIR)/$$d; \
done
#
# object rules
#
autoconf.o: $(AUTOCONF_SRCS)
cfgtool.o: $(CFGTOOL_SRCS)
codebuild.o: $(CODEBUILD_SRCS)
common.o: $(COMMON_SRCS)
compat.o: $(COMPAT_SRCS)
detect.o: $(DETECT_SRCS)
detect_cpu.o: $(DETECT_CPU_SRCS)
detect_cpu_asm.o: $(DETECT_CPU_ASM_SRCS)
dynarray.o: $(DYNARRAY_SRCS)
func.o: $(FUNC_SRCS)
functool.o: $(FUNCTOOL_SRCS)
hash.o: $(HASH_SRCS)
hash_tools.o: $(HASH_TOOLS_SRCS)
parse.o: $(PARSE_SRCS)
parse_lang.o: $(PARSE_LANG_SRCS)
pathtools.o: $(PATHTOOLS_SRCS)
pkgconfig.o: $(PKGCONFIG_SRCS)
pmk.o: $(PMK_SRCS)
pmk_obj.o: $(PMK_OBJ_SRCS)
pmkinstall.o: $(PMKINSTALL_SRCS)
pmkpc.o: $(PMKPC_SRCS)
pmkscan.o: $(PMKSCAN_SRCS)
pmksetup.o: $(PMKSETUP_SRCS)
prseng.o: $(PRSENG_SRCS)
tags.o: $(TAGS_SRCS)
#
# target rules
#
pmk: $(PMK_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PMK_OBJS)
pmk_clean:
$(RM) $(RMFLAGS) $(PMK_OBJS)
$(RM) $(RMFLAGS) pmk
pmkinstall: $(PMKINSTALL_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PMKINSTALL_OBJS)
pmkinstall_clean:
$(RM) $(RMFLAGS) $(PMKINSTALL_OBJS)
$(RM) $(RMFLAGS) pmkinstall
pmkpc: $(PMKPC_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PMKPC_OBJS)
pmkpc_clean:
$(RM) $(RMFLAGS) $(PMKPC_OBJS)
$(RM) $(RMFLAGS) pmkpc
pmkscan: $(PMKSCAN_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PMKSCAN_OBJS)
pmkscan_clean:
$(RM) $(RMFLAGS) $(PMKSCAN_OBJS)
$(RM) $(RMFLAGS) pmkscan
pmksetup: $(PMKSETUP_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PMKSETUP_OBJS)
pmksetup_clean:
$(RM) $(RMFLAGS) $(PMKSETUP_OBJS)
$(RM) $(RMFLAGS) pmksetup
|