Skip to content

Commit 1d4622d

Browse files
author
Kyle Evans
committed
Generalize Makefile.Linux a little bit, add FreeBSD support
1 parent 6207e2e commit 1d4622d

File tree

1 file changed

+83
-70
lines changed

1 file changed

+83
-70
lines changed

Makefile.linux

Lines changed: 83 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ all : $(APPS) direwolf.desktop direwolf.conf
1111
@echo " sudo make install"
1212
@echo " "
1313

14-
CC := gcc
15-
CFLAGS := -O3 -pthread -Igeotranz
14+
free := $(shell uname | grep FreeBSD)
1615

17-
LDFLAGS := -lm -lpthread -lrt
16+
PREFIX ?= /usr
17+
18+
CC ?= gcc
19+
CFLAGS ?= -O3 -pthread -Igeotranz
20+
21+
LDFLAGS ?= -lm -lpthread -lrt
1822

1923

2024

@@ -70,7 +74,7 @@ LDFLAGS := -lm -lpthread -lrt
7074
# If the compiler is generating code for the i386 target, we can
7175
# get much better results by telling it we have at least a Pentium 3.
7276

73-
arch := $(shell echo | gcc -E -dM - | grep __i386__)
77+
arch := $(shell echo | ${CC} -E -dM - | grep __i386__)
7478
ifneq ($(arch),)
7579
CFLAGS += -march=pentium3
7680
endif
@@ -108,7 +112,7 @@ endif
108112

109113
# Add -ffastmath in only if compiler version recognizes it.
110114

111-
useffast := $(shell gcc --help -v 2>/dev/null | grep ffast-math)
115+
useffast := $(shell ${CC} --help -v 2>/dev/null | grep ffast-math)
112116
ifneq ($(useffast),)
113117
CFLAGS += -ffast-math
114118
endif
@@ -171,7 +175,12 @@ endif
171175
# and the compiler target defaults.
172176
#
173177

178+
ifneq (${free},FreeBSD)
174179
neon := $(shell cat /proc/cpuinfo | grep neon)
180+
else
181+
neon := ${NEON}
182+
endif
183+
175184
ifneq ($(neon),)
176185
CFLAGS += -mfpu=neon
177186
endif
@@ -205,7 +214,7 @@ LDFLAGS += -lasound
205214
# Finding libgps.so* is more difficult because it
206215
# is in different places on different operating systems.
207216

208-
enable_gpsd := $(wildcard /usr/include/gps.h)
217+
enable_gpsd := $(wildcard ${PREFIX}/include/gps.h)
209218
ifneq ($(enable_gpsd),)
210219
CFLAGS += -DENABLE_GPSD
211220
LDFLAGS += -lgps
@@ -420,11 +429,15 @@ direwolf.conf : generic.conf
420429
# This is a step in the right direction but not sufficient to use /usr instead.
421430
# Eventually I'd like to have targets here to build the .DEB and .RPM packages.
422431

423-
INSTALLDIR := /usr/local
432+
DESTDIR ?= /usr/local
424433

425434
# Command to "install" to system directories. Use "ginstall" for Mac.
426435

427-
INSTALL=install
436+
INSTALL ?= install
437+
INSTALL_PROGRAM ?= ${INSTALL}
438+
INSTALL_SCRIPT ?= ${INSTALL}
439+
INSTALL_DATA ?= ${INSTALL} -D --mode=644
440+
INSTALL_MAN ?= ${INSTALL_DATA}
428441

