Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit 85f5b568c42e17d308e3cafc3998ab246863c24f created 11 years 8 months ago. By Werner Almesberger, Merge branch 'master' of projects.qi-hardware.com:wernermisc | |
---|---|
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 | |
13 | SHELL = /bin/bash |
14 | |
15 | OBJS_qpkg = fixup.o gobble.o id.o pkg.o prereq.o qpkg.o jrb.o |
16 | OBJS_rbtest = rbtest.o jrb.o |
17 | OBJS = $(OBJS_qpkg) $(OBJS_rbtest) |
18 | |
19 | CFLAGS = -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 | |
25 | CC_normal := $(CC) |
26 | DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG |
27 | |
28 | CC_quiet = @echo " CC " $@ && $(CC_normal) |
29 | DEPEND_quiet = @$(DEPEND_normal) |
30 | |
31 | ifeq ($(V),1) |
32 | CC = $(CC_normal) |
33 | DEPEND = $(DEPEND_normal) |
34 | else |
35 | CC = $(CC_quiet) |
36 | DEPEND = $(DEPEND_quiet) |
37 | endif |
38 | |
39 | # ----- Rules ----------------------------------------------------------------- |
40 | |
41 | .PHONY: all jlime openwrt test tests valgrind clean spotless |
42 | |
43 | all: qpkg rbtest |
44 | |
45 | jlime: |
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 | |
55 | openwrt: |
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 | |
61 | qpkg: $(OBJS_qpkg) |
62 | |
63 | rbtest: $(OBJS_rbtest) |
64 | |
65 | # ----- Tests ----------------------------------------------------------------- |
66 | |
67 | test 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 | |
74 | valgrind: |
75 | VALGRIND="valgrind -q" $(MAKE) tests |
76 | |
77 | # ----- Cleanup --------------------------------------------------------------- |
78 | |
79 | clean: |
80 | rm -f $(OBJS) $(OBJS:.o=.d) |
81 | |
82 | spotless: 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 |
Branches:
master