Makefile
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# Labjack/Nerdjack Tools
# Copyright (c) 2007-2009
# Jim Paris <jim@jtan.com>, Zach Clifford <zacharyc@mit.edu>
#
# This is free software; you can redistribute it and/or modify it and
# it is provided under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation; see COPYING.
#
# For Solaris, use: gmake CC=gcc LDFLAGS="-lsocket -lnsl"
# For Windows, build with "make win"
# Build options
CFLAGS += -Wall -g #-pg
LDFLAGS += -lm #-pg
PREFIX = /usr/local
MANPATH = ${PREFIX}/man/man1
BINPATH = ${PREFIX}/bin
WINCC = i386-mingw32-gcc
WINCFLAGS += $(CFLAGS)
WINLDFLAGS += $(LDFLAGS) -lws2_32 -s
# Targets
.PHONY: default
default: lin
.PHONY: all
all: lin win
.PHONY: lin
lin: ljtest ethstream ljconfig \
ethstream.1 ljconfig.1
.PHONY: win
win: ljtest.exe ethstream.exe ljconfig.exe
version.h: VERSION
echo "/* This file was automatically generated. */" >version.h
echo "#define VERSION \"`cat VERSION` (`date +%Y-%m-%d`)\"" >>version.h
# Object files for each executable
obj-common = opt.o ue9.o ue9error.o netutil.o debug.o nerdjack.o
obj-ljconfig = ljconfig.o $(obj-common)
obj-ethstream = ethstream.o $(obj-common)
obj-ljtest = ljtest.o $(obj-common)
ljconfig: $(obj-ljconfig)
ethstream: $(obj-ethstream)
ljtest: $(obj-ljtest)
ljconfig.exe: $(obj-ljconfig:.o=.obj) compat-win32.obj
ethstream.exe: $(obj-ethstream:.o=.obj) compat-win32.obj
ljtest.exe: $(obj-ljtest:.o=.obj) compat-win32.obj
# Manpages
%.1: %
if ! help2man -N --output=$@ ./$< ; then \
echo "No manual page available." > $@ ; fi
%.txt: %.1
nroff -man $< | colcrt | sed s/$$/\\r/ > $@
# Install/uninstall targets for Linux
.PHONY: install
install: ethstream.1 ethstream
install -m 0755 ethstream ${BINPATH}
install -m 0644 ethstream.1 ${MANPATH}
.PHONY: uninstall
uninstall:
rm -f ${BINPATH}/ethstream ${MANPATH}/ethstream.1
# Packaging
PACKAGE=labjack-`cat VERSION`
.PHONY: dist
dist: version.h
mkdir -p ${PACKAGE}
cp [A-Z]* *.[ch] ${PACKAGE}
tar cvzf ${PACKAGE}.tar.gz ${PACKAGE}
rm -r ${PACKAGE}
# Maintenance
.PHONY: clean distclean
clean distclean:
rm -f *.o *.obj *.exe ethstream ljtest ljconfig core *.d *.1 *.txt
# Dependency tracking:
allsources = $(wildcard *.c)
-include $(allsources:.c=.d)
%.o : %.c
$(COMPILE.c) -MP -MMD -MT '$*.obj' -o $@ $<
%.obj : %.c
$(WINCC) $(WINCFLAGS) -MP -MMD -MT '$*.o' -c -o $@ $<
# Win32 executable
%.exe : %.obj
$(WINCC) -o $@ $^ $(WINLDFLAGS)