429442
# direwolf.desktop was previously handcrafted for the Raspberry Pi.
430443
# It was hardcoded with lxterminal, /home/pi, and so on.
@@ -437,16 +450,16 @@ direwolf.desktop :
437450
@echo "Generating customized direwolf.desktop ..."
438451
@echo '[Desktop Entry]' > $@
439452
@echo 'Type=Application' >> $@
440-
ifneq ($(wildcard /usr/bin/lxterminal),)
441-
@echo "Exec=lxterminal -t \"Dire Wolf\" -e \"$(INSTALLDIR)/bin/direwolf\"" >> $@
442-
else ifneq ($(wildcard /usr/bin/lxterm),)
443-
@echo "Exec=lxterm -hold -title \"Dire Wolf\" -bg white -e \"$(INSTALLDIR)/bin/direwolf\"" >> $@
453+
ifneq ($(wildcard ${PREFIX}/bin/lxterminal),)
454+
@echo "Exec=lxterminal -t \"Dire Wolf\" -e \"$(DESTDIR)/bin/direwolf\"" >> $@
455+
else ifneq ($(wildcard ${PREFIX}/bin/lxterm),)
456+
@echo "Exec=lxterm -hold -title \"Dire Wolf\" -bg white -e \"$(DESTDIR)/bin/direwolf\"" >> $@
444457
else
445-
@echo "Exec=xterm -hold -title \"Dire Wolf\" -bg white -e \"$(INSTALLDIR)/bin/direwolf\"" >> $@
458+
@echo "Exec=xterm -hold -title \"Dire Wolf\" -bg white -e \"$(DESTDIR)/bin/direwolf\"" >> $@
446459
endif
447460
@echo 'Name=Dire Wolf' >> $@
448461
@echo 'Comment=APRS Soundcard TNC' >> $@
449-
@echo 'Icon=/usr/share/direwolf/dw-icon.png' >> $@
462+
@echo 'Icon=${PREFIX}/share/direwolf/dw-icon.png' >> $@
450463
@echo "Path=$(HOME)" >> $@
451464
@echo '#Terminal=true' >> $@
452465
@echo 'Categories=HamRadio' >> $@
@@ -463,83 +476,83 @@ install : $(APPS) direwolf.conf tocalls.txt symbols-new.txt symbolsX.txt dw-icon
463476
# Applications, not installed with package manager, normally go in /usr/local/bin.
464477
# /usr/bin is used instead when installing from .DEB or .RPM package.
465478
#
466-
$(INSTALL) direwolf $(INSTALLDIR)/bin
467-
$(INSTALL) decode_aprs $(INSTALLDIR)/bin
468-
$(INSTALL) text2tt $(INSTALLDIR)/bin
469-
$(INSTALL) tt2text $(INSTALLDIR)/bin
470-
$(INSTALL) ll2utm $(INSTALLDIR)/bin
471-
$(INSTALL) utm2ll $(INSTALLDIR)/bin
472-
$(INSTALL) aclients $(INSTALLDIR)/bin
473-
$(INSTALL) log2gpx $(INSTALLDIR)/bin
474-
$(INSTALL) gen_packets $(INSTALLDIR)/bin
475-
$(INSTALL) atest $(INSTALLDIR)/bin
476-
$(INSTALL) ttcalc $(INSTALLDIR)/bin
477-
$(INSTALL) dwespeak.sh $(INSTALLDIR)/bin
479+
$(INSTALL_PROGRAM) direwolf $(DESTDIR)/bin
480+
$(INSTALL_PROGRAM) decode_aprs $(DESTDIR)/bin
481+
$(INSTALL_PROGRAM) text2tt $(DESTDIR)/bin
482+
$(INSTALL_PROGRAM) tt2text $(DESTDIR)/bin
483+
$(INSTALL_PROGRAM) ll2utm $(DESTDIR)/bin
484+
$(INSTALL_PROGRAM) utm2ll $(DESTDIR)/bin
485+
$(INSTALL_PROGRAM) aclients $(DESTDIR)/bin
486+
$(INSTALL_PROGRAM) log2gpx $(DESTDIR)/bin
487+
$(INSTALL_PROGRAM) gen_packets $(DESTDIR)/bin
488+
$(INSTALL_PROGRAM) atest $(DESTDIR)/bin
489+
$(INSTALL_PROGRAM) ttcalc $(DESTDIR)/bin
490+
$(INSTALL_PROGRAM) dwespeak.sh $(DESTDIR)/bin
478491
#
479492
# Telemetry Toolkit executables. Other .conf and .txt files will go into doc directory.
480493
#
481-
$(INSTALL) telemetry-toolkit/telem-balloon.pl $(INSTALLDIR)/bin
482-
$(INSTALL) telemetry-toolkit/telem-bits.pl $(INSTALLDIR)/bin
483-
$(INSTALL) telemetry-toolkit/telem-data.pl $(INSTALLDIR)/bin
484-
$(INSTALL) telemetry-toolkit/telem-data91.pl $(INSTALLDIR)/bin
485-
$(INSTALL) telemetry-toolkit/telem-eqns.pl $(INSTALLDIR)/bin
486-
$(INSTALL) telemetry-toolkit/telem-parm.pl $(INSTALLDIR)/bin
487-
$(INSTALL) telemetry-toolkit/telem-seq.sh $(INSTALLDIR)/bin
488-
$(INSTALL) telemetry-toolkit/telem-unit.pl $(INSTALLDIR)/bin
489-
$(INSTALL) telemetry-toolkit/telem-volts.py $(INSTALLDIR)/bin
494+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-balloon.pl $(DESTDIR)/bin
495+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-bits.pl $(DESTDIR)/bin
496+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-data.pl $(DESTDIR)/bin
497+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-data91.pl $(DESTDIR)/bin
498+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-eqns.pl $(DESTDIR)/bin
499+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-parm.pl $(DESTDIR)/bin
500+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-seq.sh $(DESTDIR)/bin
501+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-unit.pl $(DESTDIR)/bin
502+
$(INSTALL_SCRIPT) telemetry-toolkit/telem-volts.py $(DESTDIR)/bin
490503
#
491504
# Misc. data such as "tocall" to system mapping.
492505
#
493-
$(INSTALL) -D --mode=644 tocalls.txt /usr/share/direwolf/tocalls.txt
494-
$(INSTALL) -D --mode=644 symbols-new.txt /usr/share/direwolf/symbols-new.txt
495-
$(INSTALL) -D --mode=644 symbolsX.txt /usr/share/direwolf/symbolsX.txt
496-
$(INSTALL) -D --mode=644 dw-icon.png /usr/share/direwolf/dw-icon.png
497-
$(INSTALL) -D --mode=644 direwolf.desktop /usr/share/applications/direwolf.desktop
506+
$(INSTALL_DATA) tocalls.txt /usr/share/direwolf/tocalls.txt
507+
$(INSTALL_DATA) symbols-new.txt /usr/share/direwolf/symbols-new.txt
508+
$(INSTALL_DATA) symbolsX.txt /usr/share/direwolf/symbolsX.txt
509+
$(INSTALL_DATA) dw-icon.png /usr/share/direwolf/dw-icon.png
510+
$(INSTALL_DATA) direwolf.desktop /usr/share/applications/direwolf.desktop
498511
#
499512
# Documentation. Various plain text files and PDF.
500513
#
501-
$(INSTALL) -D --mode=644 CHANGES.md $(INSTALLDIR)/share/doc/direwolf/CHANGES.md
502-
$(INSTALL) -D --mode=644 LICENSE-dire-wolf.txt $(INSTALLDIR)/share/doc/direwolf/LICENSE-dire-wolf.txt
503-
$(INSTALL) -D --mode=644 LICENSE-other.txt $(INSTALLDIR)/share/doc/direwolf/LICENSE-other.txt
514+
$(INSTALL_DATA) CHANGES.md $(DESTDIR)/share/doc/direwolf/CHANGES.md
515+
$(INSTALL_DATA) LICENSE-dire-wolf.txt $(DESTDIR)/share/doc/direwolf/LICENSE-dire-wolf.txt
516+
$(INSTALL_DATA) LICENSE-other.txt $(DESTDIR)/share/doc/direwolf/LICENSE-other.txt
504517
#
505518
# ./README.md is an overview for the project main page.
506519
# doc/README.md contains an overview of the PDF file contents and is more useful here.
507520
#
508-
$(INSTALL) -D --mode=644 doc/README.md $(INSTALLDIR)/share/doc/direwolf/README.md
509-
$(INSTALL) -D --mode=644 doc/User-Guide.pdf $(INSTALLDIR)/share/doc/direwolf/User-Guide.pdf
510-
$(INSTALL) -D --mode=644 doc/Raspberry-Pi-APRS.pdf $(INSTALLDIR)/share/doc/direwolf/Raspberry-Pi-APRS.pdf
511-
$(INSTALL) -D --mode=644 doc/Raspberry-Pi-APRS-Tracker.pdf $(INSTALLDIR)/share/doc/direwolf/Raspberry-Pi-APRS-Tracker.pdf
512-
$(INSTALL) -D --mode=644 doc/Raspberry-Pi-SDR-IGate.pdf $(INSTALLDIR)/share/doc/direwolf/Raspberry-Pi-SDR-IGate.pdf
513-
$(INSTALL) -D --mode=644 doc/APRStt-Implementation-Notes.pdf $(INSTALLDIR)/share/doc/direwolf/APRStt-Implementation-Notes.pdf
514-
$(INSTALL) -D --mode=644 doc/APRStt-interface-for-SARTrack.pdf $(INSTALLDIR)/share/doc/direwolf/APRStt-interface-for-SARTrack.pdf
515-
$(INSTALL) -D --mode=644 doc/APRS-Telemetry-Toolkit.pdf $(INSTALLDIR)/share/doc/direwolf/APRS-Telemetry-Toolkit.pdf
516-
$(INSTALL) -D --mode=644 doc/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf $(INSTALLDIR)/share/doc/direwolf/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf
517-
$(INSTALL) -D --mode=644 doc/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf $(INSTALLDIR)/share/doc/direwolf/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf
521+
$(INSTALL_DATA) doc/README.md $(DESTDIR)/share/doc/direwolf/README.md
522+
$(INSTALL_DATA) doc/User-Guide.pdf $(DESTDIR)/share/doc/direwolf/User-Guide.pdf
523+
$(INSTALL_DATA) doc/Raspberry-Pi-APRS.pdf $(DESTDIR)/share/doc/direwolf/Raspberry-Pi-APRS.pdf
524+
$(INSTALL_DATA) doc/Raspberry-Pi-APRS-Tracker.pdf $(DESTDIR)/share/doc/direwolf/Raspberry-Pi-APRS-Tracker.pdf
525+
$(INSTALL_DATA) doc/Raspberry-Pi-SDR-IGate.pdf $(DESTDIR)/share/doc/direwolf/Raspberry-Pi-SDR-IGate.pdf
526+
$(INSTALL_DATA) doc/APRStt-Implementation-Notes.pdf $(DESTDIR)/share/doc/direwolf/APRStt-Implementation-Notes.pdf
527+
$(INSTALL_DATA) doc/APRStt-interface-for-SARTrack.pdf $(DESTDIR)/share/doc/direwolf/APRStt-interface-for-SARTrack.pdf
528+
$(INSTALL_DATA) doc/APRS-Telemetry-Toolkit.pdf $(DESTDIR)/share/doc/direwolf/APRS-Telemetry-Toolkit.pdf
529+
$(INSTALL_DATA) doc/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf $(DESTDIR)/share/doc/direwolf/A-Better-APRS-Packet-Demodulator-Part-1-1200-baud.pdf
530+
$(INSTALL_DATA) doc/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf $(DESTDIR)/share/doc/direwolf/A-Better-APRS-Packet-Demodulator-Part-2-9600-baud.pdf
518531
#
519532
# Various sample config and other files go into examples under the doc directory.
520533
# When building from source, these can be put in home directory with "make install-conf".
521534
# When installed from .DEB or .RPM package, the user will need to copy these to
522535
# the home directory or other desired location.
523536
#
524-
$(INSTALL) -D --mode=644 direwolf.conf $(INSTALLDIR)/share/doc/direwolf/examples/direwolf.conf
525-
$(INSTALL) -D --mode=644 dw-start.sh $(INSTALLDIR)/share/doc/direwolf/examples/dw-start.sh
526-
$(INSTALL) -D --mode=644 sdr.conf $(INSTALLDIR)/share/doc/direwolf/examples/sdr.conf
527-
$(INSTALL) -D --mode=644 telemetry-toolkit/telem-m0xer-3.txt $(INSTALLDIR)/share/doc/direwolf/examples/telem-m0xer-3.txt
528-
$(INSTALL) -D --mode=644 telemetry-toolkit/telem-balloon.conf $(INSTALLDIR)/share/doc/direwolf/examples/telem-balloon.conf
529-
$(INSTALL) -D --mode=644 telemetry-toolkit/telem-volts.conf $(INSTALLDIR)/share/doc/direwolf/examples/telem-volts.conf
537+
$(INSTALL_DATA) direwolf.conf $(DESTDIR)/share/doc/direwolf/examples/direwolf.conf
538+
$(INSTALL_SCRIPT) dw-start.sh $(DESTDIR)/share/doc/direwolf/examples/dw-start.sh
539+
$(INSTALL_DATA) sdr.conf $(DESTDIR)/share/doc/direwolf/examples/sdr.conf
540+
$(INSTALL_DATA) telemetry-toolkit/telem-m0xer-3.txt $(DESTDIR)/share/doc/direwolf/examples/telem-m0xer-3.txt
541+
$(INSTALL_DATA) telemetry-toolkit/telem-balloon.conf $(DESTDIR)/share/doc/direwolf/examples/telem-balloon.conf
542+
$(INSTALL_DATA) telemetry-toolkit/telem-volts.conf $(DESTDIR)/share/doc/direwolf/examples/telem-volts.conf
530543
#
531544
# "man" pages
532545
#
533-
$(INSTALL) -D --mode=644 man1/aclients.1 $(INSTALLDIR)/man/man1/aclients.1
534-
$(INSTALL) -D --mode=644 man1/atest.1 $(INSTALLDIR)/man/man1/atest.1
535-
$(INSTALL) -D --mode=644 man1/decode_aprs.1 $(INSTALLDIR)/man/man1/decode_aprs.1
536-
$(INSTALL) -D --mode=644 man1/direwolf.1 $(INSTALLDIR)/man/man1/direwolf.1
537-
$(INSTALL) -D --mode=644 man1/gen_packets.1 $(INSTALLDIR)/man/man1/gen_packets.1
538-
$(INSTALL) -D --mode=644 man1/ll2utm.1 $(INSTALLDIR)/man/man1/ll2utm.1
539-
$(INSTALL) -D --mode=644 man1/log2gpx.1 $(INSTALLDIR)/man/man1/log2gpx.1
540-
$(INSTALL) -D --mode=644 man1/text2tt.1 $(INSTALLDIR)/man/man1/text2tt.1
541-
$(INSTALL) -D --mode=644 man1/tt2text.1 $(INSTALLDIR)/man/man1/tt2text.1
542-
$(INSTALL) -D --mode=644 man1/utm2ll.1 $(INSTALLDIR)/man/man1/utm2ll.1
546+
$(INSTALL_DATA) man1/aclients.1 $(DESTDIR)/man/man1/aclients.1
547+
$(INSTALL_DATA) man1/atest.1 $(DESTDIR)/man/man1/atest.1
548+
$(INSTALL_DATA) man1/decode_aprs.1 $(DESTDIR)/man/man1/decode_aprs.1
549+
$(INSTALL_DATA) man1/direwolf.1 $(DESTDIR)/man/man1/direwolf.1
550+
$(INSTALL_DATA) man1/gen_packets.1 $(DESTDIR)/man/man1/gen_packets.1
551+
$(INSTALL_DATA) man1/ll2utm.1 $(DESTDIR)/man/man1/ll2utm.1
552+
$(INSTALL_DATA) man1/log2gpx.1 $(DESTDIR)/man/man1/log2gpx.1
553+
$(INSTALL_DATA) man1/text2tt.1 $(DESTDIR)/man/man1/text2tt.1
554+
$(INSTALL_DATA) man1/tt2text.1 $(DESTDIR)/man/man1/tt2text.1
555+
$(INSTALL_DATA) man1/utm2ll.1 $(DESTDIR)/man/man1/utm2ll.1
543556
#
544557
@echo " "
545558
@echo "If this is your first install, not an upgrade, type this to put a copy"
@@ -574,7 +587,7 @@ endif
574587
.PHONY: install-rpi
575588
install-rpi : dw-start.sh
576589
cp dw-start.sh ~
577-
ln -f -s /usr/share/applications/direwolf.desktop ~/Desktop/direwolf.desktop
590+
ln -f -s ${PREFIX}/share/applications/direwolf.desktop ~/Desktop/direwolf.desktop
578591

579592

580593

0 commit comments

Comments
 (0)