#! /bin/make -f # ## Makefile for code snippets from http://www.berlinos.de/ # ## # Compiles the code snippets and utility programs from # http://www.berlinos.de/Snippets # ## GPL 2004 Manfred Waßmann http://www.berlinos.de/ ## # # Copyright (C) 2004 Manfred Waßmann http://www.berlinos.de/ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2, # as published by the Free Software Foundation. # MODULE := Snippets # Name of the main index file IDX := 00Index ############################# ### customization section ### ############################# # Macros defined here may be overriden from the command line or environment I9N_STYLES = kr orig linux gnu BINARIES = $(shell sed -e \ '/^\*\([A-Za-z][-0-9A-Za-z_]*\): [-0-9A-Za-z_]*\.c.*/s//\1/;t;d' \ $(IDX)) VERBOSE=-v KERNELSRC = /usr/src/linux # Program used to install files INSTALL := /usr/bin/install DVIPS = dvips TEX = latex # default CFLAGS override CFLAGS := -Wall -Wshadow -Wsign-compare \ -Wno-write-strings -Wno-conversion -Waggregate-return \ -Wstrict-prototypes -Wno-missing-prototypes \ -Wno-missing-declarations -Wredundant-decls \ -Wnested-externs -Winline \ $(CFLAGS) # gcc-3.0: -Wunreachable-code # additional (C|LD)FLAGS for optimization of release versions OPTIMIZATION_FLAGS = -Os prefix = ~ bindir = $(prefix)/bin libdir = $(prefix)/lib includedir = $(prefix)/include #################################### ### End of customization section ### #################################### programs= epmhelper lsm-genstruct.awk lsm-skeleton.awk \ char errno isascii odiff pathconf sysconf xc xor sources = $(filter-out $(BINARIES:=.c),$(wildcard *.c)) headers = berlinos_debug.h texsrc = $(wildcard *.tex) # Definitions used when building binary packages using buildpkg.mk PKGFORM = deb # Use lowercase only name for building debian package #PKGNAME = snippets PKGVERSION = $(subst evision:,,$(strip 1.13R)) #PKGRELEASE = PACKAGER = $(USER) VENDOR = http://www.berlinos.de/ README = /dev/null COPYNOTE = COPYING LICENSE = div PKGBINS = $(programs) PKGSRCS = $(sources) PKGHDRS = $(headers) PKGMKFILES = Makefile #BUILDPKG_VERSION = 2.10 export BUILDPKG_VERSION ##################### ### Macro section ### ##################### CFLAGS += -I. LDFLAGS += -L. # Additional system libraries SYSLIBS = ## glibc/dietlibc ## ifndef DIET CC = gcc else CC = diet gcc endif ## curses ifdef CURSES override CFLAGS += -DUSE_CURSES override LDFLAGS += -lcurses endif ifeq ($(CURDIR),) CURDIR := `pwd` endif CWDBASE = $(notdir $(CURDIR)) ARCHIVE = $(CURDIR).tar.gz TAG_VER = $(strip $(LIB_MAJOR))_$(strip $(LIB_MINOR)) ###################### ### Target section ### ###################### all: all-i9n $(BINARIES) $(patsubst %.tex,%.ps,$(texsrc)) @+printf "[%s]\n" $@ ################################### ### Include auxiliary makefiles ### ################################### # These have to be included after the default target include buildpkg.mk release: CFLAGS := $(OPTIMIZATION_FLAGS) -DNDEBUG -UDEBUG release: LDFLAGS := $(OPTIMIZATION_FLAGS) release: clean all @+printf "[%s]\n" $@ debug: DEBUG ?= 1 debug: CFLAGS := -g -DDEBUG=$(DEBUG) debug: LDLIBS := -lmcheck debug: clean all @+printf "[%s]\n" $@ install: install-headers install-binaries @+printf "[%s]\n" $@ install-binaries: $(programs) @+printf "[%s]\n" $@ -test "$^" && $(INSTALL) $(VERBOSE) $^ $(bindir)/ install-headers: $(headers) @+printf "[%s]\n" $@ -test "$^" && $(INSTALL) $(VERBOSE) $^ $(includedir)/ deinstall-binaries: @+printf "[%s]\n" $@ $(RM) $(programs:%=$(bindir)/%) deinstall-headers: @+printf "[%s]\n" $@ $(RM) $(headers:%=$(includedir)/%) deinstall: deinstall-binaries deinstall-headers @+printf "[%s]\n" $@ tag: @+printf "[%s]\n" $@ cvs tag -F a$(TAG_VER) branch-%: @+printf "[%s]\n" $@ cvs tag -b -f -r a$* v$* cvs tag -d a$* i9n-%: i9n.c @+printf "[%s]\n" $@ indent -$* -o $@ $< all-i9n: i9n-gnu.c i9n-kr.c i9n-orig.c @+printf "[%s]\n" $@ indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl -o i9n-linux.c i9n.c for r in $(I9N_STYLES);do for s in $(I9N_STYLES);do \ test $$r = $$s || \ diff -ub i9n-$$r.c i9n-$$s.c |tee i9n-$$r-$$s.diff; \ done;done lsm-%: @+printf "[%s]\n" $@ $(MAKE) $*_hooks.c $*_secops.c %_hooks.c: $(KERNELSRC)/include/linux/security.h @+printf "[%s]\n" $@ touch .stamp-lsm-$* ./lsm-skeleton.awk -vp=$* $^ %_secops.c: $(KERNELSRC)/include/linux/security.h @+printf "[%s]\n" $@ touch .stamp-lsm-$* ./lsm-genstruct.awk -vp=$* $^ # # Override macros for specific targets # md5test: LDFLAGS=-lcrypto # # Non-standard compilation targets # elfdump: LDFLAGS += -lelf # # Internal targets # depend: $(addsuffix .d,$(basename $(sources))) version.make @+printf "[%s]\n" $@ $(BINARIES): $(BINARIES:=.o) @+printf "[%s]\n" $@ $(CC) $(CFLAGS) $@.o $(LDFLAGS) -o $@ %.c %.h: %.et @+printf "[%s]\n" $@ compile_et $^ $@ %.et: %.et-in @+printf "[%s]\n" $@ sed $(ET_SUBST) $^ > $@ %.o: %.c %.d Makefile @+printf "[%s]\n" $@ $(CC) $(CFLAGS) -c $< -o $@ %.d: %.c @+printf "[%s]\n" $@ $(CC) $(CFLAGS) -M -MG -MMD $< %.i: %.c @+printf "[%s]\n" $@ $(CC) $(CFLAGS) -E -o - $^ | egrep -v '^[ \t]*$$' > $@ %: %.c %.d Makefile @+printf "[%s]\n" $@ $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) #%.dvi: %.tex # @+printf "[%s]\n" $@ # $(TEX) $< # $(TEX) $< # $(TEX) $< %.ps: %.dvi @+printf "[%s]\n" $@ $(DVIPS) -o $@ $< clean: @+printf "[%s]\n" $@ $(RM) a.out $(BINARIES) *.o *.s *.i *.aux *.log $(RM) $(patsubst %.tex,%.aux,$(texsrc)) \ $(patsubst %.tex,%.log,$(texsrc)) \ $(patsubst %.tex,%.toc,$(texsrc)) distclean: clean clean-lsm $(clean-pkg) @+printf "[%s]\n" $@ $(RM) *~ $(RM) *.log $(RM) version.make *.d $(RM) $(patsubst %.tex,%.dvi,$(texsrc)) \ $(patsubst %.tex,%.pdf,$(texsrc)) \ $(patsubst %.tex,%.ps,$(texsrc)) $(RM) i9n-*.c i9n-*.diff clean-lsm: $(foreach \ s,$(wildcard .stamp-lsm-*),clean-lsm-$(patsubst .stamp-lsm-%,%,$s)) @+printf "[%s]\n" $@ clean-lsm-%: @+printf "[%s]\n" $@ $(RM) $*_hooks.c $*_secops.c .stamp-lsm-$* cvsclean: @+printf "[%s]\n" $@ find . \( -name '.#*' -o -name '*.~[0-9]*.~' \) -print | xargs $(RM) -v tarball: distclean @+printf "[%s]\n" $@ cd .. && tar -chzvf $(ARCHIVE) \ --exclude=$(CWDBASE)/CVS \ --exclude=$(CWDBASE)/*/CVS \ --exclude=$(CWDBASE)/Attic \ --exclude=$(CWDBASE)/*/Attic \ --exclude=$(CWDBASE)/tmp \ --exclude=$(CWDBASE)/\*.tar.gz \ --exclude=$(CWDBASE)/unpack \ --exclude=$(CWDBASE)/\*~ \ --exclude=$(CWDBASE)/*/\*~ \ --exclude=$(CWDBASE)/\*.back \ --exclude=$(CWDBASE)/*/\*.back \ --exclude=$(CWDBASE)/\*.old \ --exclude=$(CWDBASE)/*/\*.old \ --exclude=$(CWDBASE)/\*.new \ --exclude=$(CWDBASE)/*/\*.new \ --exclude=$(CWDBASE)/testbed \ $(CWDBASE)/* .PHONY: all debug release depend clean distclean tag com_err ########################################## ### Include autogenerated dependencies ### ########################################## include $(wildcard *.d) ### Local Variables: ### tab-width: 8 ### End: