Root/qpkg/Makefile

Source at commit efacc76bace28fb955a0dd7f8638b8f0ad69253a created 9 years 3 months ago.
By root, fisl2011/: corrected flow.fig; straightened narrative
1#
2# Makefile - Makefile of qpkg
3#
4# Written 2010 by Werner Almesberger
5# Copyright 2010 by Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13SHELL = /bin/bash
14
15OBJS_qpkg = fixup.o gobble.o id.o pkg.o prereq.o qpkg.o jrb.o
16OBJS_rbtest = rbtest.o jrb.o
17OBJS = $(OBJS_qpkg) $(OBJS_rbtest)
18
19CFLAGS = -Wall -Wshadow -Wmissing-prototypes -g -O
20# -O, so that we get data flow analysis, which helps to find more bugs
21#LDFLAGS=-pg
22
23# ----- Verbosity control -----------------------------------------------------
24
25CC_normal := $(CC)
26DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
27
28CC_quiet = @echo " CC " $@ && $(CC_normal)
29DEPEND_quiet = @$(DEPEND_normal)
30
31ifeq ($(V),1)
32    CC = $(CC_normal)
33    DEPEND = $(DEPEND_normal)
34else
35    CC = $(CC_quiet)
36    DEPEND = $(DEPEND_quiet)
37endif
38
39# ----- Rules -----------------------------------------------------------------
40
41.PHONY: all jlime openwrt test tests valgrind clean spotless
42
43all: qpkg rbtest
44
45jlime:
46        $(MAKE) clean
47        $(MAKE) CC_normal=mipsel-linux-gcc
48
49#
50# OpenWRT uses mipsel-openwrt-linux-* and mipsel-openwrt-linux-uclibc-*.
51# They should both be available, but just in case, let's improve our odds
52# of picking a compiler that actualy exists.
53#
54
55openwrt:
56        $(MAKE) clean
57        $(MAKE) CC_normal=$(shell \
58          n=`which mipsel-openwrt-linux-gcc`; \
59          echo "$${n:-`which mipsel-openwrt-linux-uclibc-gcc`}")
60
61qpkg: $(OBJS_qpkg)
62
63rbtest: $(OBJS_rbtest)
64
65# ----- Tests -----------------------------------------------------------------
66
67test tests: all
68        LANG= sh -c \
69          'passed=0 && cd test && \
70          for n in [a-z]*; do \
71          [ $$n != core ] && SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
72          echo "Passed all $$passed tests"'
73
74valgrind:
75        VALGRIND="valgrind -q" $(MAKE) tests
76
77# ----- Cleanup ---------------------------------------------------------------
78
79clean:
80        rm -f $(OBJS) $(OBJS:.o=.d)
81
82spotless: clean
83        rm -f qpkg rbtest
84
85# ----- Dependencies ----------------------------------------------------------
86
87# compile and generate dependencies, from fped, based on
88# http://scottmcpeak.com/autodepend/autodepend.html
89
90%.o: %.c
91        $(CC) -c $(CFLAGS) $*.c -o $*.o
92        $(DEPEND) $*.c | \
93          sed -e \
94            '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
95            -e '$${g;p;}' -e d >$*.d; \
96          [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
97
98-include $(OBJS:.o=.d)
99

Archive Download this file

Branches:
master



interactive