• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#    Environment post-setup Makefile.
3#
4#    Copyright (C) 2009, Cisco Systems Inc.
5#
6#    This program is free software; you can redistribute it and/or modify
7#    it under the terms of the GNU General Public License as published by
8#    the Free Software Foundation; either version 2 of the License, or
9#    (at your option) any later version.
10#
11#    This program is distributed in the hope that it will be useful,
12#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#    GNU General Public License for more details.
15#
16#    You should have received a copy of the GNU General Public License along
17#    with this program; if not, write to the Free Software Foundation, Inc.,
18#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#
20# Ngie Cooper, July 2009
21#
22
23ENV_PRE_LOADED			?= $(error You must load env_pre.mk before including this file)
24
25include $(top_srcdir)/include/mk/functions.mk
26
27ifndef ENV_POST_LOADED
28ENV_POST_LOADED = 1
29
30# Default source search path. Modify as necessary, but I would call that
31# poor software design if you need more than one search directory, and
32# would suggest creating a general purpose static library to that end.
33vpath %.c $(abs_srcdir)
34
35# For config.h, et all.
36CPPFLAGS			+= -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/include/old/
37
38LDFLAGS				+= -L$(top_builddir)/lib
39
40ifeq ($(UCLINUX),1)
41CPPFLAGS			+= -D__UCLIBC__ -DUCLINUX
42endif
43
44ifeq ($(ANDROID),1)
45# There are many undeclared functions, it's best not to accidentally overlook
46# them.
47CFLAGS				+= -Werror-implicit-function-declaration
48
49LDFLAGS				+= -L$(top_builddir)/lib/android_libpthread
50LDFLAGS				+= -L$(top_builddir)/lib/android_librt
51endif
52
53MAKE_TARGETS			?= $(notdir $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c)))
54
55MAKE_TARGETS			:= $(filter-out $(FILTER_OUT_MAKE_TARGETS),$(MAKE_TARGETS))
56
57# with only *.dwo, .[0-9]+.dwo can not be cleaned
58CLEAN_TARGETS			+= $(MAKE_TARGETS) *.o *.pyc .cache.mk *.dwo .*.dwo
59
60# Majority of the files end up in testcases/bin...
61INSTALL_DIR			?= testcases/bin
62
63ifneq ($(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS))
64
65ifeq ($(strip $(INSTALL_DIR)),)
66INSTALL_DIR			:= $(error You must define INSTALL_DIR before including this file)
67endif
68
69ifneq ($(strip $(prefix)),)
70# Value specified by INSTALL_DIR isn't an absolute path, so let's tack on $(prefix).
71ifneq ($(patsubst /%,,$(INSTALL_DIR)),)
72INSTALL_DIR			:= $(prefix)/$(INSTALL_DIR)
73endif
74
75# Glob any possible expressions, but make sure to zap the $(abs_srcdir)
76# reference at the start of the filename instead of using $(notdir), so that
77# way we don't accidentally nuke the relative path from $(abs_srcdir) that
78# may have been set in the Makefile.
79INSTALL_TARGETS			:= $(wildcard $(addprefix $(abs_srcdir)/,$(INSTALL_TARGETS)))
80INSTALL_TARGETS			:= $(patsubst $(abs_srcdir)/%,%,$(INSTALL_TARGETS))
81
82# The large majority of the files that we install are going to be apps and
83# scripts, so let's chmod them like that.
84INSTALL_MODE			?= 00775
85
86ifdef MAKE_3_80_COMPAT
87
88INSTALL_PATH			:= $(call MAKE_3_80_abspath,$(DESTDIR)/$(INSTALL_DIR))
89
90INSTALL_TARGETS_ABS		:= $(call MAKE_3_80_abspath,$(addprefix $(INSTALL_PATH)/,$(INSTALL_TARGETS)))
91MAKE_TARGETS_ABS		:= $(call MAKE_3_80_abspath,$(addprefix $(INSTALL_PATH)/,$(MAKE_TARGETS)))
92
93INSTALL_FILES			:= $(INSTALL_TARGETS_ABS) $(MAKE_TARGETS_ABS)
94
95$(INSTALL_TARGETS_ABS):
96	test -d "$(@D)" || mkdir -p "$(@D)"
97	install -m $(INSTALL_MODE) "$(abs_srcdir)/$(subst $(INSTALL_PATH)/,,$@)" "$@"
98
99$(MAKE_TARGETS_ABS):
100	test -d "$(@D)" || mkdir -p "$(@D)"
101	install -m $(INSTALL_MODE) "$(abs_builddir)/$(subst $(INSTALL_PATH)/,,$@)" "$@"
102else
103$(abspath $(addprefix $(DESTDIR)/$(INSTALL_DIR)/,$(sort $(dir $(INSTALL_TARGETS) $(MAKE_TARGETS))))):
104	mkdir -p "$@"
105$(foreach install_target,$(INSTALL_TARGETS),$(eval $(call generate_install_rule,$(install_target),$(abs_srcdir),$(INSTALL_DIR))))
106$(foreach make_target,$(MAKE_TARGETS),$(eval $(call generate_install_rule,$(make_target),$(abs_builddir),$(INSTALL_DIR))))
107endif
108
109else  # else ! $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS)
110$(error You must define $$(prefix) before executing install)
111endif # END $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS)
112endif
113
114endif
115