2010-11-20 12:29:18 +02:00
|
|
|
#
|
|
|
|
# Makefile - Makefile of qpkg
|
|
|
|
#
|
|
|
|
# Written 2010 by Werner Almesberger
|
|
|
|
# Copyright 2010 by Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
SHELL = /bin/bash
|
|
|
|
|
2010-11-22 21:19:32 +02:00
|
|
|
OBJS_qpkg = fixup.o gobble.o id.o pkg.o prereq.o qpkg.o jrb.o
|
2010-11-20 12:14:52 +02:00
|
|
|
OBJS_rbtest = rbtest.o jrb.o
|
|
|
|
OBJS = $(OBJS_qpkg) $(OBJS_rbtest)
|
|
|
|
|
2010-11-20 01:51:49 +02:00
|
|
|
CFLAGS = -Wall -Wshadow -Wmissing-prototypes -g -O
|
2010-11-19 19:00:15 +02:00
|
|
|
# -O, so that we get data flow analysis, which helps to find more bugs
|
2010-11-20 00:17:47 +02:00
|
|
|
#LDFLAGS=-pg
|
2010-11-19 19:00:15 +02:00
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
# ----- Verbosity control -----------------------------------------------------
|
|
|
|
|
|
|
|
CC_normal := $(CC)
|
|
|
|
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
|
|
|
|
|
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
DEPEND_quiet = @$(DEPEND_normal)
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
CC = $(CC_normal)
|
|
|
|
DEPEND = $(DEPEND_normal)
|
|
|
|
else
|
|
|
|
CC = $(CC_quiet)
|
|
|
|
DEPEND = $(DEPEND_quiet)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# ----- Rules -----------------------------------------------------------------
|
|
|
|
|
2010-11-21 09:32:04 +02:00
|
|
|
.PHONY: all jlime openwrt test tests valgrind clean spotless
|
2010-11-19 19:00:15 +02:00
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
all: qpkg rbtest
|
2010-11-19 19:00:15 +02:00
|
|
|
|
2010-11-20 03:01:33 +02:00
|
|
|
jlime:
|
2010-11-20 12:14:52 +02:00
|
|
|
$(MAKE) clean
|
|
|
|
$(MAKE) CC_normal=mipsel-linux-gcc
|
2010-11-20 03:01:33 +02:00
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
#
|
|
|
|
# OpenWRT uses mipsel-openwrt-linux-* and mipsel-openwrt-linux-uclibc-*.
|
|
|
|
# They should both be available, but just in case, let's improve our odds
|
|
|
|
# of picking a compiler that actualy exists.
|
|
|
|
#
|
2010-11-19 19:00:15 +02:00
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
openwrt:
|
|
|
|
$(MAKE) clean
|
|
|
|
$(MAKE) CC_normal=$(shell \
|
|
|
|
n=`which mipsel-openwrt-linux-gcc`; \
|
|
|
|
echo "$${n:-`which mipsel-openwrt-linux-uclibc-gcc`}")
|
|
|
|
|
|
|
|
qpkg: $(OBJS_qpkg)
|
|
|
|
|
|
|
|
rbtest: $(OBJS_rbtest)
|
|
|
|
|
2010-11-21 09:32:04 +02:00
|
|
|
# ----- Tests -----------------------------------------------------------------
|
|
|
|
|
|
|
|
test tests: all
|
|
|
|
LANG= sh -c \
|
|
|
|
'passed=0 && cd test && \
|
|
|
|
for n in [a-z]*; do \
|
|
|
|
[ $$n != core ] && SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
|
|
|
|
echo "Passed all $$passed tests"'
|
|
|
|
|
|
|
|
valgrind:
|
|
|
|
VALGRIND="valgrind -q" $(MAKE) tests
|
|
|
|
|
2010-11-20 12:14:52 +02:00
|
|
|
# ----- Cleanup ---------------------------------------------------------------
|
2010-11-20 00:33:05 +02:00
|
|
|
|
2010-11-19 19:00:15 +02:00
|
|
|
clean:
|
2010-11-20 12:14:52 +02:00
|
|
|
rm -f $(OBJS) $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
rm -f qpkg rbtest
|
|
|
|
|
|
|
|
# ----- Dependencies ----------------------------------------------------------
|
|
|
|
|
|
|
|
# compile and generate dependencies, from fped, based on
|
|
|
|
# http://scottmcpeak.com/autodepend/autodepend.html
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c $(CFLAGS) $*.c -o $*.o
|
|
|
|
$(DEPEND) $*.c | \
|
|
|
|
sed -e \
|
|
|
|
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
|
|
|
|
-e '$${g;p;}' -e d >$*.d; \
|
|
|
|
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
|
|
|
|
|
|
|
|
-include $(OBJS:.o=.d)
|