2011-11-02 01:00:16 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
KBUILD_OUTPUT ?= /lib/modules/$(shell uname -r)/build
|
|
|
|
|
2012-09-05 23:00:30 +08:00
|
|
|
FEAT_CFLAGS :=
|
|
|
|
ifneq ($(shell grep clock_adjtime /usr/include/bits/time.h),)
|
|
|
|
FEAT_CFLAGS += -D_GNU_SOURCE -DHAVE_CLOCK_ADJTIME
|
|
|
|
endif
|
|
|
|
|
2011-11-02 01:00:16 +08:00
|
|
|
DEBUG =
|
2012-07-24 18:30:06 +08:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
2011-11-02 01:00:16 +08:00
|
|
|
INC = -I$(KBUILD_OUTPUT)/usr/include
|
2012-12-09 16:42:47 +08:00
|
|
|
VER = -DVER=$(version)
|
|
|
|
CFLAGS = -Wall $(VER) $(INC) $(DEBUG) $(FEAT_CFLAGS) $(EXTRA_CFLAGS)
|
2012-07-24 18:30:06 +08:00
|
|
|
LDLIBS = -lm -lrt $(EXTRA_LDFLAGS)
|
2012-08-05 20:14:44 +08:00
|
|
|
PRG = ptp4l pmc phc2sys hwstamp_ctl
|
2011-12-31 16:14:18 +08:00
|
|
|
OBJ = bmc.o clock.o config.o fsm.o ptp4l.o mave.o msg.o phc.o pi.o port.o \
|
2012-08-24 21:22:40 +08:00
|
|
|
print.o raw.o servo.o sk.o tlv.o tmtab.o transport.o udp.o udp6.o uds.o util.o
|
2011-11-02 01:00:16 +08:00
|
|
|
|
2012-11-26 20:25:35 +08:00
|
|
|
OBJECTS = $(OBJ) pmc.o phc2sys.o hwstamp_ctl.o sysoff.o
|
2012-01-25 02:12:57 +08:00
|
|
|
SRC = $(OBJECTS:.o=.c)
|
|
|
|
DEPEND = $(OBJECTS:.o=.d)
|
2011-11-02 01:00:16 +08:00
|
|
|
srcdir := $(dir $(lastword $(MAKEFILE_LIST)))
|
2012-12-09 16:42:47 +08:00
|
|
|
version := $(shell $(srcdir)/version.sh $(srcdir))
|
2011-11-02 01:00:16 +08:00
|
|
|
VPATH = $(srcdir)
|
|
|
|
|
2012-11-06 00:13:28 +08:00
|
|
|
prefix = /usr/local
|
|
|
|
sbindir = $(prefix)/sbin
|
|
|
|
mandir = $(prefix)/man
|
|
|
|
man8dir = $(mandir)/man8
|
|
|
|
|
2012-02-20 01:23:50 +08:00
|
|
|
all: $(PRG)
|
2011-11-02 01:00:16 +08:00
|
|
|
|
2011-12-13 16:09:08 +08:00
|
|
|
ptp4l: $(OBJ)
|
2011-11-02 01:00:16 +08:00
|
|
|
|
2012-08-24 21:22:40 +08:00
|
|
|
pmc: pmc.o msg.o print.o raw.o sk.o tlv.o transport.o udp.o udp6.o uds.o util.o
|
2012-08-05 20:14:44 +08:00
|
|
|
|
2012-11-26 20:25:35 +08:00
|
|
|
phc2sys: phc2sys.o sk.o sysoff.o print.o
|
2012-01-25 02:12:57 +08:00
|
|
|
|
2012-01-25 02:22:13 +08:00
|
|
|
hwstamp_ctl: hwstamp_ctl.o
|
|
|
|
|
2012-11-06 00:13:28 +08:00
|
|
|
install: $(PRG)
|
|
|
|
mkdir -p $(sbindir) $(man8dir)
|
|
|
|
install $(PRG) $(sbindir)
|
|
|
|
install -p -m 644 -t $(man8dir) $(PRG:%=%.8)
|
|
|
|
|
2011-11-02 01:00:16 +08:00
|
|
|
clean:
|
2012-01-25 02:12:57 +08:00
|
|
|
rm -f $(OBJECTS) $(DEPEND)
|
2011-11-02 01:00:16 +08:00
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
rm -f $(PRG)
|
|
|
|
|
|
|
|
# Implicit rule to generate a C source file's dependencies.
|
|
|
|
%.d: %.c
|
|
|
|
@echo DEPEND $<; \
|
|
|
|
rm -f $@; \
|
|
|
|
$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
|
|
|
|
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
|
|
rm -f $@.$$$$
|
|
|
|
|
2011-12-13 16:04:08 +08:00
|
|
|
ifneq ($(MAKECMDGOALS), clean)
|
|
|
|
ifneq ($(MAKECMDGOALS), distclean)
|
2011-11-02 01:00:16 +08:00
|
|
|
-include $(DEPEND)
|
2011-12-13 16:04:08 +08:00
|
|
|
endif
|
|
|
|
endif
